public override void Undo() { if (!DidCommandSucceed) { SendReport($"{ShortName} => Not restarting app pool {AppPoolName} on Undo because Do failed", ReportType.UndoneTaskWithSuccess); return; } if (AlreadyStoppedPrior) { SendReport($"{ShortName} => Not restarting app pool {AppPoolName} on Undo because it wasn't running before", ReportType.UndoneTaskWithSuccess); } else { SendReport($"{ShortName} => Attempting to restart app pool {AppPoolName} on Undo...", ReportType.Progress); var startArgs = CommandLineArguments.ToList(); startArgs[0] = "start"; using (CommandLineProcessRunner cmd = new CommandLineProcessRunner(Executable, true, string.Join(" ", startArgs))) { var exitCode = cmd.Run(outputStreamReceiver, errorStreamReceiver); if (exitCode == SuccessExitCode) { SendReport($"{ShortName} => Successfully restarted app pool {AppPoolName} on Undo", ReportType.UndoneTaskWithSuccess); } else { SendReport($"{ShortName} => Failed to restart app pool {AppPoolName} on Undo", ReportType.UndoneTaskWithFailure); } } } }
private int runCompression(string arguments, Action <string> outputStreamReceiver, Action <string> errorStreamReceiver) { using (var cmdLine = new CommandLineProcessRunner(ExeLocation, true, arguments)) { SendReport($"Running command {ExeLocation} {arguments} ...", ReportType.Progress); return(cmdLine.Run(outputStreamReceiver, errorStreamReceiver)); } }
private void runGitResetHard() { using (CommandLineProcessRunner cmd = new CommandLineProcessRunner(Executable, true, "reset --hard", GitTargetDirectory)) { SendReport($"Running git reset --hard on {GitTargetDirectory}...", ReportType.Progress); var exitCode = cmd.Run(OnOutputStreamDataIn, OnErrorStreamDataIn); DidCommandSucceed = exitCode == SuccessExitCode; } }
private bool isValidSvnRepo(string targetDirectory) { _svnInfoStreamOutput = new StringBuilder(); var startArgs = new List <string>(); startArgs.Add("info"); startArgs.Add($"{targetDirectory}"); using (CommandLineProcessRunner cmd = new CommandLineProcessRunner(Executable, true, string.Join(" ", startArgs))) { var exitCode = cmd.Run(svnInfoStreamReceiver, svnInfoStreamReceiver); var svnOutput = _svnInfoStreamOutput.ToString(); return(exitCode == SuccessExitCode && svnOutput.IndexOf("not a working copy", StringComparison.InvariantCultureIgnoreCase) < 0); } }
private bool isValidGitRepo() { _gitInfoStreamOutput = new StringBuilder(); var localGitRepo = getLocalRepoGitFile(); var startArgs = new List <string>(); startArgs.Add($"--git-dir={localGitRepo}"); startArgs.Add("status"); using (CommandLineProcessRunner cmd = new CommandLineProcessRunner(Executable, true, string.Join(" ", startArgs))) { var exitCode = cmd.Run(gitInfoStreamReceiver, gitInfoStreamReceiver); var gitOutput = _gitInfoStreamOutput.ToString(); return(exitCode == SuccessExitCode && gitOutput.IndexOf("not a git repository", StringComparison.InvariantCultureIgnoreCase) < 0); } }
public bool DoesAppPoolExist(string appPoolName = null) { _appPoolExistsOutput = new StringBuilder(); if (string.IsNullOrWhiteSpace(appPoolName)) { appPoolName = AppPoolName; } //appcmd.exe list apppool /name:training var startArgs = new List <string>(); startArgs.Add("list apppool"); startArgs.Add($"/name:{appPoolName}"); using (CommandLineProcessRunner cmd = new CommandLineProcessRunner(Executable, true, string.Join(" ", startArgs))) { var exitCode = cmd.Run(appPoolExistsStreamReceiver, appPoolExistsErrorStreamReceiver); // APPPOOL "training" (MgdVersion:v4.0,MgdMode:Integrated,state:Started) return(exitCode == SuccessExitCode && _appPoolExistsOutput.ToString().IndexOf(appPoolName) > -1); } }