| | | 1 | | using Elsa.Workflows.Helpers; |
| | | 2 | | using Elsa.Workflows.Runtime.Activities; |
| | | 3 | | using Elsa.Workflows.Runtime.Options; |
| | | 4 | | using Elsa.Workflows.Runtime.Stimuli; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Workflows.Runtime; |
| | | 7 | | |
| | | 8 | | /// <inheritdoc /> |
| | 1 | 9 | | public class TaskReporter(IBookmarkQueue bookmarkQueue, IStimulusHasher stimulusHasher) : ITaskReporter |
| | | 10 | | { |
| | 0 | 11 | | private static readonly string ActivityTypeName = ActivityTypeNameHelper.GenerateTypeName<RunTask>(); |
| | | 12 | | |
| | | 13 | | /// <inheritdoc /> |
| | | 14 | | public async Task ReportCompletionAsync(string taskId, object? result = null, CancellationToken cancellationToken = |
| | | 15 | | { |
| | 0 | 16 | | var stimulus = new RunTaskStimulus(taskId, null!); |
| | | 17 | | |
| | 0 | 18 | | var input = new Dictionary<string, object> |
| | 0 | 19 | | { |
| | 0 | 20 | | [RunTask.InputKey] = result! |
| | 0 | 21 | | }; |
| | | 22 | | |
| | 0 | 23 | | var bookmarkQueueItem = new NewBookmarkQueueItem |
| | 0 | 24 | | { |
| | 0 | 25 | | ActivityTypeName = ActivityTypeName, |
| | 0 | 26 | | StimulusHash = stimulusHasher.Hash(ActivityTypeName, stimulus), |
| | 0 | 27 | | Options = new() |
| | 0 | 28 | | { |
| | 0 | 29 | | Input = input |
| | 0 | 30 | | } |
| | 0 | 31 | | }; |
| | | 32 | | |
| | 0 | 33 | | await bookmarkQueue.EnqueueAsync(bookmarkQueueItem, cancellationToken); |
| | 0 | 34 | | } |
| | | 35 | | } |