Ejemplo n.º 1
0
        private void CheckDBVersion()
        {
            try
            {
                // DB最小版本為0;
                int    InitDBVersion      = 0;
                int    LocalDBVersion     = 0;
                int    ToDBVersion        = PaperLess_Emeeting.Properties.Settings.Default.NowDBVersion;
                string DB_FilePath        = Path.Combine(ClickOnceTool.GetDataPath(), PaperLess_Emeeting.Properties.Settings.Default.PaperLessDB_Path);
                string ConfigIni_FilePath = Path.Combine(ClickOnceTool.GetDataPath(), PaperLess_Emeeting.Properties.Settings.Default.ConfigIni_Path);

                if (File.Exists(ConfigIni_FilePath) == true)
                {
                    IniFileTool ini = new IniFileTool(ConfigIni_FilePath);
                    try
                    {
                        int.TryParse(ini.IniReadValue("DB", "Version"), out LocalDBVersion);
                    }
                    catch (Exception ex)
                    {
                        LogTool.Debug(ex);
                    }
                    bool Success = UpdateDBVersion(LocalDBVersion);
                    if (Success == true)
                    {
                        ini.IniWriteValue("DB", "Version", ToDBVersion.ToString());
                    }
                    else
                    {
                        throw new Exception("DB更新失敗!");
                    }
                }
                else
                {
                    //在嘗試更新一次,避免DB沒有更新到
                    UpdateDBVersion(LocalDBVersion);

                    using (var writer = new FileStream(ConfigIni_FilePath, FileMode.OpenOrCreate))
                    {
                    }
                    IniFileTool ini = new IniFileTool(ConfigIni_FilePath);
                    ini.IniWriteValue("DB", "Version", ToDBVersion.ToString());
                }
            }
            catch (Exception ex)
            {
                LogTool.Debug(ex);
            }
        }
Ejemplo n.º 2
0
 private void CheckDBVersion()
 {
     try
     {
         int result       = 0;
         int nowDBVersion = Settings.Default.NowDBVersion;
         Path.Combine(ClickOnceTool.GetDataPath(), Settings.Default.PaperLessDB_Path);
         string text = Path.Combine(ClickOnceTool.GetDataPath(), Settings.Default.ConfigIni_Path);
         if (File.Exists(text))
         {
             IniFileTool iniFileTool = new IniFileTool(text);
             try
             {
                 int.TryParse(iniFileTool.IniReadValue("DB", "Version"), out result);
             }
             catch (Exception ex)
             {
                 LogTool.Debug(ex);
             }
             if (!UpdateDBVersion(result))
             {
                 throw new Exception("DB更新失敗!");
             }
             iniFileTool.IniWriteValue("DB", "Version", nowDBVersion.ToString());
         }
         else
         {
             UpdateDBVersion(result);
             using (new FileStream(text, FileMode.OpenOrCreate))
             {
             }
             IniFileTool iniFileTool2 = new IniFileTool(text);
             iniFileTool2.IniWriteValue("DB", "Version", nowDBVersion.ToString());
         }
     }
     catch (Exception ex2)
     {
         LogTool.Debug(ex2);
     }
 }