| | | 1 | | using System.Linq.Expressions; |
| | | 2 | | using Elsa.Workflows.Management.Entities; |
| | | 3 | | |
| | | 4 | | namespace Elsa.Workflows.Management.Models; |
| | | 5 | | |
| | | 6 | | /// <summary> |
| | | 7 | | /// Represents a summary view of a <see cref="WorkflowInstance"/>. |
| | | 8 | | /// </summary> |
| | | 9 | | public class WorkflowInstanceSummary |
| | | 10 | | { |
| | | 11 | | /// <summary> |
| | | 12 | | /// Returns a summary view of the specified <see cref="WorkflowInstance"/>. |
| | | 13 | | /// </summary> |
| | | 14 | | public static WorkflowInstanceSummary FromInstance(WorkflowInstance workflowInstance) |
| | | 15 | | { |
| | 0 | 16 | | return new() |
| | 0 | 17 | | { |
| | 0 | 18 | | Id = workflowInstance.Id, |
| | 0 | 19 | | TenantId = workflowInstance.TenantId, |
| | 0 | 20 | | DefinitionId = workflowInstance.DefinitionId, |
| | 0 | 21 | | DefinitionVersionId = workflowInstance.DefinitionVersionId, |
| | 0 | 22 | | Version = workflowInstance.Version, |
| | 0 | 23 | | Status = workflowInstance.Status, |
| | 0 | 24 | | SubStatus = workflowInstance.SubStatus, |
| | 0 | 25 | | CorrelationId = workflowInstance.CorrelationId, |
| | 0 | 26 | | Name = workflowInstance.Name, |
| | 0 | 27 | | IncidentCount = workflowInstance.IncidentCount, |
| | 0 | 28 | | CreatedAt = workflowInstance.CreatedAt, |
| | 0 | 29 | | UpdatedAt = workflowInstance.UpdatedAt, |
| | 0 | 30 | | FinishedAt = workflowInstance.FinishedAt |
| | 0 | 31 | | }; |
| | | 32 | | } |
| | | 33 | | |
| | | 34 | | /// <summary> |
| | | 35 | | /// Returns a summary view of the specified <see cref="WorkflowInstance"/>. |
| | | 36 | | /// </summary> |
| | 78 | 37 | | public static Expression<Func<WorkflowInstance, WorkflowInstanceSummary>> FromInstanceExpression() => workflowInstan |
| | 78 | 38 | | { |
| | 78 | 39 | | Id = workflowInstance.Id, |
| | 78 | 40 | | TenantId = workflowInstance.TenantId, |
| | 78 | 41 | | DefinitionId = workflowInstance.DefinitionId, |
| | 78 | 42 | | DefinitionVersionId = workflowInstance.DefinitionVersionId, |
| | 78 | 43 | | Version = workflowInstance.Version, |
| | 78 | 44 | | Status = workflowInstance.Status, |
| | 78 | 45 | | SubStatus = workflowInstance.SubStatus, |
| | 78 | 46 | | CorrelationId = workflowInstance.CorrelationId, |
| | 78 | 47 | | Name = workflowInstance.Name, |
| | 78 | 48 | | IncidentCount = workflowInstance.IncidentCount, |
| | 78 | 49 | | CreatedAt = workflowInstance.CreatedAt, |
| | 78 | 50 | | UpdatedAt = workflowInstance.UpdatedAt, |
| | 78 | 51 | | FinishedAt = workflowInstance.FinishedAt |
| | 78 | 52 | | }; |
| | | 53 | | |
| | | 54 | | |
| | | 55 | | /// <summary>The ID of the workflow instance.</summary> |
| | 6 | 56 | | public string Id { get; set; } = null!; |
| | | 57 | | |
| | | 58 | | /// <summary>The ID of the tenant that owns the workflow instance.</summary> |
| | 3 | 59 | | public string? TenantId { get; set; } |
| | | 60 | | |
| | | 61 | | /// <summary>The ID of the workflow definition.</summary> |
| | 3 | 62 | | public string DefinitionId { get; set; } = null!; |
| | | 63 | | |
| | | 64 | | /// <summary>The version ID of the workflow definition.</summary> |
| | 3 | 65 | | public string DefinitionVersionId { get; set; } = null!; |
| | | 66 | | |
| | | 67 | | /// <summary>The version of the workflow definition.</summary> |
| | 3 | 68 | | public int Version { get; set; } |
| | | 69 | | |
| | | 70 | | /// <summary>The status of the workflow instance.</summary> |
| | 3 | 71 | | public WorkflowStatus Status { get; set; } |
| | | 72 | | |
| | | 73 | | /// <summary>The sub-status of the workflow instance.</summary> |
| | 3 | 74 | | public WorkflowSubStatus SubStatus { get; set; } |
| | | 75 | | |
| | | 76 | | /// <summary>The ID of the workflow instance.</summary> |
| | 3 | 77 | | public string? CorrelationId { get; set; } |
| | | 78 | | |
| | | 79 | | /// <summary>The name of the workflow instance.</summary> |
| | 3 | 80 | | public string? Name { get; set; } |
| | | 81 | | |
| | | 82 | | /// <summary>The number of incidents associated with the workflow instance.</summary> |
| | 3 | 83 | | public int IncidentCount { get; set; } |
| | | 84 | | |
| | | 85 | | /// <summary>The timestamp when the workflow instance was created.</summary> |
| | 3 | 86 | | public DateTimeOffset CreatedAt { get; set; } |
| | | 87 | | |
| | | 88 | | /// <summary>The timestamp when the workflow instance was last executed.</summary> |
| | 3 | 89 | | public DateTimeOffset? UpdatedAt { get; set; } |
| | | 90 | | |
| | | 91 | | /// <summary>The timestamp when the workflow instance was finished.</summary> |
| | 3 | 92 | | public DateTimeOffset? FinishedAt { get; set; } |
| | | 93 | | } |