Udostępnij za pośrednictwem


Task 5: Define the OrderProcessing State

Download sample

In this task, you add the child activities that are required to define the OrderProcessingState. When this state is entered in the state machine workflow, the order has already been submitted by the Simple Order Form host application, and the WaitingForOrderState has processed this order. The last activity in the WaitingForOrderState was a SetStateActivity that sets the current state of the state machine workflow to the state that is defined in this task, the OrderProcessingState.

Note

Although you are encouraged to follow the exercises in a linear manner, it is not required. You can start this exercise by opening the sample project and proceeding to the steps in the following section.

To create activities and fields required for the OrderProcessingState

  1. In the OrderProcessingWorkflow designer, define the following child activities.

    Type Name Location Parameters

    StateInitializationActivity

    initializeOrderOpenStateActivity

    OrderProcessingStateActivity

    CallExternalMethodActivity

    invokeProcessingNewOrderStatusUpdate

    initializeOrderOpenStateActivity

    • InterfaceType: IOrderingService

    • MethodName: ItemStatusUpdate

    CallExternalMethodActivity

    invokeOrderProcessedStatusUpdate

    initializeOrderOpenStateActivity

    • InterfaceType: IOrderingService

    • MethodName: ItemStatusUpdate

    SetStateActivity

    setStateActivityOrderCompleted

    initializeOrderOpenStateActivity

    • TargetStateName: OrderCompletedStateActivity

    The workflow should now look like the following in the designer.

    OrderProcessingState designer

    When the state initialization activity is expanded, the designer should look like the following.

    OrderProcessingState child activities

To define the CallExternalMethod methods that calls and finalizes the new orders

  1. Create a new private method named ProcessNewOrder that accepts an Object method named sender and an EventArgs object named e.

  2. In the ProcessNewOrder method, set the itemStatusfield equal to the value Processing order.

    private void ProcessNewOrder(object sender, EventArgs e)
    {
        this.orderItemStatus = "Processing order";
    }
    
  3. Create a new private method named FinalizeOrder that accepts a Object method named sender and an EventArgs object named e.

  4. In the ProcessNewOrder method, set the _itemStatus field equal to the value, Order processed.

    void FinalizeOrder(object sender, EventArgs e)
    {
        this.orderItemStatus = "Order processed";
    }
    

Compiling the Code

For more information about compiling your code, see Compiling the Code.

For a finished version of the tutorial, see Completed State Machine Workflow Tutorial.

See Also

Concepts

Windows Workflow Foundation and Application Communication
State Machine Workflows

Other Resources

Tutorial: Create a State Machine Workflow
Communications
Host Communication Sample
Ordering State Machine
Simple State Machine

Copyright © 2007 by Microsoft Corporation. All rights reserved.
Last Published: 2010-03-04