using System; using System.Collections.Generic; using FSI.Lib.Tools.RoboSharp.Interfaces; namespace FSI.Lib.Tools.RoboSharp.Results { /// /// Results provided by the RoboCopy command. Includes the Log, Exit Code, and statistics parsed from the log. /// /// /// /// public class RoboCopyResults : IResults, ITimeSpan { internal RoboCopyResults() { } #region < Properties > /// public string Source { get; internal set; } /// public string Destination { get; internal set; } /// public string CommandOptions { get; internal set; } /// public string JobName { get; internal set; } /// /// All Errors that were generated by RoboCopy during the run. /// public ErrorEventArgs[] RoboCopyErrors{ get; internal set; } /// public RoboCopyExitStatus Status { get; internal set; } /// Information about number of Directories Copied, Skipped, Failed, etc. /// /// If the job was cancelled, or run without a Job Summary, this will attempt to provide approximate results based on the Process.StandardOutput from Robocopy.
/// Results should only be treated as accurate if .ExitCodeValue >= 0 and the job was run with = FALSE ///
public Statistic DirectoriesStatistic { get; internal set; } /// Information about number of Files Copied, Skipped, Failed, etc. /// /// If the job was cancelled, or run without a Job Summary, this will attempt to provide approximate results based on the Process.StandardOutput from Robocopy.
/// Results should only be treated as accurate if .ExitCodeValue >= 0 and the job was run with = FALSE ///
public Statistic FilesStatistic { get; internal set; } /// Information about number of Bytes processed. /// /// If the job was cancelled, or run without a Job Summary, this will attempt to provide approximate results based on the Process.StandardOutput from Robocopy.
/// Results should only be treated as accurate if .ExitCodeValue >= 0 and the job was run with = FALSE ///
public Statistic BytesStatistic { get; internal set; } /// public SpeedStatistic SpeedStatistic { get; internal set; } /// Output Text reported by RoboCopy public string[] LogLines { get; internal set; } /// Time the RoboCopy process was started public DateTime StartTime { get; internal set; } /// Time the RoboCopy process was completed / cancelled. public DateTime EndTime { get; internal set; } /// Length of Time the RoboCopy Process ran public TimeSpan TimeSpan { get; internal set; } #endregion #region < IResults > IStatistic IResults.BytesStatistic => BytesStatistic; IStatistic IResults.DirectoriesStatistic => DirectoriesStatistic; IStatistic IResults.FilesStatistic => FilesStatistic; #endregion /// /// Returns a string that represents the current object. /// /// /// A string that represents the current object. /// public override string ToString() { string str = $"ExitCode: {Status.ExitCode}, Directories: {DirectoriesStatistic?.Total.ToString() ?? "Unknown"}, Files: {FilesStatistic?.Total.ToString() ?? "Unknown"}, Bytes: {BytesStatistic?.Total.ToString() ?? "Unknown"}"; if (SpeedStatistic != null) { str += $", Speed: {SpeedStatistic.BytesPerSec} Bytes/sec"; } return str; } } }