| | | 1 | | using Elsa.Alterations.Bookmarks; |
| | | 2 | | using Elsa.Alterations.Core.Notifications; |
| | | 3 | | using Elsa.Mediator.Contracts; |
| | | 4 | | using Elsa.Workflows; |
| | | 5 | | using Elsa.Workflows.Helpers; |
| | | 6 | | using Elsa.Workflows.Runtime; |
| | | 7 | | using JetBrains.Annotations; |
| | | 8 | | |
| | | 9 | | namespace Elsa.Alterations.Handlers; |
| | | 10 | | |
| | | 11 | | /// <summary> |
| | | 12 | | /// Handles <see cref="AlterationPlanCompleted"/> notifications and triggers any workflows that are waiting for the plan |
| | | 13 | | /// </summary> |
| | | 14 | | [UsedImplicitly] |
| | 320 | 15 | | public class AlterationPlanCompletedHandler(IBookmarkQueue bookmarkQueue, IStimulusHasher stimulusHasher) : INotificatio |
| | | 16 | | { |
| | | 17 | | /// <inheritdoc /> |
| | | 18 | | public async Task HandleAsync(AlterationPlanCompleted notification, CancellationToken cancellationToken) |
| | | 19 | | { |
| | | 20 | | // Trigger any workflow instances that are waiting for the plan to complete. |
| | 0 | 21 | | var planId = notification.Plan.Id; |
| | 0 | 22 | | var bookmarkPayload = new AlterationPlanCompletedPayload(planId); |
| | 0 | 23 | | var activityTypeName = ActivityTypeNameHelper.GenerateTypeName<Activities.AlterationPlanCompleted>(); |
| | 0 | 24 | | var item = new NewBookmarkQueueItem |
| | 0 | 25 | | { |
| | 0 | 26 | | ActivityTypeName = activityTypeName, |
| | 0 | 27 | | StimulusHash = stimulusHasher.Hash(activityTypeName, bookmarkPayload) |
| | 0 | 28 | | }; |
| | 0 | 29 | | await bookmarkQueue.EnqueueAsync(item, cancellationToken); |
| | 0 | 30 | | } |
| | | 31 | | } |