public MonitoringService( MonitoringConfiguration config, IAlertNotifier alertNotifier, ILoggerFactory loggerFactory) { if (config == null) { throw new ArgumentNullException(nameof(config)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } if (config.Drives == null) { throw new ArgumentNullException($"{nameof(config.Drives)} can not be null. " + "Check drive section in config file"); } if (String.IsNullOrWhiteSpace(config.MachineName)) { throw new ArgumentNullException($"{nameof(config.MachineName)} can not be null." + "Check config file"); } if (config.AlertPeriodMin <= 0) { throw new ArgumentNullException($"{nameof(config.AlertPeriodMin)} can not less than 1." + "Check config file"); } _alertNotifier = alertNotifier; _logger = loggerFactory.CreateLogger <MonitoringService>(); _checkPeriod = TimeSpan.FromMinutes(config.AlertPeriodMin); _machineName = config.MachineName; _triggers = new List <AlertTrigger>(config.Drives.Count); foreach (var drive in config.Drives) { _triggers.Add( new AlertTrigger( drive.DeviceName, drive.ThresholdValue, drive.TriggerMode, drive.MeasurementUnit)); } }
public OccupancyAlertService( IMqttClient mqttClient, IOptions <AlertsOptions> options, IAlertsStore alertsStore, ILastFiredAlertQuery lastFiredAlertQuery, IAlertNotifier alertNotifier, AlertStatusProvider alertStatusProvider, ILogger <OccupancyAlertService> logger) { _mqttClient = mqttClient; _alertsStore = alertsStore; _lastFiredAlertQuery = lastFiredAlertQuery; _alertNotifier = alertNotifier; _alertStatusProvider = alertStatusProvider; _logger = logger; _options = options.Value; }
public AlertService(IAlertNotifier alertNotifier) { _alertNotifier = alertNotifier ?? throw new ArgumentNullException(nameof(alertNotifier)); }
public AlertService(ApplicationDbContext dbContext, IAlertNotifier alertNotifier) { this.dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); this.alertNotifier = alertNotifier ?? throw new ArgumentNullException(nameof(alertNotifier)); }