| | | 1 | | using Elsa.Mediator.Contracts; |
| | | 2 | | using Elsa.Workflows.Management.Notifications; |
| | | 3 | | using Elsa.Workflows.Runtime; |
| | | 4 | | using Elsa.Workflows.Runtime.Filters; |
| | | 5 | | using Elsa.Workflows.Runtime.Notifications; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Scheduling.Handlers; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Deletes scheduled jobs based on deleted workflow triggers and bookmarks. |
| | | 11 | | /// </summary> |
| | 453 | 12 | | public class DeleteSchedules(ITriggerScheduler triggerScheduler, IBookmarkScheduler bookmarkScheduler, ITriggerStore tri |
| | | 13 | | : |
| | | 14 | | INotificationHandler<WorkflowDefinitionDeleting>, |
| | | 15 | | INotificationHandler<WorkflowDefinitionsDeleting>, |
| | | 16 | | INotificationHandler<WorkflowDefinitionVersionDeleting>, |
| | | 17 | | INotificationHandler<WorkflowDefinitionVersionsDeleting>, |
| | | 18 | | INotificationHandler<BookmarksDeleting> |
| | | 19 | | { |
| | | 20 | | async Task INotificationHandler<BookmarksDeleting>.HandleAsync(BookmarksDeleting notification, CancellationToken can |
| | | 21 | | { |
| | 99 | 22 | | var ids = notification.Bookmarks.Select(x => x.Id).ToList(); |
| | 52 | 23 | | var bookmarks = await bookmarkStore.FindManyAsync(new BookmarkFilter { BookmarkIds = ids }, cancellationToken); |
| | 52 | 24 | | await bookmarkScheduler.UnscheduleAsync(bookmarks, cancellationToken); |
| | 52 | 25 | | } |
| | | 26 | | |
| | 4 | 27 | | async Task INotificationHandler<WorkflowDefinitionDeleting>.HandleAsync(WorkflowDefinitionDeleting notification, Can |
| | 0 | 28 | | async Task INotificationHandler<WorkflowDefinitionsDeleting>.HandleAsync(WorkflowDefinitionsDeleting notification, C |
| | | 29 | | |
| | | 30 | | async Task INotificationHandler<WorkflowDefinitionVersionDeleting>.HandleAsync(WorkflowDefinitionVersionDeleting not |
| | 0 | 31 | | await RemoveSchedulesAsync(new TriggerFilter { WorkflowDefinitionVersionId = notification.WorkflowDefinition.Id |
| | | 32 | | |
| | 0 | 33 | | async Task INotificationHandler<WorkflowDefinitionVersionsDeleting>.HandleAsync(WorkflowDefinitionVersionsDeleting n |
| | | 34 | | |
| | | 35 | | private async Task RemoveSchedulesAsync(TriggerFilter filter, CancellationToken cancellationToken) |
| | | 36 | | { |
| | 4 | 37 | | var triggers = await triggerStore.FindManyAsync(filter, cancellationToken); |
| | 4 | 38 | | await triggerScheduler.UnscheduleAsync(triggers, cancellationToken); |
| | 4 | 39 | | } |
| | | 40 | | } |