| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Common.Entities; |
| | | 3 | | using Elsa.Common.Models; |
| | | 4 | | using Elsa.Workflows.Api.Endpoints.BookmarkQueueDeadLetters; |
| | | 5 | | using Elsa.Workflows.Runtime; |
| | | 6 | | using Elsa.Workflows.Runtime.Filters; |
| | | 7 | | using Elsa.Workflows.Runtime.OrderDefinitions; |
| | | 8 | | using JetBrains.Annotations; |
| | | 9 | | |
| | | 10 | | namespace Elsa.Workflows.Api.Endpoints.BookmarkQueueDeadLetters.List; |
| | | 11 | | |
| | | 12 | | [UsedImplicitly] |
| | 3 | 13 | | internal class Endpoint(IBookmarkQueueDeadLetterStore store) : ElsaEndpoint<ListRequest, ListResponse> |
| | | 14 | | { |
| | | 15 | | public override void Configure() |
| | | 16 | | { |
| | 3 | 17 | | Verbs(FastEndpoints.Http.GET, FastEndpoints.Http.POST); |
| | 3 | 18 | | Routes("/bookmark-queue/dead-letters"); |
| | 3 | 19 | | ConfigurePermissions(PermissionNames.ReadBookmarkQueueDeadLetters); |
| | 3 | 20 | | } |
| | | 21 | | |
| | | 22 | | public override async Task HandleAsync(ListRequest request, CancellationToken cancellationToken) |
| | | 23 | | { |
| | 0 | 24 | | var pageArgs = PageArgs.FromPage(request.Page ?? 0, request.PageSize ?? 50); |
| | 0 | 25 | | var filter = new BookmarkQueueDeadLetterFilter |
| | 0 | 26 | | { |
| | 0 | 27 | | WorkflowInstanceId = request.WorkflowInstanceId |
| | 0 | 28 | | }; |
| | 0 | 29 | | var order = new BookmarkQueueDeadLetterItemOrder<DateTimeOffset>(x => x.DeadLetteredAt, OrderDirection.Descendin |
| | 0 | 30 | | var page = await store.PageAsync(pageArgs, filter, order, cancellationToken); |
| | 0 | 31 | | var response = new ListResponse(page.Items.Select(BookmarkQueueDeadLetterModel.FromEntity).ToList(), page.TotalC |
| | | 32 | | |
| | 0 | 33 | | await Send.OkAsync(response, cancellationToken); |
| | 0 | 34 | | } |
| | | 35 | | } |