Search Wiki:
Resource Page Description
The Workflow Simulator is a WPF application built to accompany the monthly MSDN 'Guidance on Choosing the Right Root Workflow Type in WF' article series. The application serves as the runtime environment, allowing users to load and visualize the execution of workflows - demonstrating how the loaded workflows react to input from the scenario specific user interface.

Articles in this series:

  • Choosing the Right Workflow Root - this article showcases the Workflow Simulator, and discusses many of the decisions required when selecting between Sequential and State Machine Workflows
  • Job Requisition Workflows - This article describes a simplistic implementation of the Job Requisition workflow that can be executed within the workflow simulator.
  • Replicators in Blog Monitoring Workflows - this article defines a Blog Monitoring process that one might use to collect blog entries relevant to a user and periodically send a summary of those entries to the user.
  • Software Bug Reporting Workflows - this article examines the implementation of a simplistic bug reporting workflow and show how to approach it using WF.
  • Calendar Scheduling Workflows - this article explores an alternative use of client-side workflows, whereby the workflows themselves are computational in nature, and it is the ability to model the computation logic that creates the preference over procedural programming.
  • Merchant Service Workflows - this article examines the use of Workflow Foundation in the portion of the merchant service workflow that deals with collecting multiple small transactions under one order, and when either a time-limit expires, the transaction is “committed” to the merchant service.

Windows Workflow Foundation (WF) Workflow Simulator


The Workflow Simulator is a Windows Presentation Foundation application that serves as the runtime environment for visualizing the execution of workflows as they react to input from the scenario specific user interface.

To run any of the workflows provided with the tutorial, follow these steps:
  1. Launch WorkflowSimulator.exe
  2. From the File menu, choose Open Workflow...
  3. Navigate to the assembly containing the workflow you wish to run and click Open.
  4. Follow the instructions in the left pane to see the execution in the right.
Note that for the current version of the Workflow Simulator, workflow assemblies and dependencies must be located in the same directory as the Workflow Simulator executable.

Workflow Simulator Host
Figure 1 - Workflow Simulation Host Running a Workflow

Loading and Running Workflows in the Simulator
The Workflow Simulator has quite a few features that augment its utility in exploring the dynamics of the root workflows. To begin with, the Workflow Simulator can open and execute any workflow defined in any assembly (by default these should be .DLL’s, but it can also open workflows compiled into EXEs). It is capable of displaying and running workflows not provided by this guidance (though some workflow may require hosting configuration not supported by the Workflow Simulator). By default, unless the workflow has a special attribute described later, the Workflow Simulator will display the workflow definition on the right and provide a button on the left which will execute the workflow.

Clicking Run Simulation button to execute the workflow, shows the currently executing activities highlighted in yellow (much like within the Visual Studio Workflow Debugger), with the single activity currently executing selected as well as named in the status bar at the bottom. In addition, activities that have completed execution will have a blue check mark glyph over their top right corner. For future scenarios, additional glyphs may be added that provide additional insight into the state of the executing activity.

Implementing Dynamic User Interfaces in the Simulator
Because each business scenario will differ in the type of information requested from the user, or in how the user interacts with the workflow, the Workflow Simulator provides a pluggable user interface. The choice of which interface to display is driven by the workflow definition that is opened. The user interface hosts any UIFrameworkElement that implements the IWorkflowUI (see Figure 2) which ensures the control can receive a reference to the WorkflowDiagram (the control responsible for rendering the workflow) when it is added to the main user interface.


public interface IWorkflowUI
{
         WorkflowDiagram WorkflowDiagram { get; set; }    
}
Figure 2- The IWorkflowUI interface

With a reference to the WorkflowDiagram, the plugged-in user interface can connect to the local service registered by the workflow for supporting bi-directional communication in the scenario. This relationship between the user interface to display, local service to load, and workflow definition(as shown in Figure 3) is defined by an optional attribute on the workflow class: WorkflowSimulationUIAttribute simply specifies, in string form, the type name of the UI component and local service. The end result is that both user interface and plumbing are changed to support the scenario simply by opening the workflow assembly.

Workflow Simulator Host
Figure 3 - Relationship between simulator components


Related Articles

See the complete collection of WF and WCF samples at The Endpoint
Last edited Apr 23 2009 at 8:47 PM  by KSharkey, version 12
Updating...
Page view tracker