TrackingProfile Class

Definition

Caution

The System.Workflow.* types are deprecated. Instead, please use the new types from System.Activities.*

Defines points of interest in the potential execution path of a root workflow instance about which a tracking service should be notified.

public ref class TrackingProfile
[System.Serializable]
public class TrackingProfile
[System.Serializable]
[System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")]
public class TrackingProfile
[<System.Serializable>]
type TrackingProfile = class
[<System.Serializable>]
[<System.Obsolete("The System.Workflow.* types are deprecated.  Instead, please use the new types from System.Activities.*")>]
type TrackingProfile = class
Public Class TrackingProfile
Inheritance
TrackingProfile
Attributes

Examples

The following code example demonstrates how you can create a TrackingProfile using the TrackingProfile constructor and use the object's properties to help track the execution of a workflow. The example code uses the ActivityTrackPoints, Version, and WorkflowTrackPoints properties.

This code example is part of the Query using SQLTrackingService SDK sample from the Program.cs file. For more information, see Query Using SQLTrackingService.

private static void CreateAndInsertTrackingProfile()
{
    TrackingProfile profile = new TrackingProfile();
    ActivityTrackPoint activityTrack = new ActivityTrackPoint();
    ActivityTrackingLocation activityLocation = new ActivityTrackingLocation(typeof(Activity));
    activityLocation.MatchDerivedTypes = true;
    IEnumerable<ActivityExecutionStatus> statuses = Enum.GetValues(typeof(ActivityExecutionStatus)) as IEnumerable<ActivityExecutionStatus>;
    foreach (ActivityExecutionStatus status in statuses)
    {
        activityLocation.ExecutionStatusEvents.Add(status);
    }

    activityTrack.MatchingLocations.Add(activityLocation);
    profile.ActivityTrackPoints.Add(activityTrack);
    profile.Version = version;

    WorkflowTrackPoint workflowTrack = new WorkflowTrackPoint();
    WorkflowTrackingLocation workflowLocation = new WorkflowTrackingLocation();
    IEnumerable<TrackingWorkflowEvent> eventStatuses = Enum.GetValues(typeof(TrackingWorkflowEvent)) as IEnumerable<TrackingWorkflowEvent>;
    foreach (TrackingWorkflowEvent status in eventStatuses)
    {
        workflowLocation.Events.Add(status);
    }

    workflowTrack.MatchingLocation = workflowLocation;
    profile.WorkflowTrackPoints.Add(workflowTrack);

    TrackingProfileSerializer serializer = new TrackingProfileSerializer();
    StringWriter writer = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture);
    serializer.Serialize(writer, profile);
    string trackingprofile = writer.ToString();
    InsertTrackingProfile(trackingprofile);
}
Shared Sub CreateAndInsertTrackingProfile()
    Dim profile As TrackingProfile = New TrackingProfile()

    Dim activityTrack As ActivityTrackPoint = New ActivityTrackPoint()
    Dim activityLocation As ActivityTrackingLocation = New ActivityTrackingLocation(GetType(Activity))
    activityLocation.MatchDerivedTypes = True
    Dim statuses As IEnumerable(Of ActivityExecutionStatus) = CType(System.Enum.GetValues(GetType(ActivityExecutionStatus)), IEnumerable(Of ActivityExecutionStatus))
    For Each status As ActivityExecutionStatus In statuses
        activityLocation.ExecutionStatusEvents.Add(status)
    Next

    activityTrack.MatchingLocations.Add(activityLocation)
    profile.ActivityTrackPoints.Add(activityTrack)
    profile.Version = version

    Dim workflowTrack As WorkflowTrackPoint = New WorkflowTrackPoint()
    Dim workflowLocation As WorkflowTrackingLocation = New WorkflowTrackingLocation()
    Dim eventStatuses As IEnumerable(Of TrackingWorkflowEvent) = CType(System.Enum.GetValues(GetType(TrackingWorkflowEvent)), IEnumerable(Of TrackingWorkflowEvent))
    For Each status As TrackingWorkflowEvent In eventStatuses
        workflowLocation.Events.Add(status)
    Next

    workflowTrack.MatchingLocation = workflowLocation
    profile.WorkflowTrackPoints.Add(workflowTrack)

    Dim serializer As TrackingProfileSerializer = New TrackingProfileSerializer()
    Dim writer As StringWriter = New StringWriter(New StringBuilder(), CultureInfo.InvariantCulture)
    serializer.Serialize(writer, profile)
    Dim trackingProfile As String = writer.ToString()
    InsertTrackingProfile(trackingProfile)
End Sub

Remarks

Note

This material discusses types and namespaces that are obsolete. For more information, see Deprecated Types in Windows Workflow Foundation 4.5.

During its run time, a workflow instance emits tracking events to the runtime tracking infrastructure. The runtime tracking infrastructure uses a TrackingProfile to filter these tracking events and returns tracking records based on this filtering to a tracking service. There are three kinds of tracking events that can be filtered: activity status events, workflow status events, and user events. You can add ActivityTrackPoint objects to the ActivityTrackPoints property to match specific activity status events; WorkflowTrackPoint objects to the WorkflowTrackPoints property to match specific workflow status events; and UserTrackPoint objects to the UserTrackPoints property to match specific user events. When a track point is matched, the runtime tracking infrastructure returns the data associated with the tracking event to the tracking service over the TrackingChannel associated with that service. The data is returned in either an ActivityTrackingRecord, a WorkflowTrackingRecord, or a UserTrackingRecord depending on the type of track point that was matched.

A tracking service implements the methods in the abstract TrackingService class to provide the functionality for the runtime tracking infrastructure to request a TrackingChannel associated with the service, and a TrackingProfile associated with a particular workflow instance or with a particular workflow type. A tracking service must also implement the abstract TrackingChannel class to provide the channel over which the runtime tracking infrastructure can send tracking records.

When the tracking service returns a tracking profile object to the runtime, the workflow starts to execute, and the tracking profile is serialized. If the serialization of the tracking profile fails, an exception is raised to the workflow instance. If the exception is not handled, the workflow instance is terminated. The tracking profile can be validated before passing it to the runtime using the Schema property.

A TrackingProfile can be serialized to XML by using the TrackingProfileSerializer, which formats the XML according to the Schema. This provides a convenient format for profile storage and for authoring a profile in a non-programmatic manner. For example, the SQL Tracking Service stores serialized versions of its tracking profiles, as will any tracking service you create based on the SqlTrackingService class.

Constructors

TrackingProfile()

Initializes a new instance of TrackingProfile.

Properties

ActivityTrackPoints

Gets the collection of activity track points used by the runtime tracking infrastructure to filter activity status events.

UserTrackPoints

Gets the collection of user track points used by the runtime tracking infrastructure to filter user events.

Version

Gets or sets the version of the tracking profile.

WorkflowTrackPoints

Gets the collection of workflow track points used by the runtime tracking infrastructure to filter workflow status events.

Methods

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also