SendNSWMessageService etwas verboser gemacht um die Hänger zu identifizieren.
Außerdem gibt Transmit() jetzt ein boolean zurück und nur wenn der Prozess auch fertig war, wird das Verzeichnis gelesen. Irgendwo ist da eine Race Condition..
This commit is contained in:
parent
6f5e5b66e9
commit
b175b17fec
@ -36,7 +36,7 @@
|
||||
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
|
||||
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||
<WebPage>publish.html</WebPage>
|
||||
<ApplicationRevision>5</ApplicationRevision>
|
||||
<ApplicationRevision>6</ApplicationRevision>
|
||||
<ApplicationVersion>7.9.0.%2a</ApplicationVersion>
|
||||
<UseApplicationTrust>false</UseApplicationTrust>
|
||||
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
||||
|
||||
@ -270,9 +270,11 @@ namespace SendNSWMessageService
|
||||
}
|
||||
|
||||
// external processing for HIS-Nord
|
||||
bsmd.hisnord.transmitter.CallTransmitter();
|
||||
bsmd.hisnord.Request.ReadResponseFiles();
|
||||
bsmd.hisnord.Response.ReadAnswers();
|
||||
if (bsmd.hisnord.transmitter.Transmit())
|
||||
{
|
||||
bsmd.hisnord.Request.ReadResponseFiles();
|
||||
bsmd.hisnord.Response.ReadAnswers();
|
||||
}
|
||||
|
||||
// external processing for dbh
|
||||
bsmd.dbh.MessageController.SendAndReceive();
|
||||
|
||||
@ -10,6 +10,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Serialization;
|
||||
using bsmd.database;
|
||||
using log4net;
|
||||
@ -19,17 +20,17 @@ namespace bsmd.hisnord
|
||||
public class transmitter
|
||||
{
|
||||
private static readonly ILog _log = LogManager.GetLogger(typeof(transmitter));
|
||||
private static int? processId; // Achtung, das müsste getrennt behandelt werden Test <-> Livesystem!
|
||||
private static int? processId;
|
||||
|
||||
public static void CallTransmitter()
|
||||
public static bool Transmit()
|
||||
{
|
||||
string rootDir = Properties.Settings.Default.TransmitterRoot;
|
||||
|
||||
if(processId.HasValue)
|
||||
{
|
||||
_log.InfoFormat("Transmitter process {0} still running, aborting call", processId);
|
||||
return;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(rootDir, Properties.Settings.Default.Transmitter));
|
||||
startInfo.WorkingDirectory = rootDir;
|
||||
@ -42,13 +43,12 @@ namespace bsmd.hisnord
|
||||
// Ergebnis ab
|
||||
|
||||
using (Process transmitterProcess = new Process())
|
||||
{
|
||||
|
||||
{
|
||||
transmitterProcess.Exited += TransmitterProcess_Exited;
|
||||
|
||||
transmitterProcess.ErrorDataReceived += TransmitterProcess_ErrorDataReceived;
|
||||
transmitterProcess.OutputDataReceived += TransmitterProcess_OutputDataReceived;
|
||||
|
||||
|
||||
transmitterProcess.StartInfo = startInfo;
|
||||
transmitterProcess.EnableRaisingEvents = true;
|
||||
transmitterProcess.Start();
|
||||
@ -59,29 +59,32 @@ 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.InfoFormat($"starting transmitter, process ID: {processId}, timeout {timeout} ms.");
|
||||
|
||||
if (!transmitterProcess.WaitForExit((timeout == 0) ? int.MaxValue : timeout))
|
||||
{
|
||||
_log.WarnFormat("Transmitter process not exited within {0} minute", Properties.Settings.Default.BatchTimeoutMins);
|
||||
// dauert zu lang, beende Prozess..
|
||||
_log.Warn($"Transmitter {processId} not exited within {timeout} ms");
|
||||
try
|
||||
{
|
||||
transmitterProcess.Kill();
|
||||
_log.Info("Transmitter killed");
|
||||
_log.Warn($"Transmitter {processId} killed");
|
||||
processId = null;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.WarnFormat("Killing Transmitter failed: {0}", e.Message);
|
||||
_log.Warn($"Killing Transmitter {processId} failed: {e.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void TransmitterProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)
|
||||
{
|
||||
if(!e.Data.IsNullOrEmpty())
|
||||
_log.Debug(e.Data);
|
||||
_log.Info(e.Data);
|
||||
}
|
||||
|
||||
private static void TransmitterProcess_ErrorDataReceived(object sender, DataReceivedEventArgs e)
|
||||
@ -92,7 +95,7 @@ namespace bsmd.hisnord
|
||||
|
||||
private static void TransmitterProcess_Exited(object sender, EventArgs e)
|
||||
{
|
||||
_log.Debug("Transmitter process exited");
|
||||
_log.Info("Transmitter process exited");
|
||||
processId = null;
|
||||
}
|
||||
|
||||
@ -103,9 +106,7 @@ namespace bsmd.hisnord
|
||||
string resultDir = Path.Combine(Properties.Settings.Default.TransmitterRoot, Properties.Settings.Default.ResultDir);
|
||||
string resultFullPath = Path.Combine(resultDir, resultFilename);
|
||||
return result.ReadResult(resultFullPath);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// class to read transmitter result xml files
|
||||
|
||||
Loading…
Reference in New Issue
Block a user