3
© ITCourseware, LLC 1 Windows Workflow Foundation Using C# Rev 4.7 Microsoft’s Windows Workflow Foundation (WF) provides a framework for creating scalable applications consisting of independent program units called activities. WF 4 was a major rewrite of this technology, offering significantly higher performance and making it easier to create and execute workflow applications. WF 4.5 contains new activities, designer capabilities, and a new workflow development model (state machines). It also supports the use of C# expressions in C# workflows. This four-day course covers WF 4.5 and uses Visual Studio 2015, which provides a visual designer for creating workflows. The course begins with an overview of the concepts of workflow and the programming model provided by WF. The essentials of WF programming are then covered followed by a systematic treatment of the major features of WF, including the Built-In Activity Library. Primitive and control flow activities are discussed, and the alternatives to hosting workflows are covered. Collection and parallel activities are covered. The creation of custom activities, both using the designer and code, is explained. Flowchart and state machine activities are covered. Persistence and bookmarks are discussed. Workflow Services, using Windows Communication Foundation (WCF) is covered. The course concludes with a discussion of debugging, error handling, transactions and compensation. Audience: Experienced application developers and architects responsible for Windows applications in a Microsoft environment. Prerequisites: Experience programming in the .NET framework, C# , and be familiar with the Visual Studio development environment. Number of Days: 4 Days 1. Workflow Foundation Conceptual Overview What is Workflow? Windows Workflow Foundation Workflows Activities Standard Activities Runtime Services Workflow Business Scenario High Level Workflow Details of While Activity Structure of the Solution Orders Folder Manual Step in the Verification Main Console Display Issues Folder Invoices Folder Learning Microsoft’s WF Windows Workflow Foundation 3 Orders Workflow in WF 3 Windows Workflow Foundation 4 Windows Workflow Foundation 4.5 2. Getting Started with WF 4.5 Workflow Structure Minimal Workflow Program Sequence Activity Visual Studio Workflow Projects Workflow Designer Demo Variables Assign Activity HelloAssign Workflow C# and Visual Basic Expressions Arguments Control Flow Activities Windows Workflow Foundation Using C# (VS2015)

Windows Workflow Foundation - ITCourseware · Microsoft’s Windows Workflow Foundation (WF) provides a framework for creating scalable applications consisting of independent program

  • Upload
    vanque

  • View
    213

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Windows Workflow Foundation - ITCourseware · Microsoft’s Windows Workflow Foundation (WF) provides a framework for creating scalable applications consisting of independent program

© ITCourseware, LLC 1 Windows Workflow Foundation Using C# Rev 4.7

Microsoft’s Windows Workflow Foundation (WF) provides a framework for creating scalable

applications consisting of independent program units called activities. WF 4 was a major rewrite of this

technology, offering significantly higher performance and making it easier to create and execute

workflow applications. WF 4.5 contains new activities, designer capabilities, and a new workflow

development model (state machines). It also supports the use of C# expressions in C# workflows. This

four-day course covers WF 4.5 and uses Visual Studio 2015, which provides a visual designer for

creating workflows.

The course begins with an overview of the concepts of workflow and the programming model provided

by WF. The essentials of WF programming are then covered followed by a systematic treatment of the

major features of WF, including the Built-In Activity Library. Primitive and control flow activities are

discussed, and the alternatives to hosting workflows are covered. Collection and parallel activities are

covered. The creation of custom activities, both using the designer and code, is explained. Flowchart and

state machine activities are covered. Persistence and bookmarks are discussed. Workflow Services,

using Windows Communication Foundation (WCF) is covered. The course concludes with a discussion

of debugging, error handling, transactions and compensation.

Audience: Experienced application developers and architects responsible for Windows applications in a

Microsoft environment.

Prerequisites: Experience programming in the .NET framework, C# , and be familiar with the Visual

Studio development environment.

Number of Days: 4 Days

1. Workflow Foundation Conceptual

Overview

What is Workflow?

Windows Workflow Foundation

Workflows

Activities

Standard Activities

Runtime Services

Workflow Business Scenario

High Level Workflow

Details of While Activity

Structure of the Solution

Orders Folder

Manual Step in the Verification

Main Console Display

Issues Folder

Invoices Folder

Learning Microsoft’s WF

Windows Workflow Foundation 3

Orders Workflow in WF 3

Windows Workflow Foundation 4

Windows Workflow Foundation 4.5

2. Getting Started with WF 4.5 Workflow Structure

Minimal Workflow Program

Sequence Activity

Visual Studio Workflow Projects

Workflow Designer Demo

Variables

Assign Activity

HelloAssign Workflow

C# and Visual Basic Expressions

Arguments

Control Flow Activities

Windows Workflow Foundation

Using C# (VS2015)

Page 2: Windows Workflow Foundation - ITCourseware · Microsoft’s Windows Workflow Foundation (WF) provides a framework for creating scalable applications consisting of independent program

© ITCourseware, LLC 2 Windows Workflow Foundation Using C# Rev 4.7

While Activity

3. Primitive and Control Flow Activities

Built-In Primitive Activities

InvokeMethod (Static)

Workflow (Static InvokeMethod)

Variables in the Workflow

InvokeMethod (Instance)

Workflow (Instance InvokeMethod)

Invoking .NET Framework Library

Input in Workflows

Delay Activity

Control Flow Activities

Parallel

If

If… Else

While

DoWhile

Switch<T>

4. Custom Activities

Why Custom Activities?

Authoring Custom Activities

Arguments in Custom Activities

Activity Class Hierarchy

CodeActivity

CodeActivityContext

CodeActivity<TResult>

Composing Existing Activities

5. Workflow Hosting WorkflowInvoker

Specifying Input to a Workflow

Using Dictionaries

Output Argument

Invoking a Generic Activity

Result Output Argument

Reusing a Workflow

Workflow Timeout

Timeout with Idle Time

Long Computation without Idle Time

Invoking the Long Computation

Long Computation with Timeout

Hosting a Workflow in Windows

Windows Host Code

WorkflowInvoker Instance Methods

WorkflowInvoker Asynchronous

Methods

HelloAsync Code (Invoker)

Effect of Sleep

Workflow Application

Thread Synchronization

Arguments

HelloAsync Code (Application)

WorkflowApplication Delegates

Manual Control of Workflows

Stopping Workflow Execution

Enqueue Workflow

Dequeue Workflow

Host Code for Enqueue Workflow

Host Code for Dequeue Workflow

Hosting a Workflow in ASP.NET

ASP.NET Workflow Host

6. Collection and Parallel

Activities

Collection Activities

Top-Level Workflow

Process Command Activity

Add and Show

Remove and Clear

ForEach<T> Activity

ParallelForEach<T>

Using ForEach<T>

Using ParallelForEach<T>

Using AsyncCodeActivity

Host Code

Asynchronous Activities in WF

Factor.cs

FactorNumber.cs

Async Coding: Begin Execute

Async Coding: End Execute

7. More about Custom Activities

Waiting for Input

Bookmarks

NativeActivity

GetTwoInt Custom Activity

Host Program

Passing Data on Resume

Bookmark Options

Bookmarks and Threads

Threads in Host Code

Threads in Workflow

A Compute Intensive Workflow

EnqueueLoop

DequeueLoop

Page 3: Windows Workflow Foundation - ITCourseware · Microsoft’s Windows Workflow Foundation (WF) provides a framework for creating scalable applications consisting of independent program

© ITCourseware, LLC 3 Windows Workflow Foundation Using C# Rev 4.7

FactorConsoleWF

More Experiments

Pick Activity

Get Check and Answer

Set Timer

8. Flowchart and State Machine

Workflow Modeling Styles

Flowchart Activities

Flowchart Acitivity Designer

Auto-Connect

Using FlowDecision

Flowchart and Custom Activities

State Machine Workflows in

WF 4.5

State Machine Workflow Modeling

Power On Transition

TransitionCommand Trigger

Warming State

Heated Transition

Host Program

State Machine Activity Designer

Timer in the Math Game

Do Problem State

TimeUp Transition

Time Out State

Complete Transaction

Threading Issue

Threading Issue Resolved

Shared Trigger

Echo Transition

Quit Transition

9. Persistence

Long Running Workflows

Persistence and Bookmarks

Workflow Persistence in WF 4.5

SQL Server Persistence Database

Host Code to Enable Persistence

AutoResetEvent

PersistableIdle Event

How to Persist a Workflow

Loading a Persisted Workflow

StartAndUnloadInstance()

LoadAndCompleteInstance()

Stopping and Starting the Host

StartWorkflow

Loading After Data Available

InitNames

GetString

String Commands

Host Program

10. Workflow Services

What is WCF?

WCF Services

WCF = ABC

Address, Binding, Contract

Workflow Services

Messaging Activities

Messaging Activity Templates

IIS Express Hosting

WCF Test Client

Configuration Manager

Workflow Services (Cont’d)

Multiple Operations

Multiple Operations via Parallel

Hosting a Workflow Service

11. Debugging and Error Handling

Debugging Workflows

Control Flow and Flowchart

Breakpoint in XAML

Exceptions

Account and Bank Classes

Use of Dictionary

Deposit and Withdraw

Code Activities

Composite Activities

Top-Level Workflow

Host Program

Unhandled Exceptions

Using WorkflowApplication

TryCatch Activity

Transactions

Compensation

No Compensation

Using Compensation

Transfer.xaml

Compensable Withdrawal

Compensation Token

Canceling the Workflow

Exceptions and Compensation

Compensation Not Performed

Appendix A: Learning Resources