public PlayWavFile(XmlNode input, SoundService soundService) { _soundService = soundService; foreach (var childNode in input.ChildNodes.Cast<XmlNode>().Where(childNode => String.Equals(childNode.Name, "File", StringComparison.InvariantCultureIgnoreCase))) { _soundFile = childNode.FirstChild.Value; } }
public XmlFile(string configFilePathRoot, IMessageService messageService, EmailService emailService, AlarmService alarmService, SoundService soundService, Func<string, int, Check> checkFactory) { _configFilePathRoot = configFilePathRoot; _messageService = messageService; _emailService = emailService; _alarmService = alarmService; _soundService = soundService; _checkFactory = checkFactory; }
public static void Main() { Log.Logger = new LoggerConfiguration() .WriteTo.ColoredConsole() .CreateLogger(); Log.Information("Application Start"); try { _tempPath = AppDomain.CurrentDomain.BaseDirectory + "TEMP"; var cleanupService = new CleanupService(_tempPath); var messageService = new MessageService(); var screenshotService = new ScreenshotService(); var emailController = new EmailService(_tempPath, screenshotService, messageService, cleanupService); var soundController = new SoundService(messageService); var alarmService = new AlarmService(emailController); var guiController = new GuiController(); guiController.StartUp(() => _listOfChecks ?? new Check[0]); _listOfChecks = new XmlFile(_configFilePathRoot, messageService, emailController, alarmService, soundController, (s, i) => new Check(i, alarmService, c => guiController.Update(c))).Load(); alarmService.PrepareList(_listOfChecks); foreach (var c in _listOfChecks) c.Activate(); Thread.Sleep(Timeout.Infinite); } catch (Exception e) { Log.Error(e, "Failed to start application"); } }
private static void StartMonitoringFramework(ProductMonitorHubService hubService) { Log.Information("Initializing services"); var tempPath = AppDomain.CurrentDomain.BaseDirectory + "TEMP"; var cleanup = new CleanupService(tempPath); var messageService = new MessageService(); var screenshotService = new ScreenshotService(); var emailController = new EmailService(tempPath, screenshotService, messageService, cleanup); var soundController = new SoundService(messageService); var alarmService = new AlarmService(emailController); Log.Information("Loading configuration"); var xmlFile = new XmlFile(_configFilePathRoot, messageService, emailController, alarmService, soundController, checkFactory: (s, i) => new Check(i, alarmService, hubService.UpdateCheck)); var listOfChecks = xmlFile.Load(); alarmService.PrepareList(listOfChecks); hubService.UpdateChecks(listOfChecks); Log.Information("Running all checks offthread"); Task.Factory.StartNew(() => Parallel.ForEach(listOfChecks, check => check.Activate()), TaskCreationOptions.LongRunning); }
public RepeatWavFile(XmlNode input, SoundService soundService) { _soundService = soundService; _soundFile = input.ChildNodes.Cast<XmlNode>().Where(childNode => childNode.Name == "File").Select(childNode => childNode.FirstChild.Value).Last(); }