//public static Action<Exception> OnError; public static void OnError(Exception ex, string additional_info = null) { MessageBox.Show($"{ex.Message}.", "Erro", MessageBoxButton.OK, MessageBoxImage.Error); StaticLogger.WriteLine(ex); if (additional_info != null) { StaticLogger.WriteLine(additional_info); } }
public int Run(Action <string> outputCallback = null, Action <string> errorCallback = null) { StaticLogger.WriteLine("In Run for " + _exeName + " " + _arguments); var processInfo = new ProcessStartInfo { FileName = _exeName, Arguments = _arguments, CreateNoWindow = !_visibleProcess, UseShellExecute = _shareConsole, RedirectStandardError = _streamOutput, RedirectStandardInput = _streamOutput, RedirectStandardOutput = _streamOutput, WorkingDirectory = Directory.GetCurrentDirectory() }; Process process = null; try { process = Process.Start(processInfo); } catch (Win32Exception ex) { if (ex.Message == "The system cannot find the file specified") { throw new FileNotFoundException(ex.Message, ex); } throw ex; } if (_streamOutput) { if (outputCallback != null) { process.OutputDataReceived += (s, e) => outputCallback(e.Data); process.BeginOutputReadLine(); } if (errorCallback != null) { process.ErrorDataReceived += (s, e) => errorCallback(e.Data); process.BeginErrorReadLine(); } process.EnableRaisingEvents = true; } process.WaitForExit(); StaticLogger.WriteLine("Done with " + _exeName + " " + _arguments + ", with exitCode: " + process.ExitCode); return(process.ExitCode); }
public RunOutcome Run() { try { StaticLogger.WriteLine($"Starting step: {this._name}"); this._run(); StaticLogger.WriteLine($"Finished step: {this._name}"); return(RunOutcome.Succeeded); } catch (Exception e) { StaticLogger.WriteErrorLine($"Error in step: {this._name}, error: {e.ToString()}"); return(RunOutcome.Failed); } }
public IRun Run() { var run = new Run(); try { StaticLogger.WriteLine($"Starting step: {this._name}"); run.Start(); this._run(); run.End(); StaticLogger.WriteLine($"Finished step: {this._name}"); return(run); } catch (Exception e) { StaticLogger.WriteErrorLine($"Error in step: {this._name}, error: {e.ToString()}"); run.End(); return(new FaultedRun(run)); } }
public static void EmailFailedRun() { StaticLogger.WriteLine("In EmailFailedRun"); SendEmail($"{DeploySettings.AppName} Deployment Failed"); }
public static void EmailSuccessfulRun() { StaticLogger.WriteLine("In EmailSuccessfulRun"); SendEmail($"{DeploySettings.AppName} Deployment succeeded"); }