Пример #1
0
        public async Task Handle(FileProcessedEvent message)
        {
            try
            {
                Log.Logger.Information("Message received in UpdateSubscriptionDatabase FAKING : {@message}", message);

                if (string.IsNullOrEmpty(message.Email))
                {
                    Log.Logger.Information("Skipping subscription update as no email is supplied");
                    return;
                }
                if (string.IsNullOrEmpty(message.Allergene))
                {
                    Log.Logger.Information("Skipping subscription update as no allergene is supplied");
                    return;
                }

                lock (_subscriptionService)
                {
                    _subscriptionService
                    .AddUploaderToAllergeneSubscriptionAsync(message.Email, message.Allergene)
                    .Wait();
                }
                await Task.FromResult(0);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
        public async Task Handle(FileProcessedEvent message)
        {
            try
            {
                Log.Logger.Information("Message received in SendEmailWithResults: {@message}", message);

                var body = _mailMessageService.GetTemplateBasedMailBody("ResultsMailTemplate.html", message.DataFolder,
                                                                        "*.*", message.Email);
                var attachmentPaths = Directory.GetFiles(message.DataFolder, "*.Rout");
                var httpStatusCode  = _mailSender.SendMailAsync(
                    message.Email,
                    _appSettings.CcAddress,
                    _appSettings.SenderAddress,
                    _appSettings.SubjectResults + " " + message.Id,
                    body,
                    attachmentPaths)
                                      .Result;

                Log.Logger.Information($"Result of mail sending: {httpStatusCode}");

                await _bus.Bus.PublishAsync(Mapper.Map <FileReadyForCleanupEvent>(message))
                .ConfigureAwait(false);
            }
            catch (Exception e)
            {
                Log.Logger.Error(e, "Error during results sending");
                throw;
            }
        }
Пример #3
0
        private void WriteToDatabase(IEnumerable <FileContentModel> sales, string managerLastName)
        {
            var models = CreateModels(sales, managerLastName).ToArray();

            FileProcessedEvent?.Invoke(this, new FileProcessedEventArgs(models));
            // BL reacts and validates
            // BL adds through unitOfWork
            //_saleUnitOfWork.Add(models);
        }
Пример #4
0
 private void OnFileProcessedEvent(object sender, FileProcessedEventArgs e)
 {
     FileProcessedEvent?.Invoke(sender, e);
 }