From 6db3cc99b54582edef40b84928ca0e459dbc6288 Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Sun, 17 Dec 2023 21:45:43 +0100 Subject: [PATCH] Update BulkDispatchWorkflows activity The BulkDispatchWorkflows.cs activity in Elsa.Workflows.Runtime module has been updated with some key changes: Added detailed description to the input element, introduced the dispatchedInstancesCount to accurately track the number of instances dispatched, and removed some unnecessary white spaces for improved readability. --- .../Activities/BulkDispatchWorkflows.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/modules/Elsa.Workflows.Runtime/Activities/BulkDispatchWorkflows.cs b/src/modules/Elsa.Workflows.Runtime/Activities/BulkDispatchWorkflows.cs index 36011ba89..0ff9cd7fd 100644 --- a/src/modules/Elsa.Workflows.Runtime/Activities/BulkDispatchWorkflows.cs +++ b/src/modules/Elsa.Workflows.Runtime/Activities/BulkDispatchWorkflows.cs @@ -68,7 +68,7 @@ public class BulkDispatchWorkflows : Activity /// /// The input to send to the workflows. /// - [Input(Description = "The input to send to the workflows.")] + [Input(Description = """Additional input to send to the workflows being dispatched. The "Item" key is reserved and should not be used.""")] public Input?> Input { get; set; } = default!; /// @@ -103,18 +103,20 @@ public class BulkDispatchWorkflows : Activity await foreach (var item in items) { batch.Add(item); - - if (batch.Count < batchSize) + + if (batch.Count < batchSize) continue; - + await ProcessBatch(context, batch); + dispatchedInstancesCount += batch.Count; batch.Clear(); } - + // Process the last batch if it has any items. if (batch.Count > 0) { await ProcessBatch(context, batch); + dispatchedInstancesCount += batch.Count; } context.SetProperty(DispatchedInstancesCountKey, dispatchedInstancesCount); @@ -140,12 +142,10 @@ public class BulkDispatchWorkflows : Activity // Otherwise, we can complete immediately. await context.CompleteActivityAsync(); } - + // Cancelling children - - } - + private async Task ProcessBatch(ActivityExecutionContext context, List items) { var tasks = items.Select(async item =>