示例#1
0
		private static void RunClientJob(string mainConnectionString, string filesConnectionString, int partitionId)
		{
			using(var connection = new SqlConnection(mainConnectionString))
			{
				var executor = new SqlProcedureExecutor(mainConnectionString);
				var serializer = new Serializer();
				var events = new EventRepository(executor);
				var clientRepository = new ClientRepository(executor);
				var adminRepository = new AdminRepository(connection);
				var converter = new PasswordConverter();
				var senders = new SenderRepository(converter, executor);
				var localizedDataHelper = new CommonLocalizedDataHelper(serializer, clientRepository, senders);
				var recipients = new EventEmailRecipient(executor);
				var managerRepository = new ManagerRepository(connection);
				var recipientsFacade = new ClientEventRecipientsFacade(
					adminRepository,
					managerRepository,
					clientRepository,
					recipients);

				var messageBuilder = GetCommonMessageBuilder(
					connection,
					mainConnectionString,
					filesConnectionString,
					localizedDataHelper,
					recipientsFacade);
				var emailingProcessor = GetDefaultEmailingProcessor(partitionId, executor, messageBuilder);

				var processors = new Dictionary<EventState, IEventProcessor>
				{
					{ EventState.Emailing, emailingProcessor }
				};

				new SequentialEventJob(
					events,
					partitionId,
					new Dictionary<EventType, IDictionary<EventState, IEventProcessor>>
					{
						{ EventType.ClientAdded, processors },
					}).Work();
			}
		}
示例#2
0
		private static void RunAwbJob(string mainConnectionString, string filesConnectionString, int partitionId)
		{
			using(var connection = new SqlConnection(mainConnectionString))
			{
				var executor = new SqlProcedureExecutor(mainConnectionString);
				var events = new EventRepository(executor);
				var adminRepository = new AdminRepository(connection);
				var brokerRepository = new BrokerRepository(connection);
				var awbs = new AwbRepository(connection);
				var converter = new PasswordConverter();
				var senders = new SenderRepository(converter, executor);
				var localizedDataHelper = new AwbEventLocalizedDataHelper(awbs, senders);
				var eventEmailRecipient = new EventEmailRecipient(executor);
				var managerRepository = new ManagerRepository(connection);
				var recipientsFacade = new AwbEventRecipientsFacade(
					adminRepository,
					managerRepository,
					brokerRepository,
					awbs,
					eventEmailRecipient);

				var messageBuilder = GetCommonMessageBuilder(
					connection,
					mainConnectionString,
					filesConnectionString,
					localizedDataHelper,
					recipientsFacade);
				var emailingProcessor = GetDefaultEmailingProcessor(partitionId, executor, messageBuilder);

				var processors = (IDictionary<EventState, IEventProcessor>)new Dictionary<EventState, IEventProcessor>
				{
					{ EventState.Emailing, emailingProcessor }
				};

				new SequentialEventJob(
					events,
					partitionId,
					EventHelper.AwbEventTypes.ToDictionary(x => x, x => processors)).Work();
			}
		}