TrackingProfile.ActivityTrackPoints 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得執行階段追蹤基礎結構用來篩選活動狀態事件的活動追蹤點集合。
public:
property System::Workflow::Runtime::Tracking::ActivityTrackPointCollection ^ ActivityTrackPoints { System::Workflow::Runtime::Tracking::ActivityTrackPointCollection ^ get(); };
public System.Workflow.Runtime.Tracking.ActivityTrackPointCollection ActivityTrackPoints { get; }
member this.ActivityTrackPoints : System.Workflow.Runtime.Tracking.ActivityTrackPointCollection
Public ReadOnly Property ActivityTrackPoints As ActivityTrackPointCollection
屬性值
ActivityTrackPointCollection,可指定工作流程執行個體中的點,執行階段追蹤基礎結構會傳送這些點的 ActivityTrackingRecord 至追蹤服務。
範例
下列程式碼範例將示範如何使用 TrackingProfile 建構函式建立 TrackingProfile,並使用物件的屬性協助追蹤工作流程的執行。 此範例程式碼會使用 ActivityTrackPoints、Version 和 WorkflowTrackPoints 屬性。
這個程式碼範例是 Program.cs 檔案中<使用 SQLTrackingService 查詢 SDK>範例的一部分。 如需詳細資訊,請參閱 使用 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
備註
每當活動執行個體的 ActivityExecutionStatus 變更時,工作流程執行個體都會發出活動狀態事件到執行階段追蹤基礎結構。 執行階段追蹤基礎結構會使用 ActivityTrackPoints 屬性篩選這些活動狀態事件,以判斷何時傳送 ActivityTrackingRecord 至追蹤服務。 您可以加入 ActivityTrackPoint 至 ActivityTrackPoints 屬性中,以指定您所需要的點;這些點位於工作流程執行個體的可能執行路徑中,而且您想要傳送這個執行個體的 ActivityTrackingRecord。
ActivityTrackPoint 不會實際定義工作流程執行個體中的實體點,而會定義一組比對參數,讓執行階段追蹤基礎結構可用來比對應傳送之 ActivityTrackingRecord 的活動狀態事件。 因此,在工作流程執行個體的存留期間內,可以多次比對相同的 ActivityTrackPoint。 ActivityTrackPoint 也可以指定要從工作流程執行個體中擷取,然後在 ActivityTrackingRecord 中傳回的資料。