programming4us
programming4us
ENTERPRISE

SharePoint 2010 : Workflow Modeling and Development Tools (part 2) - Visual Studio 2010 & Workflow Modeling Tools Comparison

- How To Install Windows Server 2012 On VirtualBox
- How To Bypass Torrent Connection Blocking By Your ISP
- How To Install Actual Facebook App On Kindle Fire
6/7/2011 11:38:42 AM

3. Visual Studio 2010

Visual Studio 2010 is a development tool for developing various types of applications and services. It provides development project types for different SharePoint customizations and project templates for SharePoint 2010 workflows. Visual Studio 2010 uses the Windows Workflows Foundation (WF) designer to define a workflow’s activities, the order in which to execute them, and the conditions in which to perform them. In the following sections, you explore some of the important aspects of workflow development within Visual Studio 2010.

3.1. Visual Studio Workflow Project Types

A developer can create sequential or state machine workflows in Visual Studio 2010. Alternatively, it is possible to import a SharePoint Designer–based reusable workflow to create a workflow solution. Visual Studio 2010 provides a project template, shown in Figure 6, for all of these types of workflow development activities.

Figure 6. SharePoint 2010 project templates in Visual Studio 2010


The figure contains the following list of SharePoint 2010 project templates available in Visual Studio 2010 .

  • Sequential Workflow In a sequential workflow project, the activities happen in a specific sequence from start to finish. You can branch these activities with the help of conditions. This type of workflow is ideal for creating approval or feedback collection scenarios, where activities happen in sequence: first there is a request for feedback or approval, then the feedback or approval is sent, and so forth.

  • State Machine Workflow A state machine workflow represents a set of states, transitions, and actions. The steps in a state machine workflow execute asynchronously, and they are triggered by actions and states. One state is assigned as the start state, and then, based on an event, a transition is made to another state. The state machine can have a final state that determines the end of the workflow.

  • Import Reusable Workflow This project type is used for importing a SharePoint Designer 2010–based reusable workflow for further development, by adding code or activities that are not supported by SharePoint Designer.

3.2. Standard Workflow Activities in Visual Studio

The activities available for use while developing a workflow appear in the Toolbox on the left side of the screen, as shown in Figure 7. A developer can drag these activities onto the design surface to define the steps in a workflow. The properties of each activity can then be set in the Properties window that appears in the lower-right corner. The Base Activity Library of Windows Workflow Foundation provides a group of fundamental activities, and SharePoint 2010 also provides a set of activities designed expressly for creating workflows.

Figure 7. Visual Studio 2010 standard workflow activities


The following workflow activities are commonly used when designing SharePoint 2010 workflows.

  • OnWorkflowActivated Provides a standard starting point for a workflow. This activity can accept information supplied by a SharePoint administrator by using the Association form when the workflow is associated with a document library, list, content type, or site. It can also accept information supplied by the Initiation form when the workflow is started. Every workflow must begin with this activity.

  • CreateTask Creates a task assigned to a particular user in a task list. This activity also has a SendEmailNotification property that, when set to True, automatically sends an e-mail message to the person for whom this task was created.

  • OnTaskChanged Accepts information from the Task Completion form, which can be used in the rules and other actions in the workflow.

  • CompleteTask Marks a task as completed.

  • DeleteTask Removes a task from a task list.

  • OnWorkflowModified Accepts information from the Modification form, which can then be used to change how this instance of the workflow behaves. If the workflow’s creator chooses not to include any instances of this activity in the workflow, that workflow cannot be modified while it is running. This activity is responsible for reassigning a task to another use, adding more participants to a running workflow, and so on.

  • SendEmail Sends an e-mail message to a specified person or group of people.

  • LogToHistoryList Writes information about the workflow’s execution to a history list. The information in this list is used to let users see where a workflow is in its execution, look at the workflow’s history after it is completed, and more. To allow this kind of monitoring, the workflow’s author must write information to a history list at appropriate points in the workflow’s execution. Because it provides its own mechanism for tracking workflows, SharePoint 2010 doesn’t support the Windows Workflow Foundation’s standard tracking service.

3.3. Creating Workflows in Visual Studio

The creation of a simple workflow in Visual Studio 2010 begins with choosing the template—a sequential or state machine workflow. (Figure 8 shows an example of a workflow created using the Sequence template.) After selecting the appropriate template, you specify a site that will be used for deploying, debugging, and testing the workflow during development. You then specify the workflow association type as either a Site or List workflow. Finally, you specify the workflow history and the task list to use for testing the workflow. At this point, the graphical workflow designer is displayed; this is where you define the workflow logic.

A simple workflow in Visual Studio 2010 begins with an OnWorkflowActivated activity and then uses a CreateTask activity to assign a task to participants in the workflow. The standard WhileActivity can be used to wait until the users complete the tasks and provide necessary data through the task form, which is shown as part of task activity. An OnTaskChanged activity executes within the WhileActivity, extracting whatever information the user has entered on that form. Based on the information collected, the workflow can use the CodeActivity activity to perform any complex logic and update data on the item or document with which this workflow is associated.

SharePoint 2010 provides all activities that are available in Visual Studio 2010 under SharePoint Workflow. These activities are designed to perform typical activities that a user would perform in the SharePoint 2010 environment. The business logic a workflow implements is determined by the developer of the workflow. In fact, a developer authoring a workflow is free to create and use custom activities and is not restricted to activities provided by SharePoint 2010 or Windows Workflow Foundation.

Figure 8. A sequential workflow in Visual Studio 2010


Apart from designing the workflow’s logic, the workflow developer is also responsible for creating the forms that will interact with the users. There are four types of forms a workflow developer can create: Association, Initiation, Task, and Modification forms. As the workflow develops, you must do some work to pass information between the workflow and its .ASPX or InfoPath forms. The Microsoft.Windows.SharePoint.Workflow namespace exposes an object model for developers. By using the types in this namespace, the creator of a workflow can pass information from a form to the workflow and vice versa.

After the workflow and its forms have been created, you use a SharePoint Feature to package the workflow for deployment. An Element.xml file, part of the feature definition, is used for binding the forms with the workflow. When the feature definition is created, this feature, along with other features, pages, and so on, are packaged into a solution (WSP) for deployment. Visual Studio 2010 project templates are capable of creating the solution packages.

As the workflow developer, you can debug the workflows in Visual Studio 2010 simply by pressing the F5 key, which deploys the workflow, activates the workflow on the chosen site, and associates the workflow to the list or site chosen earlier. The developer can complete the necessary workflow tasks and see that the control comes back to the Workflow Designer for the next task on the workflow. This way you can validate that each activity on the workflow is executing as expected and yields the correct results. After validation, the developer delivers the solution package to be used on a SharePoint 2010 farm.

A SharePoint farm administrator must then install and deploy the solution to all Web applications where the workflow is to be used. The site collection administrators can activate the workflow feature on their site collection. The new workflow will now be visible to the site administrators as a workflow template that can be associated with a document library, list, content type, or site.

4. Workflow Modeling Tools Comparison

Use Table 2 to help you determine which workflow development tool is best for creating your workflows.

Table 2. Workflow Modeling Tools Comparison
FUNCTIONALITYSHAREPOINT DESIGNER 2010VISUAL STUDIO 2010
Can be scoped to a site collectionYesYes
Workflows are accessible in client applications (other than the browser)YesYes
Can use ASP.Net forms as workflow’s formsYesYes
Can use InfoPath forms as workflow’s formsYesYes
One-click publishing available for workflowsYesYes
Can be used for modifying predefined workflowsYesYes
Can be used to create workflows with serial activitiesYesYes
Can be used to create workflows with parallel activitiesYesYes
Can be used to create sequential workflowsYesYes
Workflows can be created using only actions that are approved by SharePoint administratorsYesNo
Can use Visio 2010 to create workflow logicYesNo
Workflows can be deployed remotely from workflow authoring environmentYesNo
Can be used to create state machine workflowsNoYes
Need to write codeNoYes
Additional activities (other than the ones provided by SharePoint 2010) can be used in creating workflowsNoYes
Workflow can be modified while it is runningNoYes
Can be used to create workflow that is made available across the farmNoYes
Can be used to create custom workflow activitiesNoYes
Can be used to create workflows that interact with external systemsNoYes
Other  
  •  SharePoint 2010 : Creating and Managing Workflows - Workflows in SharePoint 2010
  •  Exchange Server 2010 : Meet Message Retention Compliance (part 3) - Keep a Record of Email Communications
  •  Exchange Server 2010 : Meet Message Retention Compliance (part 2) - Archive Email
  •  Exchange Server 2010 : Meet Message Retention Compliance (part 1) - Enforce Records Management
  •  Exchange Server 2010 : Maintaining Reliability and Availability - Recover Data
  •  Exchange Server 2010 : Maintaining Reliability and Availability - Back Up Exchange
  •  Exchange Server 2010 : Utilize the Availability Options for Servers Based on Role (part 3) - Implement Redundant Transport Servers
  •  Exchange Server 2010 : Utilize the Availability Options for Servers Based on Role (part 2) - Increase Mailbox Database Availability
  •  Exchange Server 2010 : Utilize the Availability Options for Servers Based on Role (part 1) - Load-Balance Client Access Servers
  •  Exchange Server 2010 : Track Exchange Performance (part 2) - Test the Performance Limitations in a Lab
  •  
    Top 10
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
    - Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
    - Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
    - Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
    - Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
    - Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
    - Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
    REVIEW
    - First look: Apple Watch

    - 3 Tips for Maintaining Your Cell Phone Battery (part 1)

    - 3 Tips for Maintaining Your Cell Phone Battery (part 2)
    programming4us programming4us
    programming4us
     
     
    programming4us