protected override void OnStart(string[] args) { _timer1.AutoReset = true; _timer1.Enabled = true; SendMailService.WriteErrorLog("Service started"); SendMailService.SendEmail(ServiceProperty.Email, "Service Report", $"Service has been is started on {Environment.MachineName} on {DateTime.Now.ToLongTimeString()}."); }
protected override void OnStop() { _timer1.AutoReset = false; _timer1.Enabled = false; SendMailService.WriteErrorLog("Service stopped"); SendMailService.SendEmail(ServiceProperty.Email, "Service Report", $"Service on {Environment.MachineName} has been stopped on {DateTime.Now.ToLongTimeString()}."); }
// For Laptop protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus) { if (powerStatus.HasFlag(PowerBroadcastStatus.Suspend)) { SendMailService.WriteErrorLog("System has been shutdown."); SendMailService.SendEmail(ServiceProperty.Email, "Service Report", "Your system has been down on " + DateTime.Now.ToLongTimeString()); } return(true); }
private void ServiceTimer_Tick(object sender, ElapsedEventArgs e) { string msg = GetRssFeed(); if (!string.IsNullOrEmpty(msg)) { SendMailService.SendEmail(ServiceProperty.Email, "Today's Quote", msg); } if (GetCallType != 1) { return; } _timer1.Stop(); System.Threading.Thread.Sleep(1000000); SetTimer(); }
protected override void OnShutdown() { SendMailService.WriteErrorLog("System has been shutdown."); SendMailService.SendEmail(ServiceProperty.Email, "Service Report", $"{Environment.MachineName} went down on {DateTime.Now.ToLongTimeString()}"); }