SqlTrackingQueryOptions.StatusMaxDateTime 属性

定义

获取或设置一个指定时段上限的 DateTime,可以将其与 WorkflowStatus 结合使用来约束 SqlTrackingWorkflowInstance 调用所返回 GetWorkflows(SqlTrackingQueryOptions) 对象的集合。Gets or sets a DateTime that specifies the upper limit of the time period that, together with WorkflowStatus, is used to constrain the set of SqlTrackingWorkflowInstance objects returned by a call to 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

一个 DateTime,它指定用于匹配工作流实例(带有由 WorkflowStatus 指定的状态)的时段的上限。A DateTime that specifies the upper limit of the time period used for matching workflow instances with a status specified by WorkflowStatus. 默认值为 MinValueThe default is MinValue.

示例

下面的示例演示如何设置 StatusMaxDateTime 属性。The following example demonstrates setting the StatusMaxDateTime property. 此示例摘自工作流监视器 SDK 示例。This example is from the Workflow Monitor SDK sample. 有关详细信息,请参阅 工作流监视器示例For more information, see Workflow Monitor Sample.

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,具有由 WorkflowStatusStatusMinDateTimeStatusMaxDateTime 所指定期间指定的状态,并具有至少与一个 TrackingDataItemValue 所指定 TrackingDataItems 对象匹配的已提取数据。SqlTrackingQueryOptions constrains the set of SqlTrackingWorkflowInstance objects returned by a call to SqlTrackingQuery.GetWorkflows to those workflow instances that have the Type specified by WorkflowType, that have the status specified by WorkflowStatus during the period specified by StatusMinDateTime and StatusMaxDateTime, and that have extracted data that matches at least one of the TrackingDataItemValue objects specified by TrackingDataItems.

DateTime 指定的 StatusMaxDateTime 值包含在内。The DateTime value specified by StatusMaxDateTime is inclusive. 有关如何匹配工作流实例的状态的更多信息,请参见 WorkflowStatus 属性。For more information about how the status of a workflow instance is matched, see the WorkflowStatus property.

备注

如果 WorkflowStatus 设置为 Null,则会忽略 StatusMaxDateTimeStatusMinDateTimeIf WorkflowStatus is set to null, then StatusMaxDateTime and StatusMinDateTime are ignored. 调用 GetWorkflows 时将返回所有工作流实例。All workflow instances will be returned when GetWorkflows is called.

适用于