/// <summary> /// Reset the progress object if not null /// </summary> /// <param name="source"></param> public static void ResetProgress(this IProgressReportSource source) { if (ReferenceEquals(source.Progress, null) == false) { source.Progress.Reset(); } }
/// <summary> /// Check if the progress object's status is RunningRequestStop and raise an exception to interrupt /// running process if so. /// </summary> /// <param name="source"></param> public static void CheckProgressRequestStop(this IProgressReportSource source) { if (ReferenceEquals(source.Progress, null)) { return; } source.Progress.CheckRequestStop(); }
internal ProgressEventArgs(int progressId, DateTime startTime, IProgressReportSource source, string title, string details, ProgressEventArgsKind kind, ProgressEventArgsResult result) { ProgressId = progressId; StartTime = startTime; FinishTime = startTime; Source = source; Title = title; Details = details; Kind = kind; Result = result; }
/// <summary> /// Set the progress object's status to NotRunning if possible and return true if successful. /// If the progress object is null or has status NotRunning this method returns false /// </summary> /// <param name="source"></param> /// <returns></returns> public static bool SetProgressNotRunning(this IProgressReportSource source) { if (ReferenceEquals(source.Progress, null)) { return(false); } source.Progress.Status = ProgressComposerStatus.NotRunning; return(true); }
/// <summary> /// Try change the status of the progress object into RunningRequestStop if possible and return true /// if successful /// </summary> /// <param name="source"></param> /// <returns></returns> public static bool RequestProgressStop(this IProgressReportSource source) { if (ReferenceEquals(source.Progress, null)) { return(false); } source.Progress.RequestStop(); return(source.Progress.Status == ProgressComposerStatus.RunningRequestStop); }
/// <summary> /// Reports an error /// </summary> /// <param name="source"></param> /// <param name="error"></param> /// <returns>An ID of the progress event</returns> public static int ReportError(this IProgressReportSource source, Exception error) { if (ReferenceEquals(source.Progress, null) || source.Progress.Enabled == false) { return(-1); } var eventArgs = new ErrorEventArgs( source.Progress.NextProgressId++, DateTime.Now, error, source ); return(source.Progress.OnErrorEvent(eventArgs)); }
/// <summary> /// Reports the end of a process /// </summary> /// <param name="progressStartId"></param> /// <param name="source"></param> /// <param name="result"></param> /// <returns></returns> public static int ReportFinish(this IProgressReportSource source, int progressStartId, ProgressEventArgsResult result = ProgressEventArgsResult.Normal) { if (ReferenceEquals(source.Progress, null) || source.Progress.Enabled == false) { return(-1); } var eventArgs = new ProgressEventArgs( source.Progress.NextProgressId++, DateTime.Now, source, "", "", ProgressEventArgsKind.Finish, result ); return(source.Progress.OnProgressEvent(eventArgs, progressStartId)); }
/// <summary> /// Reports a warning /// </summary> /// <param name="source"></param> /// <param name="title"></param> /// <param name="result"></param> /// <returns></returns> public static int ReportWarning(this IProgressReportSource source, string title, ProgressEventArgsResult result = ProgressEventArgsResult.Normal) { if (ReferenceEquals(source.Progress, null) || source.Progress.Enabled == false) { return(-1); } var eventArgs = new ProgressEventArgs( source.Progress.NextProgressId++, DateTime.Now, source, title, "", ProgressEventArgsKind.Warning, result ); return(source.Progress.OnProgressEvent(eventArgs)); }
public static int ReportStart(this IProgressReportSource source, string title, Func <string> details) { if (ReferenceEquals(source.Progress, null) || source.Progress.Enabled == false) { return(-1); } var eventArgs = new ProgressEventArgs( source.Progress.NextProgressId++, DateTime.Now, source, title, details(), ProgressEventArgsKind.Start, ProgressEventArgsResult.Normal ); return(source.Progress.OnProgressEvent(eventArgs)); }
internal ErrorEventArgs(int progressId, DateTime startTime, Exception error, IProgressReportSource source, string title, string details) : base(progressId, startTime, source, title, details, ProgressEventArgsKind.Error, ProgressEventArgsResult.Normal) { Error = error; }
internal ErrorEventArgs(int progressId, DateTime startTime, Exception error, IProgressReportSource source) : base(progressId, startTime, source, "Error", error.ToString(), ProgressEventArgsKind.Error, ProgressEventArgsResult.Normal) { Error = error; }
/// <summary> /// True if the progress object is not null and has a status of RunningRequestStop /// </summary> /// <param name="source"></param> /// <returns></returns> public static bool IsProgressStatusRunningRequestStop(this IProgressReportSource source) { return (ReferenceEquals(source.Progress, null) == false && source.Progress.Status == ProgressComposerStatus.RunningRequestStop); }
public static int ReportNormal(this IProgressReportSource source, string title, Func <string> details, bool isSuccess) { return(ReportNormal(source, title, details, isSuccess ? ProgressEventArgsResult.Success : ProgressEventArgsResult.Failure)); }