private void DoBackup() { try { IO.StReset(); if (Settings.ProgramBeforeBackup != "") { try { HelperFunctions.UpdateStatus(Translations.Get("StartingProgram") + Settings.ProgramBeforeBackup + "..."); Process Process = new Process(); Process.StartInfo.FileName = Settings.ProgramBeforeBackup; Process.StartInfo.Arguments = Settings.ArgumentsProgramBeforeBackup; if (Settings.ProgramBeforeBackupAdmin) Process.StartInfo.Verb = "runas"; Process.Start(); Process.WaitForExit(); } catch (Exception ex) { HelperFunctions.ShowError(ex); } } if (Settings.ShadowCopy) { HelperFunctions.UpdateStatus(Translations.Get("StartingVSS") + "..."); IO.CheckSourceDrives(); if (Service.StartVSS()) { if (!CreateSnapshot()) { Service.StopVSS(); _BackupFinished = true; return; } } else { _BackupFinished = true; return; } } Backup.Initialize(); for (int i = 0; i < Settings.Sources.Count; i++) { if (Settings.ShadowCopy && Settings.Sources[i].ShadowCopy) { Settings.Sources[i].Mount = Settings.Sources[i].SourcePath.Replace(Settings.Sources[i].Volume, GlobalData.ShadowCopyMounts[Settings.Sources[i].Volume]); } } bool Error = !Backup.DoBackup(); ClearFields(); if (_ShadowCopy != null) { HelperFunctions.UpdateStatus(Translations.Get("DeletingSnapshots") + "..."); _ShadowCopy.Dispose(); _ShadowCopy = null; HelperFunctions.UpdateStatus(Translations.Get("StoppingVSS") + "..."); Service.StopVSS(); } if (GlobalData.LogPath != null) // && System.IO.Directory.Exists(IO.GetBackupRoot())) { try { String LogFilePath = GlobalData.LogPath; if (!System.IO.Directory.Exists(LogFilePath)) { System.IO.Directory.CreateDirectory(LogFilePath); } LogFilePath += "\\RoboG-Log.txt"; //+ "-" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + ".txt"; if (System.IO.File.Exists(LogFilePath)) File.Delete(LogFilePath); HelperFunctions.WriteLog(Translations.Get("Done")); using (StreamWriter SW = new StreamWriter(LogFilePath, false)) { SW.Write(_Log.ToString()); } } catch (Exception ex) { HelperFunctions.ShowError(ex); } } IO.WriteErrorLog(); if (Settings.ProgramAfterBackup != "") { try { HelperFunctions.UpdateStatus(Translations.Get("StartingProgram") + Settings.ProgramAfterBackup + "..."); Process Process = new Process(); Process.StartInfo.FileName = Settings.ProgramAfterBackup; Process.StartInfo.Arguments = Settings.ArgumentsProgramAfterBackup; if (Settings.ProgramAfterBackupAdmin) Process.StartInfo.Verb = "runas"; Process.Start(); Process.WaitForExit(); } catch (Exception ex) { HelperFunctions.ShowError(ex); } } if (Error) HelperFunctions.UpdateStatus(Translations.Get("CompletedWithErrors")); else HelperFunctions.UpdateStatus(Translations.Get("BackupCompleted")); SetProgresssBarStyle(ProgressBarStyle.Blocks); SetProgressBarValue(100); if ((Error || IO.RoboCopyErrors.Count > 0) && !_Aborting) { if (Settings.ProgramOnError != "") { try { HelperFunctions.UpdateStatus(Translations.Get("StartingProgram") + Settings.ProgramOnError + "..."); Process Process = new Process(); Process.StartInfo.FileName = Settings.ProgramOnError; Process.StartInfo.Arguments = Settings.ArgumentsProgramOnError; if (Settings.ProgramOnErrorAdmin) Process.StartInfo.Verb = "runas"; Process.Start(); Process.WaitForExit(); } catch (Exception ex) { HelperFunctions.ShowError(ex); } } } _BackupFinished = true; //Don't delete or move. Necessary for this.Close() to work ClearEventHandlers(); if (Settings.AutoExitAlways || GlobalData.AutoExitCmd) { Application.Exit(); return; } SetBnCloseVisibility(true); if (IO.RoboCopyErrors.Count > 0 && !_Aborting) { SetBnErrorVisibility(true); frmErrorSummary ES = new frmErrorSummary(); ES.ShowDialog(); } else if (!Error && Settings.AutoExit) Application.Exit(); } catch (Exception ex) { HelperFunctions.ShowError(ex); } }
private void bnErrors_Click(object sender, EventArgs e) { try { frmErrorSummary ES = new frmErrorSummary(); ES.ShowDialog(); } catch (Exception ex) { HelperFunctions.ShowError(ex); } }