Running UCMA Code in a Windows Workflow Application: Creating the Workflow (Part 2 of 4)

Summary:   Combine the capabilities of Microsoft Unified Communications Managed API (UCMA) and Windows Workflow Foundation. Part 2 describes how to create a simple Windows Workflow application.

Applies to:   Microsoft Unified Communications Managed API (UCMA) 3.0 Core SDK | Windows Workflow Foundation

Published:   October 2011 | Provided by:   John Clarkson, Microsoft | About the Author

Contents

Download code  Download code

Watch video  See video

This is the second in a series of four articles about how to add a UCMA component to a workflow.

Creating the Workflow

This section describes how to create a simple Windows Workflow application. Part 3 describes how to add a UCMA component to the workflow.

To Create the Workflow Application

  1. In Microsoft Visual Studio 10 development system, on the menu bar, choose File, New Project. In the installed templates list, select Other Project Types, choose Visual Studio Solutions, and then click OK.

  2. In Solution Explorer, right-click the solution and then choose Add, New Project.

  3. In the Installed Templates list, select Visual C# and then choose Workflow.

  4. In the .NET Framework version list, ensure that .NET Framework 4 is selected. In the Workflow list, select Workflow Console Application. Keep the default settings and then click OK. This creates a starter workflow application that has basic workflow hosting support. The basic workflow is populated with activities that model the control flow for the application.

To Add a Sequence Activity to the Workflow

  1. Drag a Sequence activity from the Control Flow section of the Toolbox and drop it on the workflow design surface.

  2. Click Variables in the lower-left side of the Workflow Designer to display the Variables pane.

  3. Click Create Variable.

  4. In the Name box type Choice, in the Variable type list select String, and then press ENTER to save the variable.

  5. Click Variables in the lower-left side of the activity designer to close the Variables pane.

To Add Activities to the Sequence Activity

  1. Drag a WriteLine activity from the Primitives section of the Toolbox and drop it in the Sequence activity.

  2. Click the WriteLine activity to select it, and then type the following instruction into the Text property value box.

    "Press a 1 or a 2."
    
  3. Drag an Assign activity from the Primitives section of the Toolbox and drop it in the Sequence activity following the WriteLine activity. In the To box type Choice, and then in the Enter a VB expression box add the following expression.

    Console.ReadLine()
    
  4. Drag an If activity from the Control Flow section of the Toolbox and drop it in the Sequence activity so that it follows the Assign activity.

  5. In the If activity’s Condition property value box, add the following expression.

    Choice = “1”
    
  6. Drag two WriteLine activities from the Primitives section of the Toolbox and drop them so that one is in the Then section of the If activity, and one is in the Else section.

  7. Click the WriteLine activity in the Then section to select it, and then type the following expression into the Text property value box.

    "You entered one."
    
  8. Click the WriteLine activity in the Else section to select it, and then type the following expression into the Text property value box.

    "You entered two."
    
  9. Drag a Delay activity from the Primitives section of the Toolbox and drop it so that it follows the If activity.

  10. In the Properties window type the following value into the Enter a VB expression box that is located to the right side of the Duration property. This value represents 5 seconds, with the result that the workflow pauses for five seconds between executing the If activity and closing.

    00:00:05
    
  11. Build, run, and test the functionality of the workflow.

Figure 1. Completed Windows Workflow application

Workflow application

Conclusion

Part 3 describes how to add a UCMA component to this workflow.

Additional Resources

For more information, see the following resources:

About the Author

John Clarkson is a programming writer with the Microsoft Lync product team.