TrackingService.GetProfile 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
必须在派生类中重写,并且在实现后为指定的工作流实例或工作流类型获取跟踪配置文件。
重载
GetProfile(Guid) |
必须在派生类中重写,并且在实现后为指定的工作流实例返回跟踪配置文件。 |
GetProfile(Type, Version) |
必须在派生类中重写,并且在实现后为指定的工作流 Type 返回由版本限定的跟踪配置文件。 |
注解
跟踪服务负责管理可用于特定工作流类型和特定工作流实例的跟踪配置文件。 可以采用您选择的任何方式实现此管理。 例如,您可以为每个工作流 TrackingProfile 和工作流实例返回相同的 Type;或者,您可以管理工作流实例、工作流 Type 和 Version 引用的跟踪配置文件的复杂存储。
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
参数
返回
指定工作流实例的跟踪配置文件。
示例
下面的示例演示 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;或者,您可以管理工作流实例、工作流 Type 和 Version 引用的跟踪配置文件的复杂存储。
适用于
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
参数
返回
指定工作流类型的跟踪配置文件。
注解
跟踪服务负责管理可用于特定工作流类型和特定工作流实例的跟踪配置文件。 可以采用您选择的任何方式实现此管理。 例如,您可以为每个工作流 TrackingProfile 和工作流实例返回相同的 Type;或者,您可以管理工作流实例、工作流 Type 和 Version 引用的跟踪配置文件的复杂存储。