diff --git a/bsmd.hisnord/transmitter.cs b/bsmd.hisnord/transmitter.cs index 62439e54..2f7c62cb 100644 --- a/bsmd.hisnord/transmitter.cs +++ b/bsmd.hisnord/transmitter.cs @@ -38,7 +38,7 @@ namespace bsmd.hisnord startInfo.RedirectStandardError = true; startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardInput = false; - startInfo.UseShellExecute = false; + startInfo.UseShellExecute = false; using (Process transmitterProcess = new Process()) { @@ -57,7 +57,7 @@ namespace bsmd.hisnord processId = transmitterProcess.Id; // _log.DebugFormat("started {0}", transmitterProcess.ProcessName); - int timeout = Properties.Settings.Default.BatchTimeoutMins * 1000 * 60; // convert to ms + int timeout = Properties.Settings.Default.BatchTimeoutMins * 1000 * 60; // convert to ms _log.DebugFormat($"starting transmitter, process ID: {processId}, timeout {timeout} ms."); @@ -75,6 +75,26 @@ namespace bsmd.hisnord _log.Warn($"Killing Transmitter {processId} failed: {e.Message}"); } } + else + { + int exitCode = transmitterProcess.ExitCode; + if (exitCode != 0) + { + string errorText = ""; + switch(exitCode) + { + case 1: errorText = "Schema violation"; break; + case 2: + case 3: errorText = "Element must not be null"; break; + case 1000: errorText = "Internal error"; break; + case 1001: errorText = "Access denied - Login"; break; + case 1004: errorText = "Access denied - Internal Configuration"; break; + case 1005: errorText = "Internal configuration error"; break; + case 2000: errorText = "File not found"; break; + } + _log.ErrorFormat("Transmitter returned code {0}: {1}", exitCode, errorText); + } + } } return true; } @@ -96,7 +116,7 @@ namespace bsmd.hisnord // Output of STDERR. HIS-Nord seems to be using this for logging, so we do not flag as error. if(!e.Data.IsNullOrEmpty()) _log.Debug(e.Data); - } + } private static void TransmitterProcess_Exited(object sender, EventArgs e) { @@ -137,12 +157,12 @@ namespace bsmd.hisnord } } _log.Info($"deleted {cnt} files from {Properties.Settings.Default.OutputArchiveDir}"); - + } catch(Exception ex) { _log.ErrorFormat("Error trying to delete old files: {0}", ex.Message); } - } + } } }