public void Setup(CancellationToken stoppingToken) { _stoppingToken = stoppingToken; _messageSender = MessageBusServiceFactory.CreateServiceBusMessageSender(_serviceBusConfiguration, _logger); FileUtil.CreateLocalDirectoriesInPath(_blobConfiguration.ImageStorePath); }
public void WhenConnectionIsValidThenCreateServiceBusMessageSenderIsNotNull() { var fakeLogger = new Mock <ILogger>(); var target = MessageBusServiceFactory.CreateServiceBusMessageSender(validConnectionString, fakeLogger.Object); Assert.NotNull(target); }
public async Task ProcessMessage(ILogger logger) { logger.LogInformation($"NotificationSummaryProcessor : Getting summary email list of notifications." + $"Connecion:{_notificationServiceBusConfiguration.ServiceBusConnection} and queuename: {_notificationServiceBusConfiguration.QueueName}"); var queryParameter = CreateParam(); var totalScan = ComputeTotalSummaryScans(queryParameter, logger); if (totalScan != null) { logger.LogInformation($"View count : {totalScan?.Count()}"); var _messageSender = MessageBusServiceFactory.CreateServiceBusMessageSender(_notificationServiceBusConfiguration, logger); foreach (var item in totalScan) { logger.LogInformation($"Total Amount daily scan - {item.TotalScans}."); var mailParam = new ParseEmailParam(item.CompanyId, item.TotalScans); mailParam.Recipients = _dataProcessor.GetRecipientsByCompanyId(item.CompanyId); mailParam.TotalAbnormalDetected = item.TotalAbnormalScan; var mailData = _summaryMailContentParser.CreateSummaryEmailAlertMessage(mailParam, logger); if (mailData != null) { var messageInstance = MessageConverter.Serialize(mailData); await _messageSender.SendMessagesAsync(messageInstance); logger.LogInformation($"Sent content {messageInstance} data to notification queue."); } else { logger.LogInformation($"No notifcation sent to queue. {DateTime.Now}"); } } } else { logger.LogInformation($"Unable to find any summary record matches in the database.{DateTime.Now}"); } }
public async Task ExecuteDataFiltering(AttendanceRecord attendanceRecord, ILogger logger) { try { if (attendanceRecord == null) { throw new ArgumentException(AttendanceRecordNullMessage); } logger.LogInformation($"Running TemperatureDataFilter sbconnection : {_notificationServiceBusConfiguration.ServiceBusConnection}, queue : {_notificationServiceBusConfiguration.QueueName} and temperature max : {_temperatureFilterConfiguration.Max} "); if (attendanceRecord.BodyTemperature > _temperatureFilterConfiguration.Max) { _messageSender = MessageBusServiceFactory.CreateServiceBusMessageSender(_notificationServiceBusConfiguration, logger); var mailParam = new EmailTemperatureHitParameter(attendanceRecord.DeviceId, _temperatureFilterConfiguration.EmailTemplateMaxTemperatureHit); mailParam.Location = attendanceRecord.Address; mailParam.TemperatureRegistered = attendanceRecord.BodyTemperature; mailParam.Image = attendanceRecord.Img; mailParam.Timestamp = attendanceRecord.TimeStamp; var mailData = _mailContentParser.CreateTemperatureEmailAlertMessage(mailParam, logger); if (mailData != null) { var messgeInstance = MessageConverter.Serialize(mailData); await _messageSender.SendMessagesAsync(messgeInstance); logger.LogInformation("MailData message sent to queue."); } else { logger.LogInformation($"No notifcation sent to queue. {DateTime.Now}"); } } } catch (Exception ex) { logger.LogInformation($"Notfication filter failed. {ex.Message}. {ex.StackTrace}"); } }
public void Setup() { targetBaseUrl = _restConfiguration.Hostname; thermoDataRequester = RequestFactory.CreateRestService(targetBaseUrl, _stoppingToken, _logger); _messageSender = MessageBusServiceFactory.CreateServiceBusMessageSender(_serviceBusConfiguration, _logger); }
public void WhenConnectionStringIsInvalidThenThrowsExceptionCreateClient() { var fakeLogger = new Mock <ILogger>(); Assert.Throws <ArgumentNullException>(() => MessageBusServiceFactory.CreateServiceBusMessageSender(incompletedConnectionString, fakeLogger.Object)); }