| | | 1 | | using Elsa.Features.Attributes; |
| | | 2 | | using Elsa.Features.Services; |
| | | 3 | | using Elsa.KeyValues.Entities; |
| | | 4 | | using Elsa.KeyValues.Features; |
| | | 5 | | using Elsa.Workflows.Runtime; |
| | | 6 | | using Elsa.Workflows.Runtime.Entities; |
| | | 7 | | using Elsa.Workflows.Runtime.Features; |
| | | 8 | | using Microsoft.Extensions.DependencyInjection; |
| | | 9 | | |
| | | 10 | | namespace Elsa.Persistence.EFCore.Modules.Runtime; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Configures the default workflow runtime to use EF Core persistence providers. |
| | | 14 | | /// </summary> |
| | | 15 | | [DependsOn(typeof(WorkflowRuntimeFeature))] |
| | 3 | 16 | | public class EFCoreWorkflowRuntimePersistenceFeature(IModule module) : PersistenceFeatureBase<EFCoreWorkflowRuntimePersi |
| | | 17 | | { |
| | | 18 | | /// <summary> |
| | | 19 | | /// Gets or sets whether to wrap workflow commit persistence in an EF Core transaction. |
| | | 20 | | /// </summary> |
| | 6 | 21 | | public bool UseWorkflowCommitTransaction { get; set; } |
| | | 22 | | |
| | | 23 | | /// <inheritdoc /> |
| | | 24 | | public override void Configure() |
| | | 25 | | { |
| | 3 | 26 | | Module.Configure<KeyValueFeature>(feature => |
| | 3 | 27 | | { |
| | 3 | 28 | | feature.KeyValueStore = sp => sp.GetRequiredService<EFCoreKeyValueStore>(); |
| | 6 | 29 | | }); |
| | 3 | 30 | | Module.Configure<WorkflowRuntimeFeature>(feature => |
| | 3 | 31 | | { |
| | 431 | 32 | | feature.TriggerStore = sp => sp.GetRequiredService<EFCoreTriggerStore>(); |
| | 616 | 33 | | feature.BookmarkStore = sp => sp.GetRequiredService<EFCoreBookmarkStore>(); |
| | 610 | 34 | | feature.BookmarkQueueStore = sp => sp.GetRequiredService<EFBookmarkQueueStore>(); |
| | 231 | 35 | | feature.BookmarkQueueDeadLetterStore = sp => sp.GetRequiredService<EFBookmarkQueueDeadLetterStore>(); |
| | 406 | 36 | | feature.WorkflowExecutionLogStore = sp => sp.GetRequiredService<EFCoreWorkflowExecutionLogStore>(); |
| | 409 | 37 | | feature.ActivityExecutionLogStore = sp => sp.GetRequiredService<EFCoreActivityExecutionStore>(); |
| | 6 | 38 | | }); |
| | 3 | 39 | | } |
| | | 40 | | |
| | | 41 | | /// <inheritdoc /> |
| | | 42 | | public override void Apply() |
| | | 43 | | { |
| | 3 | 44 | | base.Apply(); |
| | 3 | 45 | | AddEntityStore<StoredTrigger, EFCoreTriggerStore>(); |
| | 3 | 46 | | AddStore<StoredBookmark, EFCoreBookmarkStore>(); |
| | 3 | 47 | | AddStore<BookmarkQueueItem, EFBookmarkQueueStore>(); |
| | 3 | 48 | | AddStore<BookmarkQueueDeadLetterItem, EFBookmarkQueueDeadLetterStore>(); |
| | 3 | 49 | | AddEntityStore<WorkflowExecutionLogRecord, EFCoreWorkflowExecutionLogStore>(); |
| | 3 | 50 | | AddEntityStore<ActivityExecutionRecord, EFCoreActivityExecutionStore>(); |
| | 3 | 51 | | AddStore<SerializedKeyValuePair, EFCoreKeyValueStore>(); |
| | | 52 | | |
| | 3 | 53 | | if (UseWorkflowCommitTransaction) |
| | 3 | 54 | | Services.AddScoped<IWorkflowCommitTransaction, EFCoreWorkflowCommitTransaction>(); |
| | 3 | 55 | | } |
| | | 56 | | } |