| | | 1 | | using System.Runtime.CompilerServices; |
| | | 2 | | using Elsa.Common.Models; |
| | | 3 | | using Elsa.Workflows.Management; |
| | | 4 | | using Elsa.Workflows.Management.Filters; |
| | | 5 | | using Elsa.Workflows.Management.Models; |
| | | 6 | | |
| | | 7 | | namespace Elsa.Workflows.Runtime; |
| | | 8 | | |
| | | 9 | | public static class WorkflowInstanceStoreExtensions |
| | | 10 | | { |
| | | 11 | | public static async IAsyncEnumerable<WorkflowInstanceSummary> EnumerateSummariesAsync( |
| | | 12 | | this IWorkflowInstanceStore store, |
| | | 13 | | WorkflowInstanceFilter filter, |
| | | 14 | | int batchSize = 100, |
| | | 15 | | [EnumeratorCancellation] CancellationToken cancellationToken = default) |
| | | 16 | | { |
| | 2 | 17 | | var pageArgs = PageArgs.FromPage(0, batchSize); |
| | | 18 | | |
| | 2 | 19 | | while (!cancellationToken.IsCancellationRequested) |
| | | 20 | | { |
| | 2 | 21 | | var page = await store.SummarizeManyAsync(filter, pageArgs, cancellationToken); |
| | 2 | 22 | | var workflowInstances = page.Items; |
| | | 23 | | |
| | 2 | 24 | | if (workflowInstances.Count == 0) |
| | 2 | 25 | | yield break; |
| | | 26 | | |
| | 0 | 27 | | foreach (var workflowInstance in workflowInstances) |
| | 0 | 28 | | yield return workflowInstance; |
| | | 29 | | |
| | 0 | 30 | | pageArgs = pageArgs.Next(); |
| | | 31 | | } |
| | 2 | 32 | | } |
| | | 33 | | } |