private void SimulationProcess_Exited(object sender, EventArgs e) { _status.IsAbortingSupported = false; bool aborted = (_process.ExitCode == -1 || IsFinished); // alert if Robocopy could not be started normally bool fatalError = (!aborted && _process.IsAnyExitFlagSet(RobocopyExitCodes.FatalError)); if (fatalError) { Alert("A fatal Robocopy error has occurred.", MessageBoxIcon.Error); } if (aborted || fatalError) { Finish(false); return; } // prompt the user to commit the pending changes using (var dialog = new GUI.SimulationResultDialog(_process)) { if (dialog.ShowDialog() != DialogResult.OK) { Finish(false); return; } } _simulationProcessOutputLinesCount = _process.Output.Count; _process.Dispose(); _process = null; LaunchActualOperation(); }
/// <summary>Logs a Robocopy run.</summary> /// <param name="process">Terminated Robocopy process.</param> public static LogEntry LogRun(string taskGuid, RobocopyProcess process, string sourceFolder, string destinationFolder, bool updateLastSuccessTimeStamp) { if (string.IsNullOrEmpty(taskGuid)) { throw new ArgumentNullException("taskGuid"); } if (process == null) { throw new ArgumentNullException("process"); } if (string.IsNullOrEmpty(sourceFolder)) { throw new ArgumentNullException("sourceFolder"); } if (string.IsNullOrEmpty(destinationFolder)) { throw new ArgumentNullException("destinationFolder"); } EventLogEntryType type; string messageFormat; if (process.ExitCode == -1) { type = EventLogEntryType.Error; messageFormat = "Operation aborted while mirroring {0} to {1}."; } else if (process.ExitCode == 0) { type = EventLogEntryType.Information; messageFormat = "Already in sync: {0} and {1}"; } else if (process.IsAnyExitFlagSet(RobocopyExitCodes.FatalError)) { type = EventLogEntryType.Error; messageFormat = "A fatal error occurred while trying to mirror {0} to {1}."; } else if (process.IsAnyExitFlagSet(RobocopyExitCodes.CopyErrors)) { type = EventLogEntryType.Error; messageFormat = "Some items could not be mirrored from {0} to {1}."; } else if (process.IsAnyExitFlagSet(RobocopyExitCodes.MismatchedItems)) { type = EventLogEntryType.Warning; messageFormat = "Some file <-> folder mismatches while mirroring {0} to {1}."; } else { type = EventLogEntryType.Information; messageFormat = "Success: {0} mirrored to {1}"; } string message = string.Format(messageFormat, PathHelper.Quote(sourceFolder), PathHelper.Quote(destinationFolder)); return(WriteEntry(taskGuid, type, message, process.FullOutput, updateLastSuccessTimeStamp)); }