2016-11-20 14:34:50 +01:00
|
|
|
|
using System;
|
|
|
|
|
using SimpleInjector;
|
|
|
|
|
using Tapeti;
|
2017-02-12 21:43:30 +01:00
|
|
|
|
using Tapeti.DataAnnotations;
|
2017-01-31 12:01:08 +01:00
|
|
|
|
using Tapeti.Flow;
|
2016-11-20 14:34:50 +01:00
|
|
|
|
using Tapeti.SimpleInjector;
|
2017-10-17 10:34:07 +02:00
|
|
|
|
using System.Threading;
|
2018-12-19 21:41:19 +01:00
|
|
|
|
using Tapeti.Flow.SQL;
|
2016-11-20 14:34:50 +01:00
|
|
|
|
|
|
|
|
|
namespace Test
|
|
|
|
|
{
|
|
|
|
|
internal class Program
|
|
|
|
|
{
|
|
|
|
|
private static void Main()
|
|
|
|
|
{
|
2017-02-07 16:13:33 +01:00
|
|
|
|
// TODO logging
|
2018-06-12 10:12:52 +02:00
|
|
|
|
|
2016-11-20 14:34:50 +01:00
|
|
|
|
var container = new Container();
|
2016-12-07 10:19:16 +01:00
|
|
|
|
container.Register<MarcoEmitter>();
|
2016-12-13 22:01:43 +01:00
|
|
|
|
container.Register<Visualizer>();
|
2017-08-30 17:47:43 +02:00
|
|
|
|
container.Register<ILogger, Tapeti.Default.ConsoleLogger>();
|
2016-12-07 10:19:16 +01:00
|
|
|
|
|
2017-02-07 16:13:33 +01:00
|
|
|
|
var config = new TapetiConfig(new SimpleInjectorDependencyResolver(container))
|
2018-12-19 21:41:19 +01:00
|
|
|
|
//.WithFlowSqlRepository("Server=localhost;Database=TapetiTest;Integrated Security=true")
|
2017-02-05 23:22:34 +01:00
|
|
|
|
.WithFlow()
|
2017-02-12 21:43:30 +01:00
|
|
|
|
.WithDataAnnotations()
|
2016-12-07 10:19:16 +01:00
|
|
|
|
.RegisterAllControllers()
|
|
|
|
|
.Build();
|
2016-11-20 14:34:50 +01:00
|
|
|
|
|
2017-02-05 23:22:34 +01:00
|
|
|
|
using (var connection = new TapetiConnection(config)
|
|
|
|
|
{
|
2017-02-08 15:52:24 +01:00
|
|
|
|
Params = new TapetiAppSettingsConnectionParams()
|
2017-02-05 23:22:34 +01:00
|
|
|
|
})
|
|
|
|
|
{
|
2017-10-17 10:34:07 +02:00
|
|
|
|
var flowStore = container.GetInstance<IFlowStore>();
|
|
|
|
|
var flowStore2 = container.GetInstance<IFlowStore>();
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("IFlowHandler is singleton = " + (flowStore == flowStore2));
|
|
|
|
|
|
2017-07-14 12:33:09 +02:00
|
|
|
|
connection.Connected += (sender, e) => {
|
|
|
|
|
Console.WriteLine("Event Connected");
|
|
|
|
|
};
|
|
|
|
|
connection.Disconnected += (sender, e) => {
|
|
|
|
|
Console.WriteLine("Event Disconnected");
|
|
|
|
|
};
|
|
|
|
|
connection.Reconnected += (sender, e) => {
|
|
|
|
|
Console.WriteLine("Event Reconnected");
|
|
|
|
|
};
|
|
|
|
|
|
2016-11-20 14:34:50 +01:00
|
|
|
|
Console.WriteLine("Subscribing...");
|
2017-02-12 19:04:26 +01:00
|
|
|
|
var subscriber = connection.Subscribe(false).Result;
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Consuming...");
|
|
|
|
|
subscriber.Resume().Wait();
|
|
|
|
|
|
2016-11-20 14:34:50 +01:00
|
|
|
|
Console.WriteLine("Done!");
|
|
|
|
|
|
2017-07-25 15:50:38 +02:00
|
|
|
|
connection.GetPublisher().Publish(new FlowEndController.PingMessage());
|
|
|
|
|
|
2018-12-19 20:20:08 +01:00
|
|
|
|
//container.GetInstance<IFlowStarter>().Start<MarcoController, bool>(c => c.StartFlow, true);
|
|
|
|
|
container.GetInstance<IFlowStarter>().Start<MarcoController>(c => c.TestParallelRequest);
|
2017-02-15 22:05:01 +01:00
|
|
|
|
|
2017-10-17 10:34:07 +02:00
|
|
|
|
Thread.Sleep(1000);
|
|
|
|
|
|
2016-12-05 08:00:09 +01:00
|
|
|
|
var emitter = container.GetInstance<MarcoEmitter>();
|
|
|
|
|
emitter.Run().Wait();
|
2017-07-25 15:50:38 +02:00
|
|
|
|
|
|
|
|
|
|
2016-11-20 14:34:50 +01:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|