|
|
@@ -69,33 +69,51 @@ namespace BO.ProcessServer.Business.Workers
|
|
|
processInfo.FileName = scenario.ShellCommand;
|
|
|
processInfo.WindowStyle = scenario.RunWindowsStyle;
|
|
|
processInfo.WorkingDirectory = ctx.Configuration.System.ScenarioPathBase;
|
|
|
- processInfo.Arguments = TranslateArguments(scenario.ShellCommandArguments, ctx.InputFiles, document.PresetProcessProfile,document.PresetQuality, document.PresetWatermark,document.PresetTest);
|
|
|
+ processInfo.Arguments = TranslateArguments(scenario.ShellCommandArguments, ctx.InputFiles,
|
|
|
+ document.PresetProcessProfile, document.PresetQuality, document.PresetWatermark,
|
|
|
+ document.PresetTest);
|
|
|
+ processInfo.RedirectStandardOutput = true;
|
|
|
+ processInfo.RedirectStandardError = true;
|
|
|
ShellCommand = processInfo.FileName + " " + processInfo.Arguments;
|
|
|
- ctx.Process = Process.Start(processInfo);
|
|
|
- Log(LogSeverityEnum.Info, $"Starting process '{Name}.{ctx.Process?.ProcessName}' [Id:{ctx.Process?.Id}]: {ShellCommand}");
|
|
|
- if (ctx.Process != null)
|
|
|
- {
|
|
|
- ctx.Process.WaitForExit();
|
|
|
- Log(LogSeverityEnum.Info, $"End process '{Name}.{ctx.Process?.ProcessName}' [Id:{ctx.Process?.Id}]: Exit code {ctx.Process.ExitCode}");
|
|
|
|
|
|
- if (ctx.Process.ExitCode == scenario.ExitCodeSucc)
|
|
|
+ using (ctx.Process = Process.Start(processInfo))
|
|
|
+ {
|
|
|
+ var errors = await ctx.Process.StandardError.ReadToEndAsync();
|
|
|
+ var outputs = await ctx.Process.StandardOutput.ReadToEndAsync();
|
|
|
+ Log(LogSeverityEnum.Info,
|
|
|
+ $"Starting process '{Name}.{ctx.Process?.ProcessName}' [Id:{ctx.Process?.Id}]: {ShellCommand}");
|
|
|
+ if (ctx.Process != null)
|
|
|
{
|
|
|
- Status = ServerProcessStateEnum.Done;
|
|
|
+ ctx.Process.WaitForExit();
|
|
|
+ if (!string.IsNullOrEmpty(errors))
|
|
|
+ Log(LogSeverityEnum.Error, errors);
|
|
|
+ if (!string.IsNullOrEmpty(outputs))
|
|
|
+ Log(LogSeverityEnum.Info, outputs);
|
|
|
|
|
|
- }else if (ctx.Process.ExitCode == scenario.ExitCodeFail)
|
|
|
- {
|
|
|
- Status = ServerProcessStateEnum.FailExit;
|
|
|
+ Log(LogSeverityEnum.Info,
|
|
|
+ $"End process '{Name}.{ctx.Process?.ProcessName}' [Id:{ctx.Process?.Id}]: Exit code {ctx.Process.ExitCode}");
|
|
|
+
|
|
|
+ if (ctx.Process.ExitCode == scenario.ExitCodeSucc)
|
|
|
+ {
|
|
|
+ Status = ServerProcessStateEnum.Done;
|
|
|
+
|
|
|
+ }
|
|
|
+ else if (ctx.Process.ExitCode == scenario.ExitCodeFail)
|
|
|
+ {
|
|
|
+ Status = ServerProcessStateEnum.FailExit;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log(LogSeverityEnum.Warn,
|
|
|
+ $"Process '{Name}.{ctx.Process?.ProcessName}' has unhandled exitcode {ctx.Process.ExitCode}! Goes to fail.");
|
|
|
+ Status = ServerProcessStateEnum.FailInternal;
|
|
|
+ }
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- Log(LogSeverityEnum.Warn, $"Process '{Name}.{ctx.Process?.ProcessName}' has unhandled exitcode {ctx.Process.ExitCode}! Goes to fail.");
|
|
|
Status = ServerProcessStateEnum.FailInternal;
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
- {
|
|
|
- Status = ServerProcessStateEnum.FailInternal;
|
|
|
- }
|
|
|
}
|
|
|
Finished = DateTime.Now;
|
|
|
|