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.
This commit is contained in:
parent
bcc6071644
commit
effa850909
|
|
@ -139,15 +139,6 @@ public class Flowchart : Container
|
|||
private async ValueTask OnChildCompletedAsync(ActivityCompletedContext context)
|
||||
{
|
||||
var logger = context.GetRequiredService<ILogger<Flowchart>>();
|
||||
var loggerScopeState = new Dictionary<string, object>
|
||||
{
|
||||
["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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue