| | | 1 | | using Elsa.Common; |
| | | 2 | | using Elsa.Workflows.Runtime; |
| | | 3 | | using Elsa.Workflows.Runtime.Filters; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Scheduling.HostedServices; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Creates new schedules when using the default scheduler (which doesn't have its own persistence layer like Quartz or |
| | | 10 | | /// </summary> |
| | | 11 | | [UsedImplicitly] |
| | 1 | 12 | | public class CreateSchedulesBackgroundTask(ITriggerStore triggerStore, IBookmarkStore bookmarkStore, ITriggerScheduler t |
| | | 13 | | { |
| | | 14 | | /// <inheritdoc /> |
| | | 15 | | public override async Task ExecuteAsync(CancellationToken stoppingToken) |
| | | 16 | | { |
| | 1 | 17 | | var stimulusNames = new[] |
| | 1 | 18 | | { |
| | 1 | 19 | | SchedulingStimulusNames.Cron, SchedulingStimulusNames.Timer, SchedulingStimulusNames.StartAt, SchedulingStim |
| | 1 | 20 | | }; |
| | 1 | 21 | | var triggerFilter = new TriggerFilter |
| | 1 | 22 | | { |
| | 1 | 23 | | Names = stimulusNames |
| | 1 | 24 | | }; |
| | 1 | 25 | | var bookmarkFilter = new BookmarkFilter |
| | 1 | 26 | | { |
| | 1 | 27 | | Names = stimulusNames |
| | 1 | 28 | | }; |
| | 1 | 29 | | var triggers = (await triggerStore.FindManyAsync(triggerFilter, stoppingToken)).ToList(); |
| | 1 | 30 | | var bookmarks = (await bookmarkStore.FindManyAsync(bookmarkFilter, stoppingToken)).ToList(); |
| | | 31 | | |
| | 1 | 32 | | await triggerScheduler.ScheduleAsync(triggers, stoppingToken); |
| | 1 | 33 | | await bookmarkScheduler.ScheduleAsync(bookmarks, stoppingToken); |
| | 1 | 34 | | } |
| | | 35 | | } |