forked from danielgerlag/workflow-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
59 lines (48 loc) · 1.74 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Debug;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WorkflowCore.Interface;
using WorkflowCore.Services;
namespace WorkflowCore.Sample03
{
public class Program
{
public static void Main(string[] args)
{
IServiceProvider serviceProvider = ConfigureServices();
//start the workflow host
var host = serviceProvider.GetService<IWorkflowHost>();
host.RegisterWorkflow<PassingDataWorkflow, MyDataClass>();
host.RegisterWorkflow<PassingDataWorkflow2, Dictionary<string, int>>();
host.Start();
var initialData = new MyDataClass
{
Value1 = 2,
Value2 = 3
};
//host.StartWorkflow("PassingDataWorkflow", 1, initialData);
var initialData2 = new Dictionary<string, int>
{
["Value1"] = 7,
["Value2"] = 2
};
host.StartWorkflow("PassingDataWorkflow2", 1, initialData2);
Console.ReadLine();
host.Stop();
}
private static IServiceProvider ConfigureServices()
{
//setup dependency injection
IServiceCollection services = new ServiceCollection();
services.AddLogging();
services.AddWorkflow();
//services.AddWorkflow(x => x.UseSqlServer(@"Server=.\SQLEXPRESS;Database=WorkflowCore;Trusted_Connection=True;", true, true));
var serviceProvider = services.BuildServiceProvider();
return serviceProvider;
}
}
}