예제 #1
0
 object ITaskProcessor.Process(ExecTask task) {
     ProcessBaseTask(task);
     task.ExecPath = ProcessString(task.ExecPath);
     if(task.Parameters != null) {
         for(int i = 0; i < task.Parameters.Length; i++) {
             task.Parameters[i] = ProcessString(task.Parameters[i]);
         }
     }
     return null;
 }
예제 #2
0
 object ITaskProcessor.Process(ExecTask task) {
     if(task == null) return null;
     try {
         ProcessStartInfo psi = task.Parameters == null ? new ProcessStartInfo(task.ExecPath) : new ProcessStartInfo(task.ExecPath, string.Join(" ", task.Parameters));
         psi.UseShellExecute = task.ShellStart;
         psi.RedirectStandardOutput = !task.ShellStart;
         Process process = Process.Start(psi);
         if(!task.ShellStart) {
             do {
                 Console.WriteLine(process.StandardOutput.ReadLine());
             } while(!process.StandardOutput.EndOfStream);
         }
         process.WaitForExit();
         if(process.ExitCode == 1) {
             return new InvalidOperationException(string.Format("Erros while execute: {0} {1}", task.ExecPath, string.Join(" ", task.Parameters)));
         }
         return null;
     } catch(Exception ex) {
         return ex;
     }           
 }