Esempio n. 1
0
        public static void RebuildDatabase()
        {
            using (TinyMoneyDataContext context = new TinyMoneyDataContext())
            {
                DatabaseSchemaUpdater dataBaseUpdater = null;
                if (!context.DatabaseExists())
                {
                    context.CreateDatabase();
                    dataBaseUpdater = context.CreateDatabaseSchemaUpdater();
                    dataBaseUpdater.DatabaseSchemaVersion = DatabaseVersion.CurrentVersion;
                    dataBaseUpdater.Execute();
                }
                else
                {
                    dataBaseUpdater = context.CreateDatabaseSchemaUpdater();
                    int databaseSchemaVersion = dataBaseUpdater.DatabaseSchemaVersion;
                    if (dataBaseUpdater.DatabaseSchemaVersion != DatabaseVersion.CurrentVersion)
                    {
                        try
                        {
                            UpdateStructure(dataBaseUpdater);
                            failedToUpdate = false;
                        }
                        catch (System.Exception exception)
                        {
                            oldVersion = databaseSchemaVersion;
                            failedToUpdate = true;
                            throw exception;
                        }
                        finally
                        {

                        }
                    }
                }
                BudgetManager.Current.SaveCurrentMonthBudgetSettleReport(context, System.DateTime.Now);
            }
        }
Esempio n. 2
0
 public static void ForceRebuildDatabase()
 {
     GlobalIndicator.Instance.BusyForWork(LocalizedStrings.GetLanguageInfoByKey("RebuildingDatabase"));
     using (TinyMoneyDataContext context = new TinyMoneyDataContext())
     {
         DatabaseSchemaUpdater updater = null;
         if (context.DatabaseExists())
         {
             context.DeleteDatabase();
             context.CreateDatabase();
             updater = context.CreateDatabaseSchemaUpdater();
             updater.DatabaseSchemaVersion = DatabaseVersion.CurrentVersion;
             updater.Execute();
         }
     }
     ApplicationHelper.HasLoadDefaultCategorys = false;
     ViewModelLocator.instanceLoader.Reset("DataContext_AccountBookDataContext", new TinyMoneyDataContext());
     GlobalIndicator.Instance.WorkDone();
 }