public TaskVM(StepWorkflow workflow, string name, Action <StepWorkflow> shutdown)
 {
     //set fields
     Workflow = workflow;
     Steps    = new ObservableCollection <StepVM>(workflow.Steps.Where(i => i.ShowStep).Select(i => new StepVM(i)));
     Name     = name;
     Shutdown = shutdown;
 }
        void StartWorkflow(StepWorkflow workflow, string name, Action <StepWorkflow> shutdown = null)
        {
            //setup task
            workflow.StepChanged += Workflow_StepChanged;
            ActiveStep            = null;
            ActiveTask            = new TaskVM(workflow, name, shutdown);

            //start workflow
            App.Instance.Arm.Behaviors.Add(workflow);
        }
        /// <summary>
        /// Create an associative entity that stores the relationship between the workflow instance and the target entity.
        /// </summary>
        /// <param name="dataContext"></param>
        /// <param name="targetEntityId"></param>
        /// <param name="workflowId"></param>
        /// <param name="triggerId"></param>
        protected override void CreateWorkflowInstanceEntity(RockContext dataContext, int targetEntityId, int workflowId, int triggerId)
        {
            // Create a new StepWorkflow instance to track the association between the Step and the Workflow.
            var stepWorkflow = new StepWorkflow();

            stepWorkflow.StepId     = targetEntityId;
            stepWorkflow.WorkflowId = workflowId;

            stepWorkflow.StepWorkflowTriggerId = triggerId;

            var stepWorkflowService = new StepWorkflowService(dataContext);

            stepWorkflowService.Add(stepWorkflow);
        }