| | | 1 | | using Elsa.Workflows.Runtime.Entities; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Workflows.Runtime.Filters; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// A specification to use when finding activity execution log records. Only non-null fields will be included in the con |
| | | 7 | | /// </summary> |
| | | 8 | | public class ActivityExecutionRecordFilter |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// The ID of the activity execution record. |
| | | 12 | | /// </summary> |
| | 145 | 13 | | public string? Id { get; set; } |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// The IDs of the activity execution records. |
| | | 17 | | /// </summary> |
| | 58 | 18 | | public ICollection<string>? Ids { get; set; } |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// The ID of the workflow instance. |
| | | 22 | | /// </summary> |
| | 78 | 23 | | public string? WorkflowInstanceId { get; set; } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// The IDs of the workflow instances. |
| | | 27 | | /// </summary> |
| | 84 | 28 | | public ICollection<string>? WorkflowInstanceIds { get; set; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// The ID of the activity. |
| | | 32 | | /// </summary> |
| | 77 | 33 | | public string? ActivityId { get; set; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// The IDs of the activities. |
| | | 37 | | /// </summary> |
| | 58 | 38 | | public ICollection<string>? ActivityIds { get; set; } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// The node ID of the activity. |
| | | 42 | | /// </summary> |
| | 58 | 43 | | public string? ActivityNodeId { get; set; } |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// The node IDs of the activities. |
| | | 47 | | /// </summary> |
| | 58 | 48 | | public ICollection<string>? ActivityNodeIds { get; set; } |
| | | 49 | | |
| | | 50 | | /// <summary> |
| | | 51 | | /// The name of the activity. |
| | | 52 | | /// </summary> |
| | 60 | 53 | | public string? Name { get; set; } |
| | | 54 | | |
| | | 55 | | /// <summary> |
| | | 56 | | /// The names of the activities. |
| | | 57 | | /// </summary> |
| | 58 | 58 | | public ICollection<string>? Names { get; set; } |
| | | 59 | | |
| | | 60 | | /// <summary> |
| | | 61 | | /// The status of the activity. |
| | | 62 | | /// </summary> |
| | 58 | 63 | | public ActivityStatus? Status { get; set; } |
| | | 64 | | |
| | | 65 | | /// <summary> |
| | | 66 | | /// The statuses of the activities. |
| | | 67 | | /// </summary> |
| | 58 | 68 | | public ICollection<ActivityStatus>? Statuses { get; set; } |
| | | 69 | | |
| | | 70 | | /// <summary> |
| | | 71 | | /// Whether to include completed activity execution records. If not specified, all activity execution records will b |
| | | 72 | | /// </summary> |
| | 58 | 73 | | public bool? Completed { get; set; } |
| | | 74 | | |
| | | 75 | | /// <summary> |
| | | 76 | | /// The ID of the activity execution context that scheduled this activity execution. |
| | | 77 | | /// </summary> |
| | 58 | 78 | | public string? SchedulingActivityExecutionId { get; set; } |
| | | 79 | | |
| | | 80 | | /// <summary> |
| | | 81 | | /// The IDs of the activity execution contexts that scheduled activity executions. |
| | | 82 | | /// </summary> |
| | 58 | 83 | | public ICollection<string>? SchedulingActivityExecutionIds { get; set; } |
| | | 84 | | |
| | | 85 | | /// <summary> |
| | | 86 | | /// The ID of the activity that scheduled this activity execution (denormalized). |
| | | 87 | | /// </summary> |
| | 58 | 88 | | public string? SchedulingActivityId { get; set; } |
| | | 89 | | |
| | | 90 | | /// <summary> |
| | | 91 | | /// The IDs of the activities that scheduled activity executions (denormalized). |
| | | 92 | | /// </summary> |
| | 58 | 93 | | public ICollection<string>? SchedulingActivityIds { get; set; } |
| | | 94 | | |
| | | 95 | | /// <summary> |
| | | 96 | | /// The workflow instance ID of the workflow that scheduled this activity execution. |
| | | 97 | | /// Used for cross-workflow call stack tracking. |
| | | 98 | | /// </summary> |
| | 58 | 99 | | public string? SchedulingWorkflowInstanceId { get; set; } |
| | | 100 | | |
| | | 101 | | /// <summary> |
| | | 102 | | /// The workflow instance IDs of the workflows that scheduled activity executions. |
| | | 103 | | /// </summary> |
| | 58 | 104 | | public ICollection<string>? SchedulingWorkflowInstanceIds { get; set; } |
| | | 105 | | |
| | | 106 | | /// <summary> |
| | | 107 | | /// The call stack depth of the activity execution. |
| | | 108 | | /// </summary> |
| | 58 | 109 | | public int? CallStackDepth { get; set; } |
| | | 110 | | |
| | | 111 | | /// <summary> |
| | | 112 | | /// Returns true if the filter is empty. |
| | | 113 | | /// </summary> |
| | | 114 | | public bool IsEmpty => |
| | 0 | 115 | | Id == null |
| | 0 | 116 | | && Ids == null |
| | 0 | 117 | | && WorkflowInstanceId == null |
| | 0 | 118 | | && WorkflowInstanceIds == null |
| | 0 | 119 | | && ActivityId == null |
| | 0 | 120 | | && ActivityIds == null |
| | 0 | 121 | | && ActivityNodeId == null |
| | 0 | 122 | | && ActivityNodeIds == null |
| | 0 | 123 | | && Name == null |
| | 0 | 124 | | && Names == null |
| | 0 | 125 | | && Status == null |
| | 0 | 126 | | && Statuses == null |
| | 0 | 127 | | && Completed == null |
| | 0 | 128 | | && SchedulingActivityExecutionId == null |
| | 0 | 129 | | && SchedulingActivityExecutionIds == null |
| | 0 | 130 | | && SchedulingActivityId == null |
| | 0 | 131 | | && SchedulingActivityIds == null |
| | 0 | 132 | | && SchedulingWorkflowInstanceId == null |
| | 0 | 133 | | && SchedulingWorkflowInstanceIds == null |
| | 0 | 134 | | && CallStackDepth == null; |
| | | 135 | | |
| | | 136 | | /// <summary> |
| | | 137 | | /// Applies the filter to the specified queryable. |
| | | 138 | | /// </summary> |
| | | 139 | | public IQueryable<ActivityExecutionRecord> Apply(IQueryable<ActivityExecutionRecord> queryable) |
| | | 140 | | { |
| | 58 | 141 | | var filter = this; |
| | 86 | 142 | | if (filter.Id != null) queryable = queryable.Where(x => x.Id == filter.Id); |
| | 58 | 143 | | if (filter.Ids != null) queryable = queryable.Where(x => filter.Ids.Contains(x.Id)); |
| | 68 | 144 | | if (filter.WorkflowInstanceId != null) queryable = queryable.Where(x => x.WorkflowInstanceId == filter.WorkflowI |
| | 71 | 145 | | if (filter.WorkflowInstanceIds != null) queryable = queryable.Where(x => filter.WorkflowInstanceIds.Contains(x.W |
| | 64 | 146 | | if (filter.ActivityId != null) queryable = queryable.Where(x => x.ActivityId == filter.ActivityId); |
| | 58 | 147 | | if (filter.ActivityIds != null && filter.ActivityIds.Any()) queryable = queryable.Where(x => filter.ActivityIds. |
| | 58 | 148 | | if (filter.ActivityNodeId != null) queryable = queryable.Where(x => x.ActivityNodeId == filter.ActivityNodeId); |
| | 58 | 149 | | if (filter.ActivityNodeIds != null && filter.ActivityNodeIds.Any()) queryable = queryable.Where(x => filter.Acti |
| | 59 | 150 | | if (filter.Name != null) queryable = queryable.Where(x => x.ActivityName == filter.Name); |
| | 58 | 151 | | if (filter.Names != null && filter.Names.Any()) queryable = queryable.Where(x => filter.Names.Contains(x.Activit |
| | 58 | 152 | | if (filter.Status != null) queryable = queryable.Where(x => x.Status == filter.Status); |
| | 58 | 153 | | if (filter.Statuses != null && filter.Statuses.Any()) queryable = queryable.Where(x => filter.Statuses.Contains( |
| | 58 | 154 | | if (filter.Completed != null) queryable = filter.Completed == true ? queryable.Where(x => x.CompletedAt != null) |
| | 58 | 155 | | if (filter.SchedulingActivityExecutionId != null) queryable = queryable.Where(x => x.SchedulingActivityExecution |
| | 58 | 156 | | if (filter.SchedulingActivityExecutionIds != null && filter.SchedulingActivityExecutionIds.Any()) queryable = qu |
| | 58 | 157 | | if (filter.SchedulingActivityId != null) queryable = queryable.Where(x => x.SchedulingActivityId == filter.Sched |
| | 58 | 158 | | if (filter.SchedulingActivityIds != null && filter.SchedulingActivityIds.Any()) queryable = queryable.Where(x => |
| | 58 | 159 | | if (filter.SchedulingWorkflowInstanceId != null) queryable = queryable.Where(x => x.SchedulingWorkflowInstanceId |
| | 58 | 160 | | if (filter.SchedulingWorkflowInstanceIds != null && filter.SchedulingWorkflowInstanceIds.Any()) queryable = quer |
| | 58 | 161 | | if (filter.CallStackDepth != null) queryable = queryable.Where(x => x.CallStackDepth == filter.CallStackDepth); |
| | | 162 | | |
| | 58 | 163 | | return queryable; |
| | | 164 | | } |
| | | 165 | | } |