/// <summary> /// Releases the unmanaged resources used by the <see cref="ServiceClientBase"/> object and optionally releases the managed resources. /// </summary> /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { if (!m_disposed) { try { if (disposing) { if ((object)m_clientHelper != null) { m_clientHelper.Dispose(); m_clientHelper = null; } if ((object)m_remotingClient != null) { m_remotingClient.Dispose(); m_remotingClient = null; } if ((object)m_errorLogger != null) { m_errorLogger.Dispose(); m_errorLogger = null; } } } finally { m_disposed = true; // Prevent duplicate dispose. } } }
/// <summary> /// Initializes the remoting client, client helper, and error logger. /// </summary> public void Initialize() { CategorizedSettingsElementCollection remotingClientSettings; try { remotingClientSettings = ConfigurationFile.Current.Settings["remotingClient"]; } catch { remotingClientSettings = null; } if ((object)remotingClientSettings != null) { if (remotingClientSettings.Cast<CategorizedSettingsElement>().Any(element => element.Name.Equals("EnabledSslProtocols", StringComparison.OrdinalIgnoreCase) && !element.Value.Equals("None", StringComparison.OrdinalIgnoreCase))) m_remotingClient = InitializeTlsClient(); else m_remotingClient = InitializeTcpClient(); } else { m_remotingClient = InitializeTlsClient(); } m_clientHelper = new ClientHelper(); m_clientHelper.PersistSettings = true; m_clientHelper.RemotingClient = m_remotingClient; m_clientHelper.Initialize(); m_errorLogger = new ErrorLogger(); m_errorLogger.ErrorLog.FileName = "ServiceClient.ErrorLog.txt"; m_errorLogger.LogToEventLog = false; m_errorLogger.LogToUI = true; m_errorLogger.PersistSettings = true; m_errorLogger.ErrorLog.Initialize(); m_errorLogger.Initialize(); }
static ErrorModule() { s_logger = new ErrorLogger(); s_logger.PersistSettings = true; s_logger.Initialize(); // Initialize error logger for use. }
/// <summary> /// Initializes a new instance of the <see cref="ServiceHelper"/> class. /// </summary> public ServiceHelper() { m_telnetSessionPassword = "******"; m_logStatusUpdates = DefaultLogStatusUpdates; m_maxStatusUpdatesLength = DefaultMaxStatusUpdatesLength; m_maxStatusUpdatesFrequency = DefaultMaxStatusUpdatesFrequency; m_monitorServiceHealth = DefaultMonitorServiceHealth; m_healthMonitorInterval = DefaultHealthMonitorInterval; m_requestHistoryLimit = DefaultRequestHistoryLimit; m_supportFileManagementCommands = DefaultSupportFileManagementCommands; m_supportTelnetSessions = DefaultSupportTelnetSessions; m_supportSystemCommands = DefaultSupportSystemCommands; m_secureRemoteInteractions = DefaultSecureRemoteInteractions; m_serializationFormat = DefaultSerializationFormat; 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>(); m_clientStatusUpdateLookup = new Dictionary<Guid, ClientStatusUpdateConfiguration>(); m_threadScheduler = new LogicalThreadScheduler(); m_threadScheduler.UnhandledException += LogicalThread_ProcessException; m_statusUpdateThread = m_threadScheduler.CreateThread(2); m_statusUpdateQueue = new List<StatusUpdate>(); // Components 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; }
/// <summary> /// Initializes the remoting client, client helper, and error logger. /// </summary> public void Initialize() { CategorizedSettingsElementCollection remotingClientSettings; string[] args; string filter; try { remotingClientSettings = ConfigurationFile.Current.Settings["remotingClient"]; } catch { remotingClientSettings = null; } if ((object)remotingClientSettings != null) { if (remotingClientSettings.Cast<CategorizedSettingsElement>().Any(element => element.Name.Equals("EnabledSslProtocols", StringComparison.OrdinalIgnoreCase) && !element.Value.Equals("None", StringComparison.OrdinalIgnoreCase))) m_remotingClient = InitializeTlsClient(); else m_remotingClient = InitializeTcpClient(); } else { m_remotingClient = InitializeTlsClient(); } args = Arguments.ToArgs(Environment.CommandLine); filter = Enumerable.Range(0, args.Length) .Where(index => args[index].StartsWith("--filter=", StringComparison.OrdinalIgnoreCase)) .Select(index => Regex.Replace(args[index], "^--filter=", "", RegexOptions.IgnoreCase)) .FirstOrDefault() ?? ClientHelper.DefaultStatusMessageFilter; m_clientHelper = new ClientHelper(); m_clientHelper.PersistSettings = true; m_clientHelper.RemotingClient = m_remotingClient; m_clientHelper.StatusMessageFilter = filter; m_clientHelper.Initialize(); m_errorLogger = new ErrorLogger(); m_errorLogger.ErrorLog.FileName = "ServiceClient.ErrorLog.txt"; m_errorLogger.LogToEventLog = false; m_errorLogger.LogToUI = true; m_errorLogger.PersistSettings = true; m_errorLogger.ErrorLog.Initialize(); m_errorLogger.Initialize(); }