| | | 1 | | using Elsa.Mediator.Contracts; |
| | | 2 | | using Elsa.Workflows.Runtime.Entities; |
| | | 3 | | using Elsa.Workflows.Runtime.Filters; |
| | | 4 | | using Elsa.Workflows.Runtime.Notifications; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Workflows.Runtime; |
| | | 7 | | |
| | | 8 | | /// <inheritdoc /> |
| | | 9 | | public class DefaultActivityExecutionManager : IActivityExecutionManager |
| | | 10 | | { |
| | | 11 | | private readonly IActivityExecutionStore _store; |
| | | 12 | | private readonly INotificationSender _notificationSender; |
| | | 13 | | |
| | | 14 | | /// <summary> |
| | | 15 | | /// Initializes a new instance of the <see cref="DefaultActivityExecutionManager"/> class. |
| | | 16 | | /// </summary> |
| | 0 | 17 | | public DefaultActivityExecutionManager(IActivityExecutionStore store, INotificationSender notificationSender) |
| | | 18 | | { |
| | 0 | 19 | | _store = store; |
| | 0 | 20 | | _notificationSender = notificationSender; |
| | 0 | 21 | | } |
| | | 22 | | |
| | | 23 | | /// <inheritdoc /> |
| | | 24 | | public async Task<long> DeleteManyAsync(ActivityExecutionRecordFilter filter, CancellationToken cancellationToken = |
| | | 25 | | { |
| | 0 | 26 | | var records = (await _store.FindManyAsync(filter, cancellationToken)).ToList(); |
| | | 27 | | |
| | 0 | 28 | | foreach (var record in records) |
| | | 29 | | { |
| | 0 | 30 | | await _store.DeleteManyAsync(filter, cancellationToken); |
| | 0 | 31 | | await _notificationSender.SendAsync(new ActivityExecutionRecordDeleted(record), cancellationToken); |
| | 0 | 32 | | } |
| | | 33 | | |
| | 0 | 34 | | return records.Count; |
| | 0 | 35 | | } |
| | | 36 | | |
| | | 37 | | /// <inheritdoc /> |
| | | 38 | | public async Task SaveAsync(ActivityExecutionRecord record, CancellationToken cancellationToken = default) |
| | | 39 | | { |
| | 0 | 40 | | await _store.SaveAsync(record, cancellationToken); |
| | 0 | 41 | | await _notificationSender.SendAsync(new ActivityExecutionRecordUpdated(record), cancellationToken); |
| | 0 | 42 | | } |
| | | 43 | | } |