protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus) { if (powerStatus.HasFlag(PowerBroadcastStatus.QuerySuspend)) { Outlet.Turn("off"); } if (powerStatus.HasFlag(PowerBroadcastStatus.ResumeSuspend)) { Outlet.Turn("on"); } return(base.OnPowerEvent(powerStatus)); }
/* * Task todo when Service is resumed/paused on suspend events * **/ protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus) { if (powerStatus.HasFlag(PowerBroadcastStatus.Suspend)) { // TODO on suspend event namazTimer.Stop(); eventLogger.WriteEntry("Azaan Service suspended on PowerStatus: " + powerStatus); } else if (powerStatus.HasFlag(PowerBroadcastStatus.ResumeAutomatic) || powerStatus.HasFlag(PowerBroadcastStatus.ResumeSuspend) || powerStatus.HasFlag(PowerBroadcastStatus.ResumeCritical)) { // TODO on resume events eventLogger.WriteEntry("Azaan Service resumed on PowerStatus: " + powerStatus); checkStatusFile(); checkTime(); } return(base.OnPowerEvent(powerStatus)); }
// 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); }
protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus) { if (powerStatus.HasFlag(PowerBroadcastStatus.ResumeSuspend)) { EventLog.WriteEntry("ResumeSuspend"); Connect(); return(true); } else if (powerStatus.HasFlag(PowerBroadcastStatus.Suspend)) { EventLog.WriteEntry("Suspend"); Disconnect(); return(true); } return(base.OnPowerEvent(powerStatus)); }
protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus) { LogWriter.Info("Power Mode change detected"); PowerStatus status = SystemInformation.PowerStatus; if (powerStatus == PowerBroadcastStatus.PowerStatusChange) { if (status.PowerLineStatus == PowerLineStatus.Online) { PowerService.HandlePlugIn(); } if (status.PowerLineStatus == PowerLineStatus.Offline) { PowerService.HandlePlugOut(); } } else if (powerStatus.HasFlag(PowerBroadcastStatus.ResumeSuspend)) { LogWriter.Info("Resume suspended coming back from sleep"); } else if (powerStatus.HasFlag(PowerBroadcastStatus.ResumeAutomatic)) { LogWriter.Info("Resume suspended coming back from sleep automatic"); MonitorService.Initialize(); } else if (powerStatus.HasFlag(PowerBroadcastStatus.QuerySuspend)) { MonitorService.Stop("Sleep"); LogWriter.Info("Going in sleeping mode"); LogWriter.Info("Query suspended going to sleep"); //MonitorService.Stop("Sleep"); } return(false); }
protected override bool OnPowerEvent(PowerBroadcastStatus powerStatus) { if (powerStatus.HasFlag(PowerBroadcastStatus.PowerStatusChange)) { WriteLog("OnPowerEvent - [Power changed]"); // Delete data DeleteFilesAndFolder(FolderWillDelete); // Delete user demo DeleteAccount("demo"); // enable Ethernet Enable_LocalAreaConnection(true); } else { WriteLog("OnPowerEvent - " + PowerBroadcastStatus.PowerStatusChange.ToString()); } return(base.OnPowerEvent(powerStatus)); }