forked from danielgerlag/workflow-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
67 lines (57 loc) · 2.43 KB
/
Program.cs
File metadata and controls
67 lines (57 loc) · 2.43 KB
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
60
61
62
63
64
65
66
67
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using MongoDB.Driver;
using RabbitMQ.Client;
using StackExchange.Redis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WorkflowCore.Interface;
using WorkflowCore.Persistence.MongoDB.Services;
using WorkflowCore.Services;
namespace WorkflowCore.Sample04
{
public class Program
{
public static void Main(string[] args)
{
IServiceProvider serviceProvider = ConfigureServices();
//start the workflow host
var host = serviceProvider.GetService<IWorkflowHost>();
host.RegisterWorkflow<EventSampleWorkflow, MyDataClass>();
host.Start();
var initialData = new MyDataClass();
host.StartWorkflow("EventSampleWorkflow", 1, initialData);
Console.WriteLine("Enter value to publish");
string value = Console.ReadLine();
host.PublishEvent("MyEvent", "0", value);
Console.ReadLine();
host.Stop();
}
private static IServiceProvider ConfigureServices()
{
//setup dependency injection
IServiceCollection services = new ServiceCollection();
services.AddLogging();
services.AddWorkflow();
//services.AddWorkflow(x => x.UseMongoDB(@"mongodb://localhost:27017", "workflow"));
//services.AddWorkflow(x => x.UseSqlServer(@"Server=.;Database=WorkflowCore;Trusted_Connection=True;", true, true));
//services.AddWorkflow(x => x.UsePostgreSQL(@"Server=127.0.0.1;Port=5432;Database=workflow;User Id=postgres;Password=password;", true, true));
//services.AddWorkflow(x => x.UseSqlite(@"Data Source=database.db;", true));
//redis = ConnectionMultiplexer.Connect("127.0.0.1");
//services.AddWorkflow(x =>
//{
// x.UseMongoDB(@"mongodb://localhost:27017", "workflow");
// x.UseRabbitMQ(new ConnectionFactory() { HostName = "localhost" });
// x.UseRedlock(redis);
//});
var serviceProvider = services.BuildServiceProvider();
//config logging
var loggerFactory = serviceProvider.GetService<ILoggerFactory>();
loggerFactory.AddDebug();
return serviceProvider;
}
private static IConnectionMultiplexer redis;
}
}