Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
# Conflicts:
#	WorkflowCore.sln
  • Loading branch information
danielgerlag committed Nov 21, 2017
2 parents 2d1523d + 3112793 commit f050adb
Show file tree
Hide file tree
Showing 15 changed files with 127 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ There are several persistence providers available as separate Nuget packages.

* [Parallel Tasks](src/samples/WorkflowCore.Sample13)

* [Scheduled Background Tasks](src/samples/WorkflowCore.Sample16)

* [Recurring Background Tasks](src/samples/WorkflowCore.Sample14)

* [Dependency Injection](src/samples/WorkflowCore.Sample15)

* [Deferred execution & re-entrant steps](src/samples/WorkflowCore.Sample05)

* [Looping](src/samples/WorkflowCore.Sample02)
Expand Down
19 changes: 13 additions & 6 deletions WorkflowCore.sln
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowCore.TestSample01",
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Docker.Testify", "test\Docker.Testify\Docker.Testify.csproj", "{EC497168-5347-4E70-9D9E-9C2F826C1CDF}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowCore.Sample15", "WorkflowCore.Sample15\WorkflowCore.Sample15.csproj", "{F9FD8357-C299-4CF4-B0D4-D3D5E45AAAA3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WorkflowCore.Sample15", "src\samples\WorkflowCore.Sample15\WorkflowCore.Sample15.csproj", "{9B7811AC-68D6-4D19-B1E9-65423393ED83}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkflowCore.Sample16", "src\samples\WorkflowCore.Sample16\WorkflowCore.Sample16.csproj", "{0C9617A9-C8B7-45F6-A54A-261A23AC881B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -251,10 +253,14 @@ Global
{EC497168-5347-4E70-9D9E-9C2F826C1CDF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EC497168-5347-4E70-9D9E-9C2F826C1CDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EC497168-5347-4E70-9D9E-9C2F826C1CDF}.Release|Any CPU.Build.0 = Release|Any CPU
{F9FD8357-C299-4CF4-B0D4-D3D5E45AAAA3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9FD8357-C299-4CF4-B0D4-D3D5E45AAAA3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9FD8357-C299-4CF4-B0D4-D3D5E45AAAA3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9FD8357-C299-4CF4-B0D4-D3D5E45AAAA3}.Release|Any CPU.Build.0 = Release|Any CPU
{9B7811AC-68D6-4D19-B1E9-65423393ED83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9B7811AC-68D6-4D19-B1E9-65423393ED83}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9B7811AC-68D6-4D19-B1E9-65423393ED83}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9B7811AC-68D6-4D19-B1E9-65423393ED83}.Release|Any CPU.Build.0 = Release|Any CPU
{0C9617A9-C8B7-45F6-A54A-261A23AC881B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0C9617A9-C8B7-45F6-A54A-261A23AC881B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0C9617A9-C8B7-45F6-A54A-261A23AC881B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0C9617A9-C8B7-45F6-A54A-261A23AC881B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -299,7 +305,8 @@ Global
{62A9709E-27DA-42EE-B94F-5AF431D86354} = {E6CEAD8D-F565-471E-A0DC-676F54EAEDEB}
{0E3C1496-8E7C-411A-A536-C7C9CE4EED4E} = {5080DB09-CBE8-4C45-9957-C3BB7651755E}
{EC497168-5347-4E70-9D9E-9C2F826C1CDF} = {E6CEAD8D-F565-471E-A0DC-676F54EAEDEB}
{F9FD8357-C299-4CF4-B0D4-D3D5E45AAAA3} = {5080DB09-CBE8-4C45-9957-C3BB7651755E}
{9B7811AC-68D6-4D19-B1E9-65423393ED83} = {5080DB09-CBE8-4C45-9957-C3BB7651755E}
{0C9617A9-C8B7-45F6-A54A-261A23AC881B} = {5080DB09-CBE8-4C45-9957-C3BB7651755E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DC0FA8D3-6449-4FDA-BB46-ECF58FAD23B4}
Expand Down
13 changes: 13 additions & 0 deletions src/samples/WorkflowCore.Sample14/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Recur sample

Illustrates how to run a set of recurring background steps within your workflow, until a certain condition is met


```c#
builder
.StartWith(context => Console.WriteLine("Hello"))
.Recur(data => TimeSpan.FromSeconds(5), data => data.Counter > 5).Do(recur => recur
.StartWith(context => Console.WriteLine("Doing recurring task"))
)
.Then(context => Console.WriteLine("Carry on"));
```
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\src\WorkflowCore\WorkflowCore.csproj" />
<ProjectReference Include="..\..\WorkflowCore\WorkflowCore.csproj" />
</ItemGroup>

</Project>
41 changes: 41 additions & 0 deletions src/samples/WorkflowCore.Sample16/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using WorkflowCore.Interface;

namespace WorkflowCore.Sample16
{
class Program
{
static void Main(string[] args)
{
var serviceProvider = ConfigureServices();

//start the workflow host
var host = serviceProvider.GetService<IWorkflowHost>();
host.RegisterWorkflow<ScheduleWorkflow>();
host.Start();

Console.WriteLine("Starting workflow...");
var workflowId = host.StartWorkflow("schedule-sample").Result;

Console.ReadLine();
host.Stop();
}

private static IServiceProvider ConfigureServices()
{
//setup dependency injection
IServiceCollection services = new ServiceCollection();
services.AddLogging();
services.AddWorkflow();

var serviceProvider = services.BuildServiceProvider();

//config logging
var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
//loggerFactory.AddDebug(LogLevel.Debug);
return serviceProvider;
}
}
}
13 changes: 13 additions & 0 deletions src/samples/WorkflowCore.Sample16/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Schedule sample

Illustrates how to schedule a future set of steps to run asynchronously in the background within your workflow.


```c#
builder
.StartWith(context => Console.WriteLine("Hello"))
.Schedule(data => TimeSpan.FromSeconds(5)).Do(schedule => schedule
.StartWith(context => Console.WriteLine("Doing scheduled tasks"))
)
.Then(context => Console.WriteLine("Doing normal tasks"));
```
23 changes: 23 additions & 0 deletions src/samples/WorkflowCore.Sample16/ScheduleWorkflow.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Text;
using WorkflowCore.Interface;

namespace WorkflowCore.Sample16
{
class ScheduleWorkflow : IWorkflow
{
public string Id => "schedule-sample";
public int Version => 1;

public void Build(IWorkflowBuilder<object> builder)
{
builder
.StartWith(context => Console.WriteLine("Hello"))
.Schedule(data => TimeSpan.FromSeconds(5)).Do(schedule => schedule
.StartWith(context => Console.WriteLine("Doing scheduled tasks"))
)
.Then(context => Console.WriteLine("Doing normal tasks"));
}
}
}
17 changes: 17 additions & 0 deletions src/samples/WorkflowCore.Sample16/WorkflowCore.Sample16.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\WorkflowCore\WorkflowCore.csproj" />
</ItemGroup>

</Project>

0 comments on commit f050adb

Please sign in to comment.