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); } }