Merge remote-tracking branch 'origin/patch/3.2.x' into blueberry
This commit is contained in:
commit
d2d4b6ee4a
|
|
@ -27,4 +27,22 @@ public interface IActivityExecutionsApi
|
|||
/// <returns>The response containing a list of activity executions.</returns>
|
||||
[Get("/activity-executions/list")]
|
||||
Task<ListResponse<ActivityExecutionRecord>> ListAsync(ListActivityExecutionsRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Lists activity execution summaries for a given activity in a workflow instance.
|
||||
/// </summary>
|
||||
/// <param name="request">The request.</param>
|
||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||
/// <returns>The response containing a list of activity execution summaries.</returns>
|
||||
[Get("/activity-execution-summaries/list")]
|
||||
Task<ListResponse<ActivityExecutionRecordSummary>> ListSummariesAsync(ListActivityExecutionsRequest request, CancellationToken cancellationToken = default);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a single activity execution by ID.
|
||||
/// </summary>
|
||||
/// <param name="id">The ID of the activity execution.</param>
|
||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||
/// <returns>The activity execution.</returns>
|
||||
[Get("/activity-executions/{id}")]
|
||||
Task<ActivityExecutionRecord?> GetAsync(string id, CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
|
@ -0,0 +1,82 @@
|
|||
using System.Linq.Expressions;
|
||||
using Elsa.Api.Client.Resources.WorkflowInstances.Models;
|
||||
using Elsa.Api.Client.Shared.Models;
|
||||
|
||||
namespace Elsa.Api.Client.Resources.ActivityExecutions.Models;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a summarized view of a single activity execution of an activity instance.
|
||||
/// </summary>
|
||||
public class ActivityExecutionRecordSummary : Entity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the workflow instance ID.
|
||||
/// </summary>
|
||||
public string WorkflowInstanceId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the activity ID.
|
||||
/// </summary>
|
||||
public string ActivityId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the activity node ID.
|
||||
/// </summary>
|
||||
public string ActivityNodeId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The type of the activity.
|
||||
/// </summary>
|
||||
public string ActivityType { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The version of the activity type.
|
||||
/// </summary>
|
||||
public int ActivityTypeVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The name of the activity.
|
||||
/// </summary>
|
||||
public string? ActivityName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time at which the activity execution began.
|
||||
/// </summary>
|
||||
public DateTimeOffset StartedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the activity has any bookmarks.
|
||||
/// </summary>
|
||||
public bool HasBookmarks { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the status of the activity.
|
||||
/// </summary>
|
||||
public ActivityStatus Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the time at which the activity execution completed.
|
||||
/// </summary>
|
||||
public DateTimeOffset? CompletedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a summary view of the specified <see cref="ActivityExecutionRecord"/>.
|
||||
/// </summary>
|
||||
public static ActivityExecutionRecordSummary FromRecord(ActivityExecutionRecord record)
|
||||
{
|
||||
return new ActivityExecutionRecordSummary
|
||||
{
|
||||
Id = record.Id,
|
||||
WorkflowInstanceId = record.WorkflowInstanceId,
|
||||
ActivityId = record.ActivityId,
|
||||
ActivityNodeId = record.ActivityNodeId,
|
||||
ActivityType = record.ActivityType,
|
||||
ActivityTypeVersion = record.ActivityTypeVersion,
|
||||
ActivityName = record.ActivityName,
|
||||
StartedAt = record.StartedAt,
|
||||
HasBookmarks = record.HasBookmarks,
|
||||
Status = record.Status,
|
||||
CompletedAt = record.CompletedAt
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
using Elsa.Abstractions;
|
||||
using Elsa.Common.Entities;
|
||||
using Elsa.Models;
|
||||
using Elsa.Workflows.Runtime.Contracts;
|
||||
using Elsa.Workflows.Runtime.Entities;
|
||||
using Elsa.Workflows.Runtime.Filters;
|
||||
using Elsa.Workflows.Runtime.OrderDefinitions;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Workflows.Api.Endpoints.ActivityExecutionSummaries.ListSummaries;
|
||||
|
||||
/// <summary>
|
||||
/// Lists a summary view of the executions for a given activity.
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
internal class Endpoint(IActivityExecutionStore store) : ElsaEndpoint<Request, ListResponse<ActivityExecutionRecordSummary>>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/activity-execution-summaries/list");
|
||||
ConfigurePermissions("read:activity-execution");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task<ListResponse<ActivityExecutionRecordSummary>> ExecuteAsync(Request request, CancellationToken cancellationToken)
|
||||
{
|
||||
var filter = new ActivityExecutionRecordFilter
|
||||
{
|
||||
WorkflowInstanceId = request.WorkflowInstanceId,
|
||||
ActivityNodeId = request.ActivityNodeId,
|
||||
Completed = request.Completed
|
||||
};
|
||||
var order = new ActivityExecutionRecordOrder<DateTimeOffset>(x => x.StartedAt, OrderDirection.Ascending);
|
||||
var records = (await store.FindManySummariesAsync(filter, order, cancellationToken)).ToList();
|
||||
return new ListResponse<ActivityExecutionRecordSummary>(records);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
namespace Elsa.Workflows.Api.Endpoints.ActivityExecutionSummaries.ListSummaries;
|
||||
|
||||
/// <summary>
|
||||
/// A request for a list of activity execution log record summaries for a given activity in a workflow instance.
|
||||
/// </summary>
|
||||
internal class Request
|
||||
{
|
||||
/// <summary>
|
||||
/// The ID of the workflow instance to get the execution log for.
|
||||
/// </summary>
|
||||
public string WorkflowInstanceId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// The node ID of the activity to get the execution record for.
|
||||
/// </summary>
|
||||
public string ActivityNodeId { get; set; } = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to include completed activity execution records. If not specified, all activity execution records will be included.
|
||||
/// </summary>
|
||||
public bool? Completed { get; set; }
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
using Elsa.Abstractions;
|
||||
using Elsa.Workflows.Runtime.Contracts;
|
||||
using Elsa.Workflows.Runtime.Entities;
|
||||
using Elsa.Workflows.Runtime.Filters;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace Elsa.Workflows.Api.Endpoints.ActivityExecutions.Get;
|
||||
|
||||
/// <summary>
|
||||
/// Gets an individual execution for a given activity.
|
||||
/// </summary>
|
||||
[PublicAPI]
|
||||
internal class Endpoint(IActivityExecutionStore store) : ElsaEndpointWithoutRequest<ActivityExecutionRecord>
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/activity-executions/{id}");
|
||||
ConfigurePermissions("read:activity-execution");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override async Task HandleAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
var id = Route<string>("id");
|
||||
var filter = new ActivityExecutionRecordFilter
|
||||
{
|
||||
Id = id
|
||||
};
|
||||
|
||||
var record = await store.FindAsync(filter, cancellationToken);
|
||||
|
||||
if (record == null)
|
||||
{
|
||||
await SendNotFoundAsync(cancellationToken);
|
||||
return;
|
||||
}
|
||||
|
||||
await SendOkAsync(record, cancellationToken);
|
||||
}
|
||||
}
|
||||
|
|
@ -42,7 +42,7 @@ public class ActivityExecutionRecordSummary : Entity
|
|||
/// <summary>
|
||||
/// Gets or sets the time at which the activity execution began.
|
||||
/// </summary>
|
||||
public DateTimeOffset StartedAt { get; set; } = default!;
|
||||
public DateTimeOffset StartedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets whether the activity has any bookmarks.
|
||||
|
|
@ -60,7 +60,7 @@ public class ActivityExecutionRecordSummary : Entity
|
|||
public DateTimeOffset? CompletedAt { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Returns a summary view of the specified <see cref="WorkflowInstance"/>.
|
||||
/// Returns a summary view of the specified <see cref="ActivityExecutionRecord"/>.
|
||||
/// </summary>
|
||||
public static ActivityExecutionRecordSummary FromRecord(ActivityExecutionRecord record)
|
||||
{
|
||||
|
|
@ -81,7 +81,7 @@ public class ActivityExecutionRecordSummary : Entity
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a summary view of the specified <see cref="WorkflowInstance"/>.
|
||||
/// Returns a summary view of the specified <see cref="ActivityExecutionRecord"/>.
|
||||
/// </summary>
|
||||
public static Expression<Func<ActivityExecutionRecord, ActivityExecutionRecordSummary>> FromRecordExpression()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue