Oxite Administrator (gravatar)

Sequential Workflow - Part 1

public sealed partial class ATMSimulator : SequentialWorkflowActivity 1
{
      private int amountToWithdraw = 0;
      public ATMSimulator()
      {
          InitializeComponent();
      }

      private void GatherAmountInput_ExecuteCode(object sender, EventArgs e)2
      {
          Console.WriteLine("please sepecify the amount to withdraw");
          amountToWithdraw = int.Parse(Console.ReadLine());
      }

      private void DispatchAmount_ExecuteCode(object sender, EventArgs e)3
      {
          Console.WriteLine(String.Format("Please collect {0:c} from the ATM", amountToWithdraw));
      }

}

Activities are the primary building blocks in Windows Workflow Foundation (WF) and the sequential workflow itself is an activity called SequentialWorkflowActivity 1. As the SequentialWorkflowActivity inherits from the CompositeActivity, it can execute the code in the child activities 2 3 in a forward-only direction.

partial class ATMSimulator
{
      #region Designer generated code

      ///  
      /// Required method for Designer support - do not modify 
      /// the contents of this method with the code editor.
      /// 
      [System.Diagnostics.DebuggerNonUserCode]
      private void InitializeComponent()
      {
          this.CanModifyActivities = true;
          this.DispatchAmount = new System.Workflow.Activities.CodeActivity();
          this.GatherAmountInput = new System.Workflow.Activities.CodeActivity();
          // 
          // DispatchAmount
          // 
          this.DispatchAmount.Name = "DispatchAmount";
          this.DispatchAmount.ExecuteCode += new System.EventHandler(this.DispatchAmount_ExecuteCode);
          // 
          // GatherAmountInput
          // 
          this.GatherAmountInput.Name = "GatherAmountInput";
          this.GatherAmountInput.ExecuteCode += new System.EventHandler(this.GatherAmountInput_ExecuteCode);
          // 
          // ATMSimulator
          // 
          this.Activities.Add(this.GatherAmountInput);
          this.Activities.Add(this.DispatchAmount);
          this.Name = "ATMSimulator";
          this.CanModifyActivities = false;

      }

      #endregion

      private CodeActivity DispatchAmount; 4
      private CodeActivity GatherAmountInput; 5

} 

In the designer generated file of the simulator program there exists two code activities 4 5. The primary goal of the code activities are to invoke the code-beside methods 2 3. These methods will be used to examine and change the workflow instance states.

0 Comments

Your Information
Mrs. Gravatar (gravatar)

<-- It's a gravatar

your comment