0% found this document useful (0 votes)
74 views44 pages

Introduction To Windows Workflow Foundation: Adam Calderon Principal Engineer - Interknowlogy Microsoft MVP - C#

A workflow is a class using System.workflow.Activities; public class MyWorkflow: SequentialWorkflow . A workflow class may be defined in markup. An activity is a list of actions that are performed by a workflow.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views44 pages

Introduction To Windows Workflow Foundation: Adam Calderon Principal Engineer - Interknowlogy Microsoft MVP - C#

A workflow is a class using System.workflow.Activities; public class MyWorkflow: SequentialWorkflow . A workflow class may be defined in markup. An activity is a list of actions that are performed by a workflow.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 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

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


LOB Apps sales automation quote to cash MBS applications ISV / SI Solutions BPI integration, B2B BizTalk ISV / SI Solutions .NET Developer pageflow mainstream dev ASP, WinFX ISV / SI Solutions IT Management hire/fire resource provisioning MIIS ISV / SI solutions Information Worker document life cycle collaboration Office 12 ISV / SI solutions

Workflow Foundation
.NET

Consolidating workflow investments and providing a unified framework for internal products, partners and customers
4

Tenets of Workflow
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 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

long running and stateful

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

What is a workflow?
A workflow is a class
using System.Workflow.Activities; public class MyWorkflow: SequentialWorkflow { }

A workflow class may be defined in markup


<?Mapping XmlNamespace="Activities" ClrNamespace="System.Workflow.Activities" Assembly="System.Workflow.Activities" ?> <SequentialWorkflow x:Class="MyWorkflow" xmlns="Activities" xmlns:x="Definition"> </SequentialWorkflow>
8

Workflow Authoring Modes


Markup Only Declarative
XML
XML defines workflow structure logic and data flow

Markup and Code XML C#/VB

Code Only C#/VB


Code creates workflow in constructor

Application Generated
App creates activity tree and serializes

XML defines workflow Code-beside defines extra logic

XML

C#/VB

Workflow Compiler wfc.exe C#/VB Compiler


.NET

assembly ctor defines workflow


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
IfElse, Delay, While, State, etc. InvokeWebService, InvokeMethod, etc.

Custom activities can derive from the out of the box activities Built using the same component APIs thats 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 Extend activity RosettaNet IT Mgmt CRM

Author new activity

OOB activities, workflow types, base types General-purpose Activity libraries define workflow constructs

Create/Extend/ Compose activities App-specific building blocks First-class citizens

Vertical-specific activities & workflows Best-practice IP & Knowledge


14

Activities out of the box


Workflow types
SequentialWorkflow, StateMachineWorkflow

Transactions
TransactionContext, Compensate

Structural
Sequence, Parallel, Replicator, While

Communications
CallExternalMethod, HandleExternalMethod, InvokeWebService

State machine
State, StateInitialization, EventDriven, SetState

Conditions and Rules


IfElse, ConditionedActivityGroup, Policy
15

Custom Activities
Activity is unit of:
Execution Reuse Composition
Workflow Execution Logic

Simplicity
Code Activity InvokeWebService Activity InvokeMethod & EventSink Custom Activities

Activities enable workflow modeling Custom activity examples

SendEmail, FileSystemEvent, Flexibility PurchaseOrderCreated, AssignTask, etc.


16

Activity Execution States


Canceling Compensating

Initialize

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

Tracked by a Tracking Runtime Service ActivityExecutionStatus 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 Declarative nature allows domain experts to concentrate on the business requirements Model-driven design allows for rich authoring and management tools Externalization of rule logic from application code Rapid deployment model Supporting impact analysis and simulation capabilities
22

Approachability

Ease of Change

Rules and Application Development


Forms
Rules and policies

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)>

RuleSet
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 RuleSet RuleSet 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
When(Condition1)
Child activities

CAG executes
Until(Condition2)

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
Separation of business logic from application sequencing Declarative statements of business intent Execution semantics to support rich sets of business logic

Motivation

Scenarios

Order validation Warranty claims management Discount calculation

31

What about the BizTalk BRE?


The next major version of BizTalk (postBizTalk 2006) will be built on Windows Workflow Foundation Windows Workflow Foundation will provide the core rules engine evaluator and developer tools BizTalk will provide premium tooling and server infrastructure, e.g.:
Business analyst tools RuleSet storage and management RuleSet analysis
32

Policy Overview
RuleSet class contains a collection of Rules Rules define:
IF-THEN-ELSE expressions Execution priority Maximum execution count

Expressions evaluate and operate on activity properties

33

RuleSet Execution Semantics


Rules are executed in order of priority (highlow) Forward chaining causes rule re-evaluation
Implicit based on property usage Explicit using Update statement Partially explicit using method attributes

34

Policy - Forward Chaining


RuleSet
Rule 1 (P0)
If Total > $50 & < $100 Then Discount = 10%

Execution Sequence
Rule 1 Rule 3 Rule 2

Rule 2 (P0)
If Total >= $100 Then Discount = 15%

Rule 3 (P0)
If Amount > $0 Then Total = Total + Amount

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
Step1

State Machine Workflow


Event Event
State1 State2

Rule-based Activities
Rule1 Data
Step1

Step2

Rule2

Step2

Structure prescribes processing order Prescriptive, formal Automation scenarios Flowchart metaphor

External events drive processing order Reactive, event-driven Skip/re-work patterns Exception handling Graph metaphor

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
TimerService manages timers e.g. Delay activity. PersistenceService stores and retrieves instance state. TrackingService manages profiles and stores tracked information. Common resource services for managing threading and creating transactions 39

Services

Out of Box Services are provided that support SQL Server

TimerService PersistenceService

SQL
Scripts for DB are located in C:\WINDOWS\Microsoft.NET\F ramework\v3.0\Windows Workflow Foundation\SQL\EN

TrackingService
ThreadingService TransactionService

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 InterKnowlogy www.InterKnowlogy.com Contact Information E-mail: [email protected] Phone: 760-930-0075 x274 Blog: http://blogs.InterKnowlogy.com/AdamCalderon About Adam Calderon Microsoft MVP C# Microsoft ASP.NET (UI Server Frameworks) Advisory Council Developer / Author / Speaker / Teacher
43

You might also like