| | | 1 | | using Elsa.Workflows.Runtime.Entities; |
| | | 2 | | |
| | | 3 | | namespace Elsa.Workflows.Runtime.Filters; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// A filter that can be used to find messages in the workflow inbox. |
| | | 7 | | /// </summary> |
| | | 8 | | public class WorkflowInboxMessageFilter |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// The activity type name to filter by. |
| | | 12 | | /// </summary> |
| | 0 | 13 | | public string? ActivityTypeName { get; set; } |
| | | 14 | | |
| | | 15 | | /// <summary> |
| | | 16 | | /// The hash of the bookmark payload to filter by. |
| | | 17 | | /// </summary> |
| | 0 | 18 | | public string? Hash { get; set; } |
| | | 19 | | |
| | | 20 | | /// <summary> |
| | | 21 | | /// The ID of the workflow instance to filter by. |
| | | 22 | | /// </summary> |
| | 0 | 23 | | public string? WorkflowInstanceId { get; set; } |
| | | 24 | | |
| | | 25 | | /// <summary> |
| | | 26 | | /// The correlation ID of the workflow instance to filter by. |
| | | 27 | | /// </summary> |
| | 0 | 28 | | public string? CorrelationId { get; set; } |
| | | 29 | | |
| | | 30 | | /// <summary> |
| | | 31 | | /// The ID of the activity instance to filter by. |
| | | 32 | | /// </summary> |
| | 0 | 33 | | public string? ActivityInstanceId { get; set; } |
| | | 34 | | |
| | | 35 | | /// <summary> |
| | | 36 | | /// A flag indicating whether to filter by messages that have expired. |
| | | 37 | | /// </summary> |
| | 0 | 38 | | public bool? IsExpired { get; set; } |
| | | 39 | | |
| | | 40 | | /// <summary> |
| | | 41 | | /// Applies the filter to the specified query. |
| | | 42 | | /// </summary> |
| | | 43 | | /// <returns>The filtered query.</returns> |
| | | 44 | | public IQueryable<WorkflowInboxMessage> Apply(IQueryable<WorkflowInboxMessage> query, DateTimeOffset now) |
| | | 45 | | { |
| | 0 | 46 | | var filter = this; |
| | 0 | 47 | | if (filter.CorrelationId != null) query = query.Where(x => filter.CorrelationId == x.CorrelationId); |
| | 0 | 48 | | if (filter.WorkflowInstanceId != null) query = query.Where(x => filter.WorkflowInstanceId == x.WorkflowInstanceI |
| | 0 | 49 | | if (filter.Hash != null) query = query.Where(x => filter.Hash == x.Hash); |
| | 0 | 50 | | if (filter.ActivityTypeName != null) query = query.Where(x => filter.ActivityTypeName == x.ActivityTypeName); |
| | 0 | 51 | | if (filter.ActivityInstanceId != null) query = query.Where(x => filter.ActivityInstanceId == x.ActivityInstanceI |
| | 0 | 52 | | if (filter.IsExpired != null) query = query.Where(x => x.ExpiresAt <= now); |
| | | 53 | | |
| | 0 | 54 | | return query; |
| | | 55 | | } |
| | | 56 | | } |