Beispiel #1
0
 private void butOptimize_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show(Lan.g("FormDatabaseMaintenance", "This tool will backup, optimize, and repair all tables.") + "\r\n" + Lan.g("FormDatabaseMaintenance", "Continue?")
                         , Lan.g("FormDatabaseMaintenance", "Backup Optimize Repair")
                         , MessageBoxButtons.OKCancel) != DialogResult.OK)
     {
         return;
     }
     Cursor       = Cursors.WaitCursor;
     textLog.Text = DateTime.Now.ToString() + "\r\n";
     try {
         DatabaseMaintenance.BackupRepairAndOptimize();
     }
     catch (Exception ex) {
         if (ex.Message != "")
         {
             textLog.Text += ex.Message + "\r\n";
         }
         textLog.Text += Lan.g("FormDatabaseMaintenance", "Backup failed.  Your database has not been altered.") + "\r\n";
     }
     textLog.Text += Lan.g("FormDatabaseMaintenance", "Optimization Done");
     SaveLogToFile();
     Cursor = Cursors.Default;
 }
Beispiel #2
0
        ///<summary>This ONLY runs when first opening the program.  Gets run early in the sequence. Returns false if the program should exit.</summary>
        public static bool CheckMySqlVersion()
        {
            if (DataConnection.DBtype != DatabaseType.MySql)
            {
                return(true);
            }
            bool   hasBackup    = false;
            string thisVersion  = MiscData.GetMySqlVersion();
            float  floatVersion = PIn.Float(thisVersion.Substring(0, 3));

            if (floatVersion < 5.0f)
            {
                //We will force users to upgrade to 5.0, but not yet to 5.5
                MessageBox.Show(Lan.g("Prefs", "Your version of MySQL won't work with this program") + ": " + thisVersion
                                + ".  " + Lan.g("Prefs", "You should upgrade to MySQL 5.0 using the installer on our website."));
                Application.Exit();
                return(false);
            }
            if (!PrefC.ContainsKey("MySqlVersion"))             //db has not yet been updated to store this pref
            //We're going to skip this.  We will recommend that people first upgrade OD, then MySQL, so this won't be an issue.
            {
            }
            else if (Prefs.UpdateString(PrefName.MySqlVersion, floatVersion.ToString("f1")))
            {
                if (!MsgBox.Show("Prefs", MsgBoxButtons.OKCancel, "Tables will now be backed up, optimized, and repaired.  This will take a minute or two.  Continue?"))
                {
                    Application.Exit();
                    return(false);
                }
                try {
                    DatabaseMaintenance.BackupRepairAndOptimize();
                    hasBackup = true;
                }
                catch (Exception e) {
                    if (e.Message != "")
                    {
                        MessageBox.Show(e.Message);
                    }
                    MsgBox.Show("Prefs", "Backup failed. Your database has not been altered.");
                    Application.Exit();
                    return(false);                   //but this should never happen
                }
            }
            if (PrefC.ContainsKey("DatabaseConvertedForMySql41"))
            {
                return(true);               //already converted
            }
            if (!MsgBox.Show("Prefs", true, "Your database will now be converted for use with MySQL 4.1."))
            {
                Application.Exit();
                return(false);
            }
            //ClassConvertDatabase CCD=new ClassConvertDatabase();
            try {
                if (!hasBackup)                 //A backup could have been made if the tables were optimized and repaired above.
                {
                    MiscData.MakeABackup();
                }
            }
            catch (Exception e) {
                if (e.Message != "")
                {
                    MessageBox.Show(e.Message);
                }
                MsgBox.Show("Prefs", "Backup failed. Your database has not been altered.");
                Application.Exit();
                return(false);               //but this should never happen
            }
            MessageBox.Show("Backup performed");
            Prefs.ConvertToMySqlVersion41();
            MessageBox.Show("converted");
            //Refresh();
            return(true);
        }