Windows Workflow Tracking Service

 

The windows workflow tracking service can be plugged into the workflow runtime using workflowruntime.AddService()  method.

1.       To ensure that the workflow is capable of storing tracking data, we need to explicitly enable tracking on the application database. To do that, we need to execute the tracking related, schema and logic sql’s on the tracking database.

The schema and logic SQL for workflow tracking are located under:

%windir%\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\EN\tracking_schema.SQL

%windir%\Microsoft.NET\Framework\v3.0\Windows Workflow Foundation\SQL\EN\tracking_logic.SQL

2.       Workflow infrastructure can be configured to track a workflow based on several configurable settings. These settings can be stored in an XML file or the configuration can be directly manipulated using the Tracking Object Model. If it is stored in an XML file then the workflow infrastructure automatically de-serializes the XML to fit the Tracking Object Model.

3.       The XML file can be hand-crafted or more simply created using the TrackingProfileDesigner utility which is installed with the Windows Vista SDK Samples. This is located under:

\Program Files\Microsoft SDKs\Windows\v6.0\Samples\WFSamples\Applications\TrackingProfileDesigner

4.       The Tracking Profile Designer, allows to do the following:

a.       Load an assembly which has workflow inside it.

b.      Enable Tracking for Workflow level events, Activities level events and User events.

c.       Adding of annotations in each of the tracked activities.

d.      Extraction of specific workflow or user defined data items and their values

e.      Check of basic equality and non-equality conditions

f.        Apply the selected tracking to one or more matching derived types.

g.       Finally save the changes to an XML file that we can directly use while enabling tracking for a workflow in our application.

5.       The XML file is the main controlling file pertaining to what will be tracked and what will not be tracked. E.g. we want to track the Order.OrderAmount when the state of the workflow is in OrderProcessed.

 

The Tracking XML contains the following important elements and metadata:

1.       TrackingProfile element: This is the root element which defines the Tracking XML.

2.       TrackPoints: Inside a TrackingProfile, there can be various track points specific to workflows, activities or user. These are represented by:

a.       WorkflowTrackPoint

b.      ActivityTrackPoint

c.       UserTrackPoint

 

Each of the TrackPoint has

1.       TrackingLocations, which contain Activity elements, ExecutionStatusEvents and Conditions as follows:

<ActivityTrackingLocation>                <Activity>                  <Type>StateMachine1.workflow1, TrackingObjectsSample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</Type>                  <MatchDerivedTypes>false</MatchDerivedTypes>                </Activity>                <ExecutionStatusEvents>                  <ExecutionStatus>Closed</ExecutionStatus>                  <ExecutionStatus>Executing</ExecutionStatus>                </ExecutionStatusEvents><Conditions>                              <ActivityTrackingCondition>                            <Operator>Equals</Operator>                                  <Member>Name</Member>                                  <Value>setStateActivity2</Value>                              </ActivityTrackingCondition>                  </Conditions></ActivityTrackingLocation> 

The Activity elements allows specifying the assmebly and the type which contains the activity.

The ExecutionStatusEvents defines which Events to monitor, e.g. Closed and Executing

The Conditions defines the circumstance under which this tracking should happen. E.g. in the above case the tracking is done only when the Activity name is setStateActivity2.

2.       Extracts, which contain data that can be extracted in that activity. This can be workflow infrastructure related data or user defined data as follows:

    <Extracts>                <WorkflowDataTrackingExtract>                    <Member>InstanceOrder.OrderId</Member>                </WorkflowDataTrackingExtract>                     <WorkflowDataTrackingExtract>                           <Member>InstanceOrder.OrderItem</Member>                     </WorkflowDataTrackingExtract>                     <WorkflowDataTrackingExtract>                           <Member>InstanceOrder.OrderAmount</Member>                     </WorkflowDataTrackingExtract>

   </Extracts>

The Extracts contain one or more WorkflowDataTrackingExtract elements where the data that needs to be tracked can be specified. In the above example, we are tracking InstanceOrder.OrderId, InstanceOrder.OrderItem and InstanceOrder.OrderAmount.

 

This is the bare minimum configuration that is required to be done to effectively implement tracking in the workflows.