working out with Windows Workflow...
Transcript of working out with Windows Workflow...
working out with
Windows Workflow FoundationWindows Workflow Foundation
Windows Workflow FoundationWindows Workflow FoundationAgenda
Intro to Workflow FoundationWorkflow BasicsDifferent ways of authoring workflowsDemos- WF Designer- Sequential Workflow- State Machine Workflow- Embedded WF Desinger Control
Looking forward ….Conclusion
What is a workflow?Workflow is the operational aspect of a work procedure: howtasks are structured, who performs them, what their relativeorder is, how they are synchronized, how information flowsto support the tasks and how tasks are being tracked
Src: http://en.wikipedia.org/wiki/Workflow
Modeled as a flowchartModeled as a flowchart……. .
Or a state diagramOr a state diagram……. .
Workflow Scenario Spectrum
• Participants: people, roles• Flow style: flexible, dynamic• Data: unstructured, documents
• Participants: apps, services• Flow style: prescriptive, protocols• Data: structured, transactional
Information Worker• Document Review…Information Worker• Document Review…
System WorkflowHuman Workflow
Windows Workflow Foundation
Business to Business• Supply Chain Mgmt…Business to Business• Supply Chain Mgmt…
Line of Business Apps• Quote to Cash, Sales Automation…
Line of Business Apps• Quote to Cash, Sales Automation…CRM ERP
IT Management• New Hire Provisioning, Trouble Ticket,…
IT Management• New Hire Provisioning, Trouble Ticket,…
.NET Developer• Pageflow, Service Coordination…
.NET Developer• Pageflow, Service Coordination…
Src: COM210 Introduction to Workflow in Windows Applications (Bill Devlin and Paul Andrew)
Why Workflow Technology?
““Orders are confirmed in Orders are confirmed in 48 hours and shipped within 30 48 hours and shipped within 30
days.days.””
““Most suppliersMost suppliersconfirm our orders but some forget confirm our orders but some forget
and we need to and we need to followupfollowup..””
““What are the next steps in handling What are the next steps in handling this order?this order?””
Real World Examples Real World Examples Workflow ValueWorkflow Value--AddAdd
Long Running and Long Running and StatefulStatefulWorkflows Workflows need to run over an need to run over an
extended period extended period =>=> need to maintain stateneed to maintain state
Flexible Control FlowFlexible Control FlowGive users flexibility to skip steps Give users flexibility to skip steps
If necessaryIf necessary
TransparencyTransparencyGiven a defined control flow,Given a defined control flow,
users can see the next activitiesusers can see the next activitiesat a glance at a glance
ROI from Workflow Models
Useful for developers duringdevelopment and
debugging
Domain-specificlanguage for defining
workflow models +
Out-of-box Constructs
Runtime uses the modelto produce event stream
+Support for long running workflow
(state management & compensation)
Check the modelin a high-level waywithout additional
developmenteffort
Models beget Models! Combining severalworkflows
Modifying workflowon the fly
Visualization Expressiveness Execution Monitoring
Transformation Composition Manipulation
Unified Way of looking at workflows!
Src: Dave Green’s Weblog
Goals of Windows Workflow Foundation (WF)
• Provide a single engine for workflow execution for all applications built on the Windows paltform
• Support a wide range of scenarios• Bring model-driven workflow development to the
entire WinFX development community• Enable re-usage workflow component
development through strong extensibility points and ensure developers and ISVs can embed this technology in their applications
Workflow Tenets
• Workflow are long-running and stateful• Workflows are transparent and dynamic
through their lifecycle• Workflows coordinate work performed by
people and their software
WF is NOT
• A stand-alone application!• A server!• A complete out-of-the box workflow solution!• One particular language
WF is …
• A framework for developing workflow applications• Part of WinFX
WF Requirements
• O/S: – Windows Vista– Windows Server 2003 (SP1)– Windows XP (SP2)
• VS.NET 2005
• VS 2005 Extensions for Windows Workflow Foundation
Windows Workflow Foundation –Engine Architecture
Activity and Rule Authoring APIs
Workflow Model
Out of Box Activities
Sequential State Machine PolicyCustomActivities
RuntimeWorkflow Execution
Scheduler Rules
Tracking Infrastructure
Workflow Lifecycle Management
State Management Activation
Hosting
CustomServices
Runtime ServicesPersistence
Tracking
Communication
Transactions
Timer
Threading
Host Process
WF Basics
• A workflow consists of a set of Activities– A workflow is an activity!
• An activity is a step in a workflow, and is the unit of execution, re-use, and composition for a workflow– Simple Activity– Composite Activity
Out-of-the-box activities • Control flow
– Sequence, Paralle, While, IfElse, Listen, EventDrivent, ConditionedActivityGroup (CAG), Replicator, Delay
• Transaction and Exception Activities– ExceptionHanlder, Throw, Compensate, Suspend,
Terminate• Data/form-centric
– UpdateData, SelectData, WaitForData, WaitForQuery
• Communication– InvokeWebService, WebServiceReceive,
WebServiceResponse, InvokeMethod, EventSink• Code Activity
– Code
Workflow Host
• Can be hosted in any applications– E.g. Any .Net application – WinForms,
ASP.Net, ….• Specialized Host
Host Process
WindowsWorkflow Foundation
Runtime Engine
A Workflow
An Activity
Runtime Services
Base Activity Library
Custom Activity Library
Visual DesignerWF Overview
• Visual Designer Graphical and code-based construction
• Base Activity Library- Out-of-box fundamental activities for defining workflow - Extensible base for defining custom activities
• Runtime Engine– Workflow Execution– State Management– Tracking Infrastructure– Dynamic Update
• Runtime ServicesHosting flexibility and Communication
– Persistence– Communication– Tracking
Evolving WF Activities
– OOB activities, workflow types, base types
– General-purpose– Activity libraries
define workflowconstructs
– Create/Extend/ Compose activities
– App-specific building blocks
– First-class citizens
Base ActivityLibrary
Custom Activity Libraries
Author new activity
Out-of-Box Activities
Extend activity
Compose activities
– Vertical-specific activities & workflows
– Best-practice IP & Knowledge
Domain-Specific Workflow Packages
Compliance
RosettaNet
CRM
IT Mgmt
Src: COM210 Introduction to Workflow in Windows Applications (Bill Devlin and Paul Andrew)
Types of Workflow• 2 built-in workflow types
– Sequential workflow:• Prescriptive, formal• Automation scenarios• Flowchart metaphor
– State-Machine workflow• Reactive, event-driven• Skip/re-work, exception
handling• Graph metaphor
• Developers can define their own workflow types
Sequential workflow
State-Machine workflow
Types of Workflow• 2 built-in workflow types
– Sequential workflow:• Prescriptive, formal• Automation scenarios• Flowchart metaphor
– State-Machine workflow• Reactive, event-driven• Skip/re-work, exception
handling• Graph metaphor
• Developers can define their own workflow types
Expressing Workflow
• Code• Markup (XAML/XOML)• Code + markup
Workflow Authoring Modes
.NET assembly• ctor defines
workflow
Markup OnlyMarkup Only““DeclarativeDeclarative””
XAMLXAML
Markup andMarkup andCodeCode
C#/VBC#/VB
Code OnlyCode Only ApplicationApplicationGeneratedGenerated
XAMLXAML C#/VBC#/VB
•• XML definesXML definesworkflow structureworkflow structurelogic and data flowlogic and data flow
•• XML definesXML definesworkflowworkflow•• CodeCode--beside beside defines extra logic defines extra logic
•• Code createsCode createsworkflowworkflowin constructorin constructor XAMLXAML C#/VBC#/VB
App creates activityApp creates activitytree and serializestree and serializes
Workflow Compilerwfc.exe
C#/VB Compiler
Src: COM210 Introduction to Workflow in Windows Applications (Bill Devlin and Paul Andrew)
XOML Example<?Mapping XmlNamespace="ComponentModel"
ClrNamespace="System.Workflow.ComponentModel" Assembly="System.Workflow.ComponentModel" ?>
<?Mapping XmlNamespace="Compiler" ClrNamespace="System.Workflow.ComponentModel.Compiler" Assembly="System.Workflow.ComponentModel" ?>
<?Mapping XmlNamespace="Activities" ClrNamespace="System.Workflow.Activities" Assembly="System.Workflow.Activities" ?>
<?Mapping XmlNamespace="RuleConditions" ClrNamespace="System.Workflow.Activities.Rules" Assembly="System.Workflow.Activities" ?>
<?Mapping XmlNamespace="System" ClrNamespace="System" Assembly="mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" ?>
<SequentialWorkflow x:Class="WorkflowLibrary2.Workflow2" x:CompileWith="Workflow2.xoml.vb" ID="Workflow2" xmlns:x="Definition" xmlns="Activities"><Code ID="code1" /><Delay TimeoutDuration="00:00:00" ID="delay1" /><Code ID="code2" />
</SequentialWorkflow>
System.Workflow
• 3 main namespaces– System.Workflow.Activities– System.Workflow.ComponentModel– System.Workflow.Runtime
• About 450+ classes
Explore the WF APIs +
Manipulating the XOML files
Starting the WorkflowDim workflowRuntime As New WorkflowRuntime()workflowRuntime.StartRuntime()AddHandler
workflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted
Dim type As System.Type = GetType(OrderWorkflow)
workflowRuntime.StartWorkflow(type)
WaitHandle.WaitOne()workflowRuntime.StopRuntime()...
Steps• Instantiate the WorkflowRuntime• Start the Runtime• Start the workflow• Wait for completion• Stop the Runtime
VS.NET 2005Simple Sequential Workflow
Workflow Communications with .Net
• To support the interaction– Define a contract for communication (.Net interface) – Register the implementation of the interface with the workflow
runtime • Workflow runtime mediates between the exchange of
events between worfklow instance and the .Net application• Queues used to exchange information between the host
application and the workflow– Key: The separation, or proxy layer allows workflow instance to
hydrate and dehydrate without using any in-memory references that may be held by host application.
WF Communication Stack
DistributedApplication Host
Message Queues
LocalApplication Host
LocalCommunication
Service
DataActivities
Web Services
Data activities vs Local Services
• Data activities– Payload of the information being transferred
must be of the same Type or Object class– Two built-in events: data queries and data saves
• Local Services– Inbound payload does not have not match the
outbound payload– Unlimited events
Communication between .Net application and workflow instance
Data Activities
State-Machine Workflow
Dehydration vs RehydrationWorkflow InstancesWorkflow Instances
UnloadLoad
• To allow workflow instances to be durable across restarts of the Workflowruntime or the host applications
• Persistence Service (i.e. SqlStatePersistenceService) provides the ability to persist and restore the entire state of a workflow instance to a durable data source (e.g. SQL Server, file)
Looking forward…..
ApplicationApplication
WWF RuntimeWWF Runtime
Developer Ecosystem
WorkflowsWorkflows
Workflow DevelopersWorkflow DevelopersMinimal coding, full authoring Minimal coding, full authoring environmentenvironment
Activity DevelopersActivity DevelopersCustom execution & validation logicCustom execution & validation logic
Host DevelopersHost DevelopersApplication services & hostApplication services & host
Flow Flow LogicLogic
ServicesServices Custom Custom ServicesServices
Custom Custom ActivitiesActivities
Src: COM327, Hosting and Communications in Workflow Scenarios, Israel Hilerio, Ph.D. Program Manager Microsoft Corporation
WF in Action –Office 12
Workflow Designer(Professional Developer)
- Design workflow schedule,activities, forms and code
in Visual Studio- Compiles Schedule into assemblies
Workflow Designer(Knowledge Worker)
- Design no-code workflow schedule (based on pre-trusted activities) in FrontPage
- Workflow is compiled the first time it is run
SharePoint List or Site Administrator
- Associate a workflow with a list, document library or content type making it available to
items in that scope- Complete a workflow specific association form
which parameterizes the workflow
End User Initiator- Office or Sharepoint user starts a worfklow manually
through menu commands or automatically by creating an item or changing an item
End User Participant- Receive a task notification through email
- Complete the task using a task form from within Sharepoint or Office
Some activities omitted
BizTalk Server
MessagingMessagingDesignDesignToolsTools
BusinessBusinessActivityActivityMonitorMonitor
AndAndAdminAdminToolsTools
OrchestrationOrchestration
TransformationTransformation
AdaptersAdapters
BizTalk ServerAcceleratorsAccelerators
•• Future version will migrate to Windows Future version will migrate to Windows Workflow Foundation for orchestrationWorkflow Foundation for orchestration
WorkflowWorkflow
WF action!
• K2.Net (BlackPearl)• Skelta.Net (Aquila)• Epicor• Captaris
Conclusion
• Overview of Windows Workflow Foundation (WF)
• Interaction between WWF with WinFormsand ASP.Net Application
• Experience WF today!
Windows Workflow FoundationWindows Workflow FoundationResources• Download Beta1.2 or Beta2 at
http://msdn.microsoft.com/workflow• http://www.windowsworkflow.net/• http://winfx.msdn.microsoft.com/library/• http://channel9.msdn.com/tags/workflow
Thank you!