| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.Extensions; |
| | | 3 | | using Elsa.Workflows.Management; |
| | | 4 | | using JetBrains.Annotations; |
| | | 5 | | |
| | | 6 | | namespace Elsa.Workflows.Api.Endpoints.WorkflowInstances.ExecutionState; |
| | | 7 | | |
| | | 8 | | /// <summary> |
| | | 9 | | /// Returns the execution state of the specified workflow instance. |
| | | 10 | | /// </summary> |
| | | 11 | | [PublicAPI] |
| | 1 | 12 | | internal class ExecutionState(IWorkflowInstanceStore store) : ElsaEndpoint<Request, Response> |
| | | 13 | | { |
| | | 14 | | /// <inheritdoc /> |
| | | 15 | | public override void Configure() |
| | | 16 | | { |
| | 1 | 17 | | Get("/workflow-instances/{id}/execution-state"); |
| | 1 | 18 | | ConfigurePermissions("read:workflow-instances"); |
| | 1 | 19 | | } |
| | | 20 | | |
| | | 21 | | /// <inheritdoc /> |
| | | 22 | | public override async Task HandleAsync(Request request, CancellationToken cancellationToken) |
| | | 23 | | { |
| | 0 | 24 | | var workflowInstance = await store.FindAsync(request.WorkflowInstanceId, cancellationToken); |
| | | 25 | | |
| | 0 | 26 | | if (workflowInstance == null) |
| | | 27 | | { |
| | 0 | 28 | | await Send.NotFoundAsync(cancellationToken); |
| | 0 | 29 | | return; |
| | | 30 | | } |
| | | 31 | | |
| | 0 | 32 | | var response = new Response( |
| | 0 | 33 | | workflowInstance.Status, |
| | 0 | 34 | | workflowInstance.SubStatus, |
| | 0 | 35 | | workflowInstance.UpdatedAt); |
| | | 36 | | |
| | 0 | 37 | | await Send.OkAsync(response, cancellationToken); |
| | 0 | 38 | | } |
| | | 39 | | } |