protected override void OnStop() { try { ConfigSettings.SetRules(); string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData); try { //if ( DinnerMonitorTimer != null ) //{ // DinnerMonitorTimer.Stop(); // DinnerMonitorTimer = null; //} //Fire an E - mail for RED ALERT List <string> receivers = new List <string> { "*****@*****.**" }; EmailModel mail = new EmailModel() { Recipients = receivers, Body = "<p>THE <b>ACT MONITOR (Windows Service)</b> HAS BEEN STOPPED! PLEASE RECTIFY IMMEDIATELY...</p><p>You can safely ignore this e-mail but you'll be held responsible for customer unsatisfictory!</p><p>Best Regards<br /> ACT Team</p>", From = "*****@*****.**", Subject = "ACT MONITOR HAS BEEN STOPPED!" }; bool sent = Mail.Send(mail); mail.Dispose(); } catch (Exception ex) { BaseMonitor.Error(Writer, ex, "OnStop - Email"); } Writer.WriteLine(); Writer.WriteLine(string.Format("======================== SERVICE STOPPED @ {0} ========================", DateTime.Now)); Writer.Flush(); } catch (Exception ex) { BaseMonitor.Error(Writer, ex, "OnStop - Main"); } }
private void DinnerMonitorTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e) { try { //if ( DinnerMonitor.IsRunning ) //{ // return; //} //ConfigSettings.SetRules(); //ArchiveLog( ConfigSettings.SystemRules.DinnerMonitorExportPath.Replace( "\\Export", "" ), 10.0 ); //using ( StreamWriter writer = new StreamWriter( string.Format( "{0}\\log.log", ConfigSettings.SystemRules.DinnerMonitorExportPath.Replace( "\\Export", "" ) ), true ) ) //{ // try // { // writer.AutoFlush = true; // writer.WriteLine(); // writer.WriteLine( string.Format( "BEGIN DINNERS MONITOR @ {0} ========================", DateTime.Now ) ); // bool done = DinnerMonitor.Run( writer ); // writer.WriteLine(); // writer.WriteLine( string.Format( "END DINNERS MONITOR @ {0} ========================", DateTime.Now ) ); // } // catch ( Exception ex ) // { // BaseMonitor.Error( writer, ex, "DinnerMonitorTimer_Elapsed" ); // } // writer.Flush(); //} } catch (Exception ex) { BaseMonitor.Error(Writer, ex, "DinnerMonitorTimer_Elapsed"); } }
public void DisputeTimerCallback(object e) { try { ConfigSettings.SetRules(); ArchiveLog(ConfigSettings.SystemRules.DisputeMonitorPath, 10.0); using (StreamWriter writer = new StreamWriter($"{ConfigSettings.SystemRules.DisputeMonitorPath}\\log.log", true)) { writer.AutoFlush = true; try { writer.WriteLine(); writer.WriteLine($"BEGIN Dispute MONITOR @ {DateTime.Now} ========================"); DisputeMonitor.Run(writer); writer.WriteLine(); writer.WriteLine($"END Dispute MONITOR @ {DateTime.Now} ========================"); } catch (Exception ex) { BaseMonitor.Error(writer, ex, "DisputeTimerCallback"); } } } catch (Exception ex) { BaseMonitor.Error(Writer, ex, "DisputeTimerCallback"); } // Reset Timer ConfigureTimers(Timers.DisputeMonitorTimer); }