private static void LoadUpdates() { Exception exception; try { using (AvtoritetEntities entities = new AvtoritetEntities()) { //if (!(entities.Database.Connection.State == ConnectionState.Closed)) //{ int? settingVersion = entities.SettingUpdate.FirstOrDefault().SettingVersion; Version version = new Version(entities.VersionLog.FirstOrDefault().Value) , version2 = new Version(JsonConvert.DeserializeObject <VersionEntity>(FileHelper.OpenFile("Version.json")).Version); if (version > version2) { try { } catch (Exception exception1) { exception = exception1; ErrorLogHelper.AddErrorInLog("LoadUpdates()", exception.Message + " | " + exception.StackTrace); } } if (!System.IO.File.Exists("settingver.txt")) { System.IO.File.WriteAllText("settingver.txt", "1"); } int num = int.Parse(System.IO.File.ReadAllText("settingver.txt")); int?nullable2 = settingVersion; int num2 = num; if ((nullable2.GetValueOrDefault() > num2) && (nullable2.HasValue == true)) { launcherSettings = new SettingsFactory(categoryEventHandler).DownloadSettings(true, true); System.IO.File.WriteAllText("settingver.txt", settingVersion.ToString()); HaveNewUpdate = true; } //} //else //ErrorLogHelper.AddErrorInLog("Обновление приложения - LoadUpdates() - ...", string.Format("Состояние БД={0}", entities.Database.Connection.State.ToString())); } } catch (Exception exception2) { exception = exception2; ErrorLogHelper.AddErrorInLog("Обновление приложения - LoadUpdates()", exception.Message + " | " + exception.StackTrace); MessageBox.Show(exception.Message + " | " + exception.StackTrace); } }
private static void LoadUpdates() { string nameFileSettingVersion = string.Empty , nameFileAppVersion = string.Empty; Exception exception; try { nameFileSettingVersion = new File(ConfigurationManager.AppSettings["FileSettingVersion"]).Name; nameFileAppVersion = new File(ConfigurationManager.AppSettings["FileAppVersion"]).Name; if ((string.IsNullOrWhiteSpace(nameFileSettingVersion) == false) && (string.IsNullOrWhiteSpace(nameFileAppVersion) == false)) { using (AvtoritetEntities entities = new AvtoritetEntities()) { //if (!(entities.Database.Connection.State == ConnectionState.Closed)) //{ Version version = new Version(entities.VersionLog.FirstOrDefault().Value) , version2 = new Version(JsonConvert.DeserializeObject <VersionEntity>(FileHelper.OpenFile(nameFileAppVersion)).Version) , version3 = new Version(FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).ProductVersion); if (version > version2) { try { } catch (Exception exception1) { exception = exception1; ErrorLogHelper.AddErrorInLog("LoadUpdates()", string.Format("{0} | {1}", exception.Message, exception.StackTrace)); } } else { ; } if (!System.IO.File.Exists(nameFileSettingVersion)) { System.IO.File.WriteAllText(nameFileSettingVersion, "1"); } else { ; } int?settingVersion = entities.SettingUpdate.FirstOrDefault().SettingVersion; int?nullable2 = settingVersion; int num = int.Parse(System.IO.File.ReadAllText(nameFileSettingVersion)); int num2 = num; if ((nullable2.GetValueOrDefault() > num2) && (nullable2.HasValue == true)) { launcherSettings = new SettingsFactory(categoryEventHandler).DownloadSettings(true, true); System.IO.File.WriteAllText(nameFileSettingVersion, settingVersion.ToString()); HaveNewUpdate = true; } else { ; } //} //else //ErrorLogHelper.AddErrorInLog("Обновление приложения - LoadUpdates() - ...", string.Format("Состояние БД={0}", entities.Database.Connection.State.ToString())); } } else { ErrorLogHelper.AddErrorInLog("Обновление приложения - LoadUpdates() - ...", string.Format("Неизвестна версия приложения или версия конфигурация БД")); } ; } catch (Exception exception2) { exception = exception2; ErrorLogHelper.AddErrorInLog("Обновление приложения - LoadUpdates()", string.Format("{0} | {1}", exception.Message, exception.StackTrace)); MessageBox.Show(string.Format("{0}{1}{2}", Environment.NewLine, exception.Message, exception.StackTrace)); } }