예제 #1
0
        private static void ExecuteAction(ActionAfterPolicyCheck action)
        {
            if (action == null)
            {
                return;
            }

            WsapmLog.Log.WriteLine(string.Format(Resources.Wsapm_Core.ActionAfterPolicyCheckManager_ExecutingAction, action.ToString()), LogMode.Normal);

            switch (action.ActionTypeAfterPolicyCheck)
            {
            case ActionTypeAfterPolicyCheck.Standby:
                ShutdownManager.SetStandbyState();
                break;

            case ActionTypeAfterPolicyCheck.Hibernate:
                ShutdownManager.SetHibernateState();
                break;

            case ActionTypeAfterPolicyCheck.Shutdown:
                ShutdownManager.ShutDown();
                break;

            case ActionTypeAfterPolicyCheck.StartProgram:
                ExecuteProgram(action);
                break;

            default:
                break;
            }
        }
예제 #2
0
        /// <summary>
        /// Creates a new instance of WsapmManager.
        /// </summary>
        public WsapmManager()
        {
            this.settingsManager = new SettingsManager();
            LoadSettings();

            // Create managers.
            this.standbyManager  = new StandbyManager();
            this.wakeManager     = new WakeManager();
            this.pluginManager   = new PluginManager();
            this.shutdownManager = new ShutdownManager();

            this.temporaryUptimeManager = new TemporaryUptimeManager();

            this.lastWakeTime = null;

            this.settingsManager.SettingsChanged += settingsManager_SettingsChanged;
            this.temporaryUptimeManager.TemporaryUptimeChanged += TemporaryUptimeManager_TemporaryUptimeChanged;
        }
예제 #3
0
        /// <summary>
        /// Cleanup of the class.
        /// </summary>
        private void CleanUp()
        {
            try
            {
                StopResumeAutomaticTimer();

                EnableStandby();

                this.standbyManager = null;

                StopShutdownListening();
                this.shutdownManager = null;

                StopMonitoringTimer();
                this.monitoringTimer = null;

                if (this.wakeManager != null)
                {
                    this.wakeManager.WakeTimerCompleted -= wakeManager_WakeTimerCompleted;
                    this.wakeManager.CancelAllWakeTimers();
                }

                this.wakeManager   = null;
                this.pluginManager = null;

                WsapmLog.Log.WriteLine(Resources.Wsapm_Core.WsapmManager_StopMonitoringTimer, LogMode.Normal);

                if (this.settingsManager != null)
                {
                    this.settingsManager.SettingsChanged -= settingsManager_SettingsChanged;
                }

                this.currentSettings = null;
                this.settingsManager = null;
            }
            catch (Exception ex)
            {
                WriteErrorLog(ex);
            }
        }