public override ExecutionPipelineDirective InitForExecution(WorkflowExecutorResult executorResult, WorkflowDefinition defintion, WorkflowInstance workflow, ExecutionPointer executionPointer) { if (!executionPointer.EventPublished) { //resolve principal to be assigned var resolvedUser = Principal.Compile().DynamicInvoke(workflow.Data); executionPointer.ExtensionAttributes["AssignedPrincipal"] = resolvedUser; executionPointer.ExtensionAttributes["Prompt"] = UserPrompt; Dictionary <string, object> userOptions = new Dictionary <string, object>(); foreach (var outcome in Outcomes) { userOptions[outcome.Label ?? Convert.ToString(outcome.GetValue(workflow.Data) ?? "Proceed")] = outcome.GetValue(workflow.Data); } executionPointer.ExtensionAttributes["UserOptions"] = userOptions; executionPointer.EventKey = workflow.Id + "." + executionPointer.Id; executionPointer.EventName = "UserAction"; executionPointer.Active = false; executorResult.Subscriptions.Add(new EventSubscription() { WorkflowId = workflow.Id, StepId = executionPointer.StepId, EventName = executionPointer.EventName, EventKey = executionPointer.EventKey, SubscribeAsOf = DateTime.Now.ToUniversalTime() }); return(ExecutionPipelineDirective.Defer); } return(ExecutionPipelineDirective.Next); }
public override ExecutionPipelineDirective InitForExecution(IWorkflowHost host, IPersistenceProvider persistenceStore, WorkflowDefinition defintion, WorkflowInstance workflow, ExecutionPointer executionPointer) { if (!executionPointer.EventPublished) { //resolve principal to be assigned var resolvedUser = Principal.Compile().DynamicInvoke(workflow.Data); executionPointer.ExtensionAttributes["AssignedPrincipal"] = resolvedUser; executionPointer.ExtensionAttributes["Prompt"] = UserPrompt; Dictionary <string, object> userOptions = new Dictionary <string, object>(); foreach (var outcome in Outcomes) { userOptions[outcome.Label ?? Convert.ToString(outcome.Value ?? "Proceed")] = outcome.Value; } executionPointer.ExtensionAttributes["UserOptions"] = userOptions; executionPointer.EventKey = workflow.Id + "." + executionPointer.Id; executionPointer.EventName = "UserAction"; executionPointer.Active = false; persistenceStore.PersistWorkflow(workflow).Wait(); host.SubscribeEvent(workflow.Id, executionPointer.StepId, executionPointer.EventName, executionPointer.EventKey); return(ExecutionPipelineDirective.Defer); } return(ExecutionPipelineDirective.Next); }