Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF...
-
date post
21-Dec-2015 -
Category
Documents
-
view
219 -
download
1
Transcript of Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF...
Workflow in Microsoft SharePoint Products and Technologies 2007: Deep Dive for Developers
Mark ReesMicrosoft Consulting Services
OFC409
Session Objectives and Agenda
Windows Workflow Foundation (WF) Primer
Creating WF programs in Visual Studio
Creating workflow templates for WSS
Workflow associations and workflow instances
Creating and waiting on WSS tasks
Integrating workflow input forms
Reactive Programs
Automating a business processOften requires program with episodic behaviorProgram waits around and then reacts to some event
How would you automate document approval?
In a Windows Forms application…In an ASP.NET Application…
Windows Workflow Foundation (WF)
What is the Windows Workflow Foundation?Development platform for building reactive programsSet of development tools integrated with Visual StudioRuntime components that ship with.NET FX 3.0
Activities
An activity is…atomic set instructions used complete a unit of workreusable component used to compose WF programs
Activities are like a controls in forms developmentYou drag and drop them onto a design surfaceYou modify their properties through property sheetYou generate event handlers and write code inside
Activities are different than controlsActivities are resumable
Composite Activities
Composite Activities can contain children
Composite activity controls execution of childrenComposite activity can encapsulate control-of-flowExamples: IfElse, While, Sequence, Parallel, Replicator
WF program is itself a composite activity
WF program models a tree of activities
WF Program Types
WF provides two main styles of WF programsSequential WF program modeled as flow chartState machine WF program models using states
The WF Runtime
WF Runtime Services
Custom services can be written and plugged inWSS provides it own persistence service
SharePoint Workflows Concepts
Design goals for WF integration with WSSUse WF to attach logic to items and documentsAdd a human dimension on top of WFMaintain self-service capabilities common in WSSCreate strong developer story for custom WF programsProvide valuable WF programs out-of-box with MOSS
The human dimensionAny SharePoint workflow can assign tasks to usersUsers can see status on any workflow instance
SharePoint Workflow Actors
Workflow TemplateWF Program and optionally workflow input forms A feature to install it inside WSS farm
Workflow AssociationBinding of workflow template to list or content typeA named instance containing parameterized data
Workflow InstanceA running instance of a WF program attached to item
Creating a Workflow Template Project
Creating a SharePoint Workflow TemplateFirst, install the WF Extensions for Visual StudioSecond, install either the WSS SDK or the MOSS SDKThird, start creating SharePoint Workflow projects
Working in Code View
Here is what you get as a starting point
SharePoint Activity LibraryWSS-specific activities used to create SharePoint WF Programs
Data Bound Properties
WF supports data binding of propertiesAllows for declarative flow of data between activitiesUsed extensively for creating SharePoint WF programs
Generating Event HandlersGenerate event handlers to add code
Event handlers can program against WF objects
Right-click on activity and choose Generate Handlers
Workflow Template Deployment
Workflow Templates are deployed via FeaturesFeature must be scoped to site collection (Scope=Site)Feature may contain multiple workflow templates
Workflow Template Definition
Workflow Element defines Workflow TemplateMust point to one specific WF programWF program must be compiled into an assembly DLLAssembly DLL must be installed in GAC
Testing 'Hello World' Workflow Template
Creating and Waiting on Tasks
SharePoint Workflows revolve around tasksRepresents significant value-add WSS brings to WFBased on standard WSS tasks visible/editable by usersUsers update tasks through browser or Office programsYour code automatically wakes up and executes
WSS Tasks are generated with subscriptionsWSS encapsulates the listener mechanismWSS registers event handlers behind the scenesYou just add event activities and write event handlers
Task GUIDs and Correlation Tokens
WSS sets up subscriptions for tasksBased on registering event handlersWSS needs way to identify certain task across activitiesEach tasks is assigned a GUID and a correlation token
Action Activities are blue
Event Activities are green
Action Activities vs. Event Activities
Action activities perform workTheir event handlers fire before work is done
Event activities run code in response to eventTheir event handlers run after the event has occurred
Initializing a New TaskAdd event handler behind CreateTask activity
This event handlers fires before task creationGives you a chance to initialize task propertiesWSS creates task with subscription so that workflow instance wakes up when task is modified
Waiting on a TaskEvent activity creates subscription
OnTaskChanged puts activity to sleepEvent handler fires upon modifcation
While activity used to control flowWhile activity loops until task complete
Integrating Workflow Input Forms
Workflow Input Form TypesAssociation FormInitiation FormsModification FormsTask Edit Form
Sample ProjectLitwareWorkflows
The Association Form
The Initiation Form
Invoking the Modification Form
There is one link per modification
The Task Edit Form
Creating Workflow Forms with InfoPath
Workflow input forms can be created in InfoPath
Benefits to creating workflow forms with InfoPathSignificantly better forms designer experienceSignificantly less codingForms can be opened directly with Office client apps
Drawback to creating forms with InfoPathWorkflow template will only run in MOSS farmsWorkflow template will not run in WSS-only farms
InfoPath Workflow Form Integation
standard MOSStask content type
standard MOSS application pages
urn:schemas-microsoft-com:office:infopath:ReviewInitiationForm2:-myXSD-2005-11-22T23-49-53
Evaluation Forms
Questions?
© 2007 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.
The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. 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 provided after
the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.