| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Common.Entities; |
| | | 3 | | using Elsa.Models; |
| | | 4 | | using Elsa.Workflows.Runtime; |
| | | 5 | | using Elsa.Workflows.Runtime.Entities; |
| | | 6 | | using Elsa.Workflows.Runtime.Filters; |
| | | 7 | | using Elsa.Workflows.Runtime.OrderDefinitions; |
| | | 8 | | using JetBrains.Annotations; |
| | | 9 | | |
| | | 10 | | namespace Elsa.Workflows.Api.Endpoints.ActivityExecutions.List; |
| | | 11 | | |
| | | 12 | | /// <summary> |
| | | 13 | | /// Lists the executions for a given activity. |
| | | 14 | | /// </summary> |
| | | 15 | | [PublicAPI] |
| | | 16 | | internal class List : ElsaEndpoint<Request, ListResponse<ActivityExecutionRecord>> |
| | | 17 | | { |
| | | 18 | | private readonly IActivityExecutionStore _store; |
| | | 19 | | |
| | | 20 | | /// <inheritdoc /> |
| | 1 | 21 | | public List(IActivityExecutionStore store) |
| | | 22 | | { |
| | 1 | 23 | | _store = store; |
| | 1 | 24 | | } |
| | | 25 | | |
| | | 26 | | /// <inheritdoc /> |
| | | 27 | | public override void Configure() |
| | | 28 | | { |
| | 1 | 29 | | Get("/activity-executions/list"); |
| | 1 | 30 | | ConfigurePermissions("read:activity-execution"); |
| | 1 | 31 | | } |
| | | 32 | | |
| | | 33 | | /// <inheritdoc /> |
| | | 34 | | public override async Task<ListResponse<ActivityExecutionRecord>> ExecuteAsync(Request request, CancellationToken ca |
| | | 35 | | { |
| | 0 | 36 | | var filter = new ActivityExecutionRecordFilter |
| | 0 | 37 | | { |
| | 0 | 38 | | WorkflowInstanceId = request.WorkflowInstanceId, |
| | 0 | 39 | | ActivityNodeId = request.ActivityNodeId, |
| | 0 | 40 | | Completed = request.Completed |
| | 0 | 41 | | }; |
| | 0 | 42 | | var order = new ActivityExecutionRecordOrder<DateTimeOffset>(x => x.StartedAt, OrderDirection.Ascending); |
| | 0 | 43 | | var records = (await _store.FindManyAsync(filter, order, cancellationToken)).ToList(); |
| | 0 | 44 | | return new ListResponse<ActivityExecutionRecord>(records); |
| | 0 | 45 | | } |
| | | 46 | | } |