| | | 1 | | using Elsa.Mediator.Contracts; |
| | | 2 | | using Elsa.Workflows.Runtime.Entities; |
| | | 3 | | using Elsa.Workflows.Runtime.Filters; |
| | | 4 | | using Elsa.Workflows.Runtime.Notifications; |
| | | 5 | | using Microsoft.Extensions.Logging; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Workflows.Runtime; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// Default implementation of <see cref="IBookmarkManager"/>. |
| | | 11 | | /// </summary> |
| | 471 | 12 | | public class DefaultBookmarkManager(IBookmarkStore bookmarkStore, INotificationSender notificationSender, ILogger<Defaul |
| | | 13 | | : IBookmarkManager |
| | | 14 | | { |
| | | 15 | | /// <inheritdoc /> |
| | | 16 | | public async Task<long> DeleteManyAsync(BookmarkFilter filter, CancellationToken cancellationToken = default) |
| | | 17 | | { |
| | 55 | 18 | | var bookmarks = (await bookmarkStore.FindManyAsync(filter, cancellationToken)).ToList(); |
| | 55 | 19 | | await notificationSender.SendAsync(new BookmarksDeleting(bookmarks), cancellationToken); |
| | 55 | 20 | | var count = await bookmarkStore.DeleteAsync(filter, cancellationToken); |
| | 55 | 21 | | await notificationSender.SendAsync(new BookmarksDeleted(bookmarks), cancellationToken); |
| | | 22 | | |
| | 55 | 23 | | if (logger.IsEnabled(LogLevel.Debug)) |
| | | 24 | | { |
| | 52 | 25 | | foreach (var bookmark in bookmarks) |
| | 15 | 26 | | logger.LogDebug("Deleted bookmark {BookmarkId} for workflow {WorkflowInstanceId}", bookmark.Id, bookmark |
| | | 27 | | } |
| | | 28 | | |
| | 55 | 29 | | return count; |
| | 55 | 30 | | } |
| | | 31 | | |
| | | 32 | | /// <inheritdoc /> |
| | | 33 | | public async Task SaveAsync(StoredBookmark bookmark, CancellationToken cancellationToken = default) |
| | | 34 | | { |
| | 0 | 35 | | await notificationSender.SendAsync(new BookmarkSaving(bookmark), cancellationToken); |
| | 0 | 36 | | await bookmarkStore.SaveAsync(bookmark, cancellationToken); |
| | 0 | 37 | | await notificationSender.SendAsync(new BookmarkSaved(bookmark), cancellationToken); |
| | 0 | 38 | | } |
| | | 39 | | } |