static void Main() { Program.IsRunning = true; Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //bring in settings from any previous version if (Settings.Default.NeedUpgrade) { //see http://stackoverflow.com/questions/3498561/net-applicationsettingsbase-should-i-call-upgrade-every-time-i-load Settings.Default.Upgrade(); Settings.Default.Reload(); Settings.Default.NeedUpgrade = false; Settings.Default.Save(); } SetUpErrorHandling(); #if DEBUG using (new Analytics("jBh7Qg4jw2nRFE8j8EY1FDipzin3RFIP", new UserInfo { UILanguageCode = Settings.Default.UserInterfaceLanguage }, true)) #else string feedbackSetting = Environment.GetEnvironmentVariable("FEEDBACK"); //default is to allow tracking var allowTracking = string.IsNullOrEmpty(feedbackSetting) || feedbackSetting.ToLower() == "yes" || feedbackSetting.ToLower() == "true"; using (new Analytics("WEyYj2BOnZAP9kplKmo2BDPvfyofbMZy", new UserInfo { UILanguageCode = Settings.Default.UserInterfaceLanguage }, allowTracking)) #endif { Logger.Init(); var oldPgBaseFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), kCompany, kOldProductName); if (Directory.Exists(oldPgBaseFolder) && !Directory.Exists(BaseDataFolder)) { Directory.Move(oldPgBaseFolder, BaseDataFolder); } DataMigrator.UpgradeToCurrentDataFormatVersion(); SampleProject.CreateSampleProjectIfNeeded(); SetUpLocalization(); // The following not only gets the location of the settings file; // it also detects corruption and deletes it if needed so we don't crash. string userConfigSettingsPath = GetUserConfigFilePath(); if ((Control.ModifierKeys & Keys.Shift) > 0 && !string.IsNullOrEmpty(userConfigSettingsPath)) { HandleDeleteUserSettings(userConfigSettingsPath); } Application.Run(new MainForm()); } }
static void Main(string[] args) { IsRunning = true; if (GetRunningGlyssenProcessCount() > 1) { ErrorReport.NotifyUserOfProblem("There is another copy of Glyssen already running. This instance of Glyssen will now shut down."); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //bring in settings from any previous version if (Settings.Default.NeedUpgrade) { //see http://stackoverflow.com/questions/3498561/net-applicationsettingsbase-should-i-call-upgrade-every-time-i-load Settings.Default.Upgrade(); Settings.Default.Reload(); Settings.Default.NeedUpgrade = false; Settings.Default.Save(); } SetUpErrorHandling(); #if DEBUG using (new Analytics("jBh7Qg4jw2nRFE8j8EY1FDipzin3RFIP", new UserInfo { UILanguageCode = Settings.Default.UserInterfaceLanguage })) #else string feedbackSetting = Environment.GetEnvironmentVariable("FEEDBACK"); //default is to allow tracking var allowTracking = string.IsNullOrEmpty(feedbackSetting) || feedbackSetting.ToLower() == "yes" || feedbackSetting.ToLower() == "true"; using (new Analytics("WEyYj2BOnZAP9kplKmo2BDPvfyofbMZy", new UserInfo { UILanguageCode = Settings.Default.UserInterfaceLanguage }, allowTracking)) #endif { Logger.Init(); var oldPgBaseFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), GlyssenInfo.kCompany, kOldProductName); var baseDataFolder = GlyssenInfo.BaseDataFolder; if (Directory.Exists(oldPgBaseFolder) && !Directory.Exists(baseDataFolder)) { Directory.Move(oldPgBaseFolder, baseDataFolder); } if (!Directory.Exists(baseDataFolder)) { // create the directory Directory.CreateDirectory(baseDataFolder); } // PG-433, 07 JAN 2016, PH: Set the permissions so everyone can read and write to this directory DirectoryUtilities.SetFullControl(baseDataFolder, false); DataMigrator.UpgradeToCurrentDataFormatVersion(); SampleProject.CreateSampleProjectIfNeeded(); SetUpLocalization(); // The following not only gets the location of the settings file; // it also detects corruption and deletes it if needed so we don't crash. string userConfigSettingsPath = GetUserConfigFilePath(); if ((Control.ModifierKeys & Keys.Shift) > 0 && !string.IsNullOrEmpty(userConfigSettingsPath)) { HandleDeleteUserSettings(userConfigSettingsPath); } Sldr.Initialize(); try { Application.Run(new MainForm(args)); } finally { Sldr.Cleanup(); } } }
static void Main(string[] args) { IsRunning = true; if (GetRunningGlyssenProcessCount() > 1) { ErrorReport.NotifyUserOfProblem("There is another copy of Glyssen already running. This instance of Glyssen will now shut down."); return; } Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //bring in settings from any previous version if (Settings.Default.NeedUpgrade) { //see http://stackoverflow.com/questions/3498561/net-applicationsettingsbase-should-i-call-upgrade-every-time-i-load Settings.Default.Upgrade(); Settings.Default.Reload(); Settings.Default.NeedUpgrade = false; Settings.Default.Save(); } SetUpErrorHandling(); UserInfo userInfo = new UserInfo { UILanguageCode = Settings.Default.UserInterfaceLanguage }; bool sldrIsInitialized = false; Logger.Init(); Trace.Listeners.Add(new LogFileTraceListener()); Alert.Implementation = new AlertImpl(); // Do this before calling Initialize, just in case Initialize tries to display an alert. if (ParatextInfo.IsParatextInstalled) { string userName = null; try { ParatextData.Initialize(); sldrIsInitialized = true; userName = RegistrationInfo.UserName; userInfo.Email = RegistrationInfo.EmailAddress; foreach (var errMsgInfo in CompatibleParatextProjectLoadErrors.Where(e => e.Reason == UnsupportedReason.Unspecified)) { _pendingExceptionsToReportToAnalytics.Add(errMsgInfo.Exception); } } catch (Exception fatalEx) when(fatalEx is FileLoadException || fatalEx is TypeInitializationException) { ErrorReport.ReportFatalException(fatalEx); } catch (Exception ex) { _pendingExceptionsToReportToAnalytics.Add(ex); } if (userName != null) { var split = userName.LastIndexOf(" ", StringComparison.Ordinal); if (split > 0) { userInfo.FirstName = userName.Substring(0, split); userInfo.LastName = userName.Substring(split + 1); } else { userInfo.LastName = userName; } } } // ENHANCE (PG-63): Implement something like this if we decide to give the user the option of manually // specifying the location of Paratext data files if the program isn’t actually installed. //else //{ // RegistrationInfo.Implementation = new GlyssenAnonymousRegistrationInfo(); // if (!String.IsNullOrWhiteSpace(Settings.Default.UserSpecifiedParatext8ProjectsDir) && // Directory.Exists(Settings.Default.UserSpecifiedParatext8ProjectsDir)) // { // try // { // ParatextData.Initialize(Settings.Default.UserSpecifiedParatext8ProjectsDir); // sldrIsInitialized = true; // } // catch (Exception ex) // { // _pendingExceptionsToReportToAnalytics.Add(ex); // Settings.Default.UserSpecifiedParatext8ProjectsDir = null; // } // } //} #if DEBUG using (new Analytics("jBh7Qg4jw2nRFE8j8EY1FDipzin3RFIP", userInfo)) #else //default is to allow tracking if this isn't set string feedbackSetting = Environment.GetEnvironmentVariable("FEEDBACK")?.ToLower(); var allowTracking = string.IsNullOrEmpty(feedbackSetting) || feedbackSetting == "yes" || feedbackSetting == "true"; using (new Analytics("WEyYj2BOnZAP9kplKmo2BDPvfyofbMZy", userInfo, allowTracking)) #endif { foreach (var exception in _pendingExceptionsToReportToAnalytics) { Analytics.ReportException(exception); } _pendingExceptionsToReportToAnalytics.Clear(); var oldPgBaseFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), GlyssenInfo.kCompany, kOldProductName); var baseDataFolder = GlyssenInfo.BaseDataFolder; if (Directory.Exists(oldPgBaseFolder) && !Directory.Exists(baseDataFolder)) { Directory.Move(oldPgBaseFolder, baseDataFolder); } if (!Directory.Exists(baseDataFolder)) { // create the directory Directory.CreateDirectory(baseDataFolder); } // PG-433, 07 JAN 2016, PH: Set the permissions so everyone can read and write to this directory DirectoryUtilities.SetFullControl(baseDataFolder, false); SetUpLocalization(); DataMigrator.UpgradeToCurrentDataFormatVersion(); SampleProject.CreateSampleProjectIfNeeded(); // The following not only gets the location of the settings file; // it also detects corruption and deletes it if needed so we don't crash. string userConfigSettingsPath = GetUserConfigFilePath(); if ((Control.ModifierKeys & Keys.Shift) > 0 && !string.IsNullOrEmpty(userConfigSettingsPath)) { HandleDeleteUserSettings(userConfigSettingsPath); } // This might also be needed if Glyssen and ParatextData use different versions of SIL.WritingSystems.dll if (!sldrIsInitialized) { Sldr.Initialize(); } try { Application.Run(new MainForm(args)); } finally { Sldr.Cleanup(); } } }