Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ErrorLogger"/> class.
 /// </summary>
 public ErrorLogger()
     : base()
 {            
     m_logToUI = DefaultLogToUI;
     m_logToFile = DefaultLogToFile;
     m_logToEmail = DefaultLogToEmail;
     m_logToEventLog = DefaultLogToEventLog;
     m_logToScreenshot = DefaultLogToScreenshot;
     m_logUserInfo = DefaultLogUserInfo;
     m_smtpServer = DefaultSmtpServer;
     m_contactName = DefaultContactName;
     m_contactEmail = DefaultContactEmail;
     m_contactPhone = DefaultContactPhone;
     m_persistSettings = DefaultPersistSettings;
     m_settingsCategory = DefaultSettingsCategory;
     m_handleUnhandledException = DefaultHandleUnhandledException;
     m_exitOnUnhandledException = DefaultExitOnUnhandledException;
     // Initialize delegate methods.
     m_errorTextMethod = GetErrorText;
     m_scopeTextMethod = GetScopeText;
     m_actionTextMethod = GetActionText;
     m_moreInfoTextMethod = GetMoreInfoText;
     // Initialize the error log file.
     m_errorLog = new LogFile();
     m_errorLog.FileName = "ErrorLog.txt";
     // Initialize all logger methods.
     m_loggers = new List<Action<Exception>>();
     m_loggers.Add(ExceptionToScreenshot);
     m_loggers.Add(ExceptionToEventLog);
     m_loggers.Add(ExceptionToEmail);
     m_loggers.Add(ExceptionToFile);
     m_loggers.Add(ExceptionToUI);
 }
Exemplo n.º 2
0
		/// <summary>
		/// Releases the unmanaged resources used by an instance of the <see cref="ServiceHelper" /> class and optionally releases the managed resources.
		/// </summary>
		/// <param name="disposing"><strong>true</strong> to release both managed and unmanaged resources; <strong>false</strong> to release only unmanaged resources.</param>
		protected override void Dispose(bool disposing)
		{
			if (!m_disposed)
			{
			    try
			    {			
				    if (disposing)
				    {
				        SaveSettings();

                        if (m_statusLog != null)
                        {
			                m_statusLog.LogException -= m_statusLog_LogException;
				            m_statusLog.Dispose();
                        }
                        m_statusLog = null;

                        if (m_scheduler != null)
                        {
			                m_scheduler.ScheduleDue -= m_scheduler_ScheduleDue;
				            m_scheduler.Dispose();
                        }
                        m_scheduler = null;

                        if (m_errorLogger != null)
                        {
				            m_errorLogger.Dispose();
                        }
                        m_errorLogger = null;

                        if (m_performanceMonitor != null)
			            {
				            m_performanceMonitor.Dispose();
			            }
                        m_performanceMonitor = null;

                        if (m_remoteCommandProcess != null)
                        {
                            m_remoteCommandProcess.ErrorDataReceived -= m_remoteCommandProcess_ErrorDataReceived;
                            m_remoteCommandProcess.OutputDataReceived -= m_remoteCommandProcess_OutputDataReceived;

                            if (!m_remoteCommandProcess.HasExited)
                                m_remoteCommandProcess.Kill();

                            m_remoteCommandProcess.Dispose();
                        }
                        m_remoteCommandProcess = null;

                        // Service processes are created and owned by remoting server, so we dispose them
                        if (m_processes != null)
                        {
                            foreach (ServiceProcess process in m_processes)
	                        {
                        		process.Dispose(); 
	                        }

                            m_processes.Clear();
                        }
                        m_processes = null;

                        // Detach any remoting server events, we don't own this component so we don't dispose it
                        RemotingServer = null;
				    }
                }
			    finally
			    {
			    	base.Dispose(disposing);    // Call base class Dispose().
				    m_disposed = true;          // Prevent duplicate dispose.
			    }
			}
		}
Exemplo n.º 3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ServiceHelper"/> class.
        /// </summary>
        public ServiceHelper()
            : base()
        {
            m_telnetSessionPassword = "******";
            m_logStatusUpdates = DefaultLogStatusUpdates;
            m_maxStatusUpdatesLength = DefaultMaxStatusUpdatesLength;
            m_maxStatusUpdatesFrequency = DefaultMaxStatusUpdatesFrequency;
            m_monitorServiceHealth = DefaultMonitorServiceHealth;
            m_healthMonitorInterval = DefaultHealthMonitorInterval;
            m_requestHistoryLimit = DefaultRequestHistoryLimit;
            m_supportTelnetSessions = DefaultSupportTelnetSessions;
            m_supportSystemCommands = DefaultSupportSystemCommands;
            m_secureRemoteInteractions = DefaultSecureRemoteInteractions;
            m_persistSettings = DefaultPersistSettings;
            m_settingsCategory = DefaultSettingsCategory;
            m_processes = new List<ServiceProcess>();
            m_remoteClients = new List<ClientInfo>();
            m_clientRequestHistory = new List<ClientRequestInfo>();
            m_serviceComponents = new List<object>();
            m_clientRequestHandlers = new List<ClientRequestHandler>();
            m_componentEnabledStates = new Dictionary<ISupportLifecycle, bool>();

            // Components
            m_statusUpdateQueue = ProcessQueue<StatusUpdate>.CreateSynchronousQueue(ProcessStatusUpdates);
            m_statusUpdateQueue.Name = "StatusUpdateQueue";
            m_statusUpdateQueue.ProcessException += StatusUpdateQueue_ProcessException;

            m_statusLog = new LogFile();
            m_statusLog.FileName = "StatusLog.txt";
            m_statusLog.SettingsCategory = "StatusLog";
            m_statusLog.LogException += StatusLog_LogException;

            m_processScheduler = new ScheduleManager();
            m_processScheduler.SettingsCategory = "ProcessScheduler";
            m_processScheduler.ScheduleDue += Scheduler_ScheduleDue;

            m_errorLogger = new ErrorLogger();
            m_errorLogger.ExitOnUnhandledException = false;
            m_errorLogger.SettingsCategory = "ErrorLogger";
            m_errorLogger.ErrorLog.SettingsCategory = "ErrorLog";
            m_errorLogger.LoggingException += ErrorLogger_LoggingException;
        }
Exemplo n.º 4
0
        public ServiceHelper()
		{
			m_logStatusUpdates = DefaultLogStatusUpdates;
			m_monitorServiceHealth = DefaultMonitorServiceHealth;
			m_requestHistoryLimit = DefaultRequestHistoryLimit;
			m_queryableSettingsCategories = DefaultQueryableSettingsCategories;
			m_persistSettings = DefaultPersistSettings;
			m_settingsCategory = DefaultSettingsCategoryName;
			m_processes = new List<ServiceProcess>();
			m_connectedClients = new List<ClientInfo>();
			m_clientRequestHistory = new List<ClientRequestInfo>();
			m_serviceComponents = new List<IServiceComponent>();
			m_clientRequestHandlers = new List<ClientRequestHandlerInfo>();
			m_pursip = "s3cur3";

			// Components
			m_statusLog = new LogFile();
			m_statusLog.LogException += m_statusLog_LogException;
			m_statusLog.FileName = "StatusLog.txt";
			m_statusLog.PersistSettings = true;
			m_statusLog.SettingsCategory = "StatusLog";

            m_scheduler = new ScheduleManager();
			m_scheduler.ScheduleDue += m_scheduler_ScheduleDue;
			m_scheduler.PersistSettings = true;
			m_scheduler.SettingsCategory = "Scheduler";

			m_errorLogger = new ErrorLogger();
			m_errorLogger.ExitOnUnhandledException = false;
			m_errorLogger.PersistSettings = true;
			m_errorLogger.SettingsCategory = "ErrorLogger";
		}