Product Cover Image

Sams Teach Yourself Windows Workflow Foundation (WF) in 24 Hours, Safari

By Robert Eisenberg

Published by Sams

Published Date: Jan 8, 2009

More Product Info

Description

In just 24 sessions of about an hour, you’ll learn how to build robust, efficient business workflows with Windows Workflow Foundation (WF). Using a straightforward, step-by-step approach, each lesson builds the real-world foundation you need to succeed with WF from the ground up.

 

Filled with hands-on code examples, this book walks you through creating every type of workflow supported by .NET 3.5’s powerful new version of WF. One step at a time, you’ll discover how to host workflows, manage workflow lifecycles, integrate with Web services and WCF applications, create custom activities, and moreeverything you’ll need to solve real-world problems with WF!

 

Step-by-step instructions carefully walk you through the most common WF questions, issues, and tasks.

Q&As help you build and test your knowledge.

Notes point out shortcuts, solutions, and potential problems to avoid.

New terms are clearly defined and explained.

 

Learn how to...

  • Understand the value of workflows and their role in general .NET and advanced business process management systems
  • Run workflows from and exchange data with .NET applications
  • Create sequential, state-machine, and data-driven workflows
  • Define multi-level approval workflows that execute in parallel and escalate
  • Develop rulesets and manage them from SQL databases
  • Track your workflows to make them more agile and governable
  • Use Dynamic Update to change running workflows
  • Work with exceptions, compensation, and transactions
  • Expose workflows as Windows Communication Foundation (WCF) services and call Web services from workflows via WCF
  • Expose workflows as Web services and call Web services from workflows
  • Create basic, queued, event-driven, and composite custom activities

Table of Contents

Introduction     1

Book Target Audience     2

How This Book Is Organized     2

Hour Summary     3

 

Part I The Basics

HOUR 1 Understanding Windows Workflow Foundation     9

Describing Workflow and Workflow Systems     9

A Conceptual Description of Workflow     9

A Sample Expense Report Workflow     10

Workflow Segmentations     12

What Is a Business Process Management System?      13

.NET Framework 3.0 and 3.5     13

Overview of WF     14

Standard Modeling Activities     16

Multiple Workflow Styles     19

Hosting     23

Tracking     24

Rule Capabilities     26

Conditional Rules     26

RuleSets     27

Custom Activities     29

Reason for Custom Activities     29

Types of Custom Activities     30

XAML Workflows and Serialization     33

Dynamic Update     34

WF and WCF     36

WF and WCF: Conceptual Overview     36

WF and WCF: Integration Specifics     37

SharePoint Workflow     38

SharePoint Workflow Overview     38

SharePoint Workflow Visual Studio     40

SharePoint Workflow SharePoint Designer     40

Designer Rehosting and External Modeling     41

Summary     43

Installation Instructions     44

Visual Studio 2005 and .NET Framework 3.0 Installation Directions     44

Visual Studio 2008 and .NET Framework 3.5 Installation Requirements/Directions     45

 

HOUR 2 A Spin Around Windows Workflow Foundation     47

Creating a Basic Workflow     47

Creating a Workflow Project     47

Building and Running a Workflow     49

Enhancing the Workflow     53

Improving Workflow Transparency     57

Passing Parameters to the Workflow     58

Using Declarative Rules     60

Adding New Activities     60

Creating the Declarative Rule     61

Examining the Project Files     63

Creating a XAML + Code Workflow     64

Adding and Configuring Activities     64

Examining the XAML Workflow     65

Running the XAML + Code Workflow     66

Creating a XAML-Only Workflow     66

Modeling and Preparing the XAML-Only Workflow for Execution     67

Call XAML-Only Workflow from Host     68

Summary     69

Workshop     69

Quiz     69

Answers     70

 

HOUR 3 Learning Basic Hosting     71

Overview of Hosting     72

Building a Host from Scratch     72

Creating Solution and Projects     73

Create a Simple Workflow     75

Creating the Host     75

Adding the Persistence Service     80

Adding Monitoring Events     83

Creating the Persistence and Tracking Databases     85

Running the Workflow     86

Updating the Host via Configuration     87

Summary     89

Workshop     90

Quiz     90

Answers     90

 

HOUR 4 Learning Host-Workflow Data Exchange     91

Host-Workflow Data Exchange     91

Creating the Solution and Projects     93

Creating the Solution     94

Creating the Local Service Project     94

Creating the Workflow Project     95

Creating the Windows Forms Project     95

Step 1: Creating the Local Service Interface     96

Step 2: Creating the Payload (EventArgs) Class     97

Step 3: Creating the Workflow     99

Adding the DependencyProperty Type     99

Step 3A: Creating a HandleExternalMethod Activity     101

Handle External Event Activity Property Window     102

Adding an IfElse Activity and Rules     103

Adding CallExternalMethod Activities     103

Creating the Windows Forms Host     108

Adding Controls to the Form     109

Adding the WF Runtime to the Form/Host     109

Step 4A: Creating the Workflow Instance and Raising the Initial Event     112

Step 4B: Implementing the Local Service     113

Building and Running the Project     116

Summary     116

Workshop     117

Quiz     117

Answers     118

 

HOUR 5 Creating an Escalation Workflow     119

Updating the Local Services     120

Updating the Basic Local Service Interface     120

Creating the Escalation Local Service     121

Extending the Workflow     122

Adding the Activities     122

Configuring CheckCredit’s Activities     125

Updating the Workflow Code-Beside File     127

Update the Forms (Hosts)      128

Implement New Interface Members in the Escalation Form     128

Implement the MoreInfo Method in the Basic Order Form     129

Configure Hosts to Track and Persist     130

Add Tracking to Basic and Escalation Forms     130

Add Persistence to Both Forms     131

Retrieve Tracking Data     132

Retrieve the Workflow from Persistence     135

Running the Solution     137

First-Level Approval or Rejection     137

Second-Level Approval or Rejection     138

Second Level Approval and Tracking     139

Running the WorkflowMonitor SDK Sample     141

Downloading and Installing WorkflowMonitor     141

Summary     143

Workshop     144

Quiz     144

Answers     144

 

Part II State Machined Workflows and Advanced Control Flow Activities

HOUR 6 Creating Basic State Machine Workflows     147

Explaining State Machine Workflows     147

Investigating State Machine Workflow Components     149

Creating the Project     150

Creating the Workflow     150

Preparatory Work     151

Adding State and EventDriven Activities     151

Updating the EventDriven Activities     153

Running the Basic Workflow     159

Hierarchical States and State Introspection     159

Modifying the Workflow     160

StateMachineWorkflowInstance and State Introspection     165

Run the Enhanced State Machine Workflow     165

Summary     166

Workshop     166

Quiz     166

Answers     167

 

HOUR 7 Creating Advanced State Machine Workflows     169

Updating the Form and Adding Member Variables     170

Updating the Form Code-Behind Logic to Work with StateMachineWorkflowInstance Members     170

Extract “In Scope” Events     171

SetState Combo Box     174

Historical States     175

Possible State Transitions     176

Override the Current State     176

Update the UI When Workflow Idles     177

Update the UI when Workflow Completes     177

Update the UI When Workflow Terminates     178

Running the Workflow     178

Summary     180

Workshop     180

Quiz     180

Answers     180

 

HOUR 8 Working with Parallel Activities and Correlation     181

Creating the Solution and First Project     181

Create the Parallel Activity Tester Project     182

Creating the Workflow     182

Standard Parallel Activity Execution     182

Running the Parallel Workflow     183

Synchronized Parallel Execution     185

Parallel Approval and Correlation     187

Opening the Solution and Adding the Projects     188

Local Service with Correlation     188

Create the Event Payload (EventArgs)      190

Concurrent Approver Workflow     191

Summary     200

Workshop     201

Quiz     201

Answers     201

 

HOUR 9 Working with the Replicator and While Activities     203

Creating Solutions and Projects     204

Creating the Replicator Workflow     204

Adding Member Variables to the Workflow     204

Placing the Activities on the Workflow     205

Configuring the Activities     206

Updating the Host Form     210

Running the Replicator Sequentially     212

Using the While Activity for Sequential Processing     213

Modeling the Workflow     213

Adding Code-Beside for the While Activity     213

Updating the Replicator Workflow to Run in Parallel     215

Adding Parallel Support to the Replicator     215

Running the Parallel Replicator     216

Summary     217

Workshop     217

Quiz     217

Answers     218

 

HOUR 10 Working with EventHandlingScope and Strongly Typed Activities     219

Learning Basic EventHandlingScope Activity Solution and Project Setup     220

Creating the Basic EventHandlingScope Workflow     220

Placing the Activities on the EventHandlingScope Sequential Section     220

Placing the Activities on the EventHandlingScope Event Handlers Section     221

Configuring the Event Handling Scope Sequential Activities     223

Configuring the EventHandlingScope Event Handling Activities     224

Running the Basic EventHandlingScope Workflow      225

Looking at the EventHandlingScope Activity in XAML     225

Creating a More Advanced EventHandlingScope Workflow     226

Setting up the Advanced EventHandlingScope Activity Solution     226

Add the Activities to the Workflow     227

Running the Advanced EventHandlingScope Workflow     232

Using WCA.exe to Build the Strongly Typed Activities     233

Use Strongly Typed Activities on a Workflow     234

Summary     237

Workshop     238

Quiz     238

Answers     238

 

Part III Data-Driven Workflows and Rules

HOUR 11 Creating Data-Driven Workflows     241

Describing the CAG     241

Exploring the CAG and Data-Driven Workflows     243

CAG Approval Sample     243

Creating the Project     244

Adding Variable Declarations     244

Add the CAG to the Workflow     245

Configuring the Approver1Lane of the CAG     246

Configuring the Approver2Lane of the CAG     249

Running the Workflow with Two Lanes     251

Configuring the Approver3Lane of the CAG     252

Run the Workflow with Three Lanes     254

Summary     254

Workshop     255

Quiz     255

Answers     255

 

HOUR 12 Working with the WF RuleSet     257

Creating the RuleSet     258

RuleSet Terminology and Project Ruleset     258

Creating the Project     260

Creating the RuleSet via the Policy Activity     260

Monitoring the RuleSet     264

Adding RuleSet Tracing     265

Evaluating Pre-Execution Results     265

Evaluating Post-Execution Results     267

Calling Methods from Rules     267

Attributing Methods to Detect Dependency     269

Using the External RuleSet Application     271

Downloading the External RuleSet Application     271

Running the Sample Workflow     272

Uploading Rules to the External Database     273

Adding the Custom Policy Activity to the Toolbox     275

Preparing the Workflow to Use External Rules     275

Configuring the Workflow to Use External Rules     276

Running the Workflow with External Rules     277

Summary     278

Workshop     278

Quiz     278

Answers     279

 

Part IV Intermediate and Advanced Features

HOUR 13 Learning to Track Workflows     283

Tracking Architecture      284

Tracking and Business Activity Monitoring     285

TrackingProfileDesigner SDK Sample     286

Reviewing the TrackingSolution     286

Opening the TrackingProfileDesigner and Loading a Workflow     288

Tracking Workflow Level Events     289

Tracking Activity Level Executed and Completed Events     290

Uploading and Examining the Profile and Running the Workflow     292

Additional Tracking Functionality     294

Manually Updating Tracking Profile and UserTrackingRecords     298

Adding User Tracking Data     299

Retrieving and Saving the TrackingProfile to a File     299

Manually Modifying and Uploading a Tracking Profile     300

Workshop     304

Quiz     304

Answers     305

 

HOUR 14 Working with Roles     307

Explaining Roles     307

Describing the Role Solution     308

Setting up an ASP.NET Role Provider     308

Updating the Host     311

Updating the Workflow     312

Adding Level2Role Support     315

Adding Level2Role Support to the Workflow     315

Adding Level2Role Support to the Code-Beside     315

Running the Solution with Level 2 Support     316

Summary     317

Workshop     317

Quiz     317

Answers     317

 

HOUR 15 Working with Dynamic Update     319

Applying Dynamic Update: Outside and Inside     320

Applying Dynamic Update from the Inside     321

Applying Dynamic Update from the Outside Unplanned     324

Explaining Dynamic Update from the Outside Planned     326

Updating Rules Dynamically     327

Selecting Which Version to Run     329

Changing Declarative Rule Conditions with Dynamic Update     329

Changing a RuleSet Rule via the CodeDom     332

Dynamic Update: Exploring Workflow Changes Sample     337

Summary     340

Workshop     341

Quiz     341

Answers     341

 

HOUR 16 Working with Exceptions, Compensation, and Transactions     343

Creating the Project     344

Basic Exception Handling     344

Modeling the ExceptionWorkflow     345

Adding a Workflow-Level FaultHandlers Activity     345

Handling the Exception     348

Configuring Visual Studio Debugger to Not Trap CLR Exceptions     349

Hierarchical Exception Handling and the Throw Activity     350

Updating the Exception Workflow     350

Catching Exceptions in the IfElse Activity     351

Handling Exceptions in the IfElse Activity     352

Use the Throw Activity     353

Reconfiguring the Throw Activity     353

Activity Handlers Elements and Views     354

Cancellation Handlers     355

Performing Preliminary Setup     355

Modeling the CancellationWorkflow     356

Adding the Cancellation Handler     356

Compensation Overview     357

Performing Preliminary Setup     358

Registering the SQL Persistence Service     358

Modeling the CompensationWorkflow     359

Adding the Compensation Handler     359

Adding a FaultHandlers Activity to the Workflow and Rerunning the Workflow     361

Adding a Compensate Activity to the Fault Handler     361

Moving the Throw Activity into the CompensatableSequence Activity     362

Transactions     363

Performing Preliminary Setup     363

Model and Configure the TransactionWorkflow     364

Running the SQL Script to Create the TestTransaction Database     365

Running the Workflow     365

Summary     366

Workshop     367

Quiz     367

Answers     368

 

HOUR 17 Learning Advanced Hosting     369

Exploring WorkflowRuntime Events     370

Workflow Events Sample Application     371

Running the AdvancedHostingForms Project     372

Runtime Services     375

Loading Service     377

Workflow Queuing Service     378

Building the Scheduling Service Project     379

Modeling and Configuring the Workflow     379

Updating the Host to Run Three Workflows     380

Running the Workflow with the DefaultWorkflowScheduler Service     381

Updating the Host to Use the ManualWorkflowSchedulerService     381

Running the Workflow with the ManualWorkflowSchedulerService     382

Modifying the Workflow to Use Delay Activities     383

InvokeWorkflow Activity     384

InvokeWorkflow Project: Host Prematurely Exits     385

InvokeWorkflow Project: Host Waits     387

InvokeWorkflow Project: Synchronous Calls and Parameters     387

Summary     394

Workshop     394

Quiz     394

Answers     395

 

HOUR 18 Working with Web Services and ASP.NET Hosting     397

Creating the Solution and Projects     398

Creating a Workflow and Publishing It as a Web Service     398

Creating Dependency Properties     398

Modeling and Publishing the Workflow     399

Creating the Interface to Produce the WSDL     399

Configure the WebServiceInput Activity     400

Configuring the IfElse Activity     401

Configuring the WebServiceOutput Activity     402

Publishing the Workflow as a Web Service     403

Calling a Web Service from a Workflow     404

Creating Dependency Properties     404

Modeling the Workflow     404

Finishing Configuring the InvokeWebService Activity     405

Running the Basic Workflow Solution     406

Additional Workflow Topics     407

Working with SOAP Faults     407

Exploring Generated Project and Cookie Usage     410

Exploring the WebServiceInvokeActivity.WebServiceProxy Property     412

Learning ASP.NET Hosting     413

Opening the Existing Solution and Creating the ASP.NET Project     413

Instantiating the WorkflowRuntime     414

Creating the ASP.NET Web Form     415

Starting the Workflow Instance     416

Running the ASP.Net Hosted Workflow     418

Summary     418

Workshop     418

Quiz     418

Answers     419

 

HOUR 19 Learning WF-WCF Integration     421

Overview of Windows Communication Foundation     421

WF and WCF Overview     422

Hosting a Workflow in WCF Using Existing Interface and Receive Activity     424

Creating the Solution and Projects     425

ABCs of WCF and WF Specific Bindings     426

Exploring the ContractsAndWorkflows Project and Bindings     427

Creating the WCF Endpoint and Host     431

Creating the Console Application Client     434

Hosting a Workflow in WCF: Configuring Receive Activity and Updating Interface     437

Modifying the Interface     438

Configuring the Receive Activity     438

Rebuilding the Client     441

Accessing WorkflowRuntime from WorkflowServiceHost     442

Performing Preparatory Work     443

Retrieving the WorkflowRuntime     443

Running the Project     444

Connecting to a WCF Endpoint from WF     445

Updating the Workflow     445

Summary     448

Workshop     449

Quiz     449

Answers     449

 

Part V Custom Activities

HOUR 20 Creating Basic Custom Activities     453

Custom Activity Conceptual Overview     453

Improve on Out-of-the-Box Activities     454

Create Domain-Specific Activities     454

Custom Control Flow Patterns     454

Custom Activity Technical Overview     455

Basic Custom Activity Overview     456

Creating the Solution and Projects     456

Creating the Solution and Projects     457

Creating the Customer Custom Activity     457

Setting the Base Activity     457

Overriding the Execute Method     458

Adding the Custom Activity to a Workflow     459

Updating the Customer Activity to Receive Input     460

Updating the Customer Activity to Retrieve Information from a Database     462

Adding Existing Custom CreditCheck Activity     465

Adding Event Handlers to Activities     469

Creating Compound Activities     470

Creating and Modeling the Compound Activity     470

Configure the IfElse Activit     471

Configuring the CheckCredit Activity in the CompoundCreditCheck Activity     472

Configuring the Customer Activity in the CompoundCreditCheck Activity     472

Creating a New Sequential Workflow     473

Modeling the Workflow with the CompoundCreditCheck Activity     473

Activity Programming Model     475

Designer Components     475

Creating an Activity Designer Theme     476

ToolboxBitMap Class     478

Adding Graphic as Image and Associating Class     479

Adding the Activity to the Toolbox Across Projects     480

Creating the VSContent File     480

Creating the VSI file     480

Workshop     482

Quiz     482

Answers     482

 

HOUR 21 Creating Queued Activities     483

Exploring Activity Life Cycle Topics     484

WorkflowQueue     484

ActivityExecutionContext     485

Overview of Samples     486

Creating the Solution and Projects     486

Creating a Basic Custom Queued Activity     487

Performing Preliminary Custom Activity Setup     487

Override the Initialize Method     487

Override the Execute Method     489

Adding Code to the QueueItemAvailable Handler     490

Override the Uninitialize Method     492

Updating Host to Send Data to the Queue     492

Running the Workflow     493

Custom Activity Queued from Service     493

Creating the CustomerQueuedFromService Service     494

Creating the CustomerQueuedFromServiceActivity Custom Activity     498

Updating the Host to Use the New Service     503

Summary     504

Workshop     505

Quiz     505

Answers     505

 

HOUR 22 Creating Typed Queued and EventDriven-Enabled Activities     507

Creating a Custom Activity that Accesses a Typed Service     507

Preliminary Project Setup     508

Adding the CustomerEventArgs File     508

Modifying the CustomerQueuedFromTypedServiceActivity Custom Activity     09

Modifying the CustomerQueuedFromTypedService Service     510

Updating the Host to Use the Typed Service     513

Creating an EventDriven Activity     513

Creating the CustomerEventDrivenActivity Custom Activity     514

Workshop     522

Quiz     522

Answers     523

 

HOUR 23 Creating Control Flow Activities Session 1     525

Control Flow Activity Conceptual Overview     525

Creating the Solution and Projects     527

Creating the Control Flow Activity     527

Creating Nonexecuting Control Flow Activity     527

Adding Single Child Activity Execution     529

Executing All Child Activities     532

Designer Hierarchy Overview     535

Adding Parallel Execution Option     536

Adding Cancellation and Early Completion     542

Creating GeneralControlFlowBranch and Adding a Condition     545

Summary     549

Workshop     549

Quiz     549

Answers     549

 

HOUR 24 Creating Control Flow Activities Session 2     551

Enhancing the GeneralControlFlow Activity     551

Adding a Custom Designer     552

Adding ToolBoxItem     554

Adding Custom Validation     556

Adding Attached Properties and the ActivityCondition Type     561

Reviewing Activity Life Cycle Artifacts     568

Implementing Compensation     570

Summary     572

Workshop     572

Quiz     572

Answers     572

 

Index     575

Purchase Info

ISBN-10: 0-7686-8784-5

ISBN-13: 978-0-7686-8784-2

Format: Safari PTG

This publication is not currently for sale.