-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #44 from danielgerlag/refineapi2
- Loading branch information
Showing
52 changed files
with
978 additions
and
268 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Workflow Core 1.2.9 | ||
|
||
* .Recur() API, define a block of steps to execute on a recurring interval, until a condition becomes true | ||
|
||
This following example will execute the block of every day until the `StopRecurring` field on the data object becomes true | ||
```c# | ||
builder | ||
.StartWith<HelloWorld>() | ||
.Recur(data => TimeSpan.FromDays(1), data => data.StopRecurring) | ||
.Do(recur => recur | ||
.StartWith<DoSomething>() | ||
.Then<DoSomethingElse>()) | ||
.Then<GoodbyeWorld>(); | ||
``` | ||
|
||
* Added access to the execution context object when resolving an event key in the .WaitFor API | ||
|
||
```c# | ||
.WaitFor("event", (data, context) => context.Workflow.Id) | ||
``` | ||
|
||
* Deprecated `UserStep` in favour of the new `UserTask` API | ||
* Added basic escalation functionality to `UserTask` | ||
|
||
This following example will create a user task with 2 options and 2 resultant paths, as well as escalate the task after 1 day. | ||
```c# | ||
builder | ||
.StartWith(context => ExecutionResult.Next()) | ||
.UserTask("Do you approve", data => @"domain\bob") | ||
.WithOption("yes", "I approve").Do(then => then | ||
.StartWith(context => Console.WriteLine("You approved")) | ||
) | ||
.WithOption("no", "I do not approve").Do(then => then | ||
.StartWith(context => Console.WriteLine("You did not approve")) | ||
) | ||
.WithEscalation(x => TimeSpan.FromDays(1), x => @"domain\frank", action => action | ||
.StartWith(context => Console.WriteLine("Escalated task")) | ||
.Then(context => Console.WriteLine("Sending notification...")) | ||
) | ||
.Then(context => Console.WriteLine("end")); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq.Expressions; | ||
using System.Text; | ||
using WorkflowCore.Interface; | ||
using WorkflowCore.Models; | ||
|
||
namespace WorkflowCore.Primitives | ||
{ | ||
public class CancellableStep<TStepBody, TData> : WorkflowStep<TStepBody> | ||
where TStepBody : IStepBody | ||
{ | ||
private readonly Expression<Func<TData, bool>> _cancelCondition; | ||
|
||
public CancellableStep(Expression<Func<TData, bool>> cancelCondition) | ||
{ | ||
_cancelCondition = cancelCondition; | ||
} | ||
|
||
public override void AfterWorkflowIteration(WorkflowExecutorResult executorResult, WorkflowDefinition defintion, WorkflowInstance workflow, ExecutionPointer executionPointer) | ||
{ | ||
base.AfterWorkflowIteration(executorResult, defintion, workflow, executionPointer); | ||
var func = _cancelCondition.Compile(); | ||
if (func((TData) workflow.Data)) | ||
{ | ||
executionPointer.EndTime = DateTime.Now.ToUniversalTime(); | ||
executionPointer.Active = false; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using WorkflowCore.Interface; | ||
using WorkflowCore.Models; | ||
|
||
namespace WorkflowCore.Primitives | ||
{ | ||
public class Recur : ContainerStepBody | ||
{ | ||
public TimeSpan Interval { get; set; } | ||
|
||
public bool StopCondition { get; set; } | ||
|
||
public override ExecutionResult Run(IStepExecutionContext context) | ||
{ | ||
if (StopCondition) | ||
return ExecutionResult.Next(); | ||
|
||
return new ExecutionResult() | ||
{ | ||
Proceed = false, | ||
BranchValues = new List<object>() { null }, | ||
SleepFor = Interval | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.