-
-
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 #42 from danielgerlag/refineapi
* .Schedule() API, to future date a block of steps to run in parallel to the rest of the workflow. This following example will execute the block of steps after 3 days ```c# builder .StartWith<HelloWorld>() .Schedule(data => TimeSpan.FromDays(3)).Do(block => block.StartWith<DoSomething>() .Then<DoSomethingElse>()) .Then<GoodbyeWorld>(); ``` * Overload of the .Input() method to allow access to the context object ```c# builder .StartWith<SayHello>() .ForEach(data => new List<int>() { 1, 2, 3, 4 }) .Do(x => x .StartWith<DisplayContext>() .Input(step => step.Item, (data, context) => context.Item) .Then<DoSomething>()) .Then<SayGoodbye>(); ``` ```c# builder .StartWith(context => Console.WriteLine("Hello!")) .Then(context => Console.WriteLine("Bye!")); ``` * Inline action steps API ```c# builder .StartWith(context => Console.WriteLine("Hello!")) .Then(context => Console.WriteLine("Bye!")); ``` * Discontinued support for .NET 4.5.2 (.NET 4.6 is .NET Standard 1.3 compatible)
- Loading branch information
Showing
26 changed files
with
330 additions
and
91 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,43 @@ | ||
# Workflow Core 1.2.8 | ||
|
||
* .Schedule() API, to future date a block of steps to run in parallel to the rest of the workflow. | ||
|
||
This following example will execute the block of steps after 3 days | ||
```c# | ||
builder | ||
.StartWith<HelloWorld>() | ||
.Schedule(data => TimeSpan.FromDays(3)).Do(block => | ||
block.StartWith<DoSomething>() | ||
.Then<DoSomethingElse>()) | ||
.Then<GoodbyeWorld>(); | ||
``` | ||
|
||
* Overload of the .Input() method to allow access to the context object | ||
|
||
```c# | ||
builder | ||
.StartWith<SayHello>() | ||
.ForEach(data => new List<int>() { 1, 2, 3, 4 }) | ||
.Do(x => x | ||
.StartWith<DisplayContext>() | ||
.Input(step => step.Item, (data, context) => context.Item) | ||
.Then<DoSomething>()) | ||
.Then<SayGoodbye>(); | ||
``` | ||
|
||
```c# | ||
builder | ||
.StartWith(context => Console.WriteLine("Hello!")) | ||
.Then(context => Console.WriteLine("Bye!")); | ||
``` | ||
|
||
|
||
* Inline action steps API | ||
|
||
```c# | ||
builder | ||
.StartWith(context => Console.WriteLine("Hello!")) | ||
.Then(context => Console.WriteLine("Bye!")); | ||
``` | ||
|
||
* Discontinued support for .NET 4.5.2 (.NET 4.6 is .NET Standard 1.3 compatible) |
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,12 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace WorkflowCore.Models | ||
{ | ||
public class SchedulePersistenceData | ||
{ | ||
public bool Elapsed { get; set; } | ||
|
||
} | ||
} |
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,21 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Linq.Expressions; | ||
using System.Threading.Tasks; | ||
using WorkflowCore.Interface; | ||
using WorkflowCore.Models; | ||
|
||
namespace WorkflowCore.Primitives | ||
{ | ||
public class ActionStepBody : StepBody | ||
{ | ||
public Action<IStepExecutionContext> Body { get; set; } | ||
|
||
public override ExecutionResult Run(IStepExecutionContext context) | ||
{ | ||
Body(context); | ||
return ExecutionResult.Next(); | ||
} | ||
} | ||
} |
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,22 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using WorkflowCore.Interface; | ||
using WorkflowCore.Models; | ||
|
||
namespace WorkflowCore.Primitives | ||
{ | ||
public class Delay : StepBody | ||
{ | ||
public TimeSpan Period { get; set; } | ||
|
||
public override ExecutionResult Run(IStepExecutionContext context) | ||
{ | ||
if (context.PersistenceData != null) | ||
return ExecutionResult.Next(); | ||
|
||
return ExecutionResult.Sleep(Period, true); | ||
} | ||
} | ||
} |
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,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using WorkflowCore.Interface; | ||
using WorkflowCore.Models; | ||
|
||
namespace WorkflowCore.Primitives | ||
{ | ||
public class Schedule : ContainerStepBody | ||
{ | ||
public TimeSpan Period { get; set; } | ||
|
||
public override ExecutionResult Run(IStepExecutionContext context) | ||
{ | ||
if (context.PersistenceData == null) | ||
return ExecutionResult.Sleep(Period, new SchedulePersistenceData() { Elapsed = false }); | ||
|
||
|
||
if (context.PersistenceData is SchedulePersistenceData) | ||
{ | ||
if (!((SchedulePersistenceData) context.PersistenceData).Elapsed) | ||
return ExecutionResult.Branch(new List<object>() { null }, new SchedulePersistenceData() { Elapsed = true }); | ||
|
||
var complete = true; | ||
|
||
foreach (var childId in context.ExecutionPointer.Children) | ||
complete = complete && IsBranchComplete(context.Workflow.ExecutionPointers, childId); | ||
|
||
if (complete) | ||
return ExecutionResult.Next(); | ||
|
||
return ExecutionResult.Persist(context.PersistenceData); | ||
} | ||
|
||
throw new ArgumentException(); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.