Make HiS-Nord transmitter a bit more verbose when it returns a failure in log

This commit is contained in:
Daniel Schick 2024-11-07 14:35:39 +01:00
parent 14931ce2c3
commit b552bf2dd0

View File

@ -38,7 +38,7 @@ namespace bsmd.hisnord
startInfo.RedirectStandardError = true; startInfo.RedirectStandardError = true;
startInfo.RedirectStandardOutput = true; startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardInput = false; startInfo.RedirectStandardInput = false;
startInfo.UseShellExecute = false; startInfo.UseShellExecute = false;
using (Process transmitterProcess = new Process()) using (Process transmitterProcess = new Process())
{ {
@ -57,7 +57,7 @@ namespace bsmd.hisnord
processId = transmitterProcess.Id; processId = transmitterProcess.Id;
// _log.DebugFormat("started {0}", transmitterProcess.ProcessName); // _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."); _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}"); _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; 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. // Output of STDERR. HIS-Nord seems to be using this for logging, so we do not flag as error.
if(!e.Data.IsNullOrEmpty()) if(!e.Data.IsNullOrEmpty())
_log.Debug(e.Data); _log.Debug(e.Data);
} }
private static void TransmitterProcess_Exited(object sender, EventArgs e) 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}"); _log.Info($"deleted {cnt} files from {Properties.Settings.Default.OutputArchiveDir}");
} }
catch(Exception ex) catch(Exception ex)
{ {
_log.ErrorFormat("Error trying to delete old files: {0}", ex.Message); _log.ErrorFormat("Error trying to delete old files: {0}", ex.Message);
} }
} }
} }
} }