Add GoBackResult (#449)
This commit is contained in:
parent
fb2dc4d6f0
commit
2deb5d4037
|
|
@ -17,6 +17,7 @@
|
|||
<RepositoryType>GitHub</RepositoryType>
|
||||
<PackageTags>elsa, workflows, orchard</PackageTags>
|
||||
<PackageIcon>icon.png</PackageIcon>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
29
src/core/Elsa.Core/Results/GoBackResult.cs
Normal file
29
src/core/Elsa.Core/Results/GoBackResult.cs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
using System.Linq;
|
||||
using Elsa.Services;
|
||||
using Elsa.Services.Extensions;
|
||||
using Elsa.Services.Models;
|
||||
|
||||
namespace Elsa.Results
|
||||
{
|
||||
public class GoBackResult : ActivityExecutionResult
|
||||
{
|
||||
private readonly int steps;
|
||||
|
||||
public GoBackResult(int steps = 1)
|
||||
{
|
||||
this.steps = steps;
|
||||
}
|
||||
|
||||
protected override void Execute(IWorkflowInvoker invoker, WorkflowExecutionContext workflowContext)
|
||||
{
|
||||
var previousEntry = workflowContext.Workflow.ExecutionLog.Skip(steps).FirstOrDefault();
|
||||
|
||||
if (previousEntry == null)
|
||||
return;
|
||||
|
||||
var activityId = previousEntry.ActivityId;
|
||||
var activity = workflowContext.Workflow.GetActivity(activityId);
|
||||
workflowContext.ScheduleActivity(activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue