Step 1: Branching the Incoming Call

This is the first of two topics describing the steps to create the Switch Call Contexts in a Workflow walkthrough application. The procedures for creating the walkthrough application build sequentially. Completing the procedures in sequence is important.

Add an IfElseActivity to choose an outbound call to make, based on the type of incoming call.

To add an IfElseActivity to the workflow

  1. In Visual Studio development system, create a new Inbound Sequential Workflow Console Application (with Code Separation) project.

  2. In Solution Explorer, right click Program.cs and then click View Code.

  3. In the Code window, add the following using statements to the top of Program.cs.

    using Microsoft.RTC.Signaling;
    using Microsoft.RTC.Collaboration.AudioVideo;
    
  4. On the Visual Studio design surface, click communicationsSequenceActivity1 and then rename communicationsSequenceActivity1 to incomingCallCSA.

    Note Note

    The CallProvider property specifies that the call context is set to acceptCallActivity1.

  5. In the Visual Studio Toolbox, expand Windows Workflow to display the core workflow activities. Drag and drop an IfElse activity onto the design surface above disconnectCallActivity1.

  6. Rename ifElseActivity1 to ifElseCallType. Rename the branch on the left as ifElseBranchAVCall, and the branch on the right as ifElseBranchIMCall.

Add a code condition to provide the branching logic in the IfElseActivity.

To add a code condition

  1. On the Visual Studio design surface, at the top of ifElseBranchAVCall near the red exclamation mark, click the arrow and then click Property 'Condition' is not set.

  2. In the Properties window for ifElseBranchAVCall, set the Condition property to Code Condition and then expand the Condition property. For the name of the condition, type conditionCallType.

  3. To set the property, click the design surface adjacent to the Properties window.

  4. In the event handler, add a statement to set the Result property to true or false based on the type of incoming call:

    if(this.acceptCallActivity1.CallProvide.Call is AudioVideoCall)
    {
      e.Result = true;
    }
    else
    {
      e.Result = false;
    }
    
Show: