Esempio n. 1
0
        public async Task Handle(ReportGeneratedNotification notification, CancellationToken cancellationToken)
        {
            _logger.LogInfo("Report generated sucessfully!", notification.Report);

            if (notification.HasError())
            {
                await _mediator.Send(new SendMessageRabbitRequest(notification));
            }
            await _mediator.Send(new SendEmailRequest(notification.Report));
        }
        public void Run()
        {
            var listOfTasks = new List <Task>();

            foreach (var item in _parameters)
            {
                var weeklyStrategy = new WeeklyStrategy(item);
                var weeklyRequest  = new GenerateReportRequest(weeklyStrategy);
                listOfTasks.Add(_mediator.Send(weeklyRequest));

                var monthlyStrategy = new MonthlyStrategy(item);
                var monthyrequest   = new GenerateReportRequest(monthlyStrategy);
                listOfTasks.Add(_mediator.Send(monthyrequest));
            }
            Task.WaitAll(tasks: listOfTasks.ToArray());
        }
        public async Task Handle(EmailSentNotification notification, CancellationToken cancellationToken)
        {
            _logger.LogInfo($"Email sent sucessfully!", notification.Email);

            if (notification.HasError())
            {
                await _mediator.Send(new SendMessageRabbitRequest(notification));
            }
        }