Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF...

35
  • 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...

Page 1: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.
Page 2: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

Workflow in Microsoft SharePoint Products and Technologies 2007: Deep Dive for Developers

Mark ReesMicrosoft Consulting Services

OFC409

Page 3: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 4: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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…

Page 5: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 6: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 7: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 8: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

WF Program Types

WF provides two main styles of WF programsSequential WF program modeled as flow chartState machine WF program models using states

Page 9: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

The WF Runtime

Page 10: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

WF Runtime Services

Custom services can be written and plugged inWSS provides it own persistence service

Page 11: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 12: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 13: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 14: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

Working in Code View

Here is what you get as a starting point

Page 15: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

SharePoint Activity LibraryWSS-specific activities used to create SharePoint WF Programs

Page 16: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

Data Bound Properties

WF supports data binding of propertiesAllows for declarative flow of data between activitiesUsed extensively for creating SharePoint WF programs

Page 17: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

Generating Event HandlersGenerate event handlers to add code

Event handlers can program against WF objects

Right-click on activity and choose Generate Handlers

Page 18: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

Workflow Template Deployment

Workflow Templates are deployed via FeaturesFeature must be scoped to site collection (Scope=Site)Feature may contain multiple workflow templates

Page 19: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating 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

Page 20: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

Testing 'Hello World' Workflow Template

Page 21: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 22: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 23: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 24: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 25: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 26: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

Integrating Workflow Input Forms

Workflow Input Form TypesAssociation FormInitiation FormsModification FormsTask Edit Form

Sample ProjectLitwareWorkflows

Page 27: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

The Association Form

Page 28: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

The Initiation Form

Page 29: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

Invoking the Modification Form

There is one link per modification

Page 30: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

The Task Edit Form

Page 31: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 32: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

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

Page 33: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

Evaluation Forms

Page 34: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

Questions?

Page 35: Mark Rees Microsoft Consulting Services OFC409 Windows Workflow Foundation (WF) Primer Creating WF programs in Visual Studio Creating workflow templates.

© 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.