SqlTrackingQueryOptions.WorkflowStatus 属性

定义

获取或设置 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,具有由 WorkflowStatusStatusMinDateTimeStatusMaxDateTime 所指定期间指定的状态,并具有至少与一个 TrackingDataItemValue 所指定 TrackingDataItems 对象匹配的已提取数据。

如果在指定时段之前或指定时段中为某个工作流实例收到的最后一个 WorkflowStatusWorkflowTrackingRecord 属性设置为 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 对象。

适用于