| | | 1 | | using Elsa.Alterations.Core.Contracts; |
| | | 2 | | using Elsa.Alterations.Core.Results; |
| | | 3 | | using Elsa.Workflows.Runtime; |
| | | 4 | | using Elsa.Workflows.Runtime.Contracts; |
| | | 5 | | using Elsa.Workflows.Runtime.Requests; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Alterations.Core.Services; |
| | | 8 | | |
| | | 9 | | /// <inheritdoc /> |
| | | 10 | | public class AlteredWorkflowDispatcher : IAlteredWorkflowDispatcher |
| | | 11 | | { |
| | | 12 | | private readonly IWorkflowDispatcher _workflowDispatcher; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Initializes a new instance of the <see cref="AlteredWorkflowDispatcher"/> class. |
| | | 16 | | /// </summary> |
| | 1 | 17 | | public AlteredWorkflowDispatcher(IWorkflowDispatcher workflowDispatcher) |
| | | 18 | | { |
| | 1 | 19 | | _workflowDispatcher = workflowDispatcher; |
| | 1 | 20 | | } |
| | | 21 | | |
| | | 22 | | /// <inheritdoc /> |
| | | 23 | | public async Task DispatchAsync(IEnumerable<RunAlterationsResult> results, CancellationToken cancellationToken = def |
| | | 24 | | { |
| | 0 | 25 | | foreach (var result in results.Where(x => x is { IsSuccessful: true, WorkflowHasScheduledWork: true })) |
| | 0 | 26 | | await DispatchAsync(result, cancellationToken); |
| | 0 | 27 | | } |
| | | 28 | | |
| | | 29 | | /// <inheritdoc /> |
| | | 30 | | public async Task DispatchAsync(RunAlterationsResult result, CancellationToken cancellationToken = default) |
| | | 31 | | { |
| | 0 | 32 | | await _workflowDispatcher.DispatchAsync(new DispatchWorkflowInstanceRequest(result.WorkflowInstanceId), cancella |
| | 0 | 33 | | } |
| | | 34 | | } |