Volume 2: Solutions and Publishing disclaimer



Download 0.72 Mb.
Page1/12
Date10.08.2017
Size0.72 Mb.
#31124
  1   2   3   4   5   6   7   8   9   ...   12


Microsoft Visio 2010 Developer Training
Volume 2: Solutions and Publishing
DISCLAIMER

© 2010 Microsoft Corporation. All rights reserved.

Microsoft®, Internet Explorer, and Windows® are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries.

The names of actual companies and products mentioned herein may be the trademarks of their respective owners.



The contents of this package are for informational and training purposes only and are provided "as is" without warranty of any kind, whether express or implied, including but not limited to the implied warranties of merchantability, fitness for a particular purpose, and non-infringement.

No part of the text or software included in this training package may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or any information storage and retrieval system, without permission from Microsoft®. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information presented after the date of publication. The names of actual companies and products mentioned herein may be the trademarks of their respective owners.

To obtain authorization for uses other than those specified above, please visit the Microsoft Copyright Permissions Web page at http://www.microsoft.com/about/legal/permissions

This content is proprietary and confidential, and is intended only for users described in the content provided in this document. This content and information is provided to you under a Non-Disclosure Agreement and cannot be distributed. Copying, disclosing all or any portion of the content and/or information included in this document is strictly prohibited.


Table of Contents

Built in Solutions 4

Process Management 5

The Subprocess ribbon group 6

The Diagram Validation ribbon group 10

The SharePoint Workflow ribbon group 26

Process Management Additional Resources 30

Creating Visio Process Diagrams 30

Validating Visio Drawings 30

SharePoint Workflows 30

Linking Drawings using the Database Wizard 32

Overview 33

Database Concepts 34

Database Concepts (Continued) 35

Data Types 36

Visio Cell Values and Formulas 37

Connections to Visio SmartShapes 38

The Link to ODBC Database Add-on 39

Database Actions and Activities 42

The Export to Database Add-on 44

Lab 2.1 Export Shape Data to Database 46

Summary: Linking Visio Drawings to a Database 47

Organization Chart Solution 48

Overview 49

Creating organization charts in Visio 50

Organization Chart Menu 51

Organization Chart Menu (cont.) 55

Organization Chart Reporting 56

Lab 2.2: Exploring the organization chart user interface 57

Organization Chart Wizard 59

Data file structure 60

Tips on using the Organization Chart Wizard 61

Running the organization chart solution in “silent” mode 63

Lab 2.3: Running the wizard in “silent” mode 68

Summary: Visio Organization Chart Solution 69

Pivot Diagrams 70

Conceptual Overview 70

Try it! Pivot Diagram 73

Exploring Drill-down 88

Collapsing and Merging nodes 102

Promote Nodes to Root 103

Lab 2.4: Pivot Diagram – Filter a Sales database to analyze business information 104

Built in Solutions Review 106

Publishing Diagrams 108

Visio Services 109

Publishing Diagrams to Visio Services 112

Integrating Visio drawings into SharePoint Applications 116

Visio Services Additional Resources 139

Publishing and viewing Visio Solutions 140

Publish for visualization only 144

Lab 2.5: Exporting to other formats 156

Publish for visual data 156

Publish for data only 168

Manage Visio files with SharePoint® Technologies 169

Publishing Review 175

Deploying Visio Solutions 177

Deploy a Visio library solution 179

Deploy a Visio automation solution 181

Deploy solutions for use with multiple languages 182

Deploy a Windows Forms solution that contains the Visio Viewer control 184

Additional Resources 185

Deploying Solutions Review 187

Some Important Developer Features 189

Theme colors and theme effects 190

User issues 190

Developer issues 194

Trust Center and Remove Hidden Information 203

Macro Recorder considerations 207

XML changes for Visio 2007 208

XML Schema Changes 208

XMLLite 211

Additional Resources 213

Developer Features Review 216





Built in Solutions


There are many solution components included with Visio. Some of the common ones will be explored in this module: process management and drawing validation, database linking using the database wizard, organization chart solution, and creating pivot diagrams.
Module Objectives

After completing this module you will be able to:

  • Create and validate process flow diagrams

  • Create custom rules for validating drawings

  • Create SharePoint Workflow diagrams

  • Link Visio shapes or masters to an ODBC compliant datasource.

  • Read and write data to a linked datasource.

  • Use the Organization chart wizard to create diagrams from data stored externally to Visio.

  • Use the many features of the organization chart user interface.

  • Create pivot diagrams and use them to explore and analyze data.



Process Management


Simplifying Processs Management was a major focus of enhancements for Visio 2010. The techniques used to create process diagrams can vary greatly from user to user and process diagrams can range from being fairly simple to being very complex. A common method is to break a complex diagram down into manageable pieces by separating parts of the diagram across different pages and even across different documents.

To build the diagrams some users start with a bottom up approach while others build their diagrams top down. Visio 2010 makes it easier to take either approach: whether you detail out a sub process on its own page and then reference it from a high level diagram or whether you detail out the process at the top level and break out portions of the drawing into sub processes after they are developed. Visio 2010 adds explicit support to create new sub processes and reference existing ones.



Note:

The Process tab is only available in the Premium version of Visio 2010.

Below is a view of the Process ribbon in Visio 2010.


 

The Subprocess ribbon group


Items from the Subprocess group are used in constructing diagrams with sub processes. These sub processes may be on different pages in the same document or in different documents. Hyperlinks are created automatically when creating sub processes so that the overall process flow can be followed easily.

The Create New process is used to build out a new sub process represented by a selected shape. The Create New ribbon item is not enabled if there is no shape selected. When selected, this will insert a new blank page and add the page name and a hyperlink pointing to the new page from the selected shape. Below is a snippet of automation code that does the same thing as the Create New command.

Sub CreateFromShape()

'Enable diagram services

Dim DiagramServices As Integer

DiagramServices = ActiveDocument.DiagramServicesEnabled

ActiveDocument.DiagramServicesEnabled = visServiceVersion140

'Create a sub process from the first selected shape

ActiveWindow.selection(1).CreateSubProcess

'Restore diagram services

ActiveDocument.DiagramServicesEnabled = DiagramServices

End Sub


Note:

Microsoft Visio 2010 introduces two new sets of diagram behaviors: structured-diagram behaviors and AutoSize behaviors. Structured-diagram behaviors define when container-membership relationships and callout associations are created. AutoSize behaviors define when Visio automatically resizes the drawing page to adjust to changes in its contents.

Custom solutions can take advantage of these behaviors by using the DiagramServicesEnabled property to enable the desired services. When a custom solution modifies a diagram, Visio invokes the diagram behaviors associated with any of the services currently enabled.

Setting DiagramServicesEnabled=visServiceVersion140 setss all diagram services that exist in Visio 2010.


The CreateSubProcess method of the shape creates a new sub process page and links it to the selected shape.

If the sub process has already been diagramed, the Link to Existing command allows you to create a hyperlink on a selected shape to either a page in the current document or to an external document. Link to Existing can also be used to edit existing hyperlinks. Choose Link to Existing > Edit Link… to display the Hyperlinks dialog.

The Create from Selection command is used when you want to move a number of shapes from your current page onto a new sub process page.  Visio adds a new page, moves the selected shapes to the new page and adds a sub process shape to the current page. 

http://blogs.msdn.com/blogfiles/visio/windowslivewriter/subprocessesandhyperlinks_d0fe/4_8.png

Figure - Selected shapes are moved to a new page

http://blogs.msdn.com/blogfiles/visio/windowslivewriter/subprocessesandhyperlinks_d0fe/5_6.png

Figure - The selected shapes are replaced with a new shape

The new shape represents the new sub process and contains the name of the new page as well as a hyperlink pointing to it. The code snippet below does this through automation. Note that the selection is first saved because when a new page is created any currently selected shapes are lost. After the new page is created, the MoveToSubProcesss method of the saved selection is used to move the selection to the new page and to drop and link a replacement shape onto the page that replaces the selection. The second parameter of the MoveToSubProcess method is Nothing. This tells Visio to use the default shape as the replacement shape.

Sub MoveToSubProcess()

'Enable diagram services

Dim DiagramServices As Integer

DiagramServices = ActiveDocument.DiagramServicesEnabled

ActiveDocument.DiagramServicesEnabled = visServiceVersion140

'save the selection since it will be lost when the new page is created

Dim selection As Visio.selection

Set selection = ActiveWindow.selection

'create a new page for the sub process

Dim newPage As Visio.Page

Set newPage = ActiveDocument.Pages.Add

'move the sub process to the new page

selection.MoveToSubProcess newPage, Nothing

'Restore diagram services

ActiveDocument.DiagramServicesEnabled = DiagramServices

End Sub

The Diagram Validation ribbon group


Process > Check Diagram is a new feature to validate a drawing based on rules that are stored within the drawing. This feature can be used to check for common errors such as connectors not being glued or flowchart shapes without the correct number of incoming and outgoing connectors.

Rule sets are stored in document templates and are included in the Visio provided templates Basic Flowchart, Cross Functional Flowchart, Microsoft SharePoint Workflow and Business Process Modeling Notation.

A rich validation object model and corresponding API enable one to create custom solutions that add and delete rules, validate drawings with the new rules, detect the Validation events, and manage validation issues.

As seen in the object model diagram below, a ValidationRule is part of a collection of ValidationRules. A ValidationRuleSet combines the ValidationRules collection along with a Description and Enabled flag. In Visio’s Process tab choose Check Diagram and then Rules to Check. Each item listed is a rule set. If the rule set’s Enabled flag is set, then this rule set is checked in the menu and will be applied to the current drawing when Check Diagram is chosen.


Using the Visio development API one can create custom rule sets to capture specific corporate needs.



Note:

Rules stored in a drawing can be viewed easily by saving the Visio drawing as a .vdx file and then searching the resulting XML file for “validation”. It is possible to edit the XML directly, but it is recommended that the provided API be used instead.



Defining ValidationRule.FilterExpression and ValidationRule.TestExpression

When you validate a diagram by calling the Validation.Validate method or by clicking Check Diagram on the Process tab, Visio will automatically use any validation logic stored in the document to detect errors. This validation logic is expressed in the ValidationRule.TargetType, ValidationRule.FilterExpression and ValidationRule.TestExpression properties. The FilterExpression and TestExpression should be written as Boolean expressions that can be evaluated on every object of type TargetType. During validation of a rule, for every object of type TargetType, Visio uses the FilterExpression to determine whether the object must satisfy the validation rule. If the filter expression evaluates to True, Visio uses the TestExpression to determine whether to generate an issue for the object. If the filter expression evaluates to False, Visio does not apply the validation rule to the object.

The syntax for the FilterExpression and TestExpression properties are the same as that of a ShapeSheet expression. For example, since NOT(IS1D()) is a valid Boolean expression for the ShapeSheet of a shape, "NOT(Is1D())" is a valid FilterExpression or TestExpression for a validation rule with TargetType = Visio.VisRuleTargets.visRuleTargetShape. In addition to the standard ShapeSheet functions, the following validation functions can be used in a FilterExpression or TestExpression.



Function

Description

Role()

Returns an integer indicating the shape role: {Element = 0, Connector = 1, Container = 2, Callout = 4}.

OnLayer(LayerName)

Returns a Boolean indicating whether the shape is a member of the specified layer. Returns a Boolean indicating whether layer exists on page if called on a Page.

ConnectedShapes(Direction)

Returns the set of shapes, matching the Direction criteria, connected to the shape.

GluedShapes(Direction)

Returns the set of shapes, matching the Direction criteria, glued to the shape.

ContainerMembers()

Returns the set of shapes that are members of the container / list shape.

ListMembers()

Returns the set of shapes that are members of the list shape.

Callouts()

Returns the set of shapes that are callouts on the shape.

ParentContainers()

Returns the set of containers that the shape belongs to.

ShapesOnPage()

Returns the set of top-level shapes on page. If no page specifier precedes the function, the shape’s containing page is assumed.

AggCount(Set)

Counts the number of shapes in a set.

FilterSet(Set,FilterExpression)

Returns the subset of shapes in a set that match an expression.

OnBoundaryOf()

Returns the set of containers such that the shape is on the boundary of these containers.

The validation expression functions ConnectedShapes and GluedShapes correspond to connectivity API functions with the same names. Similarly, the possible values of the Direction input parameter for ConnectedShapes and GluedShapes correspond to the VisConnectedShapesFlags and VisGluedShapesFlags enumerations, respectively.



An Example: The Rule Set for the basic flowchart template


To get a better understanding of how a rule set is structured, let’s examine in detail the rule set provided with Visio 2010 for checking flowcharts. One cannot see the actual rules using the Visio user interface. However, a quick way to see how the rule objects are set up is to save a drawing that contains rules (such as a flowchart) as a .vdx file and then view it using an XML viewer such as XML Notepad. The image below shows a small portion of the file beginning with the Validation section through the first of eleven rules.


ValidationRuleSet Object

The RuleSet is an object that holds a collection of rules

  • ID: 1

  • NameU : Flowchart

  • Description: Verify that Flowchart shapes are connected properly.

NameU is the universal name of the ValidationRuleSet object and Description states the purpose of the ValidationRuleSet object. There are eleven rules defined within this ValidationRuleSet.
ValidationRule Objects

NameU is the universal name of the Rule object.

Category represents the text displayed in the Category column of the Issues window.

Description states the purpose of the ValidationRule object.

RuleTarget represents the TargetType property of the ValidationRule object. Rules can be targeted at the shape, page, or document level.

  • =0. The rule applies to shapes in the document.

  • =1. The rule applies to pages in the document.

  • =2. The rule applies to the document itself.

RuleFilter in the .vdx file is the FilterExpression property of the ValidationRule object. This defines a logical expression that determines whether the validation rule should be applied to a target object.

When you validate a diagram by calling the Validate method or by clicking Check Diagram on the Process tab, Visio uses the expression that you set as the FilterExpression property value to determine whether a target object must satisfy the validation rule. If the filter expression evaluates to True, Visio uses the TestExpression property value to determine whether to generate an issue for the target object. If the filter expression evaluates to False, Visio does not apply the validation rule to the target object during validation.

The syntax for the FilterExpression property value is the same as that for a ShapeSheet expression. When you set the FilterExpression property, Visio does not validate the syntax of the filter expression. If the expression is not syntactically correct, Visio does not apply the validation rule to the target object during validation.

RuleTest in the .vdx file is the TestExpression property value of the ValidationRule object.

The syntax for the TestExpression property value is the same as that for a ShapeSheet expression. When you set the TestExpression property value, Visio does not check the syntax of the test expression. If the test expression is not syntactically correct, the evaluation of the expression fails during validation and Visio generates a validation issue at that time.

The default property values of a validation rule are as follows:


  • Category = [empty]

  • Description = "Unknown"

  • FilterExpression = [empty]

  • Ignored = False

  • TargetType = visRuleTargetShape

  • TestExpression = [empty]
Parsing the rules for the flowchart template

The following tables show the eleven rules defined within the flowchart template for checking basic flowchart diagrams.
Rule #1

ID

1

NameU

UngluedConnector

Category

Connectivity

Description

Connector is not glued at both ends.

RuleFilter

ROLE()=1

RuleTest

AND(AGGCOUNT(GLUEDSHAPES(4)) = 1, AGGCOUNT(GLUEDSHAPES(5)) = 1)

The rule checks that a connector is glued at both ends.

ROLE()=1 as the RuleFilter expression means to select all connector shapes.

GLUEDSHAPES is a shape method that returns an array that contains the identifiers of the shapes that are glued to a shape. The method takes a flag that specifies the dimensionality and directionality of the connection points of the shapes to be returned. The flag parameter options are itemized in visGluedShapesFlags enumeration:


  • visGluedShapesIncoming2D=4. If the source object is a 1D shape, return the 2D shape to which the begin point is glued.

  • visGluedShapesOutgoing2D=5. If the source object is a 1D shape, return the 2D shape to which the end point is glued.

AGGCOUNT counts how many shapes are returned by the GLUEDSHAPES method.

In words, the RuleFilter says to look at all connector shapes. For each connector shape found check that the begin point is glued to exactly one 2D shape and the end point is glued to exactly one 2D shape.



Rule #2

ID

2

NameU

StartWithoutTerminator

Category

Start / End

Description

Flowchart shape has no incoming connectors and is not a Start/End shape.

RuleFilter

AND(OR(HASCATEGORY("Flowchart"),ONLAYER("Flowchart")),NOT(OR(HASCATEGORY("Start/End"),STRSAME(LEFT(MASTERNAME(750),9),"Start/End"),STRSAME(LEFT(MASTERNAME(750),10),"Terminator"))))

RuleTest

AGGCOUNT(GLUEDSHAPES(1)) > 0

This somewhat complex looking RuleFilter is expressed below with some added indentation to aid in understanding.

AND(


OR( HASCATEGORY("Flowchart"),

ONLAYER("Flowchart")

),

NOT(OR(HASCATEGORY("Start/End"),



STRSAME(LEFT(MASTERNAME(750),9),"Start/End"),

STRSAME(LEFT(MASTERNAME(750),10),"Terminator")

) )

)

The shape has to either have the Flowchart category defined, HASCATEGORY(“Flowchart”), meaning there is a ShapeSheet cell User.msvShapeCategories=”Flowchart”, or the shape is on the “Flowchart” layer.



The shape must also not have a cell User.msvShapeCategories=”Start/End”, not be created from the “Start/End” master and not be created from a “Terminator” master. MASTERNAME is a ShapeSheet function that returns a shape’s master name as a string. The argument is used to specify a language for the string the function returns. Use a value of 0 (default value) to specify the local language. Use 750 to specify universal language.

If the shape satisfies these RuleFilter conditions, then the FilterExpresssion is applied. GLUEDSHAPES(1) returns a list of 1D shapes whose end points are glued to this shape. AGGCOUNT(GLUEDSHAPES(1))>0 states that the target shape must therefore have at least one incoming connector.



Rule #3

ID

3

NameU

EndWithoutTerminator

Category

Start / End

Description

Flowchart shape has no outgoing connectors and is not a Start/End shape.

RuleFilter

AND(OR(HASCATEGORY("Flowchart"),ONLAYER("Flowchart")),NOT(OR(HASCATEGORY("Start/End"),STRSAME(LEFT(MASTERNAME(750),9),"Start/End"),STRSAME(LEFT(MASTERNAME(750),10),"Terminator"))))

RuleTest

AGGCOUNT(GLUEDSHAPES(2)) > 0

The RuleFilter is identical to that of rule #2.

GLUEDSHAPES(2) returns a list of 1D shapes whose begin points are glued to this shape. AGGCOUNT(GLUEDSHAPES(2))>0 states that the target shape must therefore have at least one outgoing connector.



Rule #4

ID

4

NameU

NoStartTerminator

Category

Start / End

Description

Flowchart does not start with a Start/End shape.

RuleTarget

1

RuleFilter

AGGCOUNT(FILTERSET(SHAPESONPAGE(), "OR(HASCATEGORY(""Flowchart""),ONLAYER(""Flowchart""))")) > 0

RuleTest

AGGCOUNT(FILTERSET(SHAPESONPAGE(), "AND(OR(HASCATEGORY(""Start/End""),STRSAME(LEFT(MASTERNAME(750),9),""Start/End""),STRSAME(LEFT(MASTERNAME(750),10),""Terminator"")),AGGCOUNT(CONNECTEDSHAPES(2))>0)")) > 0

RuleTarget=1 sets the target of this rule to be the page. When no RuleTarget is specified, the default is to target shapes.

The RuleFilter filters the collection of all shapes on the page, SHAPESONPAGE(), to include only those shapes that are either assigned to the “Flowchart” category, HASCATEGORY(“Flowchart”), or have been assigned to a Flowchart layer. The AGGCOUNT function is used to check that the count in this collection is >0.

The RuleTest is shown below with indentation added for easier interpretation.

AGGCOUNT(

FILTERSET( SHAPESONPAGE(),

"AND(OR(HASCATEGORY(""Start/End""),

STRSAME(LEFT(MASTERNAME(750),9),""Start/End""),

STRSAME(LEFT(MASTERNAME(750),10),""Terminator"")),

AGGCOUNT(CONNECTEDSHAPES(2))>0)")

) > 0


The innermost portion

OR(HASCATEGORY(""Start/End""),

STRSAME(LEFT(MASTERNAME(750),9),""Start/End""),

STRSAME(LEFT(MASTERNAME(750),10),""Terminator"")),

specifies that the shape must either be defined with category “Start/End”, i.e., it has msvShapeCategories=”Start/End”, or it is derived from a master named Start/End or it is derived from a master named Terminator.

CONNECTEDSHAPES(2) is a shape method that returns a list of shapes connected to the shape which are associated with outgoing connectors.

AGGCOUNT(CONNECTEDSHAPES(2))>0 says there must be at least one shape connected with an outgoing connector.

FILTERSET selects all SHAPESONPAGE and then filters these shapes to include only those that are start or end terminator shapes which also have at least one outgoing connector. The outer most AGGCOUNT checks that at least one shape satisfies these conditions.

In summary the rule checks for at least one Start/End or Terminator shape that has outgoing connectors that are connected to something.

Rule #5

ID

5

NameU

NoEndTerminator

Category

Start / End

Description

Flowchart does not end with a Start/End shape.

RuleTarget

1

RuleFilter

AGGCOUNT(FILTERSET(SHAPESONPAGE(), "OR(HASCATEGORY(""Flowchart""),ONLAYER(""Flowchart""))")) > 0

RuleTest

AGGCOUNT(FILTERSET(SHAPESONPAGE(), "AND(OR(HASCATEGORY(""Start/End""),STRSAME(LEFT(MASTERNAME(750),9),""Start/End""),STRSAME(LEFT(MASTERNAME(750),10),""Terminator"")),AGGCOUNT(CONNECTEDSHAPES(1))>0)")) > 0

The rule is identical to rule #4 except that CONNECTEDSHAPES(1) returns a list of shapes connected to the shape which are associated with incoming connectors. Thus the rule checks for at least one terminating shape with incoming connectors that are connected to something.

Rule #6

ID

6

NameU

UnconnectedShape

Category

Connectivity

Description

Flowchart shape is not connected to any other shape.

RuleFilter

OR(HASCATEGORY("Flowchart"),ONLAYER("Flowchart"))

RuleTest

AGGCOUNT(CONNECTEDSHAPES(0)) > 0

The RuleFilter looks for shapes that have category “Flowchart” or are on a “Flowchart” layer.

The shape must be connected to at least one other shape. CONNECTEDSHAPES(0) returns a list of shapes connected to the shape via either incoming or outgoing connections.



Rule #7

ID

7

NameU

TerminatorInMiddle

Category

Connectivity

Description

Start/End shape has both incoming and outgoing connectors.

RuleFilter

OR(HASCATEGORY("Start/End"),STRSAME(LEFT(MASTERNAME(750),9),"Start/End"),STRSAME(LEFT(MASTERNAME(750),10),"Terminator"))

RuleTest

NOT(AND(AGGCOUNT(CONNECTEDSHAPES(1))>0,AGGCOUNT(CONNECTEDSHAPES(2))>0))

The RuleFilter finds terminator shapes by checking msvShapeCategories=”Start/End” or shapes that inherit from master “Start/End” or from master “Terminator”.

The RuleText counts both incoming connectors (CONNECTEDSHAPES(1)>0) and outgoing connectors (CONNECTEDSHAPES(2)>0). A terminator should not have both incoming and outgoing connectors.



Rule #8

ID

8

NameU

TooFewOutConns

Category

Connectivity

Description

Decision shape should have more than one outgoing connector.

RuleFilter

OR(HASCATEGORY("Decision"),STRSAME(LEFT(MASTERNAME(750),8),"Decision"))

RuleTest

AGGCOUNT(GLUEDSHAPES(2)) > 1

The RuleFilter checks for shapes that either have a cell msvShapeCategories=”Decision” or are derived from a master named “Decision”.

GLUEDSHAPES(2) returns a list of 1D shapes whose begin points are glued to this shape. AGGCOUNT(GLUEDSHAPES(2))>0 states that the Decision shape must therefore have more than one outgoing connector.



Rule #9

ID

9

NameU

NonFlowchartShape

Category

Connectivity

Description

Connected shape is not recognized as a Flowchart shape.

RuleFilter

NOT(OR(HASCATEGORY("Flowchart"),ONLAYER("Flowchart")))

RuleTest

AGGCOUNT(GLUEDSHAPES(0)) = 0

The RuleFilter checks for shapes that do not have a cell msvShapeCategories=”Flowchart” and are not on a layer named “Flowchart”.

Any shapes found by the RuleFilter are checked. GLUEDSHAPES(0) returns a list of all 1D shapes that are glued to this shape. AGGCOUNT(GLUEDSHAPES(0))=0 states that the shape has no glued shapes. Therefore, a validation issue is raised only if there is a non flowchart shape that is glued to something else. A non flowchart shape can exist in the drawing without raising a validation issue as long as it is not glued to another shape.




Rule #10

ID

10

NameU

NoShapeText

Category

Text

Description

Flowchart shape has no text label.

RuleFilter

OR(HASCATEGORY("Flowchart"),ONLAYER("Flowchart"))

RuleTest

NOT(STRSAME(SHAPETEXT(TheText), ""))

The RuleFilter checks for “Flowchart” shapes either defined by category or assigned to a layer.

The RuleTest compares the shape text to the null string. Therefore, any flowchart shape raises an issue if it has no text.



Rule #11

ID

11

NameU

OutsideCFF

Category

Cross - Functional

Description

Flowchart shapes should belong to a Swimlane.

RuleTarget

1

RuleFilter

AGGCOUNT(FILTERSET(SHAPESONPAGE(),"HASCATEGORY(""Swimlane"")"))>0

RuleTest

AGGCOUNT(FILTERSET(SHAPESONPAGE(),"AND(OR(HASCATEGORY(""Flowchart""),ONLAYER(""Flowchart"")),AGGCOUNT(FILTERSET(PARENTCONTAINERS(),""HASCATEGORY(""""Swimlane"""")""))=0)"))=0

The last rule is a page level check (RuleTarget=1).

The RuleFilter gets all Swimlane shapes. If there are no swimlanes on the page, this rule has no effect.

If there are swimlanes on the page the RuleTest checks to see that all Flowchart shapes are within a swimlane. The RuleTest is displayed below with indentation for easier interpretation.

AGGCOUNT(

FILTERSET(

SHAPESONPAGE(),

"AND(OR(HASCATEGORY(""Flowchart""),ONLAYER(""Flowchart"")),

AGGCOUNT(FILTERSET(PARENTCONTAINERS(),

""HASCATEGORY(""""Swimlane"""")""))=0)")

)=0


The outer FILTERSET selects all SHAPESONPAGE and filters these to include only shapes that are Flowchart shapes (which have either the Flowchart category defined or are on a Flowchart layer) AND whose PARENTCONTAINERS are in the Swimlane category. If any flowchart shape does not have a swimlane parent, the outer ADDCOUNT will be greater than 0.

Custom validation rules and rule sets


There are two main approaches to creating custom validation rules and rule sets.

  1. You can write validation rules and validation logic that will be stored in a custom Visio template. These rules are automatically available to users that create diagrams based on this template. When a user clicks Check Diagram on the Process tab, Visio uses the validation logic provided to determine whether the diagram has issues. In Visio 2010, this technique is used for the Basic Flowchart, Cross Functional Flowchart and Business Process Modeling Notation templates.

  2. You can also write validation logic in code and deploy this logic as part of a Visio solution. For this approach, the solution code listens for the appropriate RuleSetValidated event and uses its own logic to determine the list of issues to add to the document. In Visio 2010, this technique is used for the Microsoft SharePoint Workflow template.
Adding custom validation rules to a template

Custom rules can be created to add to the existing rules provided with Visio or completely new rule sets can be created.

The following macro shows how to create a custom rule set. This rule set has two rules. The first tests that Process shapes have exactly one outgoing connector. The second rule tests that Decision shapes have more than 1 outgoing connector.

Sub AddPicayuneRules()

Dim RuleSet As Visio.ValidationRuleSet

Dim rule As Visio.ValidationRule

'Add a new RuleSet

Set RuleSet = ThisDocument.Validation.RuleSets.Add("Picayune Rules")

RuleSet.Description = "Verify that the Picayune rules are followed"

RuleSet.Enabled = True

RuleSet.RuleSetFlags = visRuleSetDefault

'Rule 1: Checks that process shapes have exactly one outgoing connector

Set rule = RuleSet.Rules.Add("WrongNumConn")

rule.Category = "Connectivity"

rule.Description = "Process shape should have one outgoing connector"

rule.TargetType = visRuleTargetShape

rule.FilterExpression = "OR(HASCATEGORY(""Process""),STRSAME(LEFT(MASTERNAME(750),7),""Process""))"

rule.TestExpression = "AGGCOUNT(CONNECTEDSHAPES(2)) = 1"

'Rule 2: Checks that decision shapes have more than one outgoing connector

Set rule = RuleSet.Rules.Add("TooFewOutConns")

rule.Category = "Connectivity"

rule.Description = "Decision shape should have more than one outgoing connector"

rule.TargetType = visRuleTargetShape

rule.FilterExpression = "OR(HASCATEGORY(""Decision""),STRSAME(LEFT(MASTERNAME(750),8),""Decision""))"

rule.TestExpression = "AGGCOUNT(CONNECTEDSHAPES(2)) > 1"



End Sub

Whether the rules are created via a macro as is done in the above example or imported into a drawing using the Check Diagram > Import Rules From option, the drawing can be saved as a template. Then when new drawings are created from this template the custom rules that were saved with the template can be applied to the new drawing.


Adding validation logic in code

If you save a Microsoft SharePoint Workflow diagram as an XML Drawing (*.vdx) and open the XML Drawing in an XML editor, you will see that there is no logic in the RuleFilter and RuleTest expressions. In this case, the solution contains code with the validation logic. The SharePoint Workflow solution listens for the SharePoint Workflow RuleSetValidated event, and, when this event occurs, it scans the diagram to determine if there are issues. When an issue is found, it uses the validation API to add the issue to the document. Visio automatically displays these issues in the Issues Window.

validationxml-2
Summary of options available for utilizing validation logic

  1. End-users and companies can use the default rules provide in Visio 2010 to check their diagrams for issues and ensure diagram consistency. Out-of-the box support is included for Basic Flowchart, Cross Functional Flowchart, Microsoft SharePoint Workflow and Business Process Modeling Notation diagrams.

  2. Developers can extend the out-of-box support by creating custom templates with validation rules. These rules are available to users who create diagrams from these templates.

  3. Developers can create Visio solutions that listen for the validation event. When the Check Diagram button is clicked, the solution can run code to validate complex logic and use the validation API to add issues to the list of issues displayed in the Issues Window.

  4. Developers can create Visio solutions that trigger validation from within their code. This allows solutions to make use of validation without relying on a click of the Check Diagram button. For example, the Microsoft SharePoint Workflow template triggers validation when a user clicks the SharePoint Workflow button Export on the Process tab.



Managing validation issues


When using Check Diagram to verify a process Visio will either tell you there are no problems with the diagram or display a list of issues in the Issues Window. Each problem that occurs raises a Validation Issue that is displayed in the Issues Window. Each issue displays the Description and the Category from the rule that has been violated and the page that the problem occurs on if there are multiple pages in the drawing. Selecting an issue in the Issues Window automatically selects the shape that is the target of that issue.

Once an issue is fixed, choose Check Diagram again to verify that there are no remaining problems.

Sometimes you may find that an issue does not apply to a certain shape in the drawing. When this occurs, you can ignore the issue and Visio will not display it in the Issues window. If a rule does not apply to an entire document, you can also ignore the rule so that no issues associated with that rule are displayed. To ignore an issue or a rule, right-click the issue in the Issues Window and select the appropriate command. If ignored, the issues are removed from display in the Issues window. Any ignored issues can be redisplayed at any time.

To create issues programmatically, use the Rule.AddIssue method. The issue will automatically be displayed in the Issues window. Use ValidationIssue.Delete to delete an individual issue or use ValidationIssues.Clear to remove all issues.


The SharePoint Workflow ribbon group


Beginning with SharePoint Server 2007 users have been able to create workflows that can be executed in SharePoint. Beginning with Visio 2010 users can now use Visio’s visual interface for creating the initial workflow before exporting it to SharePoint Designer for further editing before it becomes the final workflow executable in SharePoint.

A SharePoint workflow is just another type of process flow so it lends itself well to being created initially in Visio. In SharePoint there are predefined common activities such as “Send an email”, “Assign item for feedback”, and “Assign item for approval”. Visio captures each of these standard SharePoint activities in the form of shapes in a stencil which are used to create the workflow drawing in Visio. To create the workflow in Visio, simply drag and drop shapes and connect the shapes just as you would any other Visio flow diagram. And Visio’s Check Diagram feature can be used to validate the workflow before exporting it to SharePoint designer.



Note:

Visio will automatically check the workflow diagram before exporting. Visio will not allow invalid diagrams to be exported.



Try it! Create a SharePoint Workflow diagram

  1. Create a new drawing in Visio by choosing File > New > Flowchart > Microsoft SharePoint Workflow. Note that there are three stencils opened with the template: SharePoint Workflow Actions, SharePoint Workflow Conditions, and SharePoint Workflow Terminators.

  2. Create the following diagram.



  1. Validate the drawing using Process > Check Diagram. The Issues Window should look like the following.



  1. Select the issue in the Issues Window. The problem shape (a connector shape) will be selected.

  2. Add the text “Yes” to the connector.

  3. Validate the drawing again and fix any remaining issues.



Try it! Export the validated workflow

  1. Choose Export from the Process SharePoint Workflow group.

  2. Choose a location and save the file. The exported file is saved as a Visio Workflow Interchange file (.vwi).

  3. So that we may examine the file further, change the extension from .vwi to .zip.

  4. Open the .zip file.

Note that there are four files embedded in the .vwi file.

  • [ContentTypes].xml – this file stores a list of the file extensions of the files embedded in the .vwi file.

  • Workflow.vdx – the Visio drawing file in XML format.

  • Workflow.xoml – an XML representation of the workflow. This includes all conditions, activities, and their parameters. SharePoint Workflow Designer uses this file to retrieve the workflow logic and the values for each condition and activity.

  • Workflow.xoml.rules – defines the rules used when checking the workflow for errors.


Download 0.72 Mb.

Share with your friends:
  1   2   3   4   5   6   7   8   9   ...   12




The database is protected by copyright ©ininet.org 2024
send message

    Main page