Fix workflow execution

This fixes an issue where blocking activities would not actually block workflow execution from continuing, due to the workflow runner continuing to schedule the posted activities.
This commit is contained in:
Sipke Schoorstra 2020-12-24 21:38:45 +01:00
parent b74f97b115
commit 599c6a5cd6
2 changed files with 8 additions and 14 deletions

View file

@ -94,14 +94,10 @@ namespace Elsa.Services.Models
public IActivityBlueprint? GetActivityBlueprintById(string id) => WorkflowBlueprint.Activities.FirstOrDefault(x => x.Id == id);
public IActivityBlueprint? GetActivityBlueprintByName(string name) => WorkflowBlueprint.Activities.FirstOrDefault(x => x.Name == name);
public void SchedulePostActivities()
public void SchedulePostActivity()
{
var activities = WorkflowInstance.PostScheduledActivities.Reverse();
foreach (var activity in activities)
ScheduleActivity(activity);
WorkflowInstance.PostScheduledActivities.Clear();
var activity = WorkflowInstance.PostScheduledActivities.Pop();
ScheduleActivity(activity);
}
public object? GetOutputFrom(string activityName)

View file

@ -286,15 +286,13 @@ namespace Elsa.Services
activityOperation = Execute;
workflowExecutionContext.CompletePass();
// Exit execution loop if workflow has any other status than Running (i.e. Suspended). Otherwise continue the loop.
if (workflowExecutionContext.Status != WorkflowStatus.Running)
break;
// If there are no more scheduled activities, schedule any post-scheduled activities.
if (!workflowExecutionContext.HasScheduledActivities && workflowExecutionContext.HasPostScheduledActivities)
{
workflowExecutionContext.SchedulePostActivities();
// Exit execution loop if workflow has any other status than Running (i.e. Suspended). Otherwise continue the loop.
if (workflowExecutionContext.Status != WorkflowStatus.Running)
break;
}
workflowExecutionContext.SchedulePostActivity();
}
if (workflowExecutionContext.HasBlockingActivities)