/// <summary> /// Loads the workflows. /// </summary> /// <param name="workflowTypeId">The workflow type unique identifier.</param> private void LoadWorkflows(int?workflowTypeId) { int?currentWorkflowId = this.WorkflowId; _ddlWorkflow.SelectedValue = null; _ddlWorkflow.Items.Clear(); if (workflowTypeId.HasValue) { if (!Required) { _ddlWorkflow.Items.Add(new ListItem(string.Empty, Rock.Constants.None.IdValue)); } var workflowService = new Rock.Model.WorkflowService(new RockContext()); var workflows = workflowService.Queryable() .Where(w => w.WorkflowTypeId == workflowTypeId.Value && w.ActivatedDateTime.HasValue && !w.CompletedDateTime.HasValue) .OrderBy(w => w.Name) .Select(a => new { a.Id, a.Name }) .ToList(); foreach (var w in workflows) { var workflowItem = new ListItem(w.Name, w.Id.ToString().ToUpper()); workflowItem.Selected = w.Id == currentWorkflowId; _ddlWorkflow.Items.Add(workflowItem); } } }
/// <summary> /// Launch the workflow /// </summary> protected void LaunchTheWorkflow(string workflowName, IJobExecutionContext context) { Guid workflowTypeGuid = Guid.NewGuid(); if (Guid.TryParse(workflowName, out workflowTypeGuid)) { var workflowType = WorkflowTypeCache.Get(workflowTypeGuid); if (workflowType != null && (workflowType.IsActive ?? true)) { var workflow = Rock.Model.Workflow.Activate(workflowType, workflowName); List <string> workflowErrors; var processed = new Rock.Model.WorkflowService(new RockContext()).Process(workflow, out workflowErrors); context.Result = (processed ? "Processed " : "Did not process ") + workflow.ToString(); } } }
/// <summary> /// Loads the workflows. /// </summary> /// <param name="workflowTypeId">The workflow type unique identifier.</param> private void LoadWorkflows( int? workflowTypeId ) { int? currentWorkflowId = this.WorkflowId; _ddlWorkflow.SelectedValue = null; _ddlWorkflow.Items.Clear(); if ( workflowTypeId.HasValue ) { if ( !Required ) { _ddlWorkflow.Items.Add( new ListItem( string.Empty, Rock.Constants.None.IdValue ) ); } var workflowService = new Rock.Model.WorkflowService( new RockContext() ); var workflows = workflowService.Queryable() .Where( w => w.WorkflowTypeId == workflowTypeId.Value && w.ActivatedDateTime.HasValue && !w.CompletedDateTime.HasValue ) .OrderBy( w => w.Name ) .ToList(); foreach ( var w in workflows ) { var workflowItem = new ListItem( w.Name, w.Id.ToString().ToUpper() ); workflowItem.Selected = w.Id == currentWorkflowId; _ddlWorkflow.Items.Add( workflowItem ); } } }