/// <summary> /// Creates an instance of <see cref="App"/> class. /// </summary> public App() { AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); m_errorLogger = new ErrorLogger(); m_defaultErrorText = m_errorLogger.ErrorTextMethod; m_errorLogger.ErrorTextMethod = ErrorText; m_errorLogger.ExitOnUnhandledException = false; m_errorLogger.HandleUnhandledException = true; m_errorLogger.LogToEmail = false; m_errorLogger.LogToEventLog = true; m_errorLogger.LogToFile = true; m_errorLogger.LogToScreenshot = true; m_errorLogger.LogToUI = true; m_errorLogger.Initialize(); m_title = AssemblyInfo.EntryAssembly.Title; // Setup default cache for measurement keys and associated Guid based signal ID's AdoDataConnection database = null; try { database = new AdoDataConnection(CommonFunctions.DefaultSettingsCategory); MeasurementKey.EstablishDefaultCache(database.Connection, database.AdapterType); } catch (Exception ex) { // First attempt to display a modal dialog will fail to block this // thread -- modal dialog displayed by the error logger will block now MessageBox.Show(ex.Message); // Log and display error, then exit application - manager must connect to database to continue m_errorLogger.Log(new InvalidOperationException(string.Format("{0} cannot connect to database: {1}", m_title, ex.Message), ex), true); } finally { if (database != null) database.Dispose(); } IsolatedStorageManager.WriteToIsolatedStorage("MirrorMode", false); }
/// <summary> /// Creates an instance of <see cref="App"/> class. /// </summary> public App() { AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); m_errorLogger = new ErrorLogger(); m_defaultErrorText = m_errorLogger.ErrorTextMethod; m_errorLogger.ErrorTextMethod = ErrorText; m_errorLogger.ExitOnUnhandledException = false; m_errorLogger.HandleUnhandledException = true; m_errorLogger.LogToEmail = false; m_errorLogger.LogToEventLog = true; m_errorLogger.LogToFile = true; m_errorLogger.LogToScreenshot = true; m_errorLogger.LogToUI = true; m_errorLogger.Initialize(); Version appVersion = AssemblyInfo.EntryAssembly.Version; m_title = AssemblyInfo.EntryAssembly.Title + " (v" + appVersion.Major + "." + appVersion.Minor + "." + appVersion.Build + ") "; }
public App() { AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); m_errorLogger = new ErrorLogger(); m_defaultErrorText = m_errorLogger.ErrorTextMethod; m_errorLogger.ErrorTextMethod = ErrorText; m_errorLogger.ExitOnUnhandledException = false; m_errorLogger.HandleUnhandledException = true; m_errorLogger.LogToEmail = false; m_errorLogger.LogToEventLog = true; m_errorLogger.LogToFile = true; m_errorLogger.LogToScreenshot = true; m_errorLogger.LogToUI = true; m_errorLogger.Initialize(); // When run from the installer the current directory may not be the directory where this application is running Directory.SetCurrentDirectory(FilePath.GetAbsolutePath("")); // Attempt to create an event log source for the SIEGate Manager for authentication logging. This needs to be done // here since the CSU runs with administrative privileges and the SIEGate Manager normally does not; also there is // a short system delay that exists before you can write to a new event log source after it is first created. try { string applicationName = "SIEGate"; // Create the event log source based on defined application name for SIEGate if it does not already exist if (!EventLog.SourceExists(applicationName)) EventLog.CreateEventSource(applicationName, "Application"); applicationName = "SIEGate Manager"; // Create the event log source based on defined application name for SIEGate Manager if it does not already exist if (!EventLog.SourceExists(applicationName)) EventLog.CreateEventSource(applicationName, "Application"); } catch (Exception ex) { m_errorLogger.Log(new InvalidOperationException(string.Format("Warning: failed to create or validate the event log source for the SIEGate Manager: {0}", ex.Message), ex), false); } }
/// <summary> /// Creates an instance of <see cref="App"/> class. /// </summary> public App() { bool mirrorMode = true; AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); m_errorLogger = new ErrorLogger(); m_defaultErrorText = m_errorLogger.ErrorTextMethod; m_errorLogger.ErrorTextMethod = ErrorText; m_errorLogger.ExitOnUnhandledException = false; m_errorLogger.HandleUnhandledException = true; m_errorLogger.LogToEmail = false; m_errorLogger.LogToEventLog = true; m_errorLogger.LogToFile = true; m_errorLogger.LogToScreenshot = true; m_errorLogger.LogToUI = true; m_errorLogger.Initialize(); m_title = AssemblyInfo.EntryAssembly.Title; // Setup default cache for measurement keys and associated Guid based signal ID's AdoDataConnection database = null; try { database = new AdoDataConnection(CommonFunctions.DefaultSettingsCategory); MeasurementKey.EstablishDefaultCache(database.Connection, database.AdapterType); } catch (Exception ex) { // First attempt to display a modal dialog will fail to block this // thread -- modal dialog displayed by the error logger will block now MessageBox.Show(ex.Message); // Log and display error, then exit application - manager must connect to database to continue m_errorLogger.Log(new InvalidOperationException(string.Format("{0} cannot connect to database: {1}", m_title, ex.Message), ex), true); } finally { if (database != null) database.Dispose(); } try { CategorizedSettingsElementCollection systemSettings = ConfigurationFile.Current.Settings["systemSettings"]; CategorizedSettingsElement mirrorModeSetting = systemSettings["MirrorMode"]; if ((object)mirrorModeSetting != null) mirrorMode = mirrorModeSetting.ValueAsBoolean(); } catch (Exception ex) { // First attempt to display a modal dialog will fail to block this // thread -- modal dialog displayed by the error logger will block now MessageBox.Show(ex.Message); // Log and display error, but continue on - if manager fails to load MirrorMode from the config file, it can just fall back on the default m_errorLogger.Log(new InvalidOperationException(string.Format("{0} cannot access mirror mode setting in configuration file - defaulting to true: {1}", m_title, ex.Message), ex)); } IsolatedStorageManager.WriteToIsolatedStorage("MirrorMode", mirrorMode); }