| | | 1 | | using Elsa.Common; |
| | | 2 | | using Elsa.Workflows.Runtime.Entities; |
| | | 3 | | using Microsoft.Extensions.Logging; |
| | | 4 | | |
| | | 5 | | namespace Elsa.Workflows.Runtime; |
| | | 6 | | |
| | 468 | 7 | | public class StoreBookmarkQueue( |
| | 468 | 8 | | IBookmarkQueueStore store, |
| | 468 | 9 | | IBookmarkQueueSignaler bookmarkQueueSignaler, |
| | 468 | 10 | | ISystemClock systemClock, |
| | 468 | 11 | | IIdentityGenerator identityGenerator, |
| | 468 | 12 | | ILogger<StoreBookmarkQueue> logger) : IBookmarkQueue |
| | | 13 | | { |
| | | 14 | | public async Task EnqueueAsync(NewBookmarkQueueItem item, CancellationToken cancellationToken = default) |
| | | 15 | | { |
| | 64 | 16 | | var entity = new BookmarkQueueItem |
| | 64 | 17 | | { |
| | 64 | 18 | | Id = identityGenerator.GenerateId(), |
| | 64 | 19 | | WorkflowInstanceId = item.WorkflowInstanceId, |
| | 64 | 20 | | BookmarkId = item.BookmarkId, |
| | 64 | 21 | | CorrelationId = item.CorrelationId, |
| | 64 | 22 | | StimulusHash = item.StimulusHash, |
| | 64 | 23 | | ActivityInstanceId = item.ActivityInstanceId, |
| | 64 | 24 | | ActivityTypeName = item.ActivityTypeName, |
| | 64 | 25 | | Options = item.Options, |
| | 64 | 26 | | CreatedAt = systemClock.UtcNow, |
| | 64 | 27 | | }; |
| | | 28 | | |
| | 64 | 29 | | logger.LogDebug("Enqueuing bookmark queue item {BookmarkQueueItemId} with bookmark {BookmarkId} and stimulus {St |
| | | 30 | | |
| | 64 | 31 | | await store.AddAsync(entity, cancellationToken); |
| | | 32 | | |
| | | 33 | | // Trigger the bookmark queue processor. |
| | 64 | 34 | | await bookmarkQueueSignaler.TriggerAsync(cancellationToken); |
| | 64 | 35 | | } |
| | | 36 | | } |