Example #1
0
 ///<summary>Returns false if the backup, repair, or the optimze failed.
 ///Set isSilent to true to suppress the failure message boxes.  However, progress windows will always be shown.</summary>
 public static bool BackupRepairAndOptimize(bool isSilent, BackupLocation backupLocation, bool isSecurityLogged = true)
 {
     if (!MakeABackup(isSilent, backupLocation, isSecurityLogged))
     {
         return(false);
     }
     try {
         ODProgress.ShowAction(() => DatabaseMaintenances.RepairAndOptimize(),
                               eventType: typeof(MiscDataEvent),
                               odEventType: ODEventType.MiscData);
     }
     catch (Exception ex) {           //MiscData.MakeABackup() could have thrown an exception.
         //Show the user that something what went wrong when not in silent mode.
         if (!isSilent)
         {
             if (ex.Message != "")
             {
                 MessageBox.Show(ex.Message);
             }
             MsgBox.Show("FormDatabaseMaintenance", "Optimize and Repair failed.");
         }
         return(false);
     }
     return(true);
 }
Example #2
0
        ///<summary>Returns false if the backup, repair, or the optimze failed.
        ///Set isSilent to true to suppress the failure message boxes.  However, progress windows will always be shown.</summary>
        public static bool BackupRepairAndOptimize(bool isSilent, BackupLocation backupLocation, bool isSecurityLogged = true)
        {
            if (!MakeABackup(isSilent, backupLocation, isSecurityLogged))
            {
                return(false);
            }
            //Create a thread that will show a window and then stay open until the closing phrase is thrown from this form.
            Action actionCloseRepairAndOptimizeProgress = ODProgressOld.ShowProgressStatus("RepairAndOptimizeProgress", null);

            try {
                DatabaseMaintenances.RepairAndOptimize();
                actionCloseRepairAndOptimizeProgress();
            }
            catch (Exception ex) {           //MiscData.MakeABackup() could have thrown an exception.
                actionCloseRepairAndOptimizeProgress();
                //Show the user that something what went wrong when not in silent mode.
                if (!isSilent)
                {
                    if (ex.Message != "")
                    {
                        MessageBox.Show(ex.Message);
                    }
                    MsgBox.Show("FormDatabaseMaintenance", "Optimize and Repair failed.");
                }
                return(false);
            }
            return(true);
        }