Understand Workflow Services

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

Microsoft Windows Runtime Service provides a way to communicate with the outside world from a workflow instance. Microsoft Unified Communications Managed API (UCMA) provides two Windows Runtime Services:

  • CommunicationsWorkflowRuntimeService provides a way to pass UCMA call objects, endpoint objects, and culture information from the hosting environment to a workflow instance.

  • TrackingDataWorkflowRuntimeService provides workflow instance-related storage in memory for storing ActivityTrackingData objects.

These services are added to the runtime using the following code:

_workflowruntime.AddService(new TrackingDataWorkflowRuntimeService());
_workflowruntime.AddService(new CommunicationsWorkflowRuntimeService ());

CommunicationsWorkflowRuntimeService is not optional in a communications workflow application. It is required by the workflow activities. The following illustration shows the relationship between the services, the communication workflow application, and the hosting environment.

Dd146423.9e3edad1-dc3f-45e8-9343-c7f5e126c333(en-us,office.13).jpg

CommunicationsWorkflowRuntimeService Service

Use the CommunicationsWorkflowRuntimeService service to connect to other services in a communication workflow application. For example, use CommunicationsWorkflowRuntimeService to add a speech workflow component to an existing Windows Workflow Foundation application. For an example of creating and starting a CommunicationsWorkflowRuntimeService service, see thefollowing code example.

_workflowruntime = new workflowRuntime();
CommunicationsWorkflowRuntimeService service = new CommunicationsWorkflowRuntimeService();
_workflowruntime.AddService(service);
_workflowruntime.AddService(new TrackingDataWorkflowRuntimeService());

To see an example of the CommunicationsWorkflowRuntimeService service in use, in a communication workflow application, see the InitializeWorkflow method in the Program.cs file.

Data Tracking Service

Use the IsDataTrackingEnabled property to track properties during workflow execution.

Data tracking is provided for properties on the SpeechQuestionAnswerActivity, InstantMessagingQuestionAnswerActivity, SpeechStatementActivity and InstantMessagingStatementActivity. To enable the workflow data tracking service for an activity, set the IsDataTrackingEnabled property to True. Values of the following properties are recorded.

  • SpeechQuestionAnswerActivity.MainPrompt

  • InstantMessagingQuestionAnswerActivity.MainPrompt

  • SpeechQuestionAnswerActivity.RecognitionResult

  • InstantMessagingQuestionAnswerActivity.RecognitionResult

  • SpeechStatementActivity.MainPrompt

  • InstantMessagingStatementActivity.MainPrompt

An activity adds data to the store each time it is executed. If the activity executes multiple times, data is recorded as long as IsDataTrackingEnabled is set to True. The value of the IsDataTrackingEnabled property can be changed at run time. For each property, the following data is recorded by the tracking service:

  • Activity name

  • Property name

  • Property value

Accessing Property Values

As shown in the following code example, to access prompt text, use the GetTrackingData method of the TrackingDataWorkflowRuntimeService service.

protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
{
  TrackingDataWorkflowRuntimeService service = executionContext.GetService<TrackingDataWorkflowRuntimeService>();
  Collection<ActivityTrackingData> list = service.GetTrackingData(WorkflowInstanceId);

  try
  {
    StringBuilder context = new StringBuilder();
    XmlSerializer serializer = new XmlSerializer(typeof(Collection<ActivityTrackingData>));
    StringWriter stringWriter = new StringWriter();

    serializer.Serialize(stringWriter, list);

    string callContext = stringWriter.ToString();
    stringWriter.Close();
  }

  catch (InvalidOperationException invalidOpException)
  {
    Console.WriteLine(invalidOpException.Message);
  }

  return;
}

For more information about workflow tracking services, see Tracking Services in Windows Workflow Foundation.

See Also

Other Resources

WorkflowRuntime Class

Unified Communications Managed API 2.0 Workflow SDK Documentation