private async Task <WorkflowState> CreateGraphAndExecute(WorkflowContext context, IWorkflowLoader loader, IWorkflowContextPersistor instancePersistor, bool isResume = false)
        {
            IWorkflowInstance workflowInstance = loader.LoadWorkflow(context.WorkflowId, context.WorkflowVersion, context
                                                                     , new Controller(instancePersistor, context));
            await workflowInstance.Initialize();

            var state = isResume ? await workflowInstance.Resume() : await workflowInstance.Execute();

            instancePersistor.Save(context);
            return(new WorkflowState()
            {
                Context = context.ToJson(), Id = workflowInstance.Id, State = state
            });
        }
Пример #2
0
        private WorkflowState CreateGraphAndExecute(WorkflowContext context, IWorkflowLoader loader, IWorkflowContextPersistor instancePersistor, bool isResume = false)
        {
            IWorkflowInstance workflowInstance = loader.LoadWorkflow(context.WorkflowId, context.WorkflowVersion, context
                                                                     , new Controller(instancePersistor, context));

            workflowInstance.Initialize().Wait();
            var state           = isResume ?  workflowInstance.Resume().Result :workflowInstance.Execute().Result;
            var persistentState = instancePersistor.Save(context);

            return(new WorkflowState()
            {
                Context = persistentState.Context,
                Id = persistentState.InstanceId,
                State = state,
                RequiredParameters = context.RequiredParameters.ToArray()
            });
        }