Add GoBackResult (#449)

This commit is contained in:
Sipke Schoorstra 2020-11-03 12:43:33 +01:00 committed by GitHub
parent fb2dc4d6f0
commit 2deb5d4037
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View file

@ -17,6 +17,7 @@
<RepositoryType>GitHub</RepositoryType>
<PackageTags>elsa, workflows, orchard</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>

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