Introduction to Windows Workflow Foundation Adam Calderon Principal












































- Slides: 44
Introduction to Windows Workflow Foundation Adam Calderon Principal Engineer - Interknowlogy Microsoft MVP – C#
Agenda Vision, tenets and architecture What is a workflow? What is an activity? Rules More architecture and features Summary Q&A 2
Workflow Vision and Goals Vision: Deliver best-in-class workflow platform & tools for Microsoft products and partner/customer ecosystem Single workflow technology for Windows Base for Microsoft products and ISV/customer solutions One technology for human and system workflow A framework not a server product or application An extensible framework based on. NET Ships as Windows OOB release and in. NET 3. 0 Make workflow mainstream for. NET developers Strong workflow partner & solution ecosystem Reach mainstream application developer 3
Single Workflow Technology for Windows – Scenarios IT Management • hire/fire • resource provisioning • MIIS • ISV / SI solutions LOB Apps • sales automation • quote to cash • MBS applications • ISV / SI Solutions BPI • integration, B 2 B • Biz. Talk • ISV / SI Solutions. NET Developer • pageflow • mainstream dev • ASP, Win. FX • ISV / SI Solutions Workflow Foundation Information Worker • document life cycle • collaboration • Office 12 • ISV / SI solutions . NET Consolidating workflow investments and providing a unified framework for internal products, partners and customers 4
Tenets of Workflows coordinate work performed by people and by software Workflows are long running and stateful Workflows are based on extensible models Workflows are transparent and dynamic through their lifecycle 5
Architectural Concepts A Workflow “coordinate people and software” “long running and stateful” An Activity App Activity Library Workflow Foundation Base Activity Library • workflow constructs Runtime Engine • intrinsic behavior Runtime Services • hosting flexibility Host Process • my app or server “extensible models” “transparent and dynamic through their lifecycle” 6
Agenda Vision, tenets and architecture What is a workflow? What is an activity? Rules More architecture and features Summary Q&A 7
What is a workflow? A workflow is a class using System. Workflow. Activities; public class My. Workflow: Sequential. Workflow { … } A workflow class may be defined in markup <? Mapping Xml. Namespace="Activities" Clr. Namespace="System. Workflow. Activities" Assembly="System. Workflow. Activities" ? > <Sequential. Workflow x: Class="My. Workflow" xmlns="Activities" xmlns: x="Definition"> … </Sequential. Workflow> 8
Workflow Authoring Modes Markup Only “Declarative” XML • XML defines workflow structure logic and data flow Markup and Code XML C#/VB • XML defines workflow • Code-beside defines extra logic Code Only Application Generated C#/VB App creates activity tree and serializes • Code creates workflow in constructor XML C#/VB Workflow Compiler wfc. exe C#/VB Compiler assembly • ctor defines workflow . NET 9
Building a Workflow Windows Workflow Foundation
Agenda Vision, tenets and architecture What is a workflow? What is an activity? Rules More architecture and features Summary Q&A 11
What are Activities? An activity is a step in a workflow Has properties and events that are programmable within your workflow code Has methods (e. g. Execute) that are only invoked by the workflow runtime Think of Forms & Controls Activity == Controls Workflows == Forms Activities fall under two broad categories Basic – steps that “do work” Composite – manage a set of child activities 12
Out of the Box Activities Designed for modeling flow control & communications If. Else, Delay, While, State, etc. Invoke. Web. Service, Invoke. Method, etc. Custom activities can derive from the out of the box activities Built using the same component APIs that’s available to developers 13
Activities: An Extensible Approach Base Activity Library Custom Activity Libraries Domain-Specific Workflow Packages Compliance Compose activities Out-of-Box Activities OOB activities, workflow types, base types General-purpose Activity libraries define workflow constructs CRM Extend activity Author new activity Create/Extend/ Compose activities App-specific building blocks First-class citizens Rosetta. Net IT Mgmt Vertical-specific activities & workflows Best-practice IP & Knowledge 14
Activities out of the box Workflow types Sequential. Workflow, State. Machine. Workflow Structural Sequence, Parallel, Replicator, While… State machine Transactions Transaction. Context, Compensate Communications Call. External. Method, Handle. External. Method, Invoke. Web. Service… State, State. Initialization, Event. Driven, Set. State Conditions and Rules If. Else, Conditioned. Activity. Group, Policy 15
Custom Activities Activity is unit of: Execution Reuse Composition Activities enable workflow modeling Custom activity examples Workflow Execution Logic Simplicity Code Activity Invoke. Web. Service Activity Invoke. Method & Event. Sink Custom Activities Send. Email, File. System. Event, Flexibility Purchase. Order. Created, Assign. Task, etc. 16
Activity Execution States Initialize Canceling Compensating Executing Closed Activity Execution Methods Initialize() Execute() Cancel() Compensate() Transition Types Runtime Activity 17
Activity Execution Status Returned by Execute() method Can be determined by a parent activity or workflow this. Execution. Status Tracked by a Tracking Runtime Service Activity. Execution. Status Enumeration Initialized Executing Compensating Cancelling Closed Faulting 18
Property Promotion Children at any depth can have their properties exposed through the composite activity Allows the workflow author / activity consumer to configure values which affect internal activity logic without exposing logic Supported through the Custom Activity Designer 19
Building an Activity Windows Workflow Foundation
Agenda Vision, tenets and architecture What is a workflow? What is an activity? Rules More architecture and features Summary Q&A 21
Why Rules? Modeling Power Ø Simple semantics for defining discrete, atomic rules Ø Aggregation of rules into rule sets that represent rich application behavior Approachability Ø Declarative nature allows domain experts to concentrate on the business requirements Ø Model-driven design allows for rich authoring and management tools Ease of Change Ø Externalization of rule logic from application code Ø Rapid deployment model Ø Supporting impact analysis and simulation capabilities 22
Rules and Application Development Forms t n e m p o l ve Rules and e d en policies v i r d le d Mo Workflow model Application code Application logic Data Services 23
Rules and Process Policy applied based on carrier, cost and schedule Condition determines if approval is required Rules set reminder time limit 24
Terminology Condition Expression that evaluates to True or False Rule Modeled as: IF<Condition> THEN<Action(s)> ELSE<Action(s)> Rule. Set Collection of Rules with a set of execution semantics 25
Workflow Rules Conditions on activities If-Else While Replicator Conditioned Activity Group (CAG) Policy activity Contains and executes a Rule. Set execution provides priority-based, forward-chaining semantics 26
Activities - Condition Types Code Conditions Method in workflow class that returns a Boolean Rule Conditions Declarative expression that evaluates to a Boolean 27
Conditioned Activity Group (CAG) Motivation Flexible, rule-driven activity execution Modeling of activity sets with numerous sequencing permutations Scenarios Stage-Gate pattern Collaborative tasks 28
CAG - Overview Child activity executes Child activities When(Condition 1) CAG executes Until(Condition 2) Default execution is a parallel When “Activity executed count == 0” Ø Executes activity once Until Conceptually an activity executes: IF When && !(Until) “All children quiescent” Ø Executing children complete and all When conditions == false 29
CAG - Overview Reevaluation When immediate child moves to completed state Define custom Until condition to shortcircuit CAG execution Custom Until == true No new activities executed Blocked activities cancelled 30
Policy Motivation Scenarios Separation of business logic from application sequencing Declarative statements of business intent Execution semantics to support rich sets of business logic Order validation Warranty claims management Discount calculation 31
What about the Biz. Talk BRE? The next major version of Biz. Talk (post. Biz. Talk 2006) will be built on Windows Workflow Foundation will provide the core rules engine evaluator and developer tools Biz. Talk will provide premium tooling and server infrastructure, e. g. : Business analyst tools Rule. Set storage and management Rule. Set analysis 32
Policy Overview Rule. Set class contains a collection of Rules define: IF-THEN-ELSE expressions Execution priority Maximum execution count Expressions evaluate and operate on activity properties 33
Rule. Set Execution Semantics Rules are executed in order of priority (high low) Forward chaining causes rule re-evaluation Implicit based on property usage Explicit using Update statement “Partially explicit” using method attributes 34
Policy - Forward Chaining Execution Sequence Rule. Set Rule 1 (P 0) If Total > $50 & < $100 Then Discount = 10% Rule 1 Rule 3 Rule 2 (P 0) If Total >= $100 Then Discount = 15% Rule 3 (P 0) If Amount > $0 Then Total = Total + Amount = $25 Total = $80 $105 Discount = 10% 15% 35
Rules and Activities Windows Workflow Foundation
Agenda Vision, tenets and architecture What is a workflow? What is an activity? Rules More architecture and features Summary Q&A 37
Flow Styles Several styles of flow constructs are available to support human and system workflow patterns Sequential Workflow Step 1 State Machine Workflow Event State 1 Rule-based Activities Rule 1 Step 1 Data Step 2 Event State 2 Structure prescribes processing order External events drive processing order • Prescriptive, formal • Automation scenarios • Flowchart metaphor • Reactive, event-driven • Skip/re-work patterns • Exception handling • Graph metaphor Rule 2 Step 2 Business rules drive processing order • Data-driven • Rules and Policies • Used in sequential and state machine 38
Out of box Runtime Services Host Application App Domain Runtime Timer. Service manages timers – e. g. Delay activity. Persistence. Service stores and retrieves instance state. Tracking. Service manages profiles and stores tracked information. Services Out of Box Services are provided that support SQL Server Timer. Service Persistence. Service SQL Tracking. Service Threading. Service Transaction. Service Scripts for DB are located in C: WINDOWSMicrosoft. NETF rameworkv 3. 0Windows Workflow FoundationSQLEN Common resource services for managing threading and creating transactions 39
Sample Workflow Applications Windows Workflow Foundation
Additional Features Compensation Local Communication and Correlation Persistence Tracking Fault Handling Dynamic Update 41
Summary Windows Workflow Foundation is a framework for building workflow into applications A single workflow technology for Windows Base for Microsoft products and ISV/customer solutions Broad spectrum of human and system workflow scenarios Ships in Windows ( OOB and. NET 3. 0) Activities: extensible framework approach Rules: CAG, Policy Flow styles: sequential, state machine, rule-based Runtime: intrinsic behaviors and pluggable services Rich visual designers for workflows and activities 42
Adam Calderon More info on Inter. Knowlogy www. Inter. Knowlogy. com Contact Information E-mail: adamc@Inter. Knowlogy. com Phone: 760 -930 -0075 x 274 Blog: http: //blogs. Inter. Knowlogy. com/Adam. Calderon About Adam Calderon Microsoft® MVP – C# Microsoft® ASP. NET (UI Server Frameworks) Advisory Council Developer / Author / Speaker / Teacher 43