public async Task <ActionResult <string> > Start(
            [FromServices] IWorkflowInvoker wfInvoker,
            [FromServices] IWorkflowRegistry wfRegistry,
            [FromServices] IWorkflowDefinitionStore wfStore,
            string name,
            CancellationToken cancellationToken)
        {
            var correlationId = Guid.NewGuid().ToString();

            var definitions = await wfStore.ListAsync(VersionOptions.Published, cancellationToken);

            var wf = definitions.FirstOrDefault(d => d.Name.ToLower(CultureInfo.InvariantCulture) == name);

            if (wf == null)
            {
                return(NotFound());
            }

            var input = new Variables(new [] {
                new KeyValuePair <string, object>("withdrawalId", "33")
            });

            var context = await wfInvoker.StartAsync(wf, input : input, correlationId : correlationId, cancellationToken : cancellationToken);

            return(Ok($"Batched/{correlationId}"));
        }
示例#2
0
 public WorkflowInstanceAppService(IWorkflowInvoker workflowInvoker, IWorkflowDefinitionVersionRepository workflowDefinitionVersionRepository, IWorkflowInstanceRepository workflowInstanceRepository, IWorkflowInstanceStore workflowInstanceStore)
 {
     _workflowInvoker = workflowInvoker;
     _workflowDefinitionVersionRepository = workflowDefinitionVersionRepository;
     _workflowInstanceRepository          = workflowInstanceRepository;
     _workflowInstanceStore = workflowInstanceStore;
 }
示例#3
0
 public UserBusiness(
     ILogger <UserBusiness> logger,
     IWorkflowInvoker workflowInvoker)
 {
     _logger          = logger;
     _workflowInvoker = workflowInvoker;
 }
示例#4
0
 /// <summary>
 /// Starts new workflows that start with the specified activity name and resumes halted workflows that are blocked on activities with the specified activity name.
 /// </summary>
 public static Task TriggerAsync(
     this IWorkflowInvoker workflowInvoker,
     string activityType,
     Variables input,
     CancellationToken cancellationToken = default)
 {
     return(workflowInvoker.TriggerAsync(activityType, input, cancellationToken: cancellationToken));
 }
示例#5
0
        protected override void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext)
        {
            var currentActivity = workflowContext.CurrentActivity;

            foreach (var endpointName in EndpointNames)
            {
                workflowContext.ScheduleNextActivities(workflowContext, new SourceEndpoint(currentActivity, endpointName));
            }
        }
 public HttpWorkflowsController(
     ITokenService tokenService,
     IWorkflowInvoker workflowInvoker,
     IWorkflowInstanceStore workflowInstanceStore)
 {
     this.tokenService          = tokenService;
     this.workflowInvoker       = workflowInvoker;
     this.workflowInstanceStore = workflowInstanceStore;
 }
 public IndexModel(ILogger <IndexModel> logger, IWorkflowInvoker WorkflowInvoker, ElsaContextEx db,
                   IWorkflowDefinitionStore workflowDefinitionStore,
                   IWorkflowInstanceStore workflowInstanceStore)
 {
     _logger         = logger;
     workflowInvoker = WorkflowInvoker;
     this.workflowDefinitionStore = workflowDefinitionStore;
     this.workflowInstanceStore   = workflowInstanceStore;
     this.db = db;
 }
        public async Task <ActionResult <bool> > ResumeAsync(
            [FromServices] IWorkflowInstanceStore wfStore,
            [FromServices] IWorkflowInvoker wfInvoker,
            string name,
            string correlationId,
            CancellationToken cancellationToken)
        {
            await wfInvoker.TriggerSignalAsync(name, correlationId : correlationId, cancellationToken : cancellationToken); // .ResumeAsync(wf, cancellationToken: cancellationToken);

            return(Ok(true));
        }
示例#9
0
 public TriggerRequestHandler(
     IHttpContextAccessor httpContext,
     IWorkflowInvoker workflowInvoker,
     IWorkflowRegistry registry,
     IWorkflowInstanceStore workflowInstanceStore)
 {
     this.httpContext           = httpContext.HttpContext;
     this.workflowInvoker       = workflowInvoker;
     this.registry              = registry;
     this.workflowInstanceStore = workflowInstanceStore;
     cancellationToken          = httpContext.HttpContext.RequestAborted;
 }
示例#10
0
        public override async Task ExecuteAsync(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext, CancellationToken cancellationToken)
        {
            var currentActivity = workflowContext.CurrentActivity;

            foreach (var endpointName in EndpointNames)
            {
                ScheduleNextActivities(workflowContext, new SourceEndpoint(currentActivity, endpointName));
            }

            var eventHandlers = workflowContext.ServiceProvider.GetServices <IWorkflowEventHandler>();
            var logger        = workflowContext.ServiceProvider.GetRequiredService <ILogger <OutcomeResult> >();
            await eventHandlers.InvokeAsync(x => x.ActivityExecutedAsync(workflowContext, currentActivity, cancellationToken), logger);
        }
        public override async Task ExecuteAsync(
            IWorkflowInvoker invoker,
            WorkflowExecutionContext workflowContext,
            CancellationToken cancellationToken)
        {
            var currentActivity = workflowContext.CurrentActivity;
            var eventHandlers   = workflowContext.ServiceProvider.GetServices <IWorkflowEventHandler>();
            var logger          = workflowContext.ServiceProvider.GetRequiredService <ILogger <OutcomeResult> >();
            await eventHandlers.InvokeAsync(
                x => x.ActivityExecutedAsync(workflowContext, currentActivity, cancellationToken),
                logger);

            workflowContext.Finish();
        }
示例#12
0
        public override async Task ExecuteAsync(
            IWorkflowInvoker invoker,
            WorkflowExecutionContext workflowContext,
            CancellationToken cancellationToken)
        {
            var eventHandlers   = workflowContext.ServiceProvider.GetServices <IWorkflowEventHandler>();
            var logger          = workflowContext.ServiceProvider.GetRequiredService <ILogger <FaultWorkflowResult> >();
            var currentActivity = workflowContext.CurrentActivity;

            await eventHandlers.InvokeAsync(
                x => x.ActivityFaultedAsync(workflowContext, currentActivity, errorMessage, cancellationToken),
                logger);

            workflowContext.Fault(workflowContext.CurrentActivity, errorMessage, exception);
        }
示例#13
0
 public SignalRequestHandler(
     IHttpContextAccessor httpContextAccessor,
     ITokenService tokenService,
     IWorkflowInvoker workflowInvoker,
     IWorkflowRegistry workflowRegistry,
     IWorkflowFactory workflowFactory,
     IWorkflowInstanceStore workflowInstanceStore)
 {
     httpContext                = httpContextAccessor.HttpContext;
     this.tokenService          = tokenService;
     this.workflowInvoker       = workflowInvoker;
     this.workflowRegistry      = workflowRegistry;
     this.workflowFactory       = workflowFactory;
     this.workflowInstanceStore = workflowInstanceStore;
     cancellationToken          = httpContext.RequestAborted;
 }
示例#14
0
        public override async Task ExecuteAsync(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext, CancellationToken cancellationToken)
        {
            if (workflowContext.IsFirstPass)
            {
                var activity = workflowContext.CurrentActivity;
                var result   = await invoker.ActivityInvoker.ResumeAsync(workflowContext, activity, cancellationToken);

                workflowContext.IsFirstPass = false;

                await result.ExecuteAsync(invoker, workflowContext, cancellationToken);
            }
            else
            {
                workflowContext.Halt();
            }
        }
        public static async Task TriggerSignalAsync(
            this IWorkflowInvoker workflowInvoker,
            string signalName,
            Variables input = default,
            Func <JObject, bool> activityStatePredicate = null,
            string correlationId = default,
            CancellationToken cancellationToken = default)
        {
            var combinedInput = new Variables();

            combinedInput.SetVariable("Signal", signalName);

            if (input != null)
            {
                combinedInput.SetVariables(input);
            }

            await workflowInvoker.TriggerAsync(nameof(Signaled), combinedInput, correlationId, activityStatePredicate, cancellationToken);
        }
示例#16
0
        public override async Task ExecuteAsync(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext, CancellationToken cancellationToken)
        {
            var currentActivity = workflowContext.CurrentActivity;
            var previousEntry   = workflowContext.Workflow.ExecutionLog.OrderByDescending(x => x.Timestamp).Skip(steps).FirstOrDefault();

            if (previousEntry == null)
            {
                return;
            }

            var activityId = previousEntry.ActivityId;
            var activity   = workflowContext.Workflow.GetActivity(activityId);

            workflowContext.ScheduleActivity(activity);

            var eventHandlers = workflowContext.ServiceProvider.GetServices <IWorkflowEventHandler>();
            var logger        = workflowContext.ServiceProvider.GetRequiredService <ILogger <GoBackResult> >();
            await eventHandlers.InvokeAsync(x => x.ActivityExecutedAsync(workflowContext, currentActivity, cancellationToken), logger);
        }
示例#17
0
        public override async Task ExecuteAsync(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext, CancellationToken cancellationToken)
        {
            var activity = workflowContext.CurrentActivity;

            if (workflowContext.IsFirstPass && ContinueOnFirstPass)
            {
                var activityInvoker = workflowContext.ServiceProvider.GetRequiredService <IActivityInvoker>();
                var result          = await activityInvoker.ResumeAsync(workflowContext, activity, cancellationToken);

                workflowContext.IsFirstPass = false;

                await result.ExecuteAsync(invoker, workflowContext, cancellationToken);
            }
            else
            {
                workflowContext.ScheduleHaltingActivity(activity);
                workflowContext.Halt(activity);
            }
        }
示例#18
0
 protected override void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext)
 {
     workflowContext.ScheduleActivity(activity);
 }
示例#19
0
 /// <summary>
 /// Invokes a workflow asynchronously using the specified input object
 /// as input parameters, the specified time-out interval, and a unique
 /// identifier.
 /// </summary>
 /// <typeparam name="TInput">The type of the input.</typeparam>
 /// <param name="invoker">The invoker.</param>
 /// <param name="inputs">The input object which is turned into a
 /// dictionary by <see cref="ObjectExtensions.ToDict"/>.</param>
 /// <param name="timeout">The interval in which the workflow must
 /// complete before it is aborted and a System.TimeoutException is
 /// thrown.</param>
 /// <param name="userState">A user-provided object used to distinguish
 /// this particular asynchronous invoke operation from other current
 /// asynchronous invoke operations.</param>
 public static void InvokeAsync <TInput>(this IWorkflowInvoker invoker, TInput inputs, TimeSpan timeout, object userState)
     where TInput : class
 {
     invoker.InvokeAsync(inputs.ToDict(), timeout, userState);
 }
示例#20
0
 /// <summary>
 /// Invokes a workflow asynchronously using the specified input object
 /// as input parameters and a unique identifier.
 /// </summary>
 /// <typeparam name="TInput">The type of the input.</typeparam>
 /// <param name="invoker">The invoker.</param>
 /// <param name="inputs">The input object which is turned into a
 /// dictionary by <see cref="ObjectExtensions.ToDict"/>.</param>
 /// <param name="userState">A user-provided object used to distinguish
 /// this particular asynchronous invoke operation from other current
 /// asynchronous invoke operations.</param>
 public static void InvokeAsync <TInput>(this IWorkflowInvoker invoker, TInput inputs, object userState)
 {
     invoker.InvokeAsync(inputs.ToDict(), userState);
 }
示例#21
0
 /// <summary>
 /// Invokes a workflow asynchronously using the specified input object
 /// as input parameters.
 /// </summary>
 /// <typeparam name="TInput">The type of the input.</typeparam>
 /// <param name="invoker">The invoker.</param>
 /// <param name="inputs">The input object which is turned into a
 /// dictionary by <see cref="ObjectExtensions.ToDict"/>.</param>
 public static void InvokeAsync <TInput>(this IWorkflowInvoker invoker, TInput inputs)
     where TInput : class
 {
     invoker.InvokeAsync(inputs.ToDict());
 }
示例#22
0
 public TriggerWorkflow(IWorkflowInvoker workflowInvoker, IWorkflowExpressionEvaluator expressionEvaluator)
 {
     this.workflowInvoker     = workflowInvoker;
     this.expressionEvaluator = expressionEvaluator;
 }
示例#23
0
        protected override void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext)
        {
            var activity = workflowContext.CurrentActivity;

            workflowContext.Fault(errorMessage, activity);
        }
示例#24
0
 public TestController(ILogger <TestController> logger, IWorkflowInvoker invoker)
 {
     _logger      = logger;
     this.invoker = invoker;
 }
示例#25
0
 protected virtual void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext)
 {
 }
 protected override void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext)
 {
     workflowContext.SetLastResult(value);
 }
示例#27
0
 public ActivateB(IWorkflowInvoker invoker)
 {
     _invoker = invoker;
 }
示例#28
0
 protected override void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext)
 {
     // Noop.
 }
示例#29
0
 public virtual Task ExecuteAsync(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext, CancellationToken cancellationToken)
 {
     Execute(invoker, workflowContext);
     return(Task.CompletedTask);
 }
示例#30
0
 public WorkflowConsumer(IWorkflowInvoker workflowInvoker)
 {
     this.workflowInvoker = workflowInvoker;
 }