TrackingProfile.Version Property

Definition

Gets or sets the version of the tracking profile.

public Version Version { get; set; }

Property Value

The Version of the TrackingProfile.

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);
}

Remarks

Because of the semantics of profile caching in the workflow runtime engine, if you change the contents of a TrackingProfile you must update Version. If you do not, your updated TrackingProfile may not be loaded by the workflow runtime engine, even if it is returned by a call to TrackingService.TryReloadProfile, or sent in the ProfileUpdatedEventArgs associated with a ProfileUpdated event. Therefore, to ensure that the updated TrackingProfile is loaded by the workflow runtime engine, you should change the Version for the TrackingProfile. You can then explicitly call WorkflowInstance.ReloadTrackingProfiles on any appropriate workflow instances, or, depending on your implementation, you can rely on the tracking service to inform the workflow runtime engine of the change. For more information, see TrackingService.

Applies to

מוצר גירסאות
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1

See also