public override void ConfigureTaskImplementation(AsyncTaskSequence sequence) { sequence.Add(() => s_logger.Info("Checking Database schema...")); sequence.Add(() => { try { Stopwatch.Start(); System.Environment.SetEnvironmentVariable("TMP", "C:\\Temp"); System.Environment.SetEnvironmentVariable("TEMP", "C:\\Temp"); DataVersionManager dvManager = new DataVersionManager(); dvManager.CurrentConnection = ConnectionManager.DefaultConnection; dvManager.Mode = VersioningStrategy.ByTick; dvManager.RegisterChangePlan(new ChangePlan_VersionOrigin()); dvManager.RegisterChangePlan(new ChangePlan_Version_1()); dvManager.GetPlan(new Version_1()).FinishedToUpgradeTo += LibraryInitializing_FinishToUpgradeTo_Version_1; dvManager.RegisterChangePlan(new ChangePlan_Version_2()); dvManager.RegisterChangePlan(new ChangePlan_Version_3()); dvManager.GetPlan(new Version_3()).FinishedToUpgradeTo += LibraryInitializing_FinishToUpgradeTo_Version_3; dvManager.RegisterChangePlan(new ChangePlan_Version_4()); dvManager.RegisterChangePlan(new ChangePlan_Version_5()); dvManager.GetPlan(new Version_5()).FinishedToUpgradeTo += LibraryInitializing_FinishedToUpgradeTo_Version_5; dvManager.FinishedToUpgradeTo += DvManager_FinishedToUpgradeTo; dvManager.UpgradeToTargetVersion(); Stopwatch.Stop(); s_logger.Info($"Completed to check Database schema. {Stopwatch.ElapsedMilliseconds}ms"); } catch (FailedOpeningDatabaseException) { throw; } catch (SQLiteException e) { s_logger.Error("Failed to check Database schema."); s_logger.Debug(e); throw; } finally { if (Stopwatch.IsRunning) { Stopwatch.Stop(); } } }); sequence.Add(() => { DirectoryNameParserManager.Load(); }); }
private void ManageAppDB() { DataVersionManager dvManager = new DataVersionManager(); dvManager.CurrentConnection = DataAccessManager.AppDao.CurrentConnection; dvManager.Mode = VersioningStrategy.ByTick; dvManager.RegisterChangePlan(new ChangePlan_AppDb_VersionOrigin()); dvManager.RegisterChangePlan(new ChangePlan_AppDb_Version_1()); dvManager.FinishedToUpgradeTo += DvManager_FinishedToUpgradeTo; dvManager.UpgradeToTargetVersion(); }