-
Notifications
You must be signed in to change notification settings - Fork 2
/
BoxNetUploaderService.cs
38 lines (34 loc) · 1.26 KB
/
BoxNetUploaderService.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
using System.Collections.Concurrent;
using System.Collections.Generic;
using MassTransit;
using Talifun.Commander.Command.Esb;
using Talifun.Commander.Command.BoxNetUploader.Command;
using Talifun.Commander.Command.BoxNetUploader.Command.Request;
using Talifun.Commander.Command.BoxNetUploader.CommandTester;
using Talifun.Commander.Command.BoxNetUploader.Configuration;
namespace Talifun.Commander.Command.BoxNetUploader
{
public class BoxNetUploaderService : CommandServiceBase<BoxNetUploaderSaga, BoxNetUploaderConfigurationTesterSaga>
{
public static IDictionary<IExecuteBoxNetUploaderWorkflowMessage, CancellableTask> Uploaders { get; set; }
static BoxNetUploaderService()
{
Settings = BoxNetUploaderConfiguration.Instance;
Uploaders = new ConcurrentDictionary<IExecuteBoxNetUploaderWorkflowMessage, CancellableTask>();
}
public override void OnConfigure(MassTransit.BusConfigurators.ServiceBusConfigurator serviceBusConfigurator)
{
serviceBusConfigurator.Subscribe((subscriber) =>
{
subscriber.Consumer<ExecuteBoxNetUploaderWorkflowMessageHandler>().Permanent();
});
}
public override void OnStop()
{
foreach (var commandLineExecutor in Uploaders)
{
commandLineExecutor.Value.CancellationTokenSource.Cancel();
}
}
}
}