public EmailService(string tempPath, IScreenshotService screenshotService, IMessageService messageService, CleanupService cleanupService) { _tempPath = tempPath; _screenshotService = screenshotService; _messageService = messageService; _cleanupService = cleanupService; Directory.CreateDirectory(tempPath + "\\Screenshots"); _pendingMessages = new List<Message>(); _erroredTabs = new List<string>(); _timer = new Timer(10 * 60 * 1000); // Default timer is 10 minutes _timer.Elapsed += TimerElapsed; _timer.Start(); }
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); }