Export (0) Print
Expand All

Ordering State Machine Sample

Download sample

The ordering state machine sample is an application that implements an order-fulfillment solution by using state machine workflows.

In this type of application, an order might go through several states before it is completed. For this sample, there are four defined states:

  • WaitingForOrderState

  • OrderOpenState

  • OrderProcessedState

  • OrderCompletedState

In this order system, there are also rules that specify what events can occur for an order depending on its current state. For example, an order that is open can be updated, processed, canceled, or shipped. However, an order that is processed can only be updated or shipped, but not canceled. As an event occurs, the state machine workflow can optionally transition an order to a new state. For example, when an order is open and the OrderShipped event occurs, the state machine workflow transitions the completed state for the order.

To build the sample

  1. Download the sample by clicking Download Sample in this topic.

    This extracts the sample project to your local hard disk.

  2. Click Start, point to Programs, point to Microsoft Windows SDK, and then click CMD Shell.

  3. Go to the source directory of the sample.

  4. At the command prompt, type MSBUILD <Solution file name>.

To run the sample

  1. In the SDK Command Prompt window, run the .exe file in the OrderApplication\bin\debug folder (or the OrderApplication\bin folder for the VB version of the sample), which is located below the main folder for the sample.

  2. Enter a value for the OrderId field, and then click Order Created to create a new instance of the workflow and raise an OrderCreated event.

    You can repeat this process to create several instances of the Order state machine workflow.

  3. As you create the orders, you should see the Order State value for each record quickly change from WaitingForOrderState to OrderOpenState.

  4. When you select a record, you should notice that only the Order Updated and Order Processed buttons are enabled.

  5. Click Order Processed to raise an OrderProcessed event to the workflow.

  6. After several seconds, you should notice that the Order State has changed to the OrderProcessedState, and when the record is selected, only the Order Updated, Order Canceled, and Order Shipped buttons are enabled.

See Also


© 2007 Microsoft Corporation. All rights reserved.

Community Additions

ADD
Show:
© 2014 Microsoft