Fix if/else activity issue
Fixes an issue where if/else activities whose condition is based on INPUT from the previous activity would fail.
This commit is contained in:
parent
31e9b76a63
commit
2c9ad5e671
|
|
@ -22,7 +22,7 @@ namespace Elsa.Activities.ControlFlow
|
|||
[ActivityProperty(Hint = "The condition to evaluate.")]
|
||||
public bool Condition { get; set; }
|
||||
|
||||
private bool EnteredScope
|
||||
public bool EnteredScope
|
||||
{
|
||||
get => GetState<bool>();
|
||||
set => SetState(value);
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Elsa.Activities.ControlFlow;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Services
|
||||
|
|
@ -19,12 +20,23 @@ namespace Elsa.Services
|
|||
activity.Data = context.GetData();
|
||||
activity.Id = context.ActivityId;
|
||||
|
||||
if(!IsReturningComposite(activity))
|
||||
if(ShouldSetProperties(activity))
|
||||
await context.WorkflowExecutionContext.WorkflowBlueprint.ActivityPropertyProviders.SetActivityPropertiesAsync(activity, context, context.CancellationToken);
|
||||
|
||||
return activity;
|
||||
}
|
||||
|
||||
private bool ShouldSetProperties(IActivity activity)
|
||||
{
|
||||
if (IsReturningComposite(activity))
|
||||
return false;
|
||||
|
||||
if (IsReturningIfElse(activity))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
private bool IsReturningComposite(IActivity activity) => activity is CompositeActivity && activity.Data.GetState<bool>(nameof(CompositeActivity.IsScheduled));
|
||||
private bool IsReturningIfElse(IActivity activity) => activity is IfElse && activity.Data.GetState<bool>(nameof(IfElse.EnteredScope));
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue