//Reset the workflow filter options private void ResetWorkflowFilterOptions() { //Set selected item in workflow event combo box to All this.toolStripComboBoxWorkflowEvent.SelectedItem = this.toolStripComboBoxWorkflowEvent.Items[0]; selectedWorkflowEvent = this.toolStripComboBoxWorkflowEvent.Text.Trim(); //Set StatusFrom datetime to 1/1/2000 and StatusUntil to tomorrow this.toolStripTextBoxFrom.Text = new DateTime(2000, 1, 1).ToString(); this.toolStripTextBoxUntil.Text = DateTime.Now.AddDays(1).ToString(); statusFromDateTime = new DateTime(2000, 1, 1); statusUntilDateTime = DateTime.Now.AddDays(1); //Set filter by tracking data items options to empty strings this.toolStripTextBoxArtifactQualifiedId.Text = string.Empty; this.toolStripTextBoxArtifactKeyName.Text = string.Empty; this.toolStripTextBoxArtifactKeyValue.Text = string.Empty; trackingDataItemValue = new TrackingDataItemValue(string.Empty, string.Empty, string.Empty); //Set workflow instance ID to empty Guid this.toolStripTextBoxWorkflowInstanceId.Text = Guid.Empty.ToString(); //clear workflow items listViewWorkflows.Items.Clear(); //display workflows based on workflow event set earlier to All DisplayWorkflows(selectedWorkflowEvent); //update activities list UpdateActivities(); }
private void ToolStripButtonFindWorkflows_Click(object sender, EventArgs e) { statusFromDateTime = DateTime.Parse(this.toolStripTextBoxFrom.Text.ToString()); statusUntilDateTime = DateTime.Parse(this.toolStripTextBoxUntil.Text.ToString()); trackingDataItemValue = new TrackingDataItemValue(string.Empty, string.Empty, string.Empty); trackingDataItemValue.QualifiedName = this.toolStripTextBoxArtifactQualifiedId.Text.ToString(); trackingDataItemValue.FieldName = this.toolStripTextBoxArtifactKeyName.Text.ToString(); trackingDataItemValue.DataValue = this.toolStripTextBoxArtifactKeyValue.Text.ToString(); if (!((string.Empty == trackingDataItemValue.QualifiedName) && (string.Empty == trackingDataItemValue.FieldName) && (string.Empty == trackingDataItemValue.DataValue))) { if ((string.Empty == trackingDataItemValue.QualifiedName) || (string.Empty == trackingDataItemValue.FieldName) || ((string.Empty == trackingDataItemValue.DataValue))) { MessageBox.Show("If you wish to filter by artifacts you need to set the three inputs: Activity Qualified Name, Property Name, and Value.", "Workflow Monitor Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } this.listViewWorkflows.Items.Clear(); DisplayWorkflows(selectedWorkflowEvent, statusFromDateTime, statusUntilDateTime, trackingDataItemValue); UpdateActivities(); }
internal List <SqlTrackingWorkflowInstance> GetWorkflows(string workflowEvent, DateTime from, DateTime until, TrackingDataItemValue trackingDataItemValue) { 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.Empty == workflowEvent) || (null == 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); } }
private void DisplayWorkflows(string selectedWorkflowEvent, Guid workflowInstanceId, DateTime statusFrom, DateTime statusUntil, TrackingDataItemValue trackingDataItemValue) { //Try to get all of the workflows from the tracking database try { if ((null != workflowInstanceId) && (Guid.Empty != workflowInstanceId)) { displayedWorkflows.Clear(); SqlTrackingWorkflowInstance sqlTrackingWorkflowInstance = null; if (true == monitorDatabaseServiceValue.TryGetWorkflow(workflowInstanceId, out sqlTrackingWorkflowInstance)) { displayedWorkflows.Add(sqlTrackingWorkflowInstance); } } else { displayedWorkflows = monitorDatabaseServiceValue.GetWorkflows(selectedWorkflowEvent, statusFrom, statusUntil, trackingDataItemValue); } listViewWorkflows.Items.Clear(); workflowStatusList.Clear(); // For every workflow instance create a new WorkflowStatusInfo object and store in the workflowStatusList // Also populate the workflow ListView foreach (SqlTrackingWorkflowInstance sqlTrackingWorkflowInstance in displayedWorkflows) { string workflowType = (sqlTrackingWorkflowInstance.WorkflowType != null) ? sqlTrackingWorkflowInstance.WorkflowType.ToString() : "XAML"; ListViewItem listViewItem = new ListViewItem(new string[] { sqlTrackingWorkflowInstance.WorkflowInstanceInternalId.ToString(), workflowType, sqlTrackingWorkflowInstance.Status.ToString() }, -1); listViewWorkflows.Items.Add(listViewItem); workflowStatusList.Add(sqlTrackingWorkflowInstance.WorkflowInstanceInternalId.ToString(), new WorkflowStatusInfo( sqlTrackingWorkflowInstance.WorkflowInstanceInternalId.ToString(), workflowType, sqlTrackingWorkflowInstance.Status.ToString(), sqlTrackingWorkflowInstance.Initialized.ToString(), sqlTrackingWorkflowInstance.WorkflowInstanceId, listViewItem)); } //If there is at least one workflow, populate the Activities list if (listViewWorkflows.Items.Count > 0) { this.listViewWorkflows.Focus(); ListViewItem listItem = this.listViewWorkflows.Items[0]; listItem.Focused = true; listItem.Selected = true; UpdateTitle(); UpdateActivities(); this.statusLabelMonitoring.Text = String.Empty; } //Display number of workflow instances if (displayedWorkflows.Count > 0) { this.workflowsLabel.Text = " Workflows - " + displayedWorkflows.Count + " records"; ShowViewHost(true); } else { this.workflowsLabel.Text = " Workflows - no records"; ShowViewHost(false); } } //Clear all of the lists and reset the UI if there are errors catch (Exception e) { if (e.InnerException != null) { MessageBox.Show(e.Message + "\r\n" + e.InnerException.Message + "\r\n" + "Ensure your settings are correct and that you have run SqlTrackingService database schema and logic scripts", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } this.statusLabelMonitoring.Text = "Error"; ShowSettingsDialog(); workflowStatusList.Clear(); listViewWorkflows.Items.Clear(); activityStatusListValue.Clear(); listViewActivities.Items.Clear(); this.workflowsLabel.Text = " Workflows - no records"; ShowViewHost(false); } }
private void DisplayWorkflows(string selectedWorkflowEvent, DateTime statusFrom, DateTime statusUntil, TrackingDataItemValue trackingDataItemValue) { DisplayWorkflows(selectedWorkflowEvent, Guid.Empty, statusFrom, statusUntil, trackingDataItemValue); }