WE in Uko

This commit is contained in:
Daniel Schick 2019-12-15 16:30:21 +00:00
parent 849578d7a2
commit 977b92c4f4
10 changed files with 125 additions and 127 deletions

View File

@ -26,12 +26,12 @@
<value>1000</value>
</setting>
<setting name="LockingServerAddress" serializeAs="String">
<!--value>http://192.168.2.24/LockingService/LockingService.svc</value-->
<value>http://heupferd/bsmd.LockingService/LockingService.svc</value>
<value>http://192.168.2.24/LockingService/LockingService.svc</value>
<!--value>http://heupferd/bsmd.LockingService/LockingService.svc</value-->
</setting>
<setting name="ConnectionString" serializeAs="String">
<!--value>Initial Catalog=nsw;Data Source=192.168.2.24\SQLEXPRESS;Uid=dfuser;pwd=dfpasswd;Persist Security Info=False;Connection Reset=false</value-->
<value>Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=E:\DATA\DB\NSW.MDF;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False</value>
<value>Initial Catalog=nsw;Data Source=192.168.2.24\SQLEXPRESS;Uid=dfuser;pwd=dfpasswd;Persist Security Info=False;Connection Reset=false</value>
<!--value>Data Source=(localdb)\MSSQLLocalDB;Initial Catalog=E:\DATA\DB\NSW.MDF;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False;ApplicationIntent=ReadWrite;MultiSubnetFailover=False</value-->
</setting>
</ENI2.Properties.Settings>
</applicationSettings>

View File

@ -35,7 +35,7 @@
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>5.7.0.%2a</ApplicationVersion>
<ApplicationVersion>5.8.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>

Binary file not shown.

View File

@ -13,18 +13,18 @@ namespace SendNSWMessageService
public partial class NSWSendService : ServiceBase
{
private Timer _timer;
private object _timerlock = new object();
private readonly object _timerlock = new object();
private bool processRunning = false;
private ILog _log = LogManager.GetLogger(typeof(NSWSendService));
private readonly ILog _log = LogManager.GetLogger(typeof(NSWSendService));
public NSWSendService()
{
Directory.SetCurrentDirectory(AppDomain.CurrentDomain.BaseDirectory);
InitializeComponent();
System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate (object sender, System.Security.Cryptography.X509Certificates.X509Certificate certificate,
System.Security.Cryptography.X509Certificates.X509Chain chain,
System.Net.Security.SslPolicyErrors sslPolicyErrors)
System.Net.ServicePointManager.ServerCertificateValidationCallback += (object _, System.Security.Cryptography.X509Certificates.X509Certificate ____,
System.Security.Cryptography.X509Certificates.X509Chain __,
System.Net.Security.SslPolicyErrors ___) =>
{
return true; // **** Immer OK weil wir nur mit einem dedizierten Endpoint reden..
};
@ -57,7 +57,7 @@ namespace SendNSWMessageService
this.DoOnce();
}
public void Init(string[] args)
private void Init(string[] args)
{
this._timer = new Timer();
this._timer.Interval = Properties.Settings.Default.SleepSeconds * 1000;
@ -70,11 +70,11 @@ namespace SendNSWMessageService
this._timer_Elapsed(null, null);
}
void _timer_Elapsed(object sender, ElapsedEventArgs e)
private void _timer_Elapsed(object sender, ElapsedEventArgs e)
{
lock (this._timerlock)
{
if (this.processRunning) return;
if (processRunning) return;
else this.processRunning = true;
}
@ -179,7 +179,7 @@ namespace SendNSWMessageService
case Message.NSWProvider.DBH:
case Message.NSWProvider.DBH_TEST:
sendSucceeded = bsmd.dbh.Request.SendMessage(message, (message.HIS == Message.NSWProvider.DBH_TEST));
sendSucceeded = bsmd.dbh.Request.SendMessage(message, message.HIS == Message.NSWProvider.DBH_TEST);
if (!sendSucceeded)
message.InternalStatus = Message.BSMDStatus.SEND_FAILED;
else
@ -193,7 +193,7 @@ namespace SendNSWMessageService
break;
case Message.NSWProvider.DUDR:
case Message.NSWProvider.DUDR_TEST:
bool? sendResult = bsmd.hisnord.Request.CreateSendFile(core, message, (core.InitialHIS == Message.NSWProvider.DUDR_TEST));
bool? sendResult = bsmd.hisnord.Request.CreateSendFile(core, message, core.InitialHIS == Message.NSWProvider.DUDR_TEST);
if (sendResult.HasValue)
{
didSendSomething = true;

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("schick Informatik")]
[assembly: AssemblyProduct("BSMD NSW interface")]
[assembly: AssemblyInformationalVersion("5.8.0")]
[assembly: AssemblyInformationalVersion("5.9.0")]
[assembly: AssemblyCopyright("Copyright © 2014-2019 schick Informatik")]
[assembly: AssemblyTrademark("")]

View File

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("5.8.0.*")]
[assembly: AssemblyVersion("5.9.0.*")]

View File

@ -1292,7 +1292,8 @@ namespace bsmd.dbh
rootIMDG.PortOfLoading = imdgPos.PortOfLoading;
rootIMDG.PortOfDischarge = imdgPos.PortOfDischarge;
rootIMDG.Remarks = imdgPos.Remarks;
if(!imdgPos.Remarks.IsNullOrEmpty())
rootIMDG.Remarks = imdgPos.Remarks;
dpgOnArrival.DPGItemIMDG[i] = rootIMDG;
}
@ -1325,7 +1326,8 @@ namespace bsmd.dbh
rootIBC.SpecRef15_19Specified = ibcPos.SpecRef15_19.HasValue;
if (ibcPos.SpecRef15_19.HasValue)
rootIBC.SpecRef15_19 = ibcPos.SpecRef15_19.Value ? DBHWebReference.RootSECValidISSCOnBoard.Y : DBHWebReference.RootSECValidISSCOnBoard.N;
rootIBC.Remarks = ibcPos.Remarks;
if(!ibcPos.Remarks.IsNullOrEmpty() )
rootIBC.Remarks = ibcPos.Remarks;
dpgOnArrival.DPGItemIBC[i] = rootIBC;
}
@ -1349,7 +1351,8 @@ namespace bsmd.dbh
rootIGC.StowagePosition = igcPos.StowagePosition;
rootIGC.PortOfLoading = igcPos.PortOfLoading;
rootIGC.PortOfDischarge = igcPos.PortOfDischarge;
rootIGC.Remarks = igcPos.Remarks;
if(!igcPos.Remarks.IsNullOrEmpty())
rootIGC.Remarks = igcPos.Remarks;
dpgOnArrival.DPGItemIGC[i] = rootIGC;
}
@ -1375,7 +1378,8 @@ namespace bsmd.dbh
rootIMSBC.StowagePosition = imsbcPos.StowagePosition;
rootIMSBC.PortOfLoading = imsbcPos.PortOfLoading;
rootIMSBC.PortOfDischarge = imsbcPos.PortOfDischarge;
rootIMSBC.Remarks = imsbcPos.Remarks;
if(!imsbcPos.Remarks.IsNullOrEmpty())
rootIMSBC.Remarks = imsbcPos.Remarks;
dpgOnArrival.DPGItemIMSBC[i] = rootIMSBC;
}
@ -1400,7 +1404,8 @@ namespace bsmd.dbh
rootMarpol.StowagePosition = marpolPos.StowagePosition;
rootMarpol.PortOfLoading = marpolPos.PortOfLoading;
rootMarpol.PortOfDischarge = marpolPos.PortOfDischarge;
rootMarpol.Remarks = marpolPos.Remarks;
if(!marpolPos.Remarks.IsNullOrEmpty())
rootMarpol.Remarks = marpolPos.Remarks;
dpgOnArrival.DPGItemMARPOLAnnexI[i] = rootMarpol;
}
@ -1551,7 +1556,8 @@ namespace bsmd.dbh
rootIMDG.PortOfLoading = imdgPos.PortOfLoading;
rootIMDG.PortOfDischarge = imdgPos.PortOfDischarge;
rootIMDG.Remarks = imdgPos.Remarks;
if(!imdgPos.Remarks.IsNullOrEmpty())
rootIMDG.Remarks = imdgPos.Remarks;
dpgOnDeparture.DPGItemIMDG[i] = rootIMDG;
}
@ -1584,7 +1590,8 @@ namespace bsmd.dbh
rootIBC.SpecRef15_19Specified = ibcPos.SpecRef15_19.HasValue;
if (ibcPos.SpecRef15_19.HasValue)
rootIBC.SpecRef15_19 = ibcPos.SpecRef15_19.Value ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N;
rootIBC.Remarks = ibcPos.Remarks;
if(!ibcPos.Remarks.IsNullOrEmpty())
rootIBC.Remarks = ibcPos.Remarks;
dpgOnDeparture.DPGItemIBC[i] = rootIBC;
}
@ -1608,7 +1615,8 @@ namespace bsmd.dbh
rootIGC.StowagePosition = igcPos.StowagePosition;
rootIGC.PortOfLoading = igcPos.PortOfLoading;
rootIGC.PortOfDischarge = igcPos.PortOfDischarge;
rootIGC.Remarks = igcPos.Remarks;
if(!igcPos.Remarks.IsNullOrEmpty())
rootIGC.Remarks = igcPos.Remarks;
dpgOnDeparture.DPGItemIGC[i] = rootIGC;
}
@ -1634,7 +1642,8 @@ namespace bsmd.dbh
rootIMSBC.StowagePosition = imsbcPos.StowagePosition;
rootIMSBC.PortOfLoading = imsbcPos.PortOfLoading;
rootIMSBC.PortOfDischarge = imsbcPos.PortOfDischarge;
rootIMSBC.Remarks = imsbcPos.Remarks;
if(!imsbcPos.Remarks.IsNullOrEmpty())
rootIMSBC.Remarks = imsbcPos.Remarks;
dpgOnDeparture.DPGItemIMSBC[i] = rootIMSBC;
}
@ -1659,7 +1668,8 @@ namespace bsmd.dbh
rootMarpol.StowagePosition = marpolPos.StowagePosition;
rootMarpol.PortOfLoading = marpolPos.PortOfLoading;
rootMarpol.PortOfDischarge = marpolPos.PortOfDischarge;
rootMarpol.Remarks = marpolPos.Remarks;
if(!rootMarpol.Remarks.IsNullOrEmpty())
rootMarpol.Remarks = marpolPos.Remarks;
dpgOnDeparture.DPGItemMARPOLAnnexI[i] = rootMarpol;
}

View File

@ -13,20 +13,9 @@ namespace bsmd.hisnord
public class NSWResponse
{
private string _clientRequestId;
private DateTime _receiveAt;
private string _notificationId;
private string _status;
private string _visitId;
private string _transitId;
private Message.NotificationClass _notificationClass;
private bool _isReset;
private List<MessageViolation> _violations = new List<MessageViolation>();
private List<MessageError> _errors = new List<MessageError>();
private readonly DateTime _receiveAt;
private Guid? _messageCoreId;
private ILog _log = LogManager.GetLogger(typeof(NSWResponse));
private readonly ILog _log = LogManager.GetLogger(typeof(NSWResponse));
public NSWResponse(XElement xml)
{
@ -72,10 +61,9 @@ namespace bsmd.hisnord
XName idName = "ConveyanceCode";
var elem = xml.Descendants(idName);
if (elem.Count() > 0)
if (elem.Any())
{
Guid aGuid;
if (Guid.TryParse(elem.FirstOrDefault()?.Value, out aGuid))
if (Guid.TryParse(elem.FirstOrDefault()?.Value, out Guid aGuid))
_messageCoreId = aGuid;
else
_log.WarnFormat("cannot parse ConveyanceCode {0}", elem.FirstOrDefault());
@ -89,23 +77,22 @@ namespace bsmd.hisnord
var mElem = xml.Descendants(meldeTypeName);
Message.NotificationClass? notificationClass = null;
if(mElem.Count() > 0)
if(mElem.Any())
{
Message.NotificationClass tmpClass;
if (Enum.TryParse<Message.NotificationClass>(mElem.FirstOrDefault()?.Value, out tmpClass))
if (Enum.TryParse<Message.NotificationClass>(mElem.FirstOrDefault()?.Value, out Message.NotificationClass tmpClass))
notificationClass = tmpClass;
else
{
// könnte VISIT/TRANSIT Id Beantragung sein
XName test = ns15 + "VisitIdResponse";
if (xml.Descendants(test).Count() > 0)
if (xml.Descendants(test).Any())
{
notificationClass = Message.NotificationClass.VISIT;
}
else
{
test = ns16 + "TransitIdResponse";
if (xml.Descendants(test).Count() > 0) notificationClass = Message.NotificationClass.TRANSIT;
if (xml.Descendants(test).Any()) notificationClass = Message.NotificationClass.TRANSIT;
}
if (!notificationClass.HasValue)
@ -113,19 +100,19 @@ namespace bsmd.hisnord
XName cancelVisit = cancelVisitNS + "CancelVisitIdResponse";
XName cancelTransit = cancelTransitNS + "CancelTransitIdResponse";
if (xml.Descendants(cancelVisit).Count() > 0)
if (xml.Descendants(cancelVisit).Any())
{
lookupName = cancelVisit;
notificationClass = Message.NotificationClass.STO; // HACK, es gibt keine Klasse für "Cancel"
_log.WarnFormat("CANCEL VISIT, setting Not.Class to STO (experimental)");
_notificationClass = Message.NotificationClass.STO;
NotificationClass = Message.NotificationClass.STO;
}
else if(xml.Descendants(cancelTransit).Count() > 0)
else if (xml.Descendants(cancelTransit).Any())
{
lookupName = cancelTransit;
notificationClass = Message.NotificationClass.STO; // HACK, es gibt keine Klasse für "Cancel"
_log.WarnFormat("CANCEL TRANSIT, setting Not.Class to STO (experimental)");
_notificationClass = Message.NotificationClass.STO;
NotificationClass = Message.NotificationClass.STO;
}
else
{
@ -234,55 +221,55 @@ namespace bsmd.hisnord
break;
}
bool lookupMatch = (xml.Descendants(lookupName).Count() > 0);
bool resetMatch = (xml.Descendants(resetLookup).Count() > 0);
bool lookupMatch = (xml.Descendants(lookupName).Any());
bool resetMatch = (xml.Descendants(resetLookup).Any());
if(lookupMatch || resetMatch)
{
_isReset = resetMatch;
IsReset = resetMatch;
_notificationClass = notificationClass.Value;
NotificationClass = notificationClass.Value;
// match found
XName xname = ns6 + "ClientRequestId";
elem = xml.Descendants(xname);
if (elem.Count() > 0)
if (elem.Any())
{
_clientRequestId = elem.First()?.Value;
ClientRequestId = elem.First()?.Value;
}
xname = ns6 + "ReceivedAt";
elem = xml.Descendants(xname);
if(elem.Count() > 0)
if(elem.Any())
{
DateTime.TryParse(elem.First()?.Value, out _receiveAt);
}
xname = ns6 + "NotificationId";
elem = xml.Descendants(xname);
if (elem.Count() > 0)
_notificationId = elem.First()?.Value;
if (elem.Any())
NotificationId = elem.First()?.Value;
xname = ns6 + "Status";
elem = xml.Descendants(xname);
if(elem.Count() > 0)
if(elem.Any())
{
_status = elem.First()?.Value;
Status = elem.First()?.Value;
}
xname = ns6 + "VisitId";
elem = xml.Descendants(xname);
if(elem.Count() > 0)
if(elem.Any())
{
_visitId = elem.First()?.Value;
VisitId = elem.First()?.Value;
}
xname = ns6 + "TransitId";
elem = xml.Descendants(xname);
if (elem.Count() > 0)
if (elem.Any())
{
_transitId = elem.First()?.Value;
TransitId = elem.First()?.Value;
}
@ -300,7 +287,7 @@ namespace bsmd.hisnord
else
mv.ViolationCode = vCode;
mv.ViolationText = anElem.Element(vTextName).Value;
_violations.Add(mv);
Violations.Add(mv);
}
// check for errors ----------------------------------------------
@ -317,7 +304,7 @@ namespace bsmd.hisnord
else
me.ErrorCode = eCode;
me.ErrorText = anElem.Element(eTextName).Value;
_errors.Add(me);
Errors.Add(me);
}
}
@ -328,25 +315,25 @@ namespace bsmd.hisnord
public Guid? MessageCoreId { get { return _messageCoreId; } }
public string ClientRequestId { get { return _clientRequestId; } }
public string ClientRequestId { get; }
public DateTime? ReceiveAt { get { return _receiveAt; } }
public string NotificationId { get { return _notificationId; } }
public string NotificationId { get; }
public string Status { get { return this._status; } }
public string Status { get; }
public string VisitId { get { return this._visitId; } }
public string VisitId { get; }
public string TransitId { get { return this._transitId; } }
public string TransitId { get; }
public List<MessageViolation> Violations { get { return _violations; } }
public List<MessageViolation> Violations { get; } = new List<MessageViolation>();
public List<MessageError> Errors { get { return _errors; } }
public List<MessageError> Errors { get; } = new List<MessageError>();
public Message.NotificationClass NotificationClass { get { return this._notificationClass; } }
public Message.NotificationClass NotificationClass { get; }
public bool IsReset { get { return this._isReset; } }
public bool IsReset { get; }
#endregion

View File

@ -19,8 +19,8 @@ namespace bsmd.hisnord
[Serializable]
public class TransitId
{
private string _transitId = null;
private static ILog _log = LogManager.GetLogger(typeof(bsmd.hisnord.TransitId));
private readonly string _transitId = null;
private static readonly ILog _log = LogManager.GetLogger(typeof(bsmd.hisnord.TransitId));
#region Construction
@ -54,8 +54,7 @@ namespace bsmd.hisnord
int startIndex = this.ConveyanceCode.IndexOf('-');
if (startIndex > 0)
{
Guid tmpGuid;
if (Guid.TryParse(this.ConveyanceCode.Substring(startIndex + 1), out tmpGuid))
if (Guid.TryParse(this.ConveyanceCode.Substring(startIndex + 1), out Guid tmpGuid))
result = tmpGuid;
else if (Guid.TryParse(this.ConveyanceCode, out tmpGuid))
result = tmpGuid;

View File

@ -18,7 +18,7 @@ namespace bsmd.hisnord
{
public class transmitter
{
private static 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? processTestId;
@ -48,53 +48,55 @@ namespace bsmd.hisnord
// damit das gut geht schicken wir die Nachrichten einzeln und arbeiten jeweils das
// Ergebnis ab
Process transmitterProcess = new Process();
if (useTest)
{
transmitterProcess.Exited += TransmitterTestProcess_Exited;
}
else
{
transmitterProcess.Exited += TransmitterProcess_Exited;
}
transmitterProcess.ErrorDataReceived += TransmitterProcess_ErrorDataReceived;
transmitterProcess.OutputDataReceived += TransmitterProcess_OutputDataReceived;
transmitterProcess.StartInfo = startInfo;
transmitterProcess.EnableRaisingEvents = true;
transmitterProcess.Start();
transmitterProcess.BeginErrorReadLine();
transmitterProcess.BeginOutputReadLine();
int aProcessId = transmitterProcess.Id;
if (useTest)
using (Process transmitterProcess = new Process())
{
processTestId = aProcessId;
}
else
{
processId = aProcessId;
}
// _log.DebugFormat("started {0}", transmitterProcess.ProcessName);
int timeout = Properties.Settings.Default.BatchTimeoutMins * 1000 * 60; // convert to 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..
try
{
transmitterProcess.Kill();
_log.Info("Transmitter killed");
}
catch (Exception e)
if (useTest)
{
_log.WarnFormat("Killing Transmitter failed: {0}", e.Message);
transmitterProcess.Exited += TransmitterTestProcess_Exited;
}
}
else
{
transmitterProcess.Exited += TransmitterProcess_Exited;
}
transmitterProcess.ErrorDataReceived += TransmitterProcess_ErrorDataReceived;
transmitterProcess.OutputDataReceived += TransmitterProcess_OutputDataReceived;
transmitterProcess.StartInfo = startInfo;
transmitterProcess.EnableRaisingEvents = true;
transmitterProcess.Start();
transmitterProcess.BeginErrorReadLine();
transmitterProcess.BeginOutputReadLine();
int aProcessId = transmitterProcess.Id;
if (useTest)
{
processTestId = aProcessId;
}
else
{
processId = aProcessId;
}
// _log.DebugFormat("started {0}", transmitterProcess.ProcessName);
int timeout = Properties.Settings.Default.BatchTimeoutMins * 1000 * 60; // convert to 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..
try
{
transmitterProcess.Kill();
_log.Info("Transmitter killed");
}
catch (Exception e)
{
_log.WarnFormat("Killing Transmitter failed: {0}", e.Message);
}
}
}
}
private static void TransmitterProcess_OutputDataReceived(object sender, DataReceivedEventArgs e)