| | | 1 | | using Elsa.Common.Features; |
| | | 2 | | using Elsa.Common.Multitenancy; |
| | | 3 | | using Elsa.Extensions; |
| | | 4 | | using Elsa.Features.Abstractions; |
| | | 5 | | using Elsa.Features.Attributes; |
| | | 6 | | using Elsa.Features.Services; |
| | | 7 | | using Elsa.Scheduling.Bookmarks; |
| | | 8 | | using Elsa.Scheduling.Handlers; |
| | | 9 | | using Elsa.Scheduling.HostedServices; |
| | | 10 | | using Elsa.Scheduling.Services; |
| | | 11 | | using Elsa.Scheduling.TriggerPayloadValidators; |
| | | 12 | | using Elsa.Workflows.Management.Features; |
| | | 13 | | using Microsoft.Extensions.DependencyInjection; |
| | | 14 | | |
| | | 15 | | namespace Elsa.Scheduling.Features; |
| | | 16 | | |
| | | 17 | | /// <summary> |
| | | 18 | | /// Provides scheduling features to the system. |
| | | 19 | | /// </summary> |
| | | 20 | | [DependsOn(typeof(SystemClockFeature))] |
| | | 21 | | public class SchedulingFeature : FeatureBase |
| | | 22 | | { |
| | | 23 | | /// <inheritdoc /> |
| | 167 | 24 | | public SchedulingFeature(IModule module) : base(module) |
| | | 25 | | { |
| | 167 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// Gets or sets the trigger scheduler. |
| | | 30 | | /// </summary> |
| | 787 | 31 | | public Func<IServiceProvider, IWorkflowScheduler> WorkflowScheduler { get; set; } = sp => sp.GetRequiredService<Defa |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// Gets or sets the CRON parser. |
| | | 35 | | /// </summary> |
| | 337 | 36 | | public Func<IServiceProvider, ICronParser> CronParser { get; set; } = sp => sp.GetRequiredService<CronosCronParser>( |
| | | 37 | | |
| | | 38 | | /// <inheritdoc /> |
| | | 39 | | public override void Apply() |
| | | 40 | | { |
| | 167 | 41 | | Services |
| | 167 | 42 | | .AddSingleton<UpdateTenantSchedules>() |
| | 1 | 43 | | .AddSingleton<ITenantActivatedEvent>(sp => sp.GetRequiredService<UpdateTenantSchedules>()) |
| | 1 | 44 | | .AddSingleton<ITenantDeletedEvent>(sp => sp.GetRequiredService<UpdateTenantSchedules>()) |
| | 167 | 45 | | .AddSingleton<IScheduler, LocalScheduler>() |
| | 167 | 46 | | .AddSingleton<CronosCronParser>() |
| | 167 | 47 | | .AddSingleton(CronParser) |
| | 167 | 48 | | .AddScoped<ITriggerScheduler, DefaultTriggerScheduler>() |
| | 167 | 49 | | .AddScoped<IBookmarkScheduler, DefaultBookmarkScheduler>() |
| | 167 | 50 | | .AddScoped<DefaultWorkflowScheduler>() |
| | 167 | 51 | | .AddScoped(WorkflowScheduler) |
| | 167 | 52 | | .AddBackgroundTask<CreateSchedulesBackgroundTask>() |
| | 167 | 53 | | .AddHandlersFrom<ScheduleWorkflows>() |
| | 167 | 54 | | |
| | 167 | 55 | | //Trigger payload validators. |
| | 167 | 56 | | .AddTriggerPayloadValidator<CronTriggerPayloadValidator, CronTriggerPayload>(); |
| | | 57 | | |
| | 334 | 58 | | Module.Configure<WorkflowManagementFeature>(management => management.AddActivitiesFrom<SchedulingFeature>()); |
| | 167 | 59 | | } |
| | | 60 | | } |