Skip to content

Commit c2e9a40

Browse files
committed
update persistence providers
1 parent 6dcdd70 commit c2e9a40

25 files changed

+1224
-122
lines changed

WorkflowCore.Sample09/Program.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ private static IServiceProvider ConfigureServices()
2929
//setup dependency injection
3030
IServiceCollection services = new ServiceCollection();
3131
services.AddLogging();
32-
//services.AddWorkflow();
33-
services.AddWorkflow(x => x.UseMongoDB(@"mongodb://localhost:27017", "workflow-test001"));
32+
services.AddWorkflow();
33+
//services.AddWorkflow(x => x.UseMongoDB(@"mongodb://localhost:27017", "workflow-test002"));
3434
//services.AddWorkflow(x => x.UseSqlServer(@"Server=.;Database=WorkflowCore3;Trusted_Connection=True;", true, true));
3535
//services.AddWorkflow(x => x.UseSqlite(@"Data Source=database2.db;", true));
36+
//services.AddWorkflow(x => x.UsePostgreSQL(@"Server=127.0.0.1;Port=32768;Database=workflow_test001;User Id=postgres;", true, true));
3637

3738

3839
var serviceProvider = services.BuildServiceProvider();

WorkflowCore.Sample09/WorkflowCore.Sample09.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
<ItemGroup>
1515
<ProjectReference Include="..\src\providers\WorkflowCore.Persistence.MongoDB\WorkflowCore.Persistence.MongoDB.csproj" />
16+
<ProjectReference Include="..\src\providers\WorkflowCore.Persistence.PostgreSQL\WorkflowCore.Persistence.PostgreSQL.csproj" />
1617
<ProjectReference Include="..\src\WorkflowCore\WorkflowCore.csproj" />
1718
</ItemGroup>
1819

WorkflowCore.Sample10/Program.cs

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,46 @@
1-
using System;
1+
using Microsoft.Extensions.DependencyInjection;
2+
using Microsoft.Extensions.Logging;
3+
using System;
4+
using WorkflowCore.Interface;
25

36
namespace WorkflowCore.Sample10
47
{
58
class Program
69
{
7-
static void Main(string[] args)
10+
public static void Main(string[] args)
811
{
9-
Console.WriteLine("Hello World!");
12+
IServiceProvider serviceProvider = ConfigureServices();
13+
14+
//start the workflow host
15+
var host = serviceProvider.GetService<IWorkflowHost>();
16+
host.RegisterWorkflow<WhileWorkflow, MyData>();
17+
host.Start();
18+
19+
Console.WriteLine("Starting workflow...");
20+
string workflowId = host.StartWorkflow("While", new MyData() { Counter = 0 }).Result;
21+
22+
23+
Console.ReadLine();
24+
host.Stop();
25+
}
26+
27+
private static IServiceProvider ConfigureServices()
28+
{
29+
//setup dependency injection
30+
IServiceCollection services = new ServiceCollection();
31+
services.AddLogging();
32+
services.AddWorkflow();
33+
//services.AddWorkflow(x => x.UseMongoDB(@"mongodb://localhost:27017", "workflow-test001"));
34+
//services.AddWorkflow(x => x.UseSqlServer(@"Server=.\SQLEXPRESS;Database=WorkflowCore;Trusted_Connection=True;", true, true));
35+
//services.AddWorkflow(x => x.UseSqlite(@"Data Source=database2.db;", true));
36+
37+
38+
var serviceProvider = services.BuildServiceProvider();
39+
40+
//config logging
41+
var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
42+
//loggerFactory.AddDebug(LogLevel.Debug);
43+
return serviceProvider;
1044
}
1145
}
1246
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using WorkflowCore.Interface;
5+
using WorkflowCore.Models;
6+
7+
namespace WorkflowCore.Sample10
8+
{
9+
public class DoSomething : StepBody
10+
{
11+
public override ExecutionResult Run(IStepExecutionContext context)
12+
{
13+
Console.WriteLine("Doing something...");
14+
return ExecutionResult.Next();
15+
}
16+
}
17+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using WorkflowCore.Interface;
5+
using WorkflowCore.Models;
6+
7+
namespace WorkflowCore.Sample10
8+
{
9+
public class IncrementStep : StepBody
10+
{
11+
public int Value1 { get; set; }
12+
public int Value2 { get; set; }
13+
14+
public override ExecutionResult Run(IStepExecutionContext context)
15+
{
16+
Value2 = Value1 + 1;
17+
return ExecutionResult.Next();
18+
}
19+
}
20+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using WorkflowCore.Interface;
5+
using WorkflowCore.Models;
6+
7+
namespace WorkflowCore.Sample10
8+
{
9+
public class SayGoodbye : StepBody
10+
{
11+
public override ExecutionResult Run(IStepExecutionContext context)
12+
{
13+
Console.WriteLine("Goodbye");
14+
return ExecutionResult.Next();
15+
}
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using WorkflowCore.Interface;
5+
using WorkflowCore.Models;
6+
7+
namespace WorkflowCore.Sample10
8+
{
9+
public class SayHello : StepBody
10+
{
11+
public override ExecutionResult Run(IStepExecutionContext context)
12+
{
13+
Console.WriteLine("Hello");
14+
return ExecutionResult.Next();
15+
}
16+
}
17+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
using WorkflowCore.Interface;
5+
using WorkflowCore.Models;
6+
7+
namespace WorkflowCore.Sample10
8+
{
9+
public class WhileWorkflow : IWorkflow<MyData>
10+
{
11+
public string Id => "While";
12+
public int Version => 1;
13+
14+
public void Build(IWorkflowBuilder<MyData> builder)
15+
{
16+
builder
17+
.StartWith<SayHello>()
18+
.While(data => data.Counter < 3)
19+
.Do(x => x
20+
.StartWith<DoSomething>()
21+
.Then<IncrementStep>()
22+
.Input(step => step.Value1, data => data.Counter)
23+
.Output(data => data.Counter, step => step.Value2))
24+
.Then<SayGoodbye>();
25+
}
26+
}
27+
28+
public class MyData
29+
{
30+
public int Counter { get; set; }
31+
}
32+
}

WorkflowCore.Sample10/WorkflowCore.Sample10.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
<ItemGroup>
1414
<ProjectReference Include="..\src\providers\WorkflowCore.Persistence.MongoDB\WorkflowCore.Persistence.MongoDB.csproj" />
15+
<ProjectReference Include="..\src\providers\WorkflowCore.Persistence.SqlServer\WorkflowCore.Persistence.SqlServer.csproj" />
1516
<ProjectReference Include="..\src\WorkflowCore\WorkflowCore.csproj" />
1617
</ItemGroup>
1718

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Text;
4+
5+
namespace WorkflowCore.Models
6+
{
7+
public class ControlPersistenceData
8+
{
9+
public bool ChildrenActive { get; set; }
10+
}
11+
}

0 commit comments

Comments
 (0)