共用方式為


SqlTrackingQueryOptions.StatusMaxDateTime 屬性

定義

取得或設定 DateTime,指定時段上限。這個值與 WorkflowStatus 一起用於限制呼叫 SqlTrackingWorkflowInstance 時傳回的 GetWorkflows(SqlTrackingQueryOptions) 物件集合。

public:
 property DateTime StatusMaxDateTime { DateTime get(); void set(DateTime value); };
public DateTime StatusMaxDateTime { get; set; }
member this.StatusMaxDateTime : DateTime with get, set
Public Property StatusMaxDateTime As DateTime

屬性值

DateTime,指定用於比對工作流程執行個體與 WorkflowStatus 指定之狀態的時段上限。 預設值為 DateTime.MinValue

範例

下列範例示範設定 StatusMaxDateTime 屬性。 這個範例來自<工作流程監視器 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 物件集合限制在具備下列條件的工作流程執行個體:TypeWorkflowType 所指定;狀態如 WorkflowStatus 所指定,而且介於 StatusMinDateTimeStatusMaxDateTime 指定的範圍內;擷取的資料至少符合 TrackingDataItemValue 指定的其中一個 TrackingDataItems 物件。

DateTime 指定的 StatusMaxDateTime 值是內含值。 如需工作流程執行個體之狀態比對方式的詳細資訊,請參閱 WorkflowStatus 屬性。

注意

如果 WorkflowStatus 設定為 null,則 StatusMaxDateTimeStatusMinDateTime 會被忽略。 呼叫 GetWorkflows 時會傳回所有工作流程執行個體。

適用於