Introduction To Windows Workflow Foundation: Adam Calderon Principal Engineer - Interknowlogy Microsoft MVP - C#
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 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
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
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 { }
Application Generated
App creates activity tree and serializes
XML
C#/VB
Building a Workflow
Agenda
Vision, tenets and architecture What is a workflow? What is an activity? Rules More architecture and features Summary Q&A
11
Custom activities can derive from the out of the box activities Built using the same component APIs thats available to developers
13
Compliance Compose activities Out-of-Box Activities Extend activity RosettaNet IT Mgmt CRM
OOB activities, workflow types, base types General-purpose Activity libraries define workflow constructs
Transactions
TransactionContext, Compensate
Structural
Sequence, Parallel, Replicator, While
Communications
CallExternalMethod, HandleExternalMethod, InvokeWebService
State machine
State, StateInitialization, EventDriven, SetState
Custom Activities
Activity is unit of:
Execution Reuse Composition
Workflow Execution Logic
Simplicity
Code Activity InvokeWebService Activity InvokeMethod & EventSink Custom Activities
Initialize
Executing
Closed
17
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
19
Building an Activity
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
Workflow model
Application code
Application logic
Data
Services
23
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
Rule Conditions
Declarative expression that evaluates to a Boolean
27
Scenarios
28
CAG - Overview
Child activity executes
When(Condition1)
Child activities
CAG executes
Until(Condition2)
Until
All children quiescent Executing children complete and all When conditions == false
29
CAG - Overview
Reevaluation
When immediate child moves to completed state
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
31
Policy Overview
RuleSet class contains a collection of Rules Rules define:
IF-THEN-ELSE expressions Execution priority Maximum execution count
33
34
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
35
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
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
Services
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
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