From effa850909c9c2fd3fa3f0be64ec0bd07547b1df Mon Sep 17 00:00:00 2001 From: Sipke Schoorstra Date: Fri, 7 Jun 2024 18:04:31 +0200 Subject: [PATCH] Remove logging scope from OnChildCompletedAsync method The logging scope that was created within the OnChildCompletedAsync method in the Flowchart.cs file has been removed. Additionally, some trivial code formatting adjustments were made to increase readability and maintain consistency. No significant functionality changes were introduced. --- .../Flowchart/Activities/Flowchart.cs | 24 ++++++------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs b/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs index aa9b402de..514f245fa 100644 --- a/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs +++ b/src/modules/Elsa.Workflows.Core/Activities/Flowchart/Activities/Flowchart.cs @@ -139,15 +139,6 @@ public class Flowchart : Container private async ValueTask OnChildCompletedAsync(ActivityCompletedContext context) { var logger = context.GetRequiredService>(); - var loggerScopeState = new Dictionary - { - ["ThreadId"] = Environment.CurrentManagedThreadId, - ["TaskId"] = Task.CurrentId?.ToString() ?? "N/A", - ["ActivityId"] = Id, - ["ActivityInstanceId"] = context.TargetContext.Id - }; - using var loggerScope = logger.BeginScope(loggerScopeState); - var flowchartContext = context.TargetContext; var completedActivityContext = context.ChildContext; var completedActivity = completedActivityContext.Activity; @@ -180,7 +171,7 @@ public class Flowchart : Container { var existingActivity = scope.ContainsActivity(activity); scope.AddActivity(activity); - + var inboundActivities = Connections.LeftInboundActivities(activity).ToList(); // If the completed activity is not part of the left inbound path, always allow its children to be scheduled. @@ -196,15 +187,14 @@ public class Flowchart : Container var executionCount = scope.GetExecutionCount(activity); var haveInboundActivitiesExecuted = inboundActivities.All(x => scope.GetExecutionCount(x) > executionCount); - if (haveInboundActivitiesExecuted) - { + if (haveInboundActivitiesExecuted) await flowchartContext.ScheduleActivityAsync(activity, OnChildCompletedAsync); - } } else { // Select an existing activity execution context for this activity, if any. - var joinContext = flowchartContext.WorkflowExecutionContext.ActivityExecutionContexts.FirstOrDefault(x => x.ParentActivityExecutionContext == flowchartContext && x.Activity == activity); + var joinContext = flowchartContext.WorkflowExecutionContext.ActivityExecutionContexts.FirstOrDefault(x => + x.ParentActivityExecutionContext == flowchartContext && x.Activity == activity); var scheduleWorkOptions = new ScheduleWorkOptions { CompletionCallback = OnChildCompletedAsync, @@ -214,14 +204,14 @@ public class Flowchart : Container if (joinContext != null) logger.LogDebug("Next activity {ChildActivityId} is a join activity. Attaching to existing join context {JoinContext}", activity.Id, joinContext.Id); - else if(!existingActivity) + else if (!existingActivity) logger.LogDebug("Next activity {ChildActivityId} is a join activity. Creating new join context", activity.Id); else { - logger.LogDebug("Next activity {ChildActivityId} is a join activity. Join context was not found, but activity is already being created.", activity.Id); + logger.LogDebug("Next activity {ChildActivityId} is a join activity. Join context was not found, but activity is already being created", activity.Id); continue; } - + await flowchartContext.ScheduleActivityAsync(activity, scheduleWorkOptions); } }