Esempio n. 1
0
 public static IProcess CreateProcess(this IProcessFactory factory, string fileName, string arguments, NetworkCredential credentials)
 {
     Invariant.ArgumentNotNull((object)factory, "factory");
     Invariant.ArgumentNotNullOrEmpty(fileName, "fileName");
     Invariant.ArgumentNotNull((object)credentials, "credentials");
     return(factory.CreateProcess(fileName, arguments, credentials.UserName, ProcessFactoryExtensions.SecurePassword(credentials.Password), credentials.Domain));
 }
Esempio n. 2
0
        public void Save()
        {
            Console.WriteLine("Saved");
            IProcess process = _processFactory.CreateProcess();

            process.Process();
        }
        public void Execute(string input, IRespondWithSuccessOrError <string, ErrorOutputTo> presenter)
        {
            var processStartInfo = _processPipeLineTask.CommandToExecute();

            using (var process = _processFactory.CreateProcess(processStartInfo))
            {
                process.Start();

                var outputTask = process.ReadStdOutToEndAsync();
                var errorTask  = process.ReadStdErrToEndAsync();

                process.WriteToStdInput(input);

                process.WaitForExit();

                var error = errorTask.Result;
                if (!string.IsNullOrWhiteSpace(error))
                {
                    var errorOutputTo = new ErrorOutputTo();
                    errorOutputTo.AddError(error);
                    presenter.Respond(errorOutputTo);
                    return;
                }
                presenter.Respond(outputTask.Result);
            }
        }
Esempio n. 4
0
 public static IProcess CreateProcess(this IProcessFactory factory, string fileName, string arguments, string userName, SecureString password, string domain)
 {
     Invariant.ArgumentNotNull((object)factory, "factory");
     Invariant.ArgumentNotNullOrEmpty(fileName, "fileName");
     return(factory.CreateProcess(new ProcessStartInfo(fileName, arguments)
     {
         UseShellExecute = false, UserName = userName, Password = password, Domain = domain
     }));
 }
Esempio n. 5
0
        public void Execute(string input, IRespondWithSuccessOrError <string, ErrorOutput> presenter)
        {
            var processStartInfo = _processPipeLineTask.CommandToExecute();

            try
            {
                using (var process = _processFactory.CreateProcess(processStartInfo))
                {
                    process.Start();

                    var readerTask = process.ReadStdOutToEndAsync();
                    var errorTask  = process.ReadStdErrToEndAsync();

                    process.WriteToStdInput(input);

                    process.WaitForExit(_processPipeLineTask.ProcessTimeout());

                    if (process.TimeoutOccured)
                    {
                        var errorOutput = new ErrorOutput();
                        errorOutput.AddError($"The process timed out after waiting [{_processPipeLineTask.ProcessTimeout()}] seconds.");
                        return;
                    }

                    var error = errorTask.Result;
                    if (HasError(error))
                    {
                        var errorOutput     = new ErrorOutput();
                        var trimedArugments = processStartInfo.Arguments.Substring(3);
                        errorOutput.AddError($"Failed to execute {trimedArugments}");
                        errorOutput.AddError(error);
                        presenter.Respond(errorOutput);
                        return;
                    }

                    presenter.Respond(readerTask.Result);
                }
            }
            catch (Exception e)
            {
                throw new Exception($"Failed to execute [{processStartInfo.FileName}] with [{processStartInfo.Arguments}]", e);
            }
        }
Esempio n. 6
0
 public override Task <bool> Start()
 {
     _process = _processFactory.CreateProcess(System.IO.Path.Combine(Path, _appConfig.ExeName),
                                              _appConfig.MonitorInitialization, _appConfig.MonitorHealth, _appConfig.GracefulShutdown);
     return(StartProcess(_process, _appConfig.ExeArgs));
 }
Esempio n. 7
0
 public static IProcess CreateProcess(this IProcessFactory factory, string fileName)
 {
     return(factory.CreateProcess(new ProcessStartInfo(fileName)));
 }
Esempio n. 8
0
 public static IProcess CreateProcess(this IProcessFactory factory, string fileName, NetworkCredential credentials)
 {
     return(factory.CreateProcess(fileName, (string)null, credentials));
 }
Esempio n. 9
0
 public static IProcess CreateProcess(this IProcessFactory factory, string fileName, string userName, SecureString password, string domain)
 {
     return(factory.CreateProcess(fileName, (string)null, userName, password, domain));
 }
Esempio n. 10
0
 public override Task <bool> Start()
 {
     _process = _processFactory.CreateProcess(System.IO.Path.Combine(Path, _appConfig.ExeName), _appConfig.ExeArgs);
     return(StartProcess(_process));
 }