Edit

Share via


TrackingService.GetProfile Method

Definition

Must be overridden in the derived class, and when implemented, gets the tracking profile for a specified workflow instance or workflow type.

Overloads

GetProfile(Guid)

Must be overridden in the derived class, and when implemented, returns the tracking profile for the specified workflow instance.

GetProfile(Type, Version)

Must be overridden in the derived class, and when implemented, returns the tracking profile, qualified by version, for the specified workflow Type.

Remarks

A tracking service is responsible for managing the tracking profiles available for specific workflow types and specific workflow instances. You can implement this management in whatever manner you choose. For example, you can return the same TrackingProfile for every workflow Type and workflow instance; or you can manage a sophisticated store of tracking profiles referenced by workflow instance, workflow Type, and Version.

GetProfile(Guid)

Must be overridden in the derived class, and when implemented, returns the tracking profile for the specified workflow instance.

C#
protected internal abstract System.Workflow.Runtime.Tracking.TrackingProfile GetProfile(Guid workflowInstanceId);

Parameters

workflowInstanceId
Guid

The Guid of the workflow instance.

Returns

The tracking profile for the specified workflow instance.

Examples

The following example shows an implementation of the GetProfile method. In this example, several overloads of the GetProfile method call a single private GetProfile method, which returns a hard-coded, default tracking profile. This example is from the Termination Tracking Service SDK sample. For more information, see Termination Tracking Service Sample.

C#
/// <summary>
/// Returns a static tracking profile that only tracks instance terminated events.
/// </summary>
protected override TrackingProfile GetProfile(Guid workflowInstanceId)
{
    return GetProfile();
}
private volatile static TrackingProfile profile = null;
private bool sourceExists = false;
private TrackingProfile GetProfile()
{
    //
    // We shouldn't hit this point without the host ignoring an earlier exception.
    // However if we're here and the source doesn't exist we can't function.
    // Throwing an exception from here will block instance creation
    // but that is better than failing silently on termination
    // and having the admin think everything is OK because the event log is clear.
    if (!sourceExists)
        throw new InvalidOperationException(string.Format(System.Globalization.CultureInfo.InvariantCulture, "EventLog Source with the name '{0}' does not exist", source));

    //
    // The profile for this instance will never change
    if (null == profile)
    {
        lock (typeof(TerminationTrackingService))
        {
            if (null == profile)
            {
                profile = new TrackingProfile();
                profile.Version = new Version("3.0.0.0");
                WorkflowTrackPoint point = new WorkflowTrackPoint();
                point.MatchingLocation = new WorkflowTrackingLocation();
                point.MatchingLocation.Events.Add(TrackingWorkflowEvent.Terminated);
                profile.WorkflowTrackPoints.Add(point);
            }
        }
    }
    return profile;
}

Remarks

A tracking service is responsible for managing the tracking profiles available for specific workflow types and specific workflow instances. You can implement this management in whatever manner you choose. For example, you can return the same TrackingProfile for every workflow Type and workflow instance; or you can manage a sophisticated store of tracking profiles referenced by workflow instance, workflow Type, and Version.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.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

GetProfile(Type, Version)

Must be overridden in the derived class, and when implemented, returns the tracking profile, qualified by version, for the specified workflow Type.

C#
protected internal abstract System.Workflow.Runtime.Tracking.TrackingProfile GetProfile(Type workflowType, Version profileVersionId);

Parameters

workflowType
Type

The Type of the workflow.

profileVersionId
Version

The Version of the tracking profile.

Returns

The tracking profile for the specified workflow type.

Remarks

A tracking service is responsible for managing the tracking profiles available for specific workflow types and specific workflow instances. You can implement this management in whatever manner you choose. For example, you can return the same TrackingProfile for every workflow Type and workflow instance; or you can manage a sophisticated store of tracking profiles referenced by workflow instance, workflow Type, and Version.

Applies to

.NET Framework 4.8.1 and other versions
Product Versions
.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