Service kennt keinen Unterschied zwischen Test- und Produktivsystem mehr. Diese Unterscheidung wird serverseitig durch zwei Instanzen mit unterschiedlicher Konfiguration getroffen.

This commit is contained in:
Daniel Schick 2021-11-25 08:03:56 +01:00
parent 12ae616f9b
commit ee56a5dce3
19 changed files with 66 additions and 370 deletions

View File

@ -31,12 +31,12 @@ namespace SendNSWMessageService
} }
public void Commandline(string[] args) public void Commandline()
{ {
// Dieser Modus dient allein dazu, eine separate Instanz "nebenher" laufen zu lassen, ohne // Dieser Modus dient allein dazu, eine separate Instanz "nebenher" laufen zu lassen, ohne
// sie als Service zu installieren. Dies ist sinnvoll um für spezielle HIS Einstellungen Tests zu machen // sie als Service zu installieren. Dies ist sinnvoll um für spezielle HIS Einstellungen Tests zu machen
// ohne den laufenden Betrieb zu stören (hoffentlich!) // ohne den laufenden Betrieb zu stören (hoffentlich!)
this.Init(args); // setup timer this.Init(); // setup timer
this.DoOnce(); this.DoOnce();
while (true) while (true)
System.Threading.Thread.Sleep(1000); // sleep until someone kills me :) System.Threading.Thread.Sleep(1000); // sleep until someone kills me :)
@ -46,7 +46,7 @@ namespace SendNSWMessageService
{ {
this.EventLog.Source = this.ServiceName; this.EventLog.Source = this.ServiceName;
this.EventLog.Log = "Application"; this.EventLog.Log = "Application";
this.Init(args); this.Init();
System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly();
FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location); FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(assembly.Location);
@ -57,7 +57,7 @@ namespace SendNSWMessageService
this.DoOnce(); this.DoOnce();
} }
private void Init(string[] args) private void Init()
{ {
this._timer = new Timer(); this._timer = new Timer();
this._timer.Interval = Properties.Settings.Default.SleepSeconds * 1000; this._timer.Interval = Properties.Settings.Default.SleepSeconds * 1000;
@ -271,231 +271,14 @@ namespace SendNSWMessageService
} }
DBManager.Instance.Save(core); DBManager.Instance.Save(core);
#region old logic
/*
if ((core.InitialHIS == Message.NSWProvider.DUDR) || (core.InitialHIS == Message.NSWProvider.DUDR_TEST))
{
bool sendSucceeded = true;
bool didSendSomething = false;
// Fall: keine Meldeklasse aber trotzdem auf TO_SEND. Entweder beim Beantragen von Visit-Id's oder beim Storno der gesamten
// Anmeldung
if ((core.DisplayId.Length == 0) || (core.Cancelled ?? false))
{
sendSucceeded = bsmd.hisnord.Request.CreateSendFile(core, messages, (core.InitialHIS == Message.NSWProvider.DUDR_TEST)) ?? false;
}
else
{
foreach (Message message in messages)
{
bool? sendResult = bsmd.hisnord.Request.CreateSendFile(core, message, (core.InitialHIS == Message.NSWProvider.DUDR_TEST));
if (sendResult.HasValue)
{
didSendSomething = true;
if (!sendResult.Value) sendSucceeded = false;
}
}
} }
if (!didSendSomething) core.BSMDStatusInternal = MessageCore.BSMDStatus.PREPARE; // zurück zu neutral bsmd.hisnord.transmitter.CallTransmitter();
else
{
if (!sendSucceeded) core.BSMDStatusInternal = MessageCore.BSMDStatus.FAILURE;
else core.BSMDStatusInternal = MessageCore.BSMDStatus.SENT;
}
_log.InfoFormat("HIS-Nord Send: Core {0} [{1}] new Status {2}", core.Id, core.IMO, core.BSMDStatusInternal.ToString());
DBManager.Instance.Save(core);
}
else
{
bool sendSucceeded;
#region DBH / Dakosy Logik
List<Message> toSendMessageList = new List<Message>();
if ((core.IsTransit && core.TransitId.IsNullOrEmpty()) ||
(!core.IsTransit && core.VisitId.IsNullOrEmpty()))
{
foreach (Message message in messages)
{
if ((message.MessageNotificationClass == Message.NotificationClass.VISIT) ||
(message.MessageNotificationClass == Message.NotificationClass.TRANSIT))
{
if ((message.InternalStatus == Message.BSMDStatus.UNDEFINED) ||
(message.InternalStatus == Message.BSMDStatus.PREPARE) ||
(message.InternalStatus == Message.BSMDStatus.TOSEND))
{
_log.Debug("Visit/Transit not found, SENDING VISIT/TRANSIT message");
if (message.HIS == Message.NSWProvider.UNDEFINED)
message.HIS = core.InitialHIS;
if (core.DefaultReportingPartyId.HasValue)
message.ReportingPartyId = core.DefaultReportingPartyId;
toSendMessageList.Add(message);
}
}
}
}
else // eine VISIT/TRANSIT Id ist vorhanden, die Daten können gesendet werden
{
// Änderung Sept 15: versendet werden alle Nachrichten, die *nicht* bestätigt sind
// also auch alles was auf in bearbeitung / Korrektur etc steht
// Einzig bleibt die Frage offen, was mit Nachrichten passiert, die über das UI
// nachträglich geändert werden. Ich denke hier muss in dashface ggf. der Status
// wieder auf PREPARE gesetzt werden
_log.Debug("Visit/Transit found, SENDING DATA messages");
foreach (Message message in messages)
{
// Eine Nachricht mit dem Status "Suspended / Zurückgestellt" wird so lange nicht
// versendet, bis im ENI der Status wieder explizit zurückgesetzt wird (16.4.16)
// Update 5.10.17: Alles was nicht explizit auf "TOSEND" steht wird nicht verschickt!
if (message.InternalStatus != Message.BSMDStatus.TOSEND) continue;
// "virtuelle" Messages nicht versenden (DK, EU)
if ((message.MessageNotificationClass == Message.NotificationClass.STO) ||
(message.MessageNotificationClass == Message.NotificationClass.CREWD) ||
(message.MessageNotificationClass == Message.NotificationClass.PASD))
continue;
// Wenn das ein Transit ist, werden nicht erforderliche Meldeklassen übersprungen
if (core.IsTransit)
{
if ((message.MessageNotificationClass == Message.NotificationClass.BKRD) ||
(message.MessageNotificationClass == Message.NotificationClass.PRE72H) ||
(message.MessageNotificationClass == Message.NotificationClass.TIEFD) ||
(message.MessageNotificationClass == Message.NotificationClass.NAME) ||
(message.MessageNotificationClass == Message.NotificationClass.INFO) ||
(message.MessageNotificationClass == Message.NotificationClass.ATA) ||
(message.MessageNotificationClass == Message.NotificationClass.ATD) ||
(message.MessageNotificationClass == Message.NotificationClass.LADG) ||
(message.MessageNotificationClass == Message.NotificationClass.SERV) ||
(message.MessageNotificationClass == Message.NotificationClass.WAS) ||
(message.MessageNotificationClass == Message.NotificationClass.TOWD))
continue;
}
// Visit/Transit Meldeklassen werden nicht erneut übertragen
if ((message.MessageNotificationClass == Message.NotificationClass.VISIT) ||
(message.MessageNotificationClass == Message.NotificationClass.TRANSIT))
continue;
//if ((message.InternalStatus != Message.BSMDStatus.CONFIRMED) &&
//(message.InternalStatus != Message.BSMDStatus.SENT))
//{
// 28.12.2015: Das über "Overview" eingestellte HIS ist immer "führend" (zumindest aktuell zum Testen)
// if (message.HIS == Message.NSWProvider.UNDEFINED)
message.HIS = core.InitialHIS;
if (core.DefaultReportingPartyId.HasValue)
{
message.ReportingPartyId = core.DefaultReportingPartyId; // Referenz umbiegen
if (DBManager.Instance.GetReportingPartyDict().ContainsKey(core.DefaultReportingPartyId.Value)) // geladenes Objekt ersetzen
message.ReportingParty = DBManager.Instance.GetReportingPartyDict()[core.DefaultReportingPartyId.Value];
}
toSendMessageList.Add(message);
//}
}
}
foreach (Message message in toSendMessageList)
{
try
{
_log.InfoFormat("Sending {0} message to {1}",
message.MessageNotificationClass.ToString(), message.HIS.ToString());
sendSucceeded = false;
// switch über passendes HIS / Schnittstelle
switch (message.HIS)
{
case Message.NSWProvider.DBH:
case Message.NSWProvider.DBH_TEST:
if (!XtraSendLogic.ShouldSendMessage(message))
{
message.InternalStatus = Message.BSMDStatus.SUSPENDED;
}
else
{
sendSucceeded = bsmd.dbh.Request.SendMessage(message, (message.HIS == Message.NSWProvider.DBH_TEST));
if (!sendSucceeded)
message.InternalStatus = Message.BSMDStatus.SEND_FAILED;
}
break;
case Message.NSWProvider.DAKOSY:
case Message.NSWProvider.DAKOSY_TEST:
sendSucceeded = bsmd.dakosy.Request.Send(message, true);
if (!sendSucceeded) message.InternalStatus = Message.BSMDStatus.SEND_FAILED;
break;
default:
_log.WarnFormat("Initial HIS not specified for message {0}", message.Id);
break;
}
if (sendSucceeded)
{
// alte Fehlerliste entfernen (die Antwort kann praktisch noch nicht da sein)
// vor dem Versenden zu entfernen halte ich für doof, wenn das Versenden scheitert
foreach (MessageError messageError in message.ErrorList)
DBManager.Instance.Delete(messageError);
foreach (MessageViolation messageViolation in message.ViolationList)
DBManager.Instance.Delete(messageViolation);
_log.Info("send successful, saving message.");
message.InternalStatus = Message.BSMDStatus.SENT;
message.SentAt = DateTime.Now;
}
DBManager.Instance.Save(message);
}
catch (Exception ex)
{
_log.ErrorFormat("SENDING message {0}: {1}", message.Id.ToString(), ex.Message);
}
}
if (toSendMessageList.Count > 0)
{
core.BSMDStatusInternal = MessageCore.BSMDStatus.SENT;
}
else
{
core.BSMDStatusInternal = MessageCore.BSMDStatus.PREPARE;
}
DBManager.Instance.Save(core);
#endregion
}
}
*/
#endregion
}
if(bsmd.hisnord.Properties.Settings.Default.ConnectTestSystem)
bsmd.hisnord.transmitter.CallTransmitter(true);
if(bsmd.hisnord.Properties.Settings.Default.ConnectLiveSystem)
bsmd.hisnord.transmitter.CallTransmitter(false);
// ob test oder nicht ist in stat. dict gespeichert // ob test oder nicht ist in stat. dict gespeichert
bsmd.hisnord.Request.ReadResponseFiles(); bsmd.hisnord.Request.ReadResponseFiles();
if (bsmd.hisnord.Properties.Settings.Default.ConnectTestSystem) bsmd.hisnord.Response.ReadAnswers();
bsmd.hisnord.Response.ReadAnswers(true);
if (bsmd.hisnord.Properties.Settings.Default.ConnectLiveSystem)
bsmd.hisnord.Response.ReadAnswers(false);
List<MessageCore> coresMarkedForStatusQuery = DBManager.Instance.GetMessageCoresWithNSWStatusFlag(); List<MessageCore> coresMarkedForStatusQuery = DBManager.Instance.GetMessageCoresWithNSWStatusFlag();

View File

@ -24,7 +24,7 @@ namespace SendNSWMessageService
} }
else if(args.Length > 0) else if(args.Length > 0)
{ {
((NSWSendService)ServicesToRun[0]).Commandline(args); ((NSWSendService)ServicesToRun[0]).Commandline();
} }
else else
{ {

View File

@ -39,9 +39,9 @@
// //
// nswSendServiceInstaller // nswSendServiceInstaller
// //
this.nswSendServiceInstaller.Description = "Sending Testing-NSW requests to HIS"; this.nswSendServiceInstaller.Description = "Sending NSW requests to HIS";
this.nswSendServiceInstaller.DisplayName = "NSW Test Send Service"; this.nswSendServiceInstaller.DisplayName = "NSW Send Service";
this.nswSendServiceInstaller.ServiceName = "NSWTestSendService"; this.nswSendServiceInstaller.ServiceName = "NSWSendService";
// //
// ProjectInstaller // ProjectInstaller
// //

View File

@ -39,14 +39,15 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.13\lib\net45\log4net.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Configuration.Install" /> <Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Management" /> <Reference Include="System.Management" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.8" targetFramework="net45" /> <package id="log4net" version="2.0.13" targetFramework="net45" />
</packages> </packages>

View File

@ -37,12 +37,13 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.13\lib\net45\log4net.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.8" targetFramework="net45" /> <package id="log4net" version="2.0.13" targetFramework="net45" />
</packages> </packages>

View File

@ -37,15 +37,17 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<Private>True</Private> <HintPath>..\packages\log4net.2.0.13\lib\net45\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.EnterpriseServices" /> <Reference Include="System.EnterpriseServices" />
<Reference Include="System.Runtime.Serialization" /> <Reference Include="System.Runtime.Serialization" />
<Reference Include="System.ServiceModel" /> <Reference Include="System.ServiceModel" />
<Reference Include="System.ServiceModel.Web" /> <Reference Include="System.ServiceModel.Web" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Services" /> <Reference Include="System.Web.Services" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.8" targetFramework="net45" /> <package id="log4net" version="2.0.13" targetFramework="net45" />
</packages> </packages>

View File

@ -12,7 +12,7 @@ namespace bsmd.hisnord.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.8.1.0")]
public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { public sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -110,48 +110,12 @@ namespace bsmd.hisnord.Properties {
[global::System.Configuration.UserScopedSettingAttribute()] [global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("E:\\svnlager\\BSMD\\nsw\\HIS-NORD\\")] [global::System.Configuration.DefaultSettingValueAttribute("E:\\svnlager\\BSMD\\nsw\\HIS-NORD\\")]
public string TestTransmitterRoot { public string TransmitterRoot {
get { get {
return ((string)(this["TestTransmitterRoot"])); return ((string)(this["TransmitterRoot"]));
} }
set { set {
this["TestTransmitterRoot"] = value; this["TransmitterRoot"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string LiveTransmitterRoot {
get {
return ((string)(this["LiveTransmitterRoot"]));
}
set {
this["LiveTransmitterRoot"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
public bool ConnectTestSystem {
get {
return ((bool)(this["ConnectTestSystem"]));
}
set {
this["ConnectTestSystem"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool ConnectLiveSystem {
get {
return ((bool)(this["ConnectLiveSystem"]));
}
set {
this["ConnectLiveSystem"] = value;
} }
} }
} }

View File

@ -23,17 +23,8 @@
<Setting Name="AnswerCorruptDir" Type="System.String" Scope="User"> <Setting Name="AnswerCorruptDir" Type="System.String" Scope="User">
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_CORRUPT</Value> <Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_CORRUPT</Value>
</Setting> </Setting>
<Setting Name="TestTransmitterRoot" Type="System.String" Scope="User"> <Setting Name="TransmitterRoot" Type="System.String" Scope="User">
<Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\</Value> <Value Profile="(Default)">E:\svnlager\BSMD\nsw\HIS-NORD\</Value>
</Setting> </Setting>
<Setting Name="LiveTransmitterRoot" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="ConnectTestSystem" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="ConnectLiveSystem" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>

View File

@ -22,8 +22,6 @@ namespace bsmd.hisnord
private static readonly ILog _log = LogManager.GetLogger(typeof(Request)); private static readonly ILog _log = LogManager.GetLogger(typeof(Request));
private static Dictionary<Guid, ReportingParty> _reportingPartyDict = null; private static Dictionary<Guid, ReportingParty> _reportingPartyDict = null;
private static readonly Dictionary<MessageCore, Dictionary<Message, string>> coreFilenameDict = new Dictionary<MessageCore, Dictionary<Message,string>>(); private static readonly Dictionary<MessageCore, Dictionary<Message, string>> coreFilenameDict = new Dictionary<MessageCore, Dictionary<Message,string>>();
private static readonly Dictionary<MessageCore, bool> coreUseTestDict = new Dictionary<MessageCore, bool>();
//private static Dictionary<Message.NotificationClass, Message> noteMessageDict = new Dictionary<Message.NotificationClass, Message>();
internal static Dictionary<Guid, ReportingParty> ReportingPartyDict internal static Dictionary<Guid, ReportingParty> ReportingPartyDict
{ {
@ -41,7 +39,7 @@ namespace bsmd.hisnord
foreach (Message message in coreFilenameDict[core].Keys) foreach (Message message in coreFilenameDict[core].Keys)
{ {
transmitter.result theResult = transmitter.GetResult(coreFilenameDict[core][message], coreUseTestDict[core]); transmitter.result theResult = transmitter.GetResult(coreFilenameDict[core][message]);
if (theResult != null) if (theResult != null)
{ {
_log.InfoFormat("Result: Code {0} Detail {1} Message {2}", theResult.code, theResult.detail, theResult.message); _log.InfoFormat("Result: Code {0} Detail {1} Message {2}", theResult.code, theResult.detail, theResult.message);
@ -1594,9 +1592,7 @@ namespace bsmd.hisnord
#region serialize and save message #region serialize and save message
string outputDir = Path.Combine(Properties.Settings.Default.TransmitterRoot, Properties.Settings.Default.OutputDir);
string outputDir = Path.Combine(useTest ? Properties.Settings.Default.TestTransmitterRoot : Properties.Settings.Default.LiveTransmitterRoot,
Properties.Settings.Default.OutputDir);
string filename = string.Format("BSMD_{1}-{2}-{0}.xml", (message == null) ? "CANCEL" : message.MessageNotificationClassDisplay, DateTime.Now.ToString("yyyyMMddHHmmss"), core.Id.Value); string filename = string.Format("BSMD_{1}-{2}-{0}.xml", (message == null) ? "CANCEL" : message.MessageNotificationClassDisplay, DateTime.Now.ToString("yyyyMMddHHmmss"), core.Id.Value);
_log.InfoFormat("saving {0} to output directory", filename); _log.InfoFormat("saving {0} to output directory", filename);
@ -1613,7 +1609,6 @@ namespace bsmd.hisnord
if(message != null) if(message != null)
coreFilenameDict[core][message] = filename; coreFilenameDict[core][message] = filename;
coreUseTestDict[core] = useTest;
retval = true; retval = true;
#endregion #endregion

View File

@ -15,10 +15,9 @@ namespace bsmd.hisnord
private static readonly ILog _log = LogManager.GetLogger(typeof(Response)); private static readonly ILog _log = LogManager.GetLogger(typeof(Response));
public static void ReadAnswers(bool useTest) public static void ReadAnswers()
{ {
string answerDir = Path.Combine(useTest ? Properties.Settings.Default.TestTransmitterRoot : Properties.Settings.Default.LiveTransmitterRoot, string answerDir = Path.Combine(Properties.Settings.Default.TransmitterRoot, Properties.Settings.Default.AnswerDir);
Properties.Settings.Default.AnswerDir);
foreach (string answerFile in Directory.GetFiles(answerDir)) foreach (string answerFile in Directory.GetFiles(answerDir))
{ {
@ -293,8 +292,8 @@ namespace bsmd.hisnord
if(isOK) if(isOK)
{ {
// archive file // archive file
string answerArchiveDir = Path.Combine(useTest ? Properties.Settings.Default.TestTransmitterRoot : Properties.Settings.Default.LiveTransmitterRoot, string answerArchiveDir = Path.Combine(Properties.Settings.Default.TransmitterRoot, Properties.Settings.Default.AnswerArchiveDir);
Properties.Settings.Default.AnswerArchiveDir);
try try
{ {
File.Move(answerFile, Path.Combine(answerArchiveDir, Path.GetFileName(answerFile))); File.Move(answerFile, Path.Combine(answerArchiveDir, Path.GetFileName(answerFile)));
@ -307,8 +306,8 @@ namespace bsmd.hisnord
else else
{ {
// save in separate folder (to look at it later?) // save in separate folder (to look at it later?)
string answerCorruptDir = Path.Combine(useTest ? Properties.Settings.Default.TestTransmitterRoot : Properties.Settings.Default.LiveTransmitterRoot, string answerCorruptDir = Path.Combine(Properties.Settings.Default.TransmitterRoot, Properties.Settings.Default.AnswerCorruptDir);
Properties.Settings.Default.AnswerCorruptDir);
try try
{ {
File.Move(answerFile, Path.Combine(answerCorruptDir, Path.GetFileName(answerFile))); File.Move(answerFile, Path.Combine(answerCorruptDir, Path.GetFileName(answerFile)));

View File

@ -28,18 +28,9 @@
<setting name="AnswerCorruptDir" serializeAs="String"> <setting name="AnswerCorruptDir" serializeAs="String">
<value>E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_CORRUPT</value> <value>E:\svnlager\BSMD\nsw\HIS-NORD\Transmitter-Tool\ANSWERS_CORRUPT</value>
</setting> </setting>
<setting name="TestTransmitterRoot" serializeAs="String"> <setting name="TransmitterRoot" serializeAs="String">
<value>E:\svnlager\BSMD\nsw\HIS-NORD\</value> <value>E:\svnlager\BSMD\nsw\HIS-NORD\</value>
</setting> </setting>
<setting name="LiveTransmitterRoot" serializeAs="String">
<value />
</setting>
<setting name="ConnectTestSystem" serializeAs="String">
<value>False</value>
</setting>
<setting name="ConnectLiveSystem" serializeAs="String">
<value>True</value>
</setting>
</bsmd.hisnord.Properties.Settings> </bsmd.hisnord.Properties.Settings>
</userSettings> </userSettings>
</configuration> </configuration>

View File

@ -37,12 +37,13 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.13\lib\net45\log4net.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.8" targetFramework="net45" /> <package id="log4net" version="2.0.13" targetFramework="net45" />
</packages> </packages>

View File

@ -20,24 +20,17 @@ namespace bsmd.hisnord
{ {
private static readonly ILog _log = LogManager.GetLogger(typeof(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; // Achtung, das müsste getrennt behandelt werden Test <-> Livesystem!
private static int? processTestId;
public static void CallTransmitter(bool useTest) public static void CallTransmitter()
{ {
string rootDir = useTest ? Properties.Settings.Default.TestTransmitterRoot : Properties.Settings.Default.LiveTransmitterRoot; string rootDir = Properties.Settings.Default.TransmitterRoot;
if(!useTest && processId.HasValue) if(processId.HasValue)
{ {
_log.InfoFormat("Transmitter process {0} still running, aborting call", processId); _log.InfoFormat("Transmitter process {0} still running, aborting call", processId);
return; return;
} }
if(useTest && processTestId.HasValue)
{
_log.InfoFormat("Transmitter process (Test system) {0} still running, aborting call", processId);
return;
}
ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(rootDir, Properties.Settings.Default.Transmitter)); ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(rootDir, Properties.Settings.Default.Transmitter));
startInfo.WorkingDirectory = rootDir; startInfo.WorkingDirectory = rootDir;
startInfo.RedirectStandardError = true; startInfo.RedirectStandardError = true;
@ -50,14 +43,8 @@ namespace bsmd.hisnord
using (Process transmitterProcess = new Process()) using (Process transmitterProcess = new Process())
{ {
if (useTest)
{
transmitterProcess.Exited += TransmitterTestProcess_Exited;
}
else
{
transmitterProcess.Exited += TransmitterProcess_Exited; transmitterProcess.Exited += TransmitterProcess_Exited;
}
transmitterProcess.ErrorDataReceived += TransmitterProcess_ErrorDataReceived; transmitterProcess.ErrorDataReceived += TransmitterProcess_ErrorDataReceived;
transmitterProcess.OutputDataReceived += TransmitterProcess_OutputDataReceived; transmitterProcess.OutputDataReceived += TransmitterProcess_OutputDataReceived;
@ -69,16 +56,7 @@ namespace bsmd.hisnord
transmitterProcess.BeginErrorReadLine(); transmitterProcess.BeginErrorReadLine();
transmitterProcess.BeginOutputReadLine(); transmitterProcess.BeginOutputReadLine();
int aProcessId = transmitterProcess.Id; processId = transmitterProcess.Id;
if (useTest)
{
processTestId = aProcessId;
}
else
{
processId = aProcessId;
}
// _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
@ -90,8 +68,7 @@ namespace bsmd.hisnord
{ {
transmitterProcess.Kill(); transmitterProcess.Kill();
_log.Info("Transmitter killed"); _log.Info("Transmitter killed");
if (useTest) processTestId = null; processId = null;
else processId = null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -113,26 +90,17 @@ namespace bsmd.hisnord
_log.Error(e.Data); _log.Error(e.Data);
} }
private static void TransmitterTestProcess_Exited(object sender, EventArgs e)
{
_log.Debug("Transmitter process (test) exited");
processTestId = null;
}
private static void TransmitterProcess_Exited(object sender, EventArgs e) private static void TransmitterProcess_Exited(object sender, EventArgs e)
{ {
_log.Debug("Transmitter process exited"); _log.Debug("Transmitter process exited");
processId = null; processId = null;
} }
public static result GetResult(string filenameFullPath, bool useTest) public static result GetResult(string filenameFullPath)
{ {
// now we should read the response message... // now we should read the response message...
string resultFilename = string.Format("{0}.result.xml", Path.GetFileName(filenameFullPath)); string resultFilename = string.Format("{0}.result.xml", Path.GetFileName(filenameFullPath));
string resultDir = Path.Combine(Properties.Settings.Default.TransmitterRoot, Properties.Settings.Default.ResultDir);
string resultDir = Path.Combine(useTest ? Properties.Settings.Default.TestTransmitterRoot : Properties.Settings.Default.LiveTransmitterRoot,
Properties.Settings.Default.ResultDir);
string resultFullPath = Path.Combine(resultDir, resultFilename); string resultFullPath = Path.Combine(resultDir, resultFilename);
return result.ReadResult(resultFullPath); return result.ReadResult(resultFullPath);
} }

View File

@ -38,11 +38,11 @@
<AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile> <AssemblyOriginatorKeyFile>..\bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net, Version=2.0.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath> <HintPath>..\packages\log4net.2.0.13\lib\net45\log4net.dll</HintPath>
<Private>True</Private>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Web" /> <Reference Include="System.Web" />
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="log4net" version="2.0.8" targetFramework="net45" /> <package id="log4net" version="2.0.13" targetFramework="net45" />
</packages> </packages>