SqlTrackingQueryOptions.WorkflowStatus 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定 WorkflowStatus 值,用於限制呼叫 SqlTrackingWorkflowInstance 時值回的 GetWorkflows(SqlTrackingQueryOptions) 物件集合。
public:
property Nullable<System::Workflow::Runtime::WorkflowStatus> WorkflowStatus { Nullable<System::Workflow::Runtime::WorkflowStatus> get(); void set(Nullable<System::Workflow::Runtime::WorkflowStatus> value); };
public System.Workflow.Runtime.WorkflowStatus? WorkflowStatus { get; set; }
member this.WorkflowStatus : Nullable<System.Workflow.Runtime.WorkflowStatus> with get, set
Public Property WorkflowStatus As Nullable(Of WorkflowStatus)
屬性值
其中一個 WorkflowStatus 值或 null (在 Visual Basic 中為 Nothing
)。 預設為 null (Nothing
)。
範例
下列範例示範設定 WorkflowStatus 屬性。 這個範例來自<工作流程監視器 SDK>範例。 如需詳細資訊,請參閱 工作流程監視器範例。
try
{
List<SqlTrackingWorkflowInstance> queriedWorkflows = new List<SqlTrackingWorkflowInstance>();
SqlTrackingQuery sqlTrackingQuery = new SqlTrackingQuery(connectionString);
SqlTrackingQueryOptions sqlTrackingQueryOptions = new SqlTrackingQueryOptions();
sqlTrackingQueryOptions.StatusMinDateTime = from.ToUniversalTime();
sqlTrackingQueryOptions.StatusMaxDateTime = until.ToUniversalTime();
// If QualifiedName, FieldName, or DataValue is not supplied, we will not query since they are all required to match
if (!((string.Empty == trackingDataItemValue.QualifiedName) || (string.Empty == trackingDataItemValue.FieldName) || ((string.Empty == trackingDataItemValue.DataValue))))
sqlTrackingQueryOptions.TrackingDataItems.Add(trackingDataItemValue);
queriedWorkflows.Clear();
if ("created" == workflowEvent.ToLower(CultureInfo.InvariantCulture))
{
sqlTrackingQueryOptions.WorkflowStatus = WorkflowStatus.Created;
queriedWorkflows.AddRange(sqlTrackingQuery.GetWorkflows(sqlTrackingQueryOptions));
}
else if ("completed" == workflowEvent.ToLower(CultureInfo.InvariantCulture))
{
sqlTrackingQueryOptions.WorkflowStatus = WorkflowStatus.Completed;
queriedWorkflows.AddRange(sqlTrackingQuery.GetWorkflows(sqlTrackingQueryOptions));
}
else if ("running" == workflowEvent.ToLower(CultureInfo.InvariantCulture))
{
sqlTrackingQueryOptions.WorkflowStatus = WorkflowStatus.Running;
queriedWorkflows.AddRange(sqlTrackingQuery.GetWorkflows(sqlTrackingQueryOptions));
}
else if ("suspended" == workflowEvent.ToLower(CultureInfo.InvariantCulture))
{
sqlTrackingQueryOptions.WorkflowStatus = WorkflowStatus.Suspended;
queriedWorkflows.AddRange(sqlTrackingQuery.GetWorkflows(sqlTrackingQueryOptions));
}
else if ("terminated" == workflowEvent.ToLower(CultureInfo.InvariantCulture))
{
sqlTrackingQueryOptions.WorkflowStatus = WorkflowStatus.Terminated;
queriedWorkflows.AddRange(sqlTrackingQuery.GetWorkflows(sqlTrackingQueryOptions));
}
else if (("all" == workflowEvent.ToLower(CultureInfo.InvariantCulture)) || string.IsNullOrEmpty(workflowEvent))
{
sqlTrackingQueryOptions.WorkflowStatus = WorkflowStatus.Created;
queriedWorkflows.AddRange(sqlTrackingQuery.GetWorkflows(sqlTrackingQueryOptions));
sqlTrackingQueryOptions.WorkflowStatus = WorkflowStatus.Completed;
queriedWorkflows.AddRange(sqlTrackingQuery.GetWorkflows(sqlTrackingQueryOptions));
sqlTrackingQueryOptions.WorkflowStatus = WorkflowStatus.Running;
queriedWorkflows.AddRange(sqlTrackingQuery.GetWorkflows(sqlTrackingQueryOptions));
sqlTrackingQueryOptions.WorkflowStatus = WorkflowStatus.Suspended;
queriedWorkflows.AddRange(sqlTrackingQuery.GetWorkflows(sqlTrackingQueryOptions));
sqlTrackingQueryOptions.WorkflowStatus = WorkflowStatus.Terminated;
queriedWorkflows.AddRange(sqlTrackingQuery.GetWorkflows(sqlTrackingQueryOptions));
}
return queriedWorkflows;
}
catch (Exception exception)
{
throw new Exception("Exception in GetWorkflows", exception);
}
備註
SqlTrackingQueryOptions 會將 SqlTrackingWorkflowInstance 的呼叫所傳回的 SqlTrackingQuery.GetWorkflows 物件集合限制在具備下列條件的工作流程執行個體:Type 如 WorkflowType 所指定;狀態如 WorkflowStatus 所指定,而且介於 StatusMinDateTime 和 StatusMaxDateTime 指定的範圍內;擷取的資料至少符合 TrackingDataItemValue 指定的其中一個 TrackingDataItems 物件。
如果在指定的時間範圍內或之前最後一次收到的工作流程執行個體 WorkflowStatus 的 WorkflowTrackingRecord 屬性設定為 WorkflowTrackingRecord.TrackingWorkflowEvent 值,而且對應至 TrackingWorkflowEvent 指定的 System.Workflow.Runtime.WorkflowStatus 值,則工作流程執行個體會被視為擁有符合 WorkflowStatus 的狀態。 因此,工作流程執行個體的 TrackingProfile 必須有針對適當 WorkflowTrackPoint 值設定的 System.Workflow.Runtime.Tracking.TrackingWorkflowEvent。 只有已送入工作流程追蹤記錄的 TrackingWorkflowEvent 才能被比對。 如果尚未為工作流程執行個體送出任何工作流程追蹤記錄,該工作流程執行個體會被視為有 WorkflowStatus.Created 的狀態。
下表顯示 TrackingWorkflowEvent 值和 WorkflowStatus 值之間的對應。
TrackingWorkflowEvent 值 | WorkflowStatus 值 |
---|---|
Aborted | Running |
Changed | Running |
Completed | Completed |
Created | Created |
Exception | Running |
Idle | Running |
Loaded | Running |
Persisted | Running |
Resumed | Running |
Started | Running |
Suspended | Suspended |
Terminated | Terminated |
Unloaded | Running |
如果 WorkflowStatus 為 null (Nothing
),傳回的 SqlTrackingWorkflowInstance 物件集合將不受狀態限制,也就是說,只要工作流程執行個體符合 SqlTrackingWorkflowInstance 其他屬性指定的參數,就會傳回 SqlTrackingQueryOptions 物件。