共用方式為


TrackingService.GetProfile 方法

定義

必須在衍生類別中覆寫,在實作之後會取得指定之工作流程執行個體或工作流程類型的追蹤設定檔。

多載

GetProfile(Guid)

必須在衍生類別中覆寫,在實作之後會傳回指定之工作流程執行個體的追蹤設定檔。

GetProfile(Type, Version)

必須在衍生類別中覆寫,在實作之後會傳回指定之工作流程 Type、特定版本的追蹤設定檔。

備註

追蹤服務負責管理用於特定工作流程類型和特定工作流程執行個體的追蹤設定檔。 您可使用您選擇的任何方式來實作這項管理。 例如,您可以針對每個工作流程 TrackingProfile 和工作流程執行個體傳回相同的 Type,或者您也可以管理由工作流程執行個體、工作流程 TypeVersion 所參考之追蹤設定檔的複雜存放區。

GetProfile(Guid)

必須在衍生類別中覆寫,在實作之後會傳回指定之工作流程執行個體的追蹤設定檔。

protected public:
 abstract System::Workflow::Runtime::Tracking::TrackingProfile ^ GetProfile(Guid workflowInstanceId);
protected internal abstract System.Workflow.Runtime.Tracking.TrackingProfile GetProfile (Guid workflowInstanceId);
abstract member GetProfile : Guid -> System.Workflow.Runtime.Tracking.TrackingProfile
Protected Friend MustOverride Function GetProfile (workflowInstanceId As Guid) As TrackingProfile

參數

workflowInstanceId
Guid

工作流程執行個體的 Guid

傳回

指定之工作流程執行個體的追蹤設定檔。

範例

下列範例會示範 GetProfile 方法的實作。 在這個範例中,數個 GetProfile 方法的多載會呼叫單一私用 GetProfile 方法,這個方法則會傳回硬式編碼的預設追蹤設定檔。 這個範例來自<暫止追蹤服務 SDK>範例。 如需詳細資訊,請參閱 終止追蹤服務範例

/// <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;
}
'/ <summary>
'/ Returns a Shared tracking profile that only tracks instance terminated events.
'/ </summary>
Protected Overrides Function GetProfile(ByVal workflowInstanceId As Guid) As TrackingProfile
    Return GetProfile()
End Function

Private Shared profile As TrackingProfile = Nothing
Private sourceExists As Boolean = False
Private Overloads Function GetProfile() As TrackingProfile

    '
    ' We shouldn't hit me 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 Not sourceExists Then
        Throw New InvalidOperationException(String.Format(System.Globalization.CultureInfo.InvariantCulture, "EventLog Source with the name '0}' does not exist", source))
    End If
    '
    ' The profile for me instance will never change
    If profile Is Nothing Then

        SyncLock (GetType(TerminationTrackingService))

            If profile Is Nothing Then

                profile = New TrackingProfile()
                profile.Version = New Version("3.0.0.0")
                Dim point As New WorkflowTrackPoint()
                point.MatchingLocation = New WorkflowTrackingLocation()
                point.MatchingLocation.Events.Add(TrackingWorkflowEvent.Terminated)
                profile.WorkflowTrackPoints.Add(point)
            End If
        End SyncLock

    End If

    Return profile
End Function

備註

追蹤服務負責管理用於特定工作流程類型和特定工作流程執行個體的追蹤設定檔。 您可使用您選擇的任何方式來實作這項管理。 例如,您可以針對每個工作流程 TrackingProfile 和工作流程執行個體傳回相同的 Type,或者您也可以管理由工作流程執行個體、工作流程 TypeVersion 所參考之追蹤設定檔的複雜存放區。

適用於

GetProfile(Type, Version)

必須在衍生類別中覆寫,在實作之後會傳回指定之工作流程 Type、特定版本的追蹤設定檔。

protected public:
 abstract System::Workflow::Runtime::Tracking::TrackingProfile ^ GetProfile(Type ^ workflowType, Version ^ profileVersionId);
protected internal abstract System.Workflow.Runtime.Tracking.TrackingProfile GetProfile (Type workflowType, Version profileVersionId);
abstract member GetProfile : Type * Version -> System.Workflow.Runtime.Tracking.TrackingProfile
Protected Friend MustOverride Function GetProfile (workflowType As Type, profileVersionId As Version) As TrackingProfile

參數

workflowType
Type

工作流程的 Type

profileVersionId
Version

追蹤設定檔的 Version

傳回

指定之工作流程型別的追蹤設定檔。

備註

追蹤服務負責管理用於特定工作流程類型和特定工作流程執行個體的追蹤設定檔。 您可使用您選擇的任何方式來實作這項管理。 例如,您可以針對每個工作流程 TrackingProfile 和工作流程執行個體傳回相同的 Type,或者您也可以管理由工作流程執行個體、工作流程 TypeVersion 所參考之追蹤設定檔的複雜存放區。

適用於