You are previewing Beginning WF: Windows Workflow in .NET 4.0.
O'Reilly logo
Beginning WF: Windows Workflow in .NET 4.0

Book Description

Indexed by feature so you can find answers easily and written in an accessible style, Beginning WF shows how Microsoft's Workflow Foundation (WF) technology can be used in a wide variety of applications.

Table of Contents

  1. Copyright
  2. About the Author
  3. About the Technical Reviewer
  4. Acknowledgments
  5. Introduction
    1. How to Use This Book
    2. Chapter Outline
      1. Section 1: Basic Concepts
      2. Section 2: Designing Workflows
      3. Section 3: Communication
      4. Section 4: Workflow Extensions
      5. Section 5: Advanced Topics
      6. Appendix
  6. 1. Introduction
    1. 1. Building a Simple Workflow
      1. A Simple Workflow
        1. Exploring the IDE
        2. Designing the Workflow
        3. Reviewing Program.cs
        4. Running the Application
      2. Adding Procedural Elements
        1. Using Variables
        2. If
        3. Assign
        4. While
        5. Sequence
        6. Delay
        7. More Embellishments
        8. Running the Application
      3. Navigating the Designer
      4. Looking a Bit Deeper
      5. Differences from Previous Versions
    2. 2. Coded Workflows
      1. Creating a Console Application
      2. Defining the Workflow
        1. Implementing Level 1
        2. Implementing Level 2
          1. Expressions
        3. Implementing Level 3
          1. Assign Activity
          2. Sequence
      3. Running the Application
      4. Review
    3. 3. Flowchart Workflow
      1. Creating a Flowchart Workflow
        1. Designing the Flowchart
        2. Defining Connections
        3. FlowDecision
        4. Running the Application
      2. Flow Switch
        1. Adding a FlowSwitch Activity
        2. Adding the FlowStep Activities
        3. Running the Application
      3. Parallel
        1. Adding a Parallel Activity
        2. Adding the Branches
        3. Running the Application
  7. 2. Designing Workflows
    1. 4. Passing Arguments
      1. Creating a New Solution
        1. Defining the Order Class
      2. Implementing the Workflow
        1. Defining the Arguments
        2. Designing the Workflow
        3. Switch Activity
        4. Expression Activities
      3. Invoking the Workflow
      4. Running the Application
    2. 5. Replicated Activities
      1. Reusing the Chapter 4 Project
      2. Adding OrderItem Processing
        1. ForEach Activity
        2. Adding Order Items
        3. Running the Application
        4. ParallelForEach Activity
    3. 6. Exception Handling
      1. Reusing the Chapter 5 Project
      2. Adding the Check Stock Activity
        1. TryCatch Activity
        2. Defining an Exception
        3. ForEach Activity
        4. If Activity
        5. Throw Activity
        6. Catch Activity
        7. Running the Application
      3. Exceptions
    4. 7. Extending the Built-In Activities
      1. Reusing the Chapter 6 Project
      2. Using Custom Activities
        1. Implementing a Custom Activity
        2. Using the LookupItem Activity
        3. Running the Application
      3. InvokeMethod Activity
        1. Creating a Discount Class
        2. Using the InvokeMethod Activity
          1. Specifying the Target Object
          2. Specifying the Parameters
          3. Specifying the Result
        3. Adding the Discount
        4. Running the Application
      4. Summary
  8. 3. Communication
    1. 8. Send and Receive
      1. Creating the Project
        1. Define the Messages
          1. MessageContract
          2. ServiceContract
        2. Application Configuration
      2. Defining the Workflows
        1. Client-SendRequest
          1. Send Activity
          2. Custom Activity—CreateRequest
          3. ReceiveReply Activity
        2. Server–ProcessRequest
          1. Receive Activity
          2. Custom Activity—CreateResponse
          3. SendReply Activity
      3. Implementing the Application
        1. WorkflowServiceHost
          1. Service
          2. Endpoint
        2. WorkflowInvoker
      4. Running the Application
        1. Configuring a Library Branch
        2. Expected Results
    2. 9. Communicating with the Host Application
      1. Creating a WPF Project
        1. Reusing the Classes from Chapter 8
        2. Defining the Window Form
      2. Implementing a TextWriter
        1. Providing a Static Application Reference
        2. Implementing ListBoxTextWriter
      3. Implementing the Workflows
        1. Listening for Messages
          1. Implementing the Service Contract
          2. Implementing a ServiceHost
        2. Bookmarks
        3. Implementing the SendRequest Workflow
        4. Implementing the ProcessRequest Workflow
      4. Implementing the Application
        1. Maintaining Workflow Instances
        2. Event Handlers
        3. ApplicationInterface Methods
      5. Running the Application
    3. 10. Web Services
      1. Creating a Workflow Service
        1. Defining the Service Contract
        2. Configuring Receive and SendReply
        3. Creating the PerformLookup Activity
        4. Testing the Service
      2. Using Parameters
        1. Creating a Second Service
        2. Creating a Modified PerformLookup Activity
        3. Testing the Service
      3. Creating a Client Workflow
        1. Defining the Workflow
        2. Implementing the Host Application
        3. Running the Application
      4. Using Pick
      5. Review
  9. 4. Workflow Extensions
    1. 11. SQL Persistence
      1. Creating the Application
        1. Renaming the Window
        2. Defining the Window Form
        3. Implementing a TextWriter
      2. Setting Up the Database
        1. Creating a Database
        2. Installing the Schema
        3. Creating the LINQ to SQL Classes
      3. Designing the Workflow
        1. Custom CreateLead Activity
        2. Custom WaitForInput Activity
        3. Defining the Workflow Activities
      4. Implementing the Application
        1. Application Configuration File
        2. Configuring the Persistence Provider Factory
        3. Creating Leads
        4. Assigning Leads
        5. Loading Existing Leads
      5. Running the Application
      6. Digging a Bit Deeper
        1. Persisting Arguments and Variables
    2. 12. Extensions
      1. Setting Up the Solution
        1. Copy Solution from Chapter 11
        2. Setting Up the Database
        3. Implementing SetupInstance
        4. Running the Application
      2. Extensions
        1. Implementing a Simple Extension
        2. Configuring the Extension
        3. Using the Extension in an Activity
        4. Updating the Application
      3. Participating in Persistence
        1. Creating the Extension
        2. PersistenceParticipant
        3. AddComment Activity
          1. GetComments Activity
        4. Modifying the Workflow
        5. Accessing the Extension from the Application
        6. Event Handler Syntax
      4. Running the Application
    3. 13. Tracking
      1. Setting Up the Solution
        1. Copy Solution from Chapter 12
        2. Setting Up the Database
        3. Tracking Participants
      2. ListBoxTrackingParticipant
        1. Overriding the Track() Method
        2. Configuring a Tracking Participant
        3. Configuring a Tracking Profile
          1. WorkflowInstanceQuery
          2. BookmarkResumptionQuery
          3. ActivityStateQuery
          4. CustomTrackingQuery
        4. CustomTrackingRecord
        5. Running the Application
      3. Event Tracing for Windows (ETW)
        1. Setting Up the Extension
        2. Configuring the TrackingProfile
        3. Running the Application
      4. SqlTrackingParticipant
        1. Setting up the Database
        2. Implementing the SqlTrackingParticipant
        3. Configuring the Tracking Participant
        4. Running the Application
    4. 14. Transactions
      1. Setting Up the Solution
      2. Assignments
        1. Adding the LINQ to SQL Class
        2. AssignLead Activity
          1. RuntimeTransactionHandle
        3. CreateAssignment Activity
      3. Application Changes
        1. Updating the List of Leads
        2. Removing Database Updates
        3. Adding Workflow Event Handlers
      4. Workflow Changes
        1. TransactionScope
        2. InvokeMethod
      5. Running the Application
    5. 15. Transactions with Persistence
      1. Setting Up the Solution
      2. PersistenceParticipant
      3. PersistLead Extension
        1. Connecting to the Database
        2. Performing the Updates
      4. Using the PersistLead Extension
        1. Modifying the CreateLead Activity
        2. Modifying the AssignLead Activity
      5. PersistAssignment Extension
      6. Using the PersistAssignment Extension
      7. Application Changes
      8. Running the Application
    6. 16. WorkflowServiceHost
      1. Setting Up the Solution
      2. Adding LeadResponse
        1. Renaming the Window
        2. Defining the Window Form
        3. Copying Classes from LeadGenerator
        4. Implementing the Application
      3. WorkflowService
        1. Behaviors
        2. DBExtensionBehavior
        3. PersistAssignmentBehavior
      4. Defining the Workflows
        1. CompleteAssignment
        2. EnterLead Workflow Modifications
        3. WorkAssignment Workflow
        4. Persist
      5. Final Application Changes
        1. ApplicationInterface
        2. Adding the app.config File
        3. LINQ Conflict
      6. Running the Applications
      7. Review
  10. 5. Advanced Topics
    1. 17. Compensation, Confirmation, and Cancellation
      1. Designing the Workflow
        1. Modifying the Application
        2. Configuring a TryCatch Activity
        3. Using a Parallel Activity
        4. CompensableActivity
        5. Designing the Wedding Activity
        6. Designing the Reception Activity
          1. Designing Confirmation Activities
        7. Designing the Invitations Activity
          1. Designing the Confirmation Activities
        8. Running the Application
      2. Cancellation Handlers
        1. More on the Parallel Activity
      3. Designing Compensation Handlers
        1. Designing the Wedding Compensation
        2. Designing the Reception Compensation
        3. Running the Application
      4. Customizing Compensation and Confirmation
        1. Adding the Token Variables
        2. Setting the Result Property
        3. Custom Confirmation
        4. Custom Compensation
        5. Rethrow Activity
    2. 18. Collections
      1. Creating a Collection
        1. Defining the Shopping List
        2. Initial Workflow
        3. AddToCollection Activity
        4. Invoking a Workflow
        5. Running the Application
      2. Printing and Sorting
        1. Printing the Collection
        2. Sorting the Collection
      3. Searching the Collection
        1. Overriding the Equals() Method
        2. ExistsInCollection Activity
        3. RemoveFromCollection Activity
      4. ClearCollection Activity
    3. 19. Interoperability with Workflow 3.5
      1. Creating a 4.0 Workflow
        1. Creating a 3.5 Workflow
        2. Interop Activity
        3. Running the Application
      2. Executing a Custom 3.5 Activity
        1. Creating a Custom Activity
        2. Throwing an Exception
        3. Invoking the Custom Activity
        4. Running the Application
    4. 20. Policy
      1. Creating a Custom Activity
        1. Defining the Data Structures
        2. PolicyActivity
        3. Adding Dependency Properties
        4. Creating a Rule Set
        5. Defining the Rules
        6. Understanding Rule Sets
          1. Rules
          2. Chaining
          3. Halt and Update
          4. Rules File
        7. Determining the Priority
        8. Entering the Priority Rules
      2. Creating a Workflow Application
        1. Creating a Custom Activity
        2. Incrementing the Activity Counters
        3. Creating the Main Workflow
        4. Configuring the Arguments
        5. Implementing the Console Application
        6. Running the Application
      3. Review
  11. A. Sample Workflow Project
    1. Project Overview
      1. Configuring the Database
      2. Running the Application
        1. Logging In
        2. Submitting a Request
        3. Processing Requests
        4. Tracking the Workflow
    2. Generic Queue Logic
      1. Database Design
      2. Activities
      3. CompleteInstance
      4. QCPolicy
      5. Tracking
    3. Service Layer
      1. Service Contract
      2. Database Design
      3. Activities
      4. Workflow Design
        1. SubmitRequest
        2. Processing a Request
      5. Correlation
      6. Using WorkflowServiceHost
        1. Writing Extensions
        2. Configuring Extensions
        3. Configuring Persistence
        4. Configuring Tracking
    4. Summary