protected bool UpgradeDatabase() { var versionBeforeUpgrades = CurrentDatabaseVersion; foreach (var version in DatabaseVersions.Where(version => CurrentDatabaseVersion < version.DbVersion).ToList()) { try { using (var transaction = new SQLiteTransaction(SharedConnection)) { version.Upgrade(transaction); transaction.Commit(); } System.Diagnostics.Debug.WriteLine("Database upgrade from {0} to {1} succeeded", CurrentDatabaseVersion, version.DbVersion); CurrentDatabaseVersion = version.DbVersion; } catch (Exception exception) { System.Diagnostics.Debug.WriteLine(string.Format("Database upgrade from {0} to {1} failed", CurrentDatabaseVersion, version.DbVersion), exception); } } bool hasUpgraded = versionBeforeUpgrades != CurrentDatabaseVersion; return(hasUpgraded); }
public void EnsureSeedData() { if (!DatabaseVersions.Any()) { DatabaseVersions.Add(new DatabaseVersion { Version = 0 }); SaveChanges(); } var currentDatabaseVersion = DatabaseVersions.Max(m => m.Version); foreach (var seeder in _seeders) { if (seeder.Version > currentDatabaseVersion) { seeder.Seed(this); DatabaseVersions.Add(new DatabaseVersion { Version = seeder.Version }); SaveChanges(); currentDatabaseVersion = seeder.Version; } } }
/// <summary> /// Check for old poorly named settings that don't directly match setting property names /// </summary> /// <param name="settings">The node that holds all the settings nodes</param> public void ApplyLegacySettings(List <XElement> settings) { for (int i = 0; i < settings.Count; i++) { XElement setting = settings[i]; switch (setting.Name.LocalName) { //put legacy names here to direct name change case "backupModFolder": BackupModFolder = bool.Parse(setting.Value); break; case "cleanInstallation": CleanInstallation = bool.Parse(setting.Value); break; case "forceManuel": ForceManuel = bool.Parse(setting.Value); break; case "saveLastConfig": SaveLastSelection = bool.Parse(setting.Value); break; case "saveUserData": SaveUserData = bool.Parse(setting.Value); break; case "EnableChildColorChangeLegacyView": EnableColorChangeLegacyView = bool.Parse(setting.Value); break; case "EnableChildColorChangeDefaultV2View": EnableColorChangeDefaultV2View = bool.Parse(setting.Value); break; case "clearCache": ClearCache = bool.Parse(setting.Value); break; case "deleteLogs": DeleteLogs = bool.Parse(setting.Value); break; case "modSelectionHeight": ModSelectionHeight = int.Parse(setting.Value); break; case "modSelectionWidth": ModSelectionWidth = int.Parse(setting.Value); break; case "previewX": PreviewX = int.Parse(setting.Value); break; case "previewY": PreviewY = int.Parse(setting.Value); break; case "language": Language = (Languages)int.Parse(setting.Value); break; case "SelectionView": ModSelectionView = (SelectionView)int.Parse(setting.Value); break; case "BetaApplication": if (CommonUtils.ParseBool(setting.Value, false)) { ApplicationDistroVersion = ApplicationVersions.Beta; } else { ApplicationDistroVersion = ApplicationVersions.Stable; } break; case "BetaDatabase": if (CommonUtils.ParseBool(setting.Value, false)) { DatabaseDistroVersion = DatabaseVersions.Beta; } else { DatabaseDistroVersion = DatabaseVersions.Stable; } break; case "SuperExtraction": MulticoreExtraction = CommonUtils.ParseBool(setting.Value, false); break; case "InstantExtraction": InstallWhileDownloading = CommonUtils.ParseBool(setting.Value, false); break; } } }
/// <summary> /// Check for old poorly named settings that don't directly match setting property names /// </summary> /// <param name="settings">The node that holds all the settings nodes</param> public static void ApplyOldSettings(XmlNodeList settings) { for (int i = 0; i < settings.Count; i++) { XmlNode setting = settings[i]; switch (setting.Name) { //put legacy names here to direct name change //TODO: super extraction and instant extraction? case "backupModFolder": BackupModFolder = bool.Parse(setting.InnerText); break; case "cleanInstallation": CleanInstallation = bool.Parse(setting.InnerText); break; case "forceManuel": ForceManuel = bool.Parse(setting.InnerText); break; case "saveLastConfig": SaveLastSelection = bool.Parse(setting.InnerText); break; case "saveUserData": SaveUserData = bool.Parse(setting.InnerText); break; case "EnableChildColorChangeLegacyView": EnableColorChangeLegacyView = bool.Parse(setting.InnerText); break; case "EnableChildColorChangeDefaultV2View": EnableColorChangeDefaultV2View = bool.Parse(setting.InnerText); break; case "clearCache": ClearCache = bool.Parse(setting.InnerText); break; case "deleteLogs": DeleteLogs = bool.Parse(setting.InnerText); break; case "modSelectionHeight": ModSelectionHeight = int.Parse(setting.InnerText); break; case "modSelectionWidth": ModSelectionWidth = int.Parse(setting.InnerText); break; case "previewX": PreviewX = int.Parse(setting.InnerText); break; case "previewY": PreviewY = int.Parse(setting.InnerText); break; case "language": Language = (Languages)int.Parse(setting.InnerText); break; case "SelectionView": ModSelectionView = (SelectionView)int.Parse(setting.InnerText); break; case "BetaApplication": ApplicationDistroVersion = ApplicationVersions.Beta; break; case "BetaDatabase": DatabaseDistroVersion = DatabaseVersions.Beta; break; } } }