| | | 1 | | using System.Linq.Expressions; |
| | | 2 | | using Elsa.Common.Entities; |
| | | 3 | | |
| | | 4 | | namespace Elsa.Workflows.Runtime.Entities; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Represents a summarized view of a single activity execution of an activity instance. |
| | | 8 | | /// </summary> |
| | | 9 | | public class ActivityExecutionRecordSummary : Entity |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Gets or sets the workflow instance ID. |
| | | 13 | | /// </summary> |
| | 0 | 14 | | public string WorkflowInstanceId { get; set; } = null!; |
| | | 15 | | |
| | | 16 | | /// <summary> |
| | | 17 | | /// Gets or sets the activity ID. |
| | | 18 | | /// </summary> |
| | 0 | 19 | | public string ActivityId { get; set; } = null!; |
| | | 20 | | |
| | | 21 | | /// <summary> |
| | | 22 | | /// Gets or sets the activity node ID. |
| | | 23 | | /// </summary> |
| | 0 | 24 | | public string ActivityNodeId { get; set; } = null!; |
| | | 25 | | |
| | | 26 | | /// <summary> |
| | | 27 | | /// The type of the activity. |
| | | 28 | | /// </summary> |
| | 0 | 29 | | public string ActivityType { get; set; } = null!; |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// The version of the activity type. |
| | | 33 | | /// </summary> |
| | 0 | 34 | | public int ActivityTypeVersion { get; set; } |
| | | 35 | | |
| | | 36 | | /// <summary> |
| | | 37 | | /// The name of the activity. |
| | | 38 | | /// </summary> |
| | 0 | 39 | | public string? ActivityName { get; set; } |
| | | 40 | | |
| | | 41 | | /// <summary> |
| | | 42 | | /// Gets or sets the time at which the activity execution began. |
| | | 43 | | /// </summary> |
| | 0 | 44 | | public DateTimeOffset StartedAt { get; set; } |
| | | 45 | | |
| | | 46 | | /// <summary> |
| | | 47 | | /// Gets or sets whether the activity has any bookmarks. |
| | | 48 | | /// </summary> |
| | 0 | 49 | | public bool HasBookmarks { get; set; } |
| | | 50 | | |
| | | 51 | | /// <summary> |
| | | 52 | | /// Gets or sets the status of the activity. |
| | | 53 | | /// </summary> |
| | 0 | 54 | | public ActivityStatus Status { get; set; } |
| | | 55 | | |
| | | 56 | | /// <summary> |
| | | 57 | | /// Gets or sets a dictionary of key-value pairs representing additional metadata for the activity execution record |
| | | 58 | | /// </summary> |
| | 0 | 59 | | public IDictionary<string, object>? Metadata { get; set; } |
| | | 60 | | |
| | | 61 | | /// <summary> |
| | | 62 | | /// Gets or sets the aggregated count of faults encountered during the execution of the activity instance and its de |
| | | 63 | | /// </summary> |
| | 0 | 64 | | public int AggregateFaultCount { get; set; } |
| | | 65 | | |
| | | 66 | | /// <summary> |
| | | 67 | | /// Gets or sets the time at which the activity execution completed. |
| | | 68 | | /// </summary> |
| | 0 | 69 | | public DateTimeOffset? CompletedAt { get; set; } |
| | | 70 | | |
| | | 71 | | /// <summary> |
| | | 72 | | /// Returns a summary view of the specified <see cref="ActivityExecutionRecord"/>. |
| | | 73 | | /// </summary> |
| | | 74 | | public static ActivityExecutionRecordSummary FromRecord(ActivityExecutionRecord record) |
| | | 75 | | { |
| | 0 | 76 | | return new() |
| | 0 | 77 | | { |
| | 0 | 78 | | Id = record.Id, |
| | 0 | 79 | | WorkflowInstanceId = record.WorkflowInstanceId, |
| | 0 | 80 | | ActivityId = record.ActivityId, |
| | 0 | 81 | | ActivityNodeId = record.ActivityNodeId, |
| | 0 | 82 | | ActivityType = record.ActivityType, |
| | 0 | 83 | | ActivityTypeVersion = record.ActivityTypeVersion, |
| | 0 | 84 | | ActivityName = record.ActivityName, |
| | 0 | 85 | | StartedAt = record.StartedAt, |
| | 0 | 86 | | HasBookmarks = record.HasBookmarks, |
| | 0 | 87 | | Status = record.Status, |
| | 0 | 88 | | AggregateFaultCount = record.AggregateFaultCount, |
| | 0 | 89 | | Metadata = record.Metadata?.Count > 0 ? record.Metadata : null, |
| | 0 | 90 | | CompletedAt = record.CompletedAt, |
| | 0 | 91 | | }; |
| | | 92 | | } |
| | | 93 | | |
| | | 94 | | /// <summary> |
| | | 95 | | /// Returns a summary view of the specified <see cref="ActivityExecutionRecord"/>. |
| | | 96 | | /// </summary> |
| | | 97 | | public static Expression<Func<ActivityExecutionRecord, ActivityExecutionRecordSummary>> FromRecordExpression() |
| | | 98 | | { |
| | 0 | 99 | | return record => new() |
| | 0 | 100 | | { |
| | 0 | 101 | | Id = record.Id, |
| | 0 | 102 | | WorkflowInstanceId = record.WorkflowInstanceId, |
| | 0 | 103 | | ActivityId = record.ActivityId, |
| | 0 | 104 | | ActivityNodeId = record.ActivityNodeId, |
| | 0 | 105 | | ActivityType = record.ActivityType, |
| | 0 | 106 | | ActivityTypeVersion = record.ActivityTypeVersion, |
| | 0 | 107 | | ActivityName = record.ActivityName, |
| | 0 | 108 | | StartedAt = record.StartedAt, |
| | 0 | 109 | | HasBookmarks = record.HasBookmarks, |
| | 0 | 110 | | Status = record.Status, |
| | 0 | 111 | | AggregateFaultCount = record.AggregateFaultCount, |
| | 0 | 112 | | Metadata = record.Metadata, |
| | 0 | 113 | | CompletedAt = record.CompletedAt |
| | 0 | 114 | | }; |
| | | 115 | | } |
| | | 116 | | } |