21
SharePoint Workflow Development Using Visual Studio Brian LaSitis February 27, 2008

SharePoint Workflow Development Using Visual Studio

  • Upload
    gali

  • View
    67

  • Download
    0

Embed Size (px)

DESCRIPTION

SharePoint Workflow Development Using Visual Studio. Brian LaSitis February 27, 2008. Topics. Why use Visual Studio vs. SP Designer? Advantages & Disadvantages Windows WF Overview General Concepts & Usage Scenarios Workflow Types Activity Overview SharePoint WF Extensions - PowerPoint PPT Presentation

Citation preview

Page 1: SharePoint Workflow Development Using Visual Studio

SharePoint Workflow DevelopmentUsing Visual Studio

Brian LaSitisFebruary 27, 2008

Page 2: SharePoint Workflow Development Using Visual Studio

Topics Why use Visual Studio vs. SP Designer?

Advantages & Disadvantages Windows WF Overview

General Concepts & Usage Scenarios Workflow Types Activity Overview

SharePoint WF Extensions Custom Workflow Solutions

Demo Custom SP Designer Actions

Demo

Page 3: SharePoint Workflow Development Using Visual Studio

SharePoint Designer - Workflow

Advantages Disadvantages Targets the Information

Worker Allows business users to

apply simple business logic within a document library or list

Uses a rules-based approach, similar to the Rules Wizard in Outlook

Can be deployed without installing custom code to a server

Default capabilities limited to the actions available out of box

Limited wide-deployment options since each workflow is inherently tied to a specific list/document library

Does not support state-machine workflows

Workflows cannot be modified while they are executing

Page 4: SharePoint Workflow Development Using Visual Studio

Visual Studio / Windows WF

Advantages Disadvantages Graphical, flow-chart like

development tools. Builds upon WF foundation,

and adds SharePoint-specific activities.

Supports custom association, initiation, modification, and task forms.

Allows deployment through use of SharePoint features.

Requires significant knowledge of the .NET development and the WF framework.

Requires custom code to be deployed to the SharePoint server.

Requires the developer to fully understand the underlying business logic of the workflow process.

Page 5: SharePoint Workflow Development Using Visual Studio

SharePoint Features Overview Modular framework for deploying functionality

within a specific scope within SharePoint: Farm Web Application Site Collection Web Site

Stored within 12\TEMPLATE\FEATURES. Must be installed and activated to be used

within their configured scope. Can be “stapled” to existing site collections,

including those provided out-of-the-box.

Page 6: SharePoint Workflow Development Using Visual Studio

What is Windows WF? A pillar within the .NET Framework 3.0 that

provides the programming model, engine, and toolset for creating workflows in Windows Not product specific; leveraged by many products.

In its most basic form, WF is a multithreaded execution engine that can be leveraged by any type of .NET application

Graphical development tools are directly integrated with Visual Studio 2005, through the Windows WF Designer.

Page 7: SharePoint Workflow Development Using Visual Studio

WF Usage Scenarios Windows WF can be leveraged for any of the

following: Workflow within LOB applications Windows Forms / ASP.NET UI Page Flow Document-centric workflow Human workflow Composite workflow for SOA Business rule-driven workflow Workflow for systems management

Page 8: SharePoint Workflow Development Using Visual Studio

What products use Windows WF? Windows SharePoint Services 3.0 Microsoft Office SharePoint Server 2007 Microsoft BizTalk Server 2006 R2 Microsoft Dynamics CRM 4.0 Microsoft Identity Integration Server

Page 9: SharePoint Workflow Development Using Visual Studio

A WF Workflow Definition Can be one of three types: sequential, state-

machine, or rules-based. Composed of a set of activities, that are

interconnected to form a business process.

Sequential State-Machine Rules-Based

Ideal for business processes

Ideal for processes with external interaction

Ideal for complex decision scenarios

Typically execute autonomously without external interaction

Typically are reliant upon outside control to complete execution

Typically use large, chained rule-trees to drive execution

Execution controlled by the workflow itself

Events control the workflow execution

Rules & policies control workflow execution

Root Activity: SequentialWorkflow

Root Activity: StateMachineWorkflow

Either state-machine or sequential can be used.

Page 10: SharePoint Workflow Development Using Visual Studio

Common WF ActivitiesActivity Name Description

Sequence Activity Composite activity that executes the set of activities within it in a sequential fashion.

Code Activity Executes a snippet of .NET code.

IfElse Activity Implements If-Then-Else conditional logic within a workflow.

While Activity Implements looping logic within a workflow.

Parallel Activity Composite activity that executes two or more Sequence activities in a cooperative multithreaded manner.

CallExternalMethod Activity Invokes an external (.NET) method on an object, as defined in an interface bound to the activity.

Page 11: SharePoint Workflow Development Using Visual Studio

The Workflow Runtime The Workflow Runtime is responsible for

coordinating the following events: Starting workflow instances Invoking workflow events Tracks and uses pluggable services for providing

functionality such as transactions, persistence, and tracking.

Only one Workflow Runtime can exist within the application executing the workflow. Windows Forms, Console, ASP.NET applications Windows Services SharePoint

Page 12: SharePoint Workflow Development Using Visual Studio

SharePoint Workflows in WF SharePoint extends the WF foundational framework

by adding new workflow activities. Visual Studio add-ins are installed as part of the

SharePoint 2007 SDK; supported by VS 2005 & 2008. It is advisable to perform the development of

SharePoint WF workflows on an actual server running SharePoint. Results in simplified development and deployment since

assembly references and post-build deployment steps are automated using the default project templates.

The development of custom workflow actions in Visual Studio that are callable from SP Designer workflows is also possible.

Page 13: SharePoint Workflow Development Using Visual Studio

Custom Workflow Forms SharePoint WF-based workflows can be

configured to use a custom form for association, instantiation, and modification, as well as custom task forms. These can be implemented as ASPX forms or as

InfoPath web-enabled forms (MOSS only)

Form Type Description

Association Used to capture information when a workflow is associated with a list or document library.

Initiation Used to capture information when a workflow is manually started for an item by a user.

Task Completion Used to capture custom information when a workflow participant completes a task.

Modification Used to capture changes for processing workflows, if they are modified externally.

Page 14: SharePoint Workflow Development Using Visual Studio

SharePoint WF ActivitiesActivity Name Description

OnWorkflowActivated Activity Starting activity for all SharePoint WF workflows; can accept inputs from Association & Initiation forms.

CreateTask Activity Creates a new task for a given user in the workflow.

OnTaskChanged Activity Captures changes to a task that affect workflow processing.

SendEmail Activity Sends email to a person or group of people.

LogToHistoryList Activity Allows entries to be written to a workflow’s History list, for tracking purposes.

OnWorkflowModified Activity Accepts inputs from the Modification form to change a workflow’s behavior.

Page 15: SharePoint Workflow Development Using Visual Studio

SharePoint WF Development Tasks Create a SharePoint Sequential or State

Machine workflow project within Visual Studio 2005.

Add and configure activities on the WF design surface.

Create any necessary custom forms (InfoPath or ASP.NET-based)

Create a workflow.xml file. Create a SharePoint feature for deploying the

workflow and custom forms (if any).

Page 16: SharePoint Workflow Development Using Visual Studio

Demo WF Workflow Example – Content Submission

Process the serial approval of an item within a document library.

Upon approval, the document is automatically moved to a secured document library.

Page 17: SharePoint Workflow Development Using Visual Studio

Custom SP Designer Actions Allows custom logic to be leveraged in SP

Designer workflows. All built-in actions within SP Designer are custom

WF activities Defined in 12\TEMPLATE\1033\WORKFLOW\

WSS.ACTIONS Custom actions are created within Windows WF

Activity Library projects in Visual Studio New actions require a one-time server

deployment process, yet they can be leveraged on any SP Designer workflows that are developed. No client deployment is required.

Page 18: SharePoint Workflow Development Using Visual Studio

Custom Action Development Tasks Create a new Workflow Activity Library project

in Visual Studio 2005. Create 1 or more DependencyProperties for

handing custom action inputs and outputs. Define custom execution logic using Workflow

activities or by overriding the Execute method of the custom activity being developed.

Create a .ACTIONS file (XML), describing the custom action. Deploy to 12\TEMPLATE\1033\WORKFLOW

Deploy assembly to GAC and add an authorizedType entry in the web.config for it.

Page 19: SharePoint Workflow Development Using Visual Studio

SP Designer Auto-Properties The following properties, if defined on a

custom SP Designer workflow action, are auto-populated with data at runtime.

Property Name Assigned Value .NET Data Type

__ActivationProperties The activation properties data for the running workflow instance.

Microsoft.SharePoint.Workflow.SPWorkflowActivationProperties

__ListId String containing the GUID for the list the workflow is defined on.

System.String

__ListItem Integer value for the list item the workflow instance is running on.

System.Int32

__Context The context object for the running workflow instance.

Microsoft.SharePoint.WorkflowActions.WorkflowContext

Page 20: SharePoint Workflow Development Using Visual Studio

Demo Custom SharePoint Designer Workflow Action

Create sub-site using input parameters of Site Title and Site Description.

Page 21: SharePoint Workflow Development Using Visual Studio

Wrap-up Custom-developed Windows WF solutions are

supported on the SharePoint 2007 platform: Sequential & State Machine workflows Custom activities (actions) for use in SP Designer

Decision factors to determine the technology to use: Developer skillsets Information Worker roles vs. Developer roles Reusability needs Governance policies in place

Questions?