예제 #1
0
        private void rebootTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                //Try to restart
                if (_monitorService.IsAlarmWindow() == false)
                {
                    Logger.WriteDebug(MethodBase.GetCurrentMethod(), "Try to reboot system");

                    RebootSystem();
                }
                else
                {
                    Logger.WriteDebug(MethodBase.GetCurrentMethod(), "Reboot not possible -> alarmwindow open");

                    //Restart timer
                    _rebootTimer.Interval = MsUntilMidnight();
                    _rebootTimer.Start();
                    Logger.WriteDebug(MethodBase.GetCurrentMethod(),
                                      string.Format("Time until reboot: " + TimeSpan.FromMilliseconds(_rebootTimer.Interval)
                                                    .ToString(@"hh\:mm\:ss", null)));
                }
            }
            catch (Exception ex)
            {
                ExceptionOccured.RaiseEvent(this, new ExceptionEventArgs
                {
                    Methode = MethodBase.GetCurrentMethod(),
                    Error   = ex
                });
            }
        }