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}")); }
public WorkflowInstanceAppService(IWorkflowInvoker workflowInvoker, IWorkflowDefinitionVersionRepository workflowDefinitionVersionRepository, IWorkflowInstanceRepository workflowInstanceRepository, IWorkflowInstanceStore workflowInstanceStore) { _workflowInvoker = workflowInvoker; _workflowDefinitionVersionRepository = workflowDefinitionVersionRepository; _workflowInstanceRepository = workflowInstanceRepository; _workflowInstanceStore = workflowInstanceStore; }
public UserBusiness( ILogger <UserBusiness> logger, IWorkflowInvoker workflowInvoker) { _logger = logger; _workflowInvoker = workflowInvoker; }
/// <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)); }
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)); }
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; }
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(); }
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); }
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; }
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); }
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); }
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); } }
protected override void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext) { workflowContext.ScheduleActivity(activity); }
/// <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); }
/// <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); }
/// <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()); }
public TriggerWorkflow(IWorkflowInvoker workflowInvoker, IWorkflowExpressionEvaluator expressionEvaluator) { this.workflowInvoker = workflowInvoker; this.expressionEvaluator = expressionEvaluator; }
protected override void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext) { var activity = workflowContext.CurrentActivity; workflowContext.Fault(errorMessage, activity); }
public TestController(ILogger <TestController> logger, IWorkflowInvoker invoker) { _logger = logger; this.invoker = invoker; }
protected virtual void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext) { }
protected override void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext) { workflowContext.SetLastResult(value); }
public ActivateB(IWorkflowInvoker invoker) { _invoker = invoker; }
protected override void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext) { // Noop. }
public virtual Task ExecuteAsync(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext, CancellationToken cancellationToken) { Execute(invoker, workflowContext); return(Task.CompletedTask); }
public WorkflowConsumer(IWorkflowInvoker workflowInvoker) { this.workflowInvoker = workflowInvoker; }