|
@@ -49,6 +49,10 @@ namespace BO.ProcessServer.Business.Workers
|
|
|
Status = ServerProcessStateEnum.Running;
|
|
Status = ServerProcessStateEnum.Running;
|
|
|
Started = DateTime.Now;
|
|
Started = DateTime.Now;
|
|
|
|
|
|
|
|
|
|
+ var processName = string.Empty;
|
|
|
|
|
+ var processId = 0;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
// get document metadata
|
|
// get document metadata
|
|
|
var document = await ctx.Connection.GetDocumentInfoAsync(ctx.DocumentId);
|
|
var document = await ctx.Connection.GetDocumentInfoAsync(ctx.DocumentId);
|
|
|
|
|
|
|
@@ -66,9 +70,9 @@ namespace BO.ProcessServer.Business.Workers
|
|
|
{
|
|
{
|
|
|
// scenario exists
|
|
// scenario exists
|
|
|
var processInfo = new ProcessStartInfo();
|
|
var processInfo = new ProcessStartInfo();
|
|
|
- processInfo.FileName = scenario.ShellCommand;
|
|
|
|
|
processInfo.WindowStyle = scenario.RunWindowsStyle;
|
|
processInfo.WindowStyle = scenario.RunWindowsStyle;
|
|
|
- processInfo.WorkingDirectory = ctx.Configuration.System.ScenarioPathBase;
|
|
|
|
|
|
|
+ processInfo.WorkingDirectory = TranslatePath(ctx.Configuration.System.ScenarioPathBase);
|
|
|
|
|
+ processInfo.FileName = _fileSystem.Path.Combine(processInfo.WorkingDirectory, scenario.ShellCommand);
|
|
|
processInfo.Arguments = TranslateArguments(scenario.ShellCommandArguments, ctx.InputFiles,
|
|
processInfo.Arguments = TranslateArguments(scenario.ShellCommandArguments, ctx.InputFiles,
|
|
|
document.PresetProcessProfile, document.PresetQuality, document.PresetWatermark,
|
|
document.PresetProcessProfile, document.PresetQuality, document.PresetWatermark,
|
|
|
document.PresetTest);
|
|
document.PresetTest);
|
|
@@ -78,10 +82,12 @@ namespace BO.ProcessServer.Business.Workers
|
|
|
|
|
|
|
|
using (ctx.Process = Process.Start(processInfo))
|
|
using (ctx.Process = Process.Start(processInfo))
|
|
|
{
|
|
{
|
|
|
- var errors = await ctx.Process.StandardError.ReadToEndAsync();
|
|
|
|
|
- var outputs = await ctx.Process.StandardOutput.ReadToEndAsync();
|
|
|
|
|
|
|
+ processName = "process";
|
|
|
|
|
+ processId = ctx.Process?.Id ?? 0;
|
|
|
|
|
+ var errors = await ctx.Process?.StandardError?.ReadToEndAsync();
|
|
|
|
|
+ var outputs = await ctx.Process?.StandardOutput?.ReadToEndAsync();
|
|
|
Log(LogSeverityEnum.Info,
|
|
Log(LogSeverityEnum.Info,
|
|
|
- $"Starting process '{Name}.{ctx.Process?.ProcessName}' [Id:{ctx.Process?.Id}]: {ShellCommand}");
|
|
|
|
|
|
|
+ $"Starting process '{Name}.{processName}' [Id:{processId}]: {ShellCommand}");
|
|
|
if (ctx.Process != null)
|
|
if (ctx.Process != null)
|
|
|
{
|
|
{
|
|
|
ctx.Process.WaitForExit();
|
|
ctx.Process.WaitForExit();
|
|
@@ -91,7 +97,7 @@ namespace BO.ProcessServer.Business.Workers
|
|
|
Log(LogSeverityEnum.Info, outputs);
|
|
Log(LogSeverityEnum.Info, outputs);
|
|
|
|
|
|
|
|
Log(LogSeverityEnum.Info,
|
|
Log(LogSeverityEnum.Info,
|
|
|
- $"End process '{Name}.{ctx.Process?.ProcessName}' [Id:{ctx.Process?.Id}]: Exit code {ctx.Process.ExitCode}");
|
|
|
|
|
|
|
+ $"End process '{Name}.{processName}' [Id:{processId}]: Exit code {ctx.Process.ExitCode}");
|
|
|
|
|
|
|
|
if (ctx.Process.ExitCode == scenario.ExitCodeSucc)
|
|
if (ctx.Process.ExitCode == scenario.ExitCodeSucc)
|
|
|
{
|
|
{
|
|
@@ -105,7 +111,7 @@ namespace BO.ProcessServer.Business.Workers
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
Log(LogSeverityEnum.Warn,
|
|
Log(LogSeverityEnum.Warn,
|
|
|
- $"Process '{Name}.{ctx.Process?.ProcessName}' has unhandled exitcode {ctx.Process.ExitCode}! Goes to fail.");
|
|
|
|
|
|
|
+ $"Process '{Name}.{processName}' has unhandled exitcode {ctx.Process.ExitCode}! Goes to fail.");
|
|
|
Status = ServerProcessStateEnum.FailInternal;
|
|
Status = ServerProcessStateEnum.FailInternal;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -127,7 +133,7 @@ namespace BO.ProcessServer.Business.Workers
|
|
|
await ctx.Connection.SetDocumentContentAsync(document.Id,
|
|
await ctx.Connection.SetDocumentContentAsync(document.Id,
|
|
|
_fileSystem.Path.GetFileNameWithoutExtension(file),
|
|
_fileSystem.Path.GetFileNameWithoutExtension(file),
|
|
|
MimeTypeUtil.GetMimeType(_fileSystem.Path.GetExtension(file)), false, fs);
|
|
MimeTypeUtil.GetMimeType(_fileSystem.Path.GetExtension(file)), false, fs);
|
|
|
- Log(LogSeverityEnum.Debug, $"Process '{Name}.{ctx.Process?.ProcessName}' file '{file}' uploaded.");
|
|
|
|
|
|
|
+ Log(LogSeverityEnum.Debug, $"Process '{Name}.{processName}' file '{file}' uploaded.");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
await ctx.Connection.SetDocumentStateAsync(document.Id, DocumentStatusEnum.DoneOk);
|
|
await ctx.Connection.SetDocumentStateAsync(document.Id, DocumentStatusEnum.DoneOk);
|
|
@@ -138,7 +144,7 @@ namespace BO.ProcessServer.Business.Workers
|
|
|
{
|
|
{
|
|
|
ctx.Pool.MoveDocumentFiles(Pool.PoolTypeEnum.Working, Pool.PoolTypeEnum.Fail, document.Id);
|
|
ctx.Pool.MoveDocumentFiles(Pool.PoolTypeEnum.Working, Pool.PoolTypeEnum.Fail, document.Id);
|
|
|
}
|
|
}
|
|
|
- Log(LogSeverityEnum.Info, $"Process '{Name}.{ctx.Process?.ProcessName}' resolution state is '{Status}'.");
|
|
|
|
|
|
|
+ Log(LogSeverityEnum.Info, $"Process '{Name}.{processName}' resolution state is '{Status}'.");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
#endregion
|
|
@@ -173,6 +179,12 @@ namespace BO.ProcessServer.Business.Workers
|
|
|
result = result.Replace(Constants.CS_TAG_P_OUT_EXT, Constants.CS_POOL_OUTFILE_EXT, StringComparison.OrdinalIgnoreCase);
|
|
result = result.Replace(Constants.CS_TAG_P_OUT_EXT, Constants.CS_POOL_OUTFILE_EXT, StringComparison.OrdinalIgnoreCase);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
+ private string TranslatePath(string path)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (string.IsNullOrEmpty(path))
|
|
|
|
|
+ return path;
|
|
|
|
|
+ return path.Replace(Constants.CS_TAG_CURRENT_DIR, _fileSystem.Directory.GetCurrentDirectory());
|
|
|
|
|
+ }
|
|
|
#endregion
|
|
#endregion
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|