Sicherung

This commit is contained in:
Maier Stephan SI
2023-01-02 04:33:49 +01:00
parent bea46135fd
commit d01747f75a
284 changed files with 6106 additions and 65112 deletions

View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
// Do Not change NameSpace here! -> Must be RoboSharp due to prior releases
namespace RoboSharp
{
/// <summary>
/// Describes an error that occured when generating the command
/// </summary>
public class CommandErrorEventArgs : EventArgs
{
/// <summary>
/// Error Description
/// </summary>
public string Error { get; }
/// <summary>
/// If this CommandErrorEventArgs object was created in response to an exception, that exception is captured here. <br/>
/// If no exception was thrown, this property will be null.
/// </summary>
public Exception Exception { get; }
/// <summary>
/// <inheritdoc cref="CommandErrorEventArgs"/>
/// </summary>
/// <param name="error"><inheritdoc cref="Error"/></param>
/// <param name="ex"><inheritdoc cref="Exception"/></param>
public CommandErrorEventArgs(string error, Exception ex)
{
Error = error;
this.Exception = ex;
}
/// <summary>
/// <inheritdoc cref="CommandErrorEventArgs"/>
/// </summary>
/// <param name="ex">Exception to data to pass to the event handler</param>
public CommandErrorEventArgs(Exception ex)
{
Error = ex.Message;
this.Exception = ex;
}
}
}

View File

@@ -0,0 +1,40 @@
using System;
// Do Not change NameSpace here! -> Must be RoboSharp due to prior releases
namespace RoboSharp
{
/// <summary>
/// Current File Progress reported as <see cref="double"/>
/// </summary>
public class CopyProgressEventArgs : EventArgs
{
/// <summary><inheritdoc cref="CopyProgressEventArgs"/></summary>
/// <param name="progress"><inheritdoc cref="CurrentFileProgress"/></param>
public CopyProgressEventArgs(double progress)
{
CurrentFileProgress = progress;
}
/// <summary><inheritdoc cref="CopyProgressEventArgs"/></summary>
/// <param name="progress"><inheritdoc cref="CurrentFileProgress"/></param>
/// <param name="currentFile"><inheritdoc cref="CurrentFile"/></param>
/// <param name="SourceDir"><inheritdoc cref="CurrentDirectory"/></param>
public CopyProgressEventArgs(double progress, ProcessedFileInfo currentFile, ProcessedFileInfo SourceDir)
{
CurrentFileProgress = progress;
CurrentFile = currentFile;
CurrentDirectory = SourceDir;
}
/// <summary>
/// Current File Progress Percentage
/// </summary>
public double CurrentFileProgress { get; internal set; }
/// <inheritdoc cref="ProcessedFileInfo"/>
public ProcessedFileInfo CurrentFile { get; internal set; }
/// <summary>Contains information about the Last Directory RoboCopy reported into the log. </summary>
public ProcessedFileInfo CurrentDirectory{ get; internal set; }
}
}

View File

@@ -0,0 +1,89 @@
using System;
using System.Linq;
using System.Text.RegularExpressions;
// Do Not change NameSpace here! -> Must be RoboSharp due to prior releases
namespace RoboSharp
{
/// <summary>
/// Information about an Error reported by the RoboCopy process
/// </summary>
public class ErrorEventArgs : EventArgs
{
/// <summary>
/// Error Code
/// </summary>
public string Error { get; }
/// <summary>
/// Error Description
/// </summary>
public string ErrorDescription { get; }
/// <summary>
/// Error Code
/// </summary>
public int ErrorCode { get; }
/// <summary>
/// Signed Error Code
/// </summary>
public string SignedErrorCode { get; }
/// <summary>
/// The File or Directory Path the Error refers to
/// </summary>
public string ErrorPath { get; }
/// <summary>
/// DateTime the error occurred
/// </summary>
public DateTime DateTime { get; }
/// <summary>
/// Concatenate the <see cref="Error"/> and <see cref="ErrorDescription"/> into a string seperated by an <see cref="Environment.NewLine"/>
/// </summary>
/// <returns></returns>
public override string ToString()
{
if (ErrorDescription.IsNullOrWhiteSpace())
return Error;
else
return String.Format("{0}{1}{2}", Error, Environment.NewLine, ErrorDescription);
}
/// <summary>
/// <inheritdoc cref="ErrorEventArgs"/>
/// </summary>
/// <param name="errorData"><inheritdoc cref="Error"/></param>
/// <param name="descripData"><inheritdoc cref="ErrorCode"/></param>
/// <param name="errTokenRegex">
/// Regex used to split the Error Code into its various parts. <br/>
/// Must have the following groups: Date, ErrCode, SignedErrCode, Descrip, Path
/// </param>
internal ErrorEventArgs(string errorData, string descripData, Regex errTokenRegex)
{
var match = errTokenRegex.Match(errorData);
var groups = match.Groups;
//Date
string dateStr = groups["Date"].Value;
if (DateTime.TryParse(dateStr, out var DT))
this.DateTime = DT;
else
this.DateTime = DateTime.Now;
//Path
ErrorPath = groups["Path"].Value;
//Error Code
ErrorCode = Convert.ToInt32(groups["ErrCode"].Value);
SignedErrorCode = groups["SignedErrCode"].Value;
//Error String
Error = errorData;
ErrorDescription = descripData;
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
// Do Not change NameSpace here! -> Must be RoboSharp due to prior releases
namespace RoboSharp
{
/// <summary>
/// <inheritdoc cref="ProcessedFileInfo"/>
/// </summary>
public class FileProcessedEventArgs : EventArgs
{
/// <inheritdoc cref="ProcessedFileInfo"/>
public ProcessedFileInfo ProcessedFile { get; set; }
/// <inheritdoc cref="EventArgs.EventArgs"/>
public FileProcessedEventArgs(ProcessedFileInfo file)
{
ProcessedFile = file;
}
}
}

View File

@@ -0,0 +1,54 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RoboSharp.Interfaces;
using RoboSharp.Results;
// Do Not change NameSpace here! -> Must be RoboSharp due to prior releases
namespace RoboSharp.EventArgObjects
{
/// <summary>
/// Event Args provided by IProgressEstimator objects to notify the UI it should refresh the stat values
/// </summary>
public class IProgressEstimatorUpdateEventArgs : EventArgs
{
/// <summary> Dummy Args with Values of 0 to perform final updates through ProgressEstimator without creating new args every time</summary>
internal static IProgressEstimatorUpdateEventArgs DummyArgs { get; } = new IProgressEstimatorUpdateEventArgs(null, null, null, null);
private IProgressEstimatorUpdateEventArgs() : base() { }
internal IProgressEstimatorUpdateEventArgs(IProgressEstimator estimator, IStatistic ByteChange, IStatistic FileChange, IStatistic DirChange) : base()
{
Estimator = estimator;
ValueChange_Bytes = ByteChange ?? Statistic.Default_Bytes;
ValueChange_Files = FileChange ?? Statistic.Default_Files;
ValueChange_Directories = DirChange ?? Statistic.Default_Dirs;
}
/// <summary>
/// <inheritdoc cref="Results.ProgressEstimator"/>
/// </summary>
private IProgressEstimator Estimator { get; }
/// <inheritdoc cref="IProgressEstimator.BytesStatistic"/>
public IStatistic BytesStatistic => Estimator?.BytesStatistic;
/// <inheritdoc cref="IProgressEstimator.FilesStatistic"/>
public IStatistic FilesStatistic => Estimator?.FilesStatistic;
/// <inheritdoc cref="IProgressEstimator.DirectoriesStatistic"/>
public IStatistic DirectoriesStatistic => Estimator?.DirectoriesStatistic;
/// <summary>IStatistic Object that shows how much was added to the { <see cref="BytesStatistic"/> } object during this UI Update</summary>
public IStatistic ValueChange_Bytes { get; }
/// <summary>IStatistic Object that shows how much was added to the { <see cref="FilesStatistic"/> } object during this UI Update</summary>
public IStatistic ValueChange_Files { get; }
/// <summary>IStatistic Object that shows how much was added to the { <see cref="DirectoriesStatistic"/> } object during this UI Update</summary>
public IStatistic ValueChange_Directories { get; }
}
}

View File

@@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RoboSharp.Interfaces;
// Do Not change NameSpace here! -> Must be RoboSharp due to prior releases
namespace RoboSharp.EventArgObjects
{
/// <summary>
/// Reports that a ProgressEstimator object is now available for binding
/// </summary>
public class ProgressEstimatorCreatedEventArgs : EventArgs
{
private ProgressEstimatorCreatedEventArgs() : base() { }
internal ProgressEstimatorCreatedEventArgs(IProgressEstimator estimator) : base()
{
ResultsEstimate = estimator;
}
/// <summary>
/// <inheritdoc cref="Results.ProgressEstimator"/>
/// </summary>
public IProgressEstimator ResultsEstimate { get; }
}
}

View File

@@ -0,0 +1,24 @@
using System;
using RoboSharp.Results;
using RoboSharp.Interfaces;
namespace RoboSharp.EventArgObjects
{
/// <summary> EventArgs for the <see cref="RoboCopyResultsList.ResultsListUpdated"/> delegate </summary>
public class ResultListUpdatedEventArgs : EventArgs
{
private ResultListUpdatedEventArgs() { }
/// <summary> Create the EventArgs for the <see cref="RoboCopyResultsList.ResultsListUpdated"/> delegate </summary>
/// <param name="list">Results list to present as an interface</param>
public ResultListUpdatedEventArgs(IRoboCopyResultsList list)
{
ResultsList = list;
}
/// <summary>
/// Read-Only interface to the List that has been updated.
/// </summary>
public IRoboCopyResultsList ResultsList { get; }
}
}

View File

@@ -0,0 +1,25 @@
using System;
using System.Security.Cryptography.X509Certificates;
using RoboSharp.EventArgObjects;
// Do Not change NameSpace here! -> Must be RoboSharp due to prior releases
namespace RoboSharp
{
/// <summary>
/// <inheritdoc cref="Results.RoboCopyResults"/>
/// </summary>
public class RoboCommandCompletedEventArgs : TimeSpanEventArgs
{
/// <summary>
/// Return the Results object
/// </summary>
/// <param name="results"></param>
internal RoboCommandCompletedEventArgs(Results.RoboCopyResults results) : base(results.StartTime, results.EndTime, results.TimeSpan)
{
this.Results = results;
}
/// <inheritdoc cref="Results.RoboCopyResults"/>
public Results.RoboCopyResults Results { get; }
}
}

View File

@@ -0,0 +1,32 @@
using RoboSharp.Interfaces;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RoboSharp.EventArgObjects
{
/// <summary>
/// EventArgs to declare when a RoboCommand process starts
/// </summary>
public class RoboQueueCommandStartedEventArgs : EventArgs
{
private RoboQueueCommandStartedEventArgs() : base() { }
internal RoboQueueCommandStartedEventArgs(IRoboCommand cmd) : base() { Command = cmd; StartTime = DateTime.Now; }
/// <summary>
/// Command that started.
/// </summary>
public IRoboCommand Command { get; }
/// <summary>
/// Returns TRUE if the command's <see cref="RoboSharp.Results.ProgressEstimator"/> is available for binding
/// </summary>
public bool ProgressEstimatorAvailable => Command.IsRunning;
/// <summary>
/// Local time the command started.
/// </summary>
public DateTime StartTime { get; }
}
}

View File

@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RoboSharp.Interfaces;
using RoboSharp.Results;
namespace RoboSharp.EventArgObjects
{
/// <summary>
/// EventArgs to declare when a RoboCommand process starts
/// </summary>
public class RoboQueueCompletedEventArgs : TimeSpanEventArgs
{
internal RoboQueueCompletedEventArgs(RoboQueueResults runResults, bool listOnlyRun) : base(runResults.StartTime, runResults.EndTime, runResults.TimeSpan)
{
RunResults = runResults;
CopyOperation = !listOnlyRun;
}
/// <summary>
/// RoboQueue Results Object
/// </summary>
public RoboQueueResults RunResults { get; }
/// <summary>
/// TRUE if this run was a COPY OPERATION, FALSE is the results were created after a <see cref="RoboQueue.StartAll_ListOnly(string, string, string)"/> call.
/// </summary>
public bool CopyOperation { get; }
}
}

View File

@@ -0,0 +1,110 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using RoboSharp.Results;
using RoboSharp.Interfaces;
namespace RoboSharp.EventArgObjects
{
/// <summary>
/// Interface helper for dealing with Statistic Event Args
/// </summary>
public interface IStatisticPropertyChangedEventArg
{
/// <inheritdoc cref="Statistic.Type"/>
Statistic.StatType StatType { get; }
/// <summary>TRUE if of type <see cref="StatChangedEventArg"/>. Otherwise false.</summary>
bool Is_StatChangedEventArg { get; }
/// <summary>TRUE if of type <see cref="StatisticPropertyChangedEventArgs"/>. Otherwise false.</summary>
bool Is_StatisticPropertyChangedEventArgs { get; }
/// <inheritdoc cref="PropertyChangedEventArgs.PropertyName"/>
string PropertyName { get; }
}
/// <summary>
/// EventArgs provided by <see cref="Statistic.StatChangedHandler"/> when any individual property gets modified.
/// </summary>
/// <remarks>
/// Under most circumstances, the 'PropertyName' property will detail which parameter has been updated. <br/>
/// When the Statistic object has multiple values change via a method call ( Reset / Add / Subtract methods ), then PropertyName will be String.Empty, indicating multiple values have changed. <br/>
/// If this is the case, then the <see cref="StatChangedEventArg.NewValue"/>, <see cref="StatChangedEventArg.OldValue"/>, and <see cref="StatChangedEventArg.Difference"/> will report the value from the sender's <see cref="Statistic.Total"/> property.
/// </remarks>
public class StatChangedEventArg : PropertyChangedEventArgs, IStatisticPropertyChangedEventArg
{
private StatChangedEventArg() : base("") { }
internal StatChangedEventArg(Statistic stat, long oldValue, long newValue, string PropertyName) : base(PropertyName)
{
Sender = stat;
StatType = stat.Type;
OldValue = oldValue;
NewValue = newValue;
}
/// <summary> This is a reference to the Statistic that generated the EventArg object </summary>
public IStatistic Sender { get; }
/// <inheritdoc cref="Statistic.Type"/>
public Statistic.StatType StatType { get; }
/// <summary> Old Value of the object </summary>
public long OldValue { get; }
/// <summary> Current Value of the object </summary>
public long NewValue { get; }
/// <summary>
/// Result of NewValue - OldValue
/// </summary>
public long Difference => NewValue - OldValue;
bool IStatisticPropertyChangedEventArg.Is_StatChangedEventArg => true;
bool IStatisticPropertyChangedEventArg.Is_StatisticPropertyChangedEventArgs => false;
}
/// <summary>
/// EventArgs provided by <see cref="Statistic.PropertyChanged"/>
/// </summary>
/// <remarks>
/// Under most circumstances, the 'PropertyName' property will detail which parameter has been updated. <br/>
/// When the Statistic object has multiple values change via a method call ( Reset / Add / Subtract methods ), then PropertyName will be String.Empty, indicating multiple values have changed. <br/>
/// If this is the case, then the <see cref="StatChangedEventArg.NewValue"/>, <see cref="StatChangedEventArg.OldValue"/>, and <see cref="StatChangedEventArg.Difference"/> will report the value from the sender's <see cref="Statistic.Total"/> property.
/// </remarks>
public class StatisticPropertyChangedEventArgs : PropertyChangedEventArgs, IStatisticPropertyChangedEventArg
{
private StatisticPropertyChangedEventArgs() : base("") { }
internal StatisticPropertyChangedEventArgs(Statistic stat, Statistic oldValue, string PropertyName) : base(PropertyName)
{
//Sender = stat;
StatType = stat.Type;
OldValue = oldValue;
NewValue = stat.Clone();
Lazydifference = new Lazy<Statistic>(() => Statistic.Subtract(NewValue, OldValue));
}
/// <inheritdoc cref="Statistic.Type"/>
public Statistic.StatType StatType { get; }
/// <summary> Old Value of the object </summary>
public IStatistic OldValue { get; }
/// <summary> Current Value of the object </summary>
public IStatistic NewValue { get; }
/// <summary>
/// Result of NewValue - OldValue
/// </summary>
public IStatistic Difference => Lazydifference.Value;
private Lazy<Statistic> Lazydifference;
bool IStatisticPropertyChangedEventArg.Is_StatChangedEventArg => false;
bool IStatisticPropertyChangedEventArg.Is_StatisticPropertyChangedEventArgs => true;
}
}

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace RoboSharp.EventArgObjects
{
/// <summary>
/// Provide a base class that includes a StartTime, EndTime and will calculate the TimeSpan in between
/// </summary>
public abstract class TimeSpanEventArgs : EventArgs, RoboSharp.Interfaces.ITimeSpan
{
private TimeSpanEventArgs() : base() { }
/// <summary>
/// Create New Args
/// </summary>
/// <param name="startTime"></param>
/// <param name="endTime"></param>
public TimeSpanEventArgs(DateTime startTime, DateTime endTime) : base()
{
StartTime = startTime;
EndTime = endTime;
TimeSpan = EndTime.Subtract(StartTime);
}
internal TimeSpanEventArgs(DateTime startTime, DateTime endTime, TimeSpan tSpan) : base()
{
StartTime = startTime;
EndTime = endTime;
TimeSpan = tSpan;
}
/// <summary>
/// Local time the command started.
/// </summary>
public virtual DateTime StartTime { get; }
/// <summary>
/// Local time the command stopped.
/// </summary>
public virtual DateTime EndTime { get; }
/// <summary>
/// Length of time the process took to run
/// </summary>
public virtual TimeSpan TimeSpan { get; }
}
}