Edit

Share via


SqlTrackingQueryOptions Constructor

Definition

Initializes a new instance of the SqlTrackingQueryOptions class.

public:
 SqlTrackingQueryOptions();
public SqlTrackingQueryOptions ();
Public Sub New ()

Examples

The following example demonstrates creating an instance of the SqlTrackingQueryOptions class. 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);
}

Remarks

The following table shows the initial property values for an instance of the SqlTrackingQueryOptions class.

Property Value
StatusMaxDateTime MaxValue.
StatusMinDateTime MinValue.
TrackingDataItems An empty List<T>.
WorkflowStatus A null reference (Nothing in Visual Basic).
WorkflowType A null reference (Nothing in Visual Basic).

These values specify that a call to SqlTrackingQuery.GetWorkflows should return a SqlTrackingWorkflowInstance object for every workflow instance that has tracking data in the database.

Applies to