コード例 #1
0
 public static SubprocessResult Packaging(PackageParms objPackageParms)
 {
     CommandArgs objCommandArgs = new CommandArgs();
     objCommandArgs.command = "cmd.exe";
     objCommandArgs.Args = GetPackageArgs(objPackageParms);
     return Subprocess.RunProgram(objCommandArgs);
 }
コード例 #2
0
 public SubprocessResult Deploying(DeployParms objDeployeParms)
 {
     CommandArgs objCommandArgs = new CommandArgs();
     objCommandArgs.command = "cmd.exe";
     objCommandArgs.Args = GetDeployArgs(objDeployeParms);
     return Subprocess.RunProgram(objCommandArgs);
 }
コード例 #3
0
 public static string GetTestRun_Click()
 {
     string[] testCasesFiles = Common.GetFiles(ProjectLoaction, "vsmdi");
     foreach (var item in testCasesFiles)
     {
         CommandArgs objCommandArgs = new CommandArgs();
         objCommandArgs.command = "";
         var result = Subprocess.RunProgram(objCommandArgs);
     }
     return "Success";
 }
コード例 #4
0
ファイル: Subprocess.cs プロジェクト: RKishore222/TestProject
        /// <summary>
        /// Executes a command-line program, specifying a maximum time to wait
        /// for it to complete.
        /// </summary>
        /// <param name="command">
        /// The path to the program executable.
        /// </param>
        /// <param name="args">
        /// The command-line arguments for the program.
        /// </param>
        /// <param name="timeout">
        /// The maximum time to wait for the subprocess to complete, in milliseconds.
        /// </param>
        /// <returns>
        /// A <see cref="SubprocessResult"/> containing the results of
        /// running the program.
        /// </returns>
        public static SubprocessResult RunProgram(CommandArgs objCommandArgs)
        {
            bool timedOut = false;
            ProcessStartInfo pinfo = new ProcessStartInfo(objCommandArgs.command);
            pinfo.Arguments = objCommandArgs.Args;
            pinfo.UseShellExecute = false;
            pinfo.CreateNoWindow = true;
            //pinfo.WorkingDirectory = ?
            pinfo.RedirectStandardOutput = true;
            pinfo.RedirectStandardError = true;
            Process subprocess = Process.Start(pinfo);

            ProcessStream processStream = new ProcessStream();
            try
            {
                processStream.Read(subprocess);

                subprocess.WaitForExit(objCommandArgs.TimeOut);
                processStream.Stop();
                if (!subprocess.HasExited)
                {
                    // OK, we waited until the timeout but it still didn't exit; just kill the process now
                    timedOut = true;
                    try
                    {
                        subprocess.Kill();
                        processStream.Stop();
                    }
                    catch { }
                    subprocess.WaitForExit();
                }
            }
            catch (Exception ex)
            {
                subprocess.Kill();
                processStream.Stop();
                throw ex;
            }
            finally
            {
                processStream.Stop();
            }

            TimeSpan duration = subprocess.ExitTime - subprocess.StartTime;
            float executionTime = (float)duration.TotalSeconds;
            SubprocessResult result = new SubprocessResult(
                executionTime,
                processStream.StandardOutput.Trim(),
                processStream.StandardError.Trim(),
                subprocess.ExitCode,
                timedOut);
            return result;
        }
コード例 #5
0
ファイル: TestCases.cs プロジェクト: RKishore222/TestProject
 public static void Run(CommandArgs objCommandArgs)
 {
     Subprocess.RunProgram(objCommandArgs);
 }