private void HourlyTimerOnElapsed(object sender, ElapsedEventArgs elapsedEventArgs)
        {
            LogWriter.Info("Timer elapsed.. time to send event");
            MonitorService.Stop("Interval");
            bool isLoggedIn = true;

            Boolean.TryParse(XmlHelper.ReadSetting(VariableConstants.IsLoggedIn), out isLoggedIn);
            MonitorService.Initialize(isLoggedIn);
        }
 protected override void OnShutdown()
 {
     LogWriter.Info("Shutting down");
     MonitorService.Stop("ShutDown");
     if (myHost != null)
     {
         myHost.Close();
     }
     base.OnShutdown();
 }
 protected override void OnStop()
 {
     LogWriter.Info("Time to send hourly event with proper trigger");
     XmlHelper.UpdateSetting(VariableConstants.ServiceStopTime, DateTime.Now.ToString());
     MonitorService.Stop("close");
     if (myHost != null)
     {
         myHost.Close();
     }
 }
        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);
        }