diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index 67ab9049..d84cdffa 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ diff --git a/nsw/HIS-NORD/Transmitter-Tool/DD-ImportClient.jar b/nsw/HIS-NORD/Transmitter-Tool/DD-ImportClient.jar index 45bb3b07..5af0b306 100644 Binary files a/nsw/HIS-NORD/Transmitter-Tool/DD-ImportClient.jar and b/nsw/HIS-NORD/Transmitter-Tool/DD-ImportClient.jar differ diff --git a/nsw/HIS-NORD/Transmitter-Tool/Installation of DD-ImportClient.pdf b/nsw/HIS-NORD/Transmitter-Tool/Installation of DD-ImportClient.pdf index 69f07be6..9dc9ffec 100644 Binary files a/nsw/HIS-NORD/Transmitter-Tool/Installation of DD-ImportClient.pdf and b/nsw/HIS-NORD/Transmitter-Tool/Installation of DD-ImportClient.pdf differ diff --git a/nsw/HIS-NORD/Transmitter-Tool/client.bat b/nsw/HIS-NORD/Transmitter-Tool/client.bat new file mode 100644 index 00000000..cb1105f8 --- /dev/null +++ b/nsw/HIS-NORD/Transmitter-Tool/client.bat @@ -0,0 +1 @@ +"C:\Program Files\Java\jre1.8.0_51\bin\java" -jar DD-ImportClient.jar -log=client.log -cfg=client.conf \ No newline at end of file diff --git a/nsw/HIS-NORD/Transmitter-Tool/client.conf b/nsw/HIS-NORD/Transmitter-Tool/client.conf index c31b7b03..5ec1d30a 100644 --- a/nsw/HIS-NORD/Transmitter-Tool/client.conf +++ b/nsw/HIS-NORD/Transmitter-Tool/client.conf @@ -20,4 +20,5 @@ CORDIR = CORRUPT # Version des Protokolls VERSION = NSW_V1-0 MODE = ONCE -XMLRESULTDIR = RESULTS\ \ No newline at end of file +XMLRESULTDIR = RESULTS\ +ANSWERDIR = ANSWERS\ \ No newline at end of file diff --git a/nsw/HIS-NORD/Transmitter-Tool/client.log b/nsw/HIS-NORD/Transmitter-Tool/client.log index e69de29b..84585633 100644 --- a/nsw/HIS-NORD/Transmitter-Tool/client.log +++ b/nsw/HIS-NORD/Transmitter-Tool/client.log @@ -0,0 +1,55 @@ + ----------------------------- +25.07.2015 12:26:38 Client started + ----------------------------- +25.07.2015 12:26:38 No files to send + ----------------------------- +25.07.2015 02:59:17 Client started + ----------------------------- +25.07.2015 02:59:18 FileName: IMP\20150725145813-df8bb348-81ee-4803-85af-fff6641a810c.xml +25.07.2015 02:59:18 FileSize: 11525 + ----------------------------- +25.07.2015 02:59:21 20150725145813-df8bb348-81ee-4803-85af-fff6641a810c.xml(11,25 kB) - XML file doesnt fit Schema +25.07.2015 02:59:21 XML Document has Error:truecvc-type.3.1.3: The value '0' of element 'TowageBeam_MTR' is not valid. + ----------------------------- +25.07.2015 03:12:21 Client started + ----------------------------- +25.07.2015 03:12:22 FileName: IMP\20150725151154-df8bb348-81ee-4803-85af-fff6641a810c.xml +25.07.2015 03:12:22 FileSize: 12369 + ----------------------------- +25.07.2015 03:12:23 20150725151154-df8bb348-81ee-4803-85af-fff6641a810c.xml(12,08 kB) - XML file doesnt fit Schema +25.07.2015 03:12:23 XML Document has Error:truecvc-complex-type.2.4.a: Invalid content was found starting with element 'PortOfItineryETA'. One of '{PortOfItineryName}' is expected. + ----------------------------- +25.07.2015 03:15:22 Client started + ----------------------------- +25.07.2015 03:15:24 FileName: IMP\20150725151517-df8bb348-81ee-4803-85af-fff6641a810c.xml +25.07.2015 03:15:24 FileSize: 12428 + ----------------------------- +25.07.2015 03:15:24 20150725151517-df8bb348-81ee-4803-85af-fff6641a810c.xml(12,14 kB) - XML file doesnt fit Schema +25.07.2015 03:15:24 XML Document has Error:truecvc-complex-type.4: Attribute 'Index' must appear on element 'PortOfItinery'. + ----------------------------- +25.07.2015 03:29:38 Client started + ----------------------------- +25.07.2015 03:29:40 FileName: IMP\20150725152924-df8bb348-81ee-4803-85af-fff6641a810c.xml +25.07.2015 03:29:40 FileSize: 12438 + ----------------------------- +25.07.2015 03:29:40 20150725152924-df8bb348-81ee-4803-85af-fff6641a810c.xml(12,15 kB) - XML file doesnt fit Schema +25.07.2015 03:29:40 XML Document has Error:truecvc-complex-type.2.4.a: Invalid content was found starting with element 'ConfirmationOfCorrectness'. One of '{Wastes}' is expected. + ----------------------------- +29.07.2015 21:50:35 Client started + ----------------------------- +29.07.2015 21:50:37 FileName: IMP\20150729214822-df8bb348-81ee-4803-85af-fff6641a810c.xml +29.07.2015 21:50:37 FileSize: 12538(12,24 kB) + ----------------------------- +29.07.2015 21:50:39 Getting Answers +29.07.2015 21:50:39 20150729214822-df8bb348-81ee-4803-85af-fff6641a810c.xml(12538) - XML file doesnt fit Schema +29.07.2015 21:50:39 XML Document has Error:truecvc-complex-type.2.4.a: Invalid content was found starting with element 'ConfirmationOfCorrectness'. One of '{Wastes}' is expected. +29.07.2015 21:50:39 Filename: DEWVN-2015-ZGGPEQ_VISIT.xml +29.07.2015 21:50:39 Filesize: 149(149 B) +29.07.2015 21:50:39 PACKETSIZE: 500 +29.07.2015 21:50:39 Tiles: 1 +29.07.2015 21:50:39 Getting Answers +29.07.2015 21:50:40 Filename: DEWVN-2015-XTGWNE_VISIT.xml +29.07.2015 21:50:40 Filesize: 148(148 B) +29.07.2015 21:50:40 PACKETSIZE: 500 +29.07.2015 21:50:40 Tiles: 1 +29.07.2015 21:50:40 No more Answers diff --git a/nsw/Source/SendNSWMessageService/NSWSendService.cs b/nsw/Source/SendNSWMessageService/NSWSendService.cs index c3529f82..75d0a93c 100644 --- a/nsw/Source/SendNSWMessageService/NSWSendService.cs +++ b/nsw/Source/SendNSWMessageService/NSWSendService.cs @@ -60,6 +60,8 @@ namespace SendNSWMessageService else this.processRunning = true; } + bool sendSucceeded; + if (DBManager.Instance.Connect(Properties.Settings.Default.ConnectionString)) { @@ -69,106 +71,113 @@ namespace SendNSWMessageService foreach (MessageCore core in coresMarkedForSending) { - List messages = DBManager.Instance.GetMessagesForCore(core); - List toSendMessageList = new List(); - - if ((core.IsTransit && core.TransitId.IsNullOrEmpty()) || - (!core.IsTransit && core.VisitId.IsNullOrEmpty())) + if (core.InitialHIS == Message.NSWProvider.DUDR) { - foreach (Message message in messages) + // Rostocker: wir senden alle Nachrichten auf einmal + sendSucceeded = bsmd.hisnord.Request.Send(messages); + + if (!sendSucceeded) core.BSMDStatusInternal = MessageCore.BSMDStatus.FAILURE; + else core.BSMDStatusInternal = MessageCore.BSMDStatus.SENT; + DBManager.Instance.Save(core); + } + + else + { + + List toSendMessageList = new List(); + + if ((core.IsTransit && core.TransitId.IsNullOrEmpty()) || + (!core.IsTransit && core.VisitId.IsNullOrEmpty())) { - if((message.MessageNotificationClass == Message.NotificationClass.VISIT) || - (message.MessageNotificationClass == Message.NotificationClass.TRANSIT)) + foreach (Message message in messages) { - if((message.InternalStatus == Message.BSMDStatus.UNDEFINED) || + 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)) + { + if (message.HIS == Message.NSWProvider.UNDEFINED) + message.HIS = core.InitialHIS; + toSendMessageList.Add(message); + } + } + } + } + else // eine VISIT/TRANSIT Id ist vorhanden, die Daten können gesendet werden + { + // versendet werden nur die Nachrichten, die den Status "UNDEFINED", "PREPARE" und "TOSEND" haben + // diese wurden entweder von EU-NOAD angelegt oder durch den Melder bearbeitet + // Wichtig ist eine erfolgreich versendete Meldung nicht erneut zu versenden + foreach (Message message in messages) + { + if ((message.InternalStatus == Message.BSMDStatus.UNDEFINED) || (message.InternalStatus == Message.BSMDStatus.PREPARE) || (message.InternalStatus == Message.BSMDStatus.TOSEND)) { if (message.HIS == Message.NSWProvider.UNDEFINED) message.HIS = core.InitialHIS; + toSendMessageList.Add(message); } } } - } - else // eine VISIT/TRANSIT Id ist vorhanden, die Daten können gesendet werden - { - // versendet werden nur die Nachrichten, die den Status "UNDEFINED", "PREPARE" und "TOSEND" haben - // diese wurden entweder von EU-NOAD angelegt oder durch den Melder bearbeitet - // Wichtig ist eine erfolgreich versendete Meldung nicht erneut zu versenden - foreach (Message message in messages) - { - if ((message.InternalStatus == Message.BSMDStatus.UNDEFINED) || - (message.InternalStatus == Message.BSMDStatus.PREPARE) || - (message.InternalStatus == Message.BSMDStatus.TOSEND)) - { - if (message.HIS == Message.NSWProvider.UNDEFINED) - message.HIS = core.InitialHIS; - 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: + sendSucceeded = bsmd.dbh.Request.SendMessage(message); + if (!sendSucceeded) + message.InternalStatus = Message.BSMDStatus.SEND_FAILED; + break; + + case Message.NSWProvider.DAKOSY: + sendSucceeded = bsmd.dakosy.Request.Send(message); + 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); } } } - - foreach (Message message in toSendMessageList) - { - try - { - _log.InfoFormat("Sending {0} message to {1}", - message.MessageNotificationClass.ToString(), message.HIS.ToString()); - - bool sendSucceeded = false; - - - // switch über passendes HIS / Schnittstelle - switch (message.HIS) - { - case Message.NSWProvider.DBH: - sendSucceeded = bsmd.dbh.Request.SendMessage(message); - if (!sendSucceeded) - message.InternalStatus = Message.BSMDStatus.SEND_FAILED; - break; - - case Message.NSWProvider.DAKOSY: - sendSucceeded = bsmd.dakosy.Request.Send(message); - if (!sendSucceeded) message.InternalStatus = Message.BSMDStatus.SEND_FAILED; - break; - - case Message.NSWProvider.DUDR: - sendSucceeded = bsmd.hisnord.Request.Send(message); - 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); - } - } } DBManager.Instance.Disconnect(); diff --git a/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs b/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs index 78cbfba3..33605406 100644 --- a/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs +++ b/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs @@ -27,7 +27,7 @@ namespace bsmd.ReportGenerator #region create document public static Document CreateDocument(string title, string subject, string author, - Dictionary coverInfos) + Dictionary coverInfos, bool isUpdate) { // Create a new MigraDoc document Document document = new Document(); @@ -37,7 +37,7 @@ namespace bsmd.ReportGenerator BSMDDocument.DefineStyles(document); - BSMDDocument.DefineCover(document, coverInfos); + BSMDDocument.DefineCover(document, coverInfos, isUpdate); BSMDDocument.DefineContentSection(document, Orientation.Portrait, true); //TableOfContents.DefineTableOfContents(document); @@ -137,7 +137,7 @@ namespace bsmd.ReportGenerator /// /// Defines the cover page. /// - public static void DefineCover(Document document, Dictionary coverInfos) + public static void DefineCover(Document document, Dictionary coverInfos, bool isUpdate) { Section section = document.AddSection(); @@ -147,7 +147,11 @@ namespace bsmd.ReportGenerator Image image = section.AddImage(Properties.Settings.Default.LogoPath); image.Width = "3cm"; - paragraph = section.AddParagraph("EU-NOAD incoming data receipt"); + if (isUpdate) + section.AddParagraph("EU-NOAD data UPDATE"); + else + paragraph = section.AddParagraph("EU-NOAD incoming data receipt"); + paragraph.Format.Font.Size = 16; paragraph.Format.Font.Color = Colors.DarkRed; paragraph.Format.SpaceBefore = Unit.FromCentimeter(4); diff --git a/nsw/Source/bsmd.ReportGenerator/ReportService.cs b/nsw/Source/bsmd.ReportGenerator/ReportService.cs index 00d63880..1afbce3a 100644 --- a/nsw/Source/bsmd.ReportGenerator/ReportService.cs +++ b/nsw/Source/bsmd.ReportGenerator/ReportService.cs @@ -60,93 +60,12 @@ namespace bsmd.ReportGenerator { // load all messages with report flag set List reportCores = DBManager.Instance.GetMessageCoresByReportStatus(MessageCore.ReportStatusEnum.COMPLETE); - + reportCores.AddRange(DBManager.Instance.GetMessageCoresByReportStatus(MessageCore.ReportStatusEnum.HE_REPORTTYPE)); + reportCores.AddRange(DBManager.Instance.GetMessageCoresByReportStatus(MessageCore.ReportStatusEnum.HE_REVISION)); // create report documents for each of the messages foreach (MessageCore reportCore in reportCores) { - List messages = DBManager.Instance.GetMessagesForCore(reportCore); - Dictionary coverInfos = new Dictionary(); - // Schiffsname aus der STAT meldung fischen - foreach (Message msg in messages) - { - if (msg.MessageNotificationClass == Message.NotificationClass.STAT) - { - if (msg.Elements.Count > 0) - { - STAT stat = msg.Elements[0] as STAT; - if (stat != null) - { - coverInfos.Add("Ship", stat.ShipName); - } - } - } - } - coverInfos.Add("IMO", reportCore.IMO); - DateTime eta = reportCore.ETA ?? (reportCore.ETAKielCanal ?? new DateTime(0)); - coverInfos.Add("ETA", eta.ToShortDateString()); - coverInfos.Add("Port", reportCore.Portname); - coverInfos.Add("", ""); - if (reportCore.Customer != null) - { - coverInfos.Add("Name", reportCore.Customer.Name); - coverInfos.Add("Contact first name", reportCore.Customer.ContactFirstName); - coverInfos.Add("Contact last name", reportCore.Customer.ContactLastName); - coverInfos.Add("Customer number", reportCore.Customer.CustomerNumber); - coverInfos.Add("Street", reportCore.Customer.StreetAndNumber); - coverInfos.Add("Postal code", reportCore.Customer.PostalCode); - coverInfos.Add("City", reportCore.Customer.City); - coverInfos.Add("Country", reportCore.Customer.Country); - coverInfos.Add("Phone", reportCore.Customer.Phone); - coverInfos.Add("E-Mail", reportCore.Customer.Email); - } - - Document migraDocument = BSMDDocument.CreateDocument( - string.Format("NSW Eingangsdatenübersicht für IMO {0}, ETA {1}", reportCore.IMO, reportCore.ETA), - "NSW Meldung", - Properties.Settings.Default.ReportAuthor, coverInfos); - - // print header area (with message core data) - - // print messages in subsequent tables - foreach (Message message in messages) - { - BSMDDocument.AddNSWMessageParagraph(migraDocument, message); - } - - // prepare and send E-Mail with generated attachment - string fullPath = string.Format("{0}\\{1}.pdf", Properties.Settings.Default.OutputDirectory, - reportCore.Id); - BSMDDocument.RenderDocument(migraDocument, fullPath); - _log.InfoFormat("Document created for MessageCoreId {0}, IMO {1}", reportCore.Id, reportCore.IMO); - string subject = string.Format("NSW message report for {0}", reportCore.IMO); - List attachments = new List(); - attachments.Add(fullPath); - - // 10.7.15: Check PAS/CREW messages to create extra csv files and add them as well - - Message pas = messages.Find(x => x.MessageNotificationClass == Message.NotificationClass.PAS); - string passengerCSV = null; - if ((pas != null) && (pas.Elements.Count > 0)) - { - passengerCSV = CrewPasHelper.CreateCSV(pas); - attachments.Add(passengerCSV); - } - - Message crew = messages.Find(x => x.MessageNotificationClass == Message.NotificationClass.CREW); - string crewCSV = null; - if ((crew != null) && (crew.Elements.Count > 0)) - { - crewCSV = CrewPasHelper.CreateCSV(crew); - attachments.Add(crewCSV); - } - - BSMDMail.SendNSWReportWithAttachments(subject, attachments); - // reset report status - reportCore.ReportStatus = MessageCore.ReportStatusEnum.NONE; - DBManager.Instance.Save(reportCore); - - if (passengerCSV != null) File.Delete(passengerCSV); - if (crewCSV != null) File.Delete(crewCSV); + this.CreateReport(reportCore); } DBManager.Instance.Disconnect(); @@ -178,5 +97,103 @@ namespace bsmd.ReportGenerator { this._timer_Elapsed(null, null); } + + #region create and send report + + private void CreateReport(MessageCore reportCore) + { + List messages = DBManager.Instance.GetMessagesForCore(reportCore); + Dictionary coverInfos = new Dictionary(); + bool isReportUpdate = reportCore.ReportStatus != MessageCore.ReportStatusEnum.COMPLETE; + + coverInfos.Add("Type", reportCore.HerbergReportType); + // Schiffsname aus der STAT meldung fischen + foreach (Message msg in messages) + { + if (msg.MessageNotificationClass == Message.NotificationClass.STAT) + { + if (msg.Elements.Count > 0) + { + STAT stat = msg.Elements[0] as STAT; + if (stat != null) + { + coverInfos.Add("Ship", stat.ShipName); + } + } + } + } + coverInfos.Add("IMO", reportCore.IMO); + DateTime eta = reportCore.ETA ?? (reportCore.ETAKielCanal ?? new DateTime(0)); + coverInfos.Add("ETA", eta.ToShortDateString()); + coverInfos.Add("Port", reportCore.Portname); + coverInfos.Add("", ""); + if (reportCore.Customer != null) + { + coverInfos.Add("Name", reportCore.Customer.Name); + coverInfos.Add("Contact first name", reportCore.Customer.ContactFirstName); + coverInfos.Add("Contact last name", reportCore.Customer.ContactLastName); + coverInfos.Add("Customer number", reportCore.Customer.CustomerNumber); + coverInfos.Add("Street", reportCore.Customer.StreetAndNumber); + coverInfos.Add("Postal code", reportCore.Customer.PostalCode); + coverInfos.Add("City", reportCore.Customer.City); + coverInfos.Add("Country", reportCore.Customer.Country); + coverInfos.Add("Phone", reportCore.Customer.Phone); + coverInfos.Add("E-Mail", reportCore.Customer.Email); + } + + // create document and print header area (with message core data) + Document migraDocument = BSMDDocument.CreateDocument( + string.Format("NSW Eingangsdatenübersicht für IMO {0}, ETA {1}", reportCore.IMO, reportCore.ETA), + "NSW Meldung", + Properties.Settings.Default.ReportAuthor, + coverInfos, + isReportUpdate); + + // print messages in subsequent tables + foreach (Message message in messages) + { + BSMDDocument.AddNSWMessageParagraph(migraDocument, message); + } + + // prepare and send E-Mail with generated attachment + string fullPath = string.Format("{0}\\{1}.pdf", Properties.Settings.Default.OutputDirectory, + reportCore.Id); + BSMDDocument.RenderDocument(migraDocument, fullPath); + _log.InfoFormat("Document created for MessageCoreId {0}, IMO {1}", reportCore.Id, reportCore.IMO); + string subject = string.Format("NEW EU-NOAD message IMO {0}", reportCore.IMO); + if(isReportUpdate) + subject = string.Format("UPDATE EU-NOAD message IMO {0}", reportCore.IMO); + List attachments = new List(); + attachments.Add(fullPath); + + // 10.7.15: Check PAS/CREW messages to create extra csv files and add them as well + + Message pas = messages.Find(x => x.MessageNotificationClass == Message.NotificationClass.PAS); + string passengerCSV = null; + if ((pas != null) && (pas.Elements.Count > 0)) + { + passengerCSV = CrewPasHelper.CreateCSV(pas); + attachments.Add(passengerCSV); + } + + Message crew = messages.Find(x => x.MessageNotificationClass == Message.NotificationClass.CREW); + string crewCSV = null; + if ((crew != null) && (crew.Elements.Count > 0)) + { + crewCSV = CrewPasHelper.CreateCSV(crew); + attachments.Add(crewCSV); + } + + BSMDMail.SendNSWReportWithAttachments(subject, attachments); + // reset report status + reportCore.ReportStatus = MessageCore.ReportStatusEnum.NONE; + DBManager.Instance.Save(reportCore); + + if (passengerCSV != null) File.Delete(passengerCSV); + if (crewCSV != null) File.Delete(crewCSV); + } + + #endregion + } } diff --git a/nsw/Source/bsmd.database/DBManager.cs b/nsw/Source/bsmd.database/DBManager.cs index b8672c34..42afeb92 100644 --- a/nsw/Source/bsmd.database/DBManager.cs +++ b/nsw/Source/bsmd.database/DBManager.cs @@ -18,11 +18,16 @@ namespace bsmd.database { public class DBManager { + + #region Fields + private SqlConnection _con; private static DBManager _instance; private static ILog _log = LogManager.GetLogger(typeof(DBManager)); private static Dictionary allReportingParties; + #endregion + #region Properties public static DBManager Instance @@ -66,6 +71,7 @@ namespace bsmd.database #region public helper funcs + /* public Dictionary GetToSendMessageCoreList() { List toSendList = this.GetMessageCoresByStatus(MessageCore.BSMDStatus.TOSEND); @@ -75,6 +81,8 @@ namespace bsmd.database return result; } + */ + public List GetMessageCoresByStatus(MessageCore.BSMDStatus status) { MessageCore aMessageCore = new MessageCore(); @@ -85,7 +93,10 @@ namespace bsmd.database List cores = aMessageCore.LoadList(reader); List result = new List(); foreach (MessageCore core in cores) + { + this.LoadCustomer(core); result.Add(core); + } return result; } @@ -100,19 +111,8 @@ namespace bsmd.database List result = new List(); foreach (MessageCore core in cores) { + this.LoadCustomer(core); result.Add(core); - - if (core.CustomerId.HasValue) - { - Customer c = new Customer(); - SqlCommand cCmd = new SqlCommand(); - c.PrepareLoadCommand(cCmd, Message.LoadFilter.BY_ID, core.CustomerId.Value); - reader = this.PerformCommand(cCmd); - List customers = c.LoadList(reader); - if (customers.Count > 0) - core.Customer = customers[0] as Customer; - } - } return result; } @@ -124,6 +124,7 @@ namespace bsmd.database /// public MessageCore GetHerbergFormMessage(Guid herbergFormGuid) { + MessageCore result = null; MessageCore aMessageCore = new MessageCore(); SqlCommand cmd = new SqlCommand(); aMessageCore.PrepareLoadCommand(cmd, Message.LoadFilter.HERBERG_FORMGUID, herbergFormGuid); @@ -132,9 +133,12 @@ namespace bsmd.database List cores = aMessageCore.LoadList(reader); if (cores.Count > 1) _log.WarnFormat("Herberg form message: {0} cores found for guid {1}", cores.Count, herbergFormGuid); - if(cores.Count > 0) - return (MessageCore) cores[0]; - return null; + if (cores.Count > 0) + { + result = (MessageCore)cores[0]; + this.LoadCustomer(result); + } + return result; } public List GetMessagesForCore(MessageCore core) @@ -638,6 +642,20 @@ namespace bsmd.database message.ViolationList.Add(violation); } + internal void LoadCustomer(MessageCore core) + { + if (core.CustomerId.HasValue) + { + Customer c = new Customer(); + SqlCommand cCmd = new SqlCommand(); + c.PrepareLoadCommand(cCmd, Message.LoadFilter.BY_ID, core.CustomerId.Value); + SqlDataReader reader = this.PerformCommand(cCmd); + List customers = c.LoadList(reader); + if (customers.Count > 0) + core.Customer = customers[0] as Customer; + } + } + #region DB access methods internal SqlDataReader PerformCommand(SqlCommand cmd) @@ -645,7 +663,11 @@ namespace bsmd.database try { cmd.Connection = this._con; + Stopwatch sw = new Stopwatch(); + sw.Start(); SqlDataReader reader = cmd.ExecuteReader(); + sw.Stop(); + _log.DebugFormat("{1}ms: {0}", cmd.CommandText, sw.ElapsedMilliseconds); return reader; } catch (SqlException ex) diff --git a/nsw/Source/bsmd.database/Message.cs b/nsw/Source/bsmd.database/Message.cs index d02d3038..0f7d0c81 100644 --- a/nsw/Source/bsmd.database/Message.cs +++ b/nsw/Source/bsmd.database/Message.cs @@ -12,7 +12,10 @@ namespace bsmd.database /// Basisklasse aller Nachrichtentypen, zentrale Klasse für die NSW App /// public class Message : DatabaseEntity, ISublistContainer - { + { + + #region Fields + private Guid? messageCoreId; private Guid? reportingPartyId; private ReportingParty reportingParty; @@ -21,6 +24,8 @@ namespace bsmd.database private List violationList = new List(); private List elements = new List(); + #endregion + #region Enumerations /// @@ -90,13 +95,17 @@ namespace bsmd.database #endregion + #region Construction + public Message() { this.tablename = "[dbo].[MessageHeader]"; } + #endregion + #region Properties - + /// /// Dieser Wert wird vom NSW / HIS vergeben /// diff --git a/nsw/Source/bsmd.database/MessageCore.cs b/nsw/Source/bsmd.database/MessageCore.cs index 0b006748..8086eaa1 100644 --- a/nsw/Source/bsmd.database/MessageCore.cs +++ b/nsw/Source/bsmd.database/MessageCore.cs @@ -141,6 +141,7 @@ namespace bsmd.database scmd.Parameters.AddWithNullableValue("@P21", this.HerbergRevDate); scmd.Parameters.AddWithValue("@P22", this.ReportStatus); scmd.Parameters.AddWithNullableValue("@P23", this.SietasSheetVersion); + scmd.Parameters.AddWithValue("@P24", this.Incoming ? 1 : 0); if (this.IsNew) { @@ -149,9 +150,9 @@ namespace bsmd.database string query = string.Format("INSERT INTO {0} (Id, VisitId, TransitId, IMO, ENI, PoC, Portname, ETA, CustomerId, " + "Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS, HerbergFormGuid, " + "HerbergFormTemplateGuid, HerbergReportType, HerbergEmailcontactReportingVessel, HerbergEmail24HrsContact, " + - "ETAKielCanal, HerbergRevDate, ReportStatus, SietasSheetVersion) VALUES " + + "ETAKielCanal, HerbergRevDate, ReportStatus, SietasSheetVersion, Incoming) VALUES " + "(@ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, @P15, @P16, @P17, " + - "@P18, @P19, @P20, @P21, @P22, @P23)", + "@P18, @P19, @P20, @P21, @P22, @P23, @P24)", this.Tablename); scmd.CommandText = query; } @@ -163,7 +164,7 @@ namespace bsmd.database "Wetris_zz_56_datensatz_id = @P12, BSMDStatus = @P13, InitialHIS = @P14, HerbergFormGuid = @P15, " + "HerbergFormTemplateGuid = @P16, HerbergReportType = @P17, HerbergEmailContactReportingVessel = @P18, " + "HerbergEmail24HrsContact = @P19, ETAKielCanal = @P20, HerbergRevDate = @P21, ReportStatus = @P22, " + - "SietasSheetVersion = @P23 WHERE Id = @ID", this.Tablename); + "SietasSheetVersion = @P23, Incoming = @P24 WHERE Id = @ID", this.Tablename); scmd.CommandText = query; } } @@ -173,7 +174,7 @@ namespace bsmd.database string query = string.Format("SELECT Id, VisitId, TransitId, IMO, ENI, PoC, Portname, " + "ETA, CustomerId, Previous, Next, IsTransit, Wetris_zz_56_datensatz_id, BSMDStatus, InitialHIS, " + "HerbergFormGuid, HerbergFormTemplateGuid, HerbergReportType, HerbergEmailContactReportingVessel, " + - "HerbergEmail24HrsContact, ETAKielCanal, HerbergRevDate, ReportStatus, SietasSheetVersion FROM {0} ", + "HerbergEmail24HrsContact, ETAKielCanal, HerbergRevDate, ReportStatus, SietasSheetVersion, Incoming FROM {0} ", this.Tablename); switch (filter) @@ -254,6 +255,7 @@ namespace bsmd.database if (!reader.IsDBNull(21)) core.HerbergRevDate = reader.GetDateTime(21); if (!reader.IsDBNull(22)) core.ReportStatus = (ReportStatusEnum) Enum.ToObject(typeof(ReportStatusEnum), reader.GetByte(22)); if (!reader.IsDBNull(23)) core.SietasSheetVersion = reader.GetString(23); + if (!reader.IsDBNull(24)) core.Incoming = reader.GetBoolean(24); result.Add(core); } diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs index ec26fe56..8a727b78 100644 --- a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs +++ b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs @@ -2,6 +2,6 @@ [assembly: AssemblyCompany("Informatikbüro Daniel Schick")] [assembly: AssemblyProduct("BSMD NSW interface")] -[assembly: AssemblyInformationalVersion("2.0.0")] +[assembly: AssemblyInformationalVersion("2.1.0")] [assembly: AssemblyCopyright("Copyright © 2014-2015 Informatikbüro Daniel Schick. All rights reserved.")] [assembly: AssemblyTrademark("")] \ No newline at end of file diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs index a1106733..c714c609 100644 --- a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs +++ b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs @@ -4,6 +4,6 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.0.0.*")] +[assembly: AssemblyVersion("2.1.0.*")] // wenn das nicht auskommentiert wird erhalten wir eine Warnung // [assembly: AssemblyFileVersion("1.0.0.*")] diff --git a/nsw/Source/bsmd.herberg.FormService/Util.cs b/nsw/Source/bsmd.herberg.FormService/Util.cs index b69148f8..98234d0b 100644 --- a/nsw/Source/bsmd.herberg.FormService/Util.cs +++ b/nsw/Source/bsmd.herberg.FormService/Util.cs @@ -74,7 +74,7 @@ namespace bsmd.herberg.FormService if ((aMessageCore.HerbergReportType != formData.value) && (aMessageCore.ReportStatus != MessageCore.ReportStatusEnum.COMPLETE)) - aMessageCore.ReportStatus = MessageCore.ReportStatusEnum.HE_REPORTTYPE; + aMessageCore.ReportStatus = MessageCore.ReportStatusEnum.HE_REPORTTYPE; // neuer Report-Type! aMessageCore.HerbergReportType = formData.value; if (aMessageCore.HerbergReportType.Equals("Pre-Departure Notification Update") || diff --git a/nsw/Source/bsmd.hisnord/Request.cs b/nsw/Source/bsmd.hisnord/Request.cs index 987b6ca7..eb59e45b 100644 --- a/nsw/Source/bsmd.hisnord/Request.cs +++ b/nsw/Source/bsmd.hisnord/Request.cs @@ -9,6 +9,9 @@ using System; using System.Collections.Generic; +using System.IO; +using System.Xml; +using System.Xml.Serialization; using log4net; using bsmd.database; @@ -18,7 +21,7 @@ namespace bsmd.hisnord { private static ILog _log = LogManager.GetLogger(typeof(Request)); - public static bool Send(Message message) + public static bool Send(List messages) { bool retval = true; @@ -42,713 +45,810 @@ namespace bsmd.hisnord _nsw.conveyance.owner_sender.contact.phone = "0171 641 6421"; _nsw.conveyance.owner_sender.contact.fax = "+49 (0)421 – 38 08 887"; - _nsw.conveyance.owner_sender.name_short = message.MessageCore.Customer.Name; - _nsw.conveyance.owner_sender.name_long = message.MessageCore.Customer.Name; + if (messages[0].MessageCore.Customer != null) + { + _nsw.conveyance.owner_sender.name_short = messages[0].MessageCore.Customer.Name; + _nsw.conveyance.owner_sender.name_long = messages[0].MessageCore.Customer.Name; - _nsw.conveyance.owner_sender.address = new addresstype(); - _nsw.conveyance.owner_sender.address.StreetNumber = message.MessageCore.Customer.StreetAndNumber; - _nsw.conveyance.owner_sender.address.PostCode = message.MessageCore.Customer.PostalCode; - _nsw.conveyance.owner_sender.address.Place = message.MessageCore.Customer.City; + _nsw.conveyance.owner_sender.address = new addresstype(); + _nsw.conveyance.owner_sender.address.StreetNumber = messages[0].MessageCore.Customer.StreetAndNumber; + _nsw.conveyance.owner_sender.address.PostCode = messages[0].MessageCore.Customer.PostalCode; + _nsw.conveyance.owner_sender.address.Place = messages[0].MessageCore.Customer.City; + } _nsw.conveyance.vessel = new vesseltype(); - _nsw.conveyance.vessel.ENINumber = message.MessageCore.ENI; - _nsw.conveyance.vessel.IMONumber = message.MessageCore.IMO; + _nsw.conveyance.vessel.ENINumber = messages[0].MessageCore.ENI; + _nsw.conveyance.vessel.IMONumber = messages[0].MessageCore.IMO; + _nsw.document_reference = messages[0].MessageCore.Id.Value.ToString(); + _nsw.conveyance.Items = new string[1]; + _nsw.conveyance.ItemsElementName = new ItemsChoiceType[1]; + if (!messages[0].MessageCore.VisitId.IsNullOrEmpty()) + { + _nsw.conveyance.Items[0] = messages[0].MessageCore.VisitId; + _nsw.conveyance.ItemsElementName[0] = ItemsChoiceType.VisitId; + } + else if (!messages[0].MessageCore.TransitId.IsNullOrEmpty()) + { + _nsw.conveyance.Items[0] = messages[0].MessageCore.TransitId; + _nsw.conveyance.ItemsElementName[0] = ItemsChoiceType.TransitId; + } + else // liegt noch nix vor + { + _nsw.conveyance.Items[0] = messages[0].MessageCore.Id.ToString(); + _nsw.conveyance.ItemsElementName[0] = ItemsChoiceType.code; + } #endregion #region NSW message area - - - switch (message.MessageNotificationClass) + foreach (Message message in messages) { - case Message.NotificationClass.VISIT: - break; - case Message.NotificationClass.TRANSIT: - - break; + switch (message.MessageNotificationClass) + { + case Message.NotificationClass.VISIT: - #region ATA/ATD - case Message.NotificationClass.ATA: - if (message.MessageCore.Incoming) - { - import _import = null; - portofcallhazmat _poc = null; - if (_nsw.conveyance.Item != null) + break; + case Message.NotificationClass.TRANSIT: + + break; + + #region ATA/ATD + case Message.NotificationClass.ATA: + if (message.MessageCore.Incoming) { - _import = _nsw.conveyance.Item as import; - if (_import.PortOfCall != null) + import _import = null; + portofcallhazmat _poc = null; + if (_nsw.conveyance.Item != null) { - _poc = _import.PortOfCall; + _import = _nsw.conveyance.Item as import; + if (_import.PortOfCall != null) + { + _poc = _import.PortOfCall; + } + else + { + _poc = new portofcallhazmat(); + _import.PortOfCall = _poc; + } } else { + _import = new import(); + _nsw.conveyance.Item = _import; _poc = new portofcallhazmat(); _import.PortOfCall = _poc; } - } - else - { - _import = new import(); - _nsw.conveyance.Item = _import; - _poc = new portofcallhazmat(); - _import.PortOfCall = _poc; - } - ATA ata = message.Elements[0] as ATA; - if (ata != null) - { - if (ata.ATAPortOfCall.HasValue) - _import.PortOfCall.ATA = ata.ATAPortOfCall.Value; - _import.PortOfCall.ATASpecified = ata.ATAPortOfCall.HasValue; - } - } - break; - case Message.NotificationClass.ATD: - if(!message.MessageCore.Incoming) - { - export _export = null; - portofcallhazmat _poc = null; - if (_nsw.conveyance.Item != null) - { - _export = _nsw.conveyance.Item as export; - if (_export.PortOfCall != null) + ATA ata = message.Elements[0] as ATA; + if (ata != null) { - _poc = _export.PortOfCall; + if (ata.ATAPortOfCall.HasValue) + _import.PortOfCall.ATA = ata.ATAPortOfCall.Value; + _import.PortOfCall.ATASpecified = ata.ATAPortOfCall.HasValue; + } + } + break; + case Message.NotificationClass.ATD: + if (!message.MessageCore.Incoming) + { + export _export = null; + portofcallhazmat _poc = null; + if (_nsw.conveyance.Item != null) + { + _export = _nsw.conveyance.Item as export; + if (_export.PortOfCall != null) + { + _poc = _export.PortOfCall; + } + else + { + _poc = new portofcallhazmat(); + _export.PortOfCall = _poc; + } } else { + _export = new export(); + _nsw.conveyance.Item = _export; _poc = new portofcallhazmat(); _export.PortOfCall = _poc; } + ATD atd = message.Elements[0] as ATD; + if (atd != null) + { + if (atd.ATDPortOfCall.HasValue) + _export.PortOfCall.ATD = atd.ATDPortOfCall.Value; + _export.PortOfCall.ATDSpecified = atd.ATDPortOfCall.HasValue; + } + } + break; + #endregion + + #region BKRA/BKRD + case Message.NotificationClass.BKRA: + if (message.MessageCore.Incoming) + { + if (message.Elements.Count > 0) + { + _nsw.conveyance.BunkerFuelList = new bunkerfuel[message.Elements.Count]; + for (int i = 0; i < message.Elements.Count; i++) + { + BRKA brka = message.Elements[i] as BRKA; + _nsw.conveyance.BunkerFuelList[i] = new bunkerfuel(); + _nsw.conveyance.BunkerFuelList[i].Name = brka.BunkerFuelType; + if (brka.BunkerFuelQuantity_TNE.HasValue) + _nsw.conveyance.BunkerFuelList[i].NetMassTNE = (float)brka.BunkerFuelQuantity_TNE.Value; + } + } + } + break; + case Message.NotificationClass.BKRD: + if (!message.MessageCore.Incoming) + { + if (message.Elements.Count > 0) + { + _nsw.conveyance.BunkerFuelList = new bunkerfuel[message.Elements.Count]; + for (int i = 0; i < message.Elements.Count; i++) + { + BRKD brkd = message.Elements[i] as BRKD; + _nsw.conveyance.BunkerFuelList[i] = new bunkerfuel(); + _nsw.conveyance.BunkerFuelList[i].Name = brkd.BunkerFuelType; + if (brkd.BunkerFuelQuantity_TNE.HasValue) + _nsw.conveyance.BunkerFuelList[i].NetMassTNE = (float)brkd.BunkerFuelQuantity_TNE.Value; + } + } + } + break; + #endregion + + #region BPOL + case Message.NotificationClass.BPOL: + if (message.Elements.Count > 0) + { + BPOL bpol = message.Elements[0] as BPOL; + _nsw.conveyance.BPOL = new bpol(); + _nsw.conveyance.BPOL.StowawayOnBoard = (bpol.StowawaysOnBoard ?? false) ? yorntype.Y : yorntype.N; + if (!bpol.PortOfItineraries.IsNullOrEmpty()) + { + _nsw.conveyance.BPOL.PortsOfItinery = new portofitinery[bpol.PortOfItineraries.Count]; + for (int i = 0; i < bpol.PortOfItineraries.Count; i++) + { + _nsw.conveyance.BPOL.PortsOfItinery[i] = new portofitinery(); + _nsw.conveyance.BPOL.PortsOfItinery[i].PortOfItineryName = bpol.PortOfItineraries[i].PortOfItineraryName; + if (bpol.PortOfItineraries[i].PortOfItineraryETA.HasValue) + _nsw.conveyance.BPOL.PortsOfItinery[i].PortOfItineryETA = bpol.PortOfItineraries[i].PortOfItineraryETA.Value; + _nsw.conveyance.BPOL.PortsOfItinery[i].Index = (i+1).ToString(); + } + } + } + break; + #endregion + + #region CREW + case Message.NotificationClass.CREW: + if (message.Elements.Count > 0) + { + _nsw.conveyance.CREW = new crew(); + _nsw.conveyance.CREW.CrewMembers = new crewmember[message.Elements.Count]; + for (int i = 0; i < message.Elements.Count; i++) + { + CREW crew = message.Elements[i] as CREW; + _nsw.conveyance.CREW.CrewMembers[i] = new crewmember(); + if (crew.CrewMemberDateOfBirth.HasValue) + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberDateOfBirth = crew.CrewMemberDateOfBirth.Value; + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberDuty = crew.CrewMemberDuty; + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberFirstName = crew.CrewMemberFirstName; + if (crew.CrewMemberGender.HasValue) + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberGender = (gendertype)crew.CrewMemberGender.Value; + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberGenderSpecified = crew.CrewMemberGender.HasValue; + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberIdentityDocumentId = crew.CrewMemberIdentityDocumentId; + if (crew.CrewMemberIdentityDocumentType.HasValue) + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberIdentityDocumentType = (documenttype)crew.CrewMemberIdentityDocumentType.Value; + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberLastName = crew.CrewMemberLastName; + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberNationality = crew.CrewMemberNationality; + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberPlaceOfBirth = crew.CrewMemberPlaceOfBirth; + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberVisaNumber = crew.CrewMemberVisaNumber; + } + } + break; + #endregion + + case Message.NotificationClass.HAZA: + // abh. von LADG! + break; + case Message.NotificationClass.HAZD: + // abh. von LADG! + break; + + #region INFO + case Message.NotificationClass.INFO: + INFO info = message.Elements[0] as INFO; + _nsw.conveyance.Info = new info(); + _nsw.conveyance.Info.ConstructionCharacteristicsOfShip = info.ConstructionCharacteristicsOfShip; + if (info.DeplacementSummerDraught_TNE.HasValue) + _nsw.conveyance.Info.DeadWeightSummer_TNE = (float)info.DeplacementSummerDraught_TNE.Value; + _nsw.conveyance.Info.DeadWeightSummer_TNESpecified = info.DeplacementSummerDraught_TNE.HasValue; + if (info.FumigatedBulkCargo.HasValue) + _nsw.conveyance.Info.FumigatedBulkCargo = (info.FumigatedBulkCargo.Value == 1) ? yorntype.Y : yorntype.N; + _nsw.conveyance.Info.RequestedPositionInPortOfCall = info.RequestedPositionInPortOfCall; + if (info.ShippingArea.HasValue) + _nsw.conveyance.Info.ShippingArea = (shippingareatype)info.ShippingArea.Value; + _nsw.conveyance.Info.SpecialRequirementsOfShipAtBerth = info.SpecialRequirementsOfShipAtBerth; + break; + #endregion + + #region LADG + case Message.NotificationClass.LADG: + if (message.Elements.Count > 0) + { + _nsw.conveyance.GeneralCargo = new loadunit[message.Elements.Count]; + for (int i = 0; i < message.Elements.Count; i++) + { + LADG ladg = message.Elements[i] as LADG; + loadunit lu = new loadunit(); + lu.CargoCodeNST = ladg.CargoCodeNST; + if (ladg.CargoGrossQuantity_TNE.HasValue) + lu.CargoGrossQuantity_TNE = (float)ladg.CargoGrossQuantity_TNE.Value; + if (ladg.CargoNumberOfItems.HasValue) + lu.CargoNumberOfItems = ladg.CargoNumberOfItems.Value.ToString(); + if (ladg.CargoHandlingType.HasValue) + lu.HandlingCode = (handlingcodetype)ladg.CargoHandlingType.Value; + _nsw.conveyance.GeneralCargo[i] = lu; + } + } + break; + #endregion + + #region MDH + case Message.NotificationClass.MDH: + MDH mdh = message.Elements[0] as MDH; + if (mdh.MDHSimplification.HasValue && mdh.MDHSimplification.Value) + { + _nsw.conveyance.Items3 = new object[2]; + _nsw.conveyance.Items3[0] = ytype.Y; + _nsw.conveyance.Items3[1] = mdh.PortOfCallWhereCompleteMDHNotified; } else { - _export = new export(); - _nsw.conveyance.Item = _export; - _poc = new portofcallhazmat(); - _export.PortOfCall = _poc; - } - ATD atd = message.Elements[0] as ATD; - if (atd != null) - { - if (atd.ATDPortOfCall.HasValue) - _export.PortOfCall.ATD = atd.ATDPortOfCall.Value; - _export.PortOfCall.ATDSpecified = atd.ATDPortOfCall.HasValue; - } - } - break; - #endregion - - #region BKRA/BKRD - case Message.NotificationClass.BKRA: - if (message.MessageCore.Incoming) - { - if (message.Elements.Count > 0) - { - _nsw.conveyance.BunkerFuelList = new bunkerfuel[message.Elements.Count]; - for (int i = 0; i < message.Elements.Count; i++) { - BRKA brka = message.Elements[i] as BRKA; - _nsw.conveyance.BunkerFuelList[i] = new bunkerfuel(); - _nsw.conveyance.BunkerFuelList[i].Name = brka.BunkerFuelType; - if (brka.BunkerFuelQuantity_TNE.HasValue) - _nsw.conveyance.BunkerFuelList[i].NetMassTNE = (float)brka.BunkerFuelQuantity_TNE.Value; + _nsw.conveyance.Items3 = new object[1]; + mdh _mdh = new mdh(); + if (mdh.AwareOfFurtherInfections.HasValue) + _mdh.AwareOfConditionsForFurtherInfections = mdh.AwareOfFurtherInfections.Value ? yorntype.Y : yorntype.N; + _mdh.InfectedArea = new infectedarea(); + if (mdh.InfectedAreaDate.HasValue) + _mdh.InfectedArea.InfectedAreaDate = mdh.InfectedAreaDate.Value; + _mdh.InfectedArea.InfectedAreaPort = mdh.InfectedAreaPort; + if (mdh.InfectedAreaVisited.HasValue) + _mdh.InfectedAreaVisited = mdh.InfectedAreaVisited.Value ? yorntype.Y : yorntype.N; + if (mdh.MedicalConsulted.HasValue) + _mdh.MedicalConsulted = mdh.MedicalConsulted.Value ? yorntype.Y : yorntype.N; + if (mdh.NonAccidentalDeathsDuringVoyage.HasValue) + _mdh.NonAccidentialDeathsDuringVoyage = mdh.NonAccidentalDeathsDuringVoyage.Value ? yorntype.Y : yorntype.N; + if (mdh.NonAccidentalDeathsDuringVoyageCount.HasValue) + _mdh.NonAccidentialDeathsDuringVoyageCount = mdh.NonAccidentalDeathsDuringVoyageCount.Value.ToString(); + if (mdh.NumberOfIllPersons.HasValue) + _mdh.NumberOfIllPersons = mdh.NumberOfIllPersons.Value.ToString(); + if (mdh.NumberOfIllPersonsHigherThanExpected.HasValue) + _mdh.NumberOfIllPersonsHigherThanExpected = mdh.NumberOfIllPersonsHigherThanExpected.Value ? yorntype.Y : yorntype.N; + if (mdh.PortOfCallLast30Days.Count > 0) + { + _mdh.PortsOfCallLast30Days = new portofcallmdh[mdh.PortOfCallLast30Days.Count]; + for (int i = 0; i < mdh.PortOfCallLast30Days.Count; i++) + { + _mdh.PortsOfCallLast30Days[i] = new portofcallmdh(); + _mdh.PortsOfCallLast30Days[i].Index = i.ToString(); + if (mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count > 0) + { + _mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip = new string[mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count]; + for (int j = 0; j < mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count; j++) + { + _mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip[j] = mdh.PortOfCallLast30Days[i].CrewJoinedShip[j].PortOfCallLast30DaysCrewJoinedShipName; + } + } + if (mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined.HasValue) + _mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined.Value ? yorntype.Y : yorntype.N; + if (mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.HasValue) + _mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.Value; + _mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysLocode = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysLocode; + } } + if (mdh.SanitaryControlReinspectionRequired.HasValue) + _mdh.SanitaryControlReinspectionRequired = mdh.SanitaryControlReinspectionRequired.Value ? yorntype.Y : yorntype.N; + if (mdh.SanitaryMeasuresApplied.HasValue) + _mdh.SanitaryMeasuresApplied = mdh.SanitaryMeasuresApplied.Value ? yorntype.Y : yorntype.N; + _mdh.SanitaryMeasuresDetails = new sanitarydetails(); + if (mdh.SanitaryMeasuresDate.HasValue) + _mdh.SanitaryMeasuresDetails.SanitaryMeasuresDate = mdh.SanitaryMeasuresDate.Value; + _mdh.SanitaryMeasuresDetails.SanitaryMeasuresLocation = mdh.SanitaryMeasuresLocation; + _mdh.SanitaryMeasuresDetails.SanitaryMeasuresType = mdh.SanitaryMeasuresType; + if (mdh.SickAnimalOrPetOnBoard.HasValue) + _mdh.SickAnimalOrPetOnBoard = mdh.SickAnimalOrPetOnBoard.Value ? yorntype.Y : yorntype.N; + if (mdh.SickPersonsOnBoard.HasValue) + _mdh.SickPersonOnBoard = mdh.SickPersonsOnBoard.Value ? yorntype.Y : yorntype.N; + _mdh.StowawayJoiningLocation = mdh.StowawaysJoiningLocation; + if (mdh.StowawaysDetected.HasValue) + _mdh.StowawaysDetected = mdh.StowawaysDetected.Value ? yorntype.Y : yorntype.N; + if (mdh.SuspisionInfectiousNature.HasValue) + _mdh.SuspisionInfectiousNature = mdh.SuspisionInfectiousNature.Value ? yorntype.Y : yorntype.N; + if (mdh.ValidSanitaryControlExemptionOrCertificateOnBoard.HasValue) + _mdh.ValidSanitaryControlExemptionOrCertificateOnBoard = mdh.ValidSanitaryControlExemptionOrCertificateOnBoard.Value ? yorntype.Y : yorntype.N; + _mdh.ValidSanitaryControlExemptionOrCertificate = new sanitarycertificate(); + if (mdh.DateOfIssue.HasValue) + _mdh.ValidSanitaryControlExemptionOrCertificate.DateOfIssue = mdh.DateOfIssue.Value; + _mdh.ValidSanitaryControlExemptionOrCertificate.PlaceOfIssue = mdh.PlaceOfIssue; + + _nsw.conveyance.Items3[0] = _mdh; } - } - break; - case Message.NotificationClass.BKRD: - if(!message.MessageCore.Incoming) - { + break; + #endregion + + #region NAME + case Message.NotificationClass.NAME: + NAME name = message.Elements[0] as NAME; + _nsw.conveyance.NameOfMaster = name.NameOfMaster; + break; + #endregion + + #region NOA_NOD + case Message.NotificationClass.NOA_NOD: + NOA_NOD noa_nod = message.Elements[0] as NOA_NOD; + + if (message.MessageCore.IsTransit) + { + transit _transit = _nsw.conveyance.Item as transit; + + _transit.LastPort = new lastport(); + if (noa_nod.ETDFromLastPort.HasValue) + _transit.LastPort.ETD = noa_nod.ETDFromLastPort.Value; + _transit.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue; + _transit.LastPort.Locode = noa_nod.LastPort; + + _transit.NextPort = new nextporthazmat(); + if (noa_nod.ETAToNextPort.HasValue) + _transit.NextPort.ETA = noa_nod.ETAToNextPort.Value; + _transit.NextPort.ETASpecified = noa_nod.ETAToNextPort.HasValue; + _transit.NextPort.Locode = noa_nod.NextPort; + } + else if (message.MessageCore.Incoming) // einlaufend + { + import _import = _nsw.conveyance.Item as import; + _import.LastPort = new lastport(); + if (noa_nod.ETDFromLastPort.HasValue) + _import.LastPort.ETD = noa_nod.ETDFromLastPort.Value; + _import.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue; + _import.LastPort.Locode = noa_nod.LastPort; + _import.PortOfCall = new portofcallhazmat(); + if (noa_nod.ETAToPortOfCall.HasValue) + _import.PortOfCall.ETA = noa_nod.ETAToPortOfCall.Value; + if (noa_nod.ETDFromPortOfCall.HasValue) + _import.PortOfCall.ETD = noa_nod.ETDFromPortOfCall.Value; + _import.PortOfCall.Locode = message.MessageCore.PoC; + + } + else // auslaufend + { + export _export = _nsw.conveyance.Item as export; + _export.NextPort = new nextporthazmat(); + if (noa_nod.ETAToNextPort.HasValue) + _export.NextPort.ETA = noa_nod.ETAToNextPort.Value; + _export.NextPort.ETASpecified = noa_nod.ETAToNextPort.HasValue; + _export.NextPort.Locode = noa_nod.NextPort; + _export.PortOfCall = new portofcallhazmat(); + if (noa_nod.ETAToPortOfCall.HasValue) + _export.PortOfCall.ETA = noa_nod.ETAToPortOfCall.Value; + if (noa_nod.ETDFromPortOfCall.HasValue) + _export.PortOfCall.ETD = noa_nod.ETDFromPortOfCall.Value; + _export.PortOfCall.Locode = message.MessageCore.PoC; + } + + break; + #endregion + + #region PAS + case Message.NotificationClass.PAS: if (message.Elements.Count > 0) { - _nsw.conveyance.BunkerFuelList = new bunkerfuel[message.Elements.Count]; + _nsw.conveyance.PAS = new pas(); + _nsw.conveyance.PAS.Passengers = new passenger[message.Elements.Count]; for (int i = 0; i < message.Elements.Count; i++) { - BRKD brkd = message.Elements[i] as BRKD; - _nsw.conveyance.BunkerFuelList[i] = new bunkerfuel(); - _nsw.conveyance.BunkerFuelList[i].Name = brkd.BunkerFuelType; - if (brkd.BunkerFuelQuantity_TNE.HasValue) - _nsw.conveyance.BunkerFuelList[i].NetMassTNE = (float)brkd.BunkerFuelQuantity_TNE.Value; + PAS pas = message.Elements[i] as PAS; + _nsw.conveyance.PAS.Passengers[i] = new passenger(); + if (pas.PassengerDateOfBirth.HasValue) + _nsw.conveyance.PAS.Passengers[i].PassengerDateOfBirth = pas.PassengerDateOfBirth.Value; + _nsw.conveyance.PAS.Passengers[i].PassengerFirstName = pas.PassengerFirstName; + if (pas.PassengerGender.HasValue) + _nsw.conveyance.PAS.Passengers[i].PassengerGender = (gendertype)pas.PassengerGender.Value; + _nsw.conveyance.PAS.Passengers[i].PassengerGenderSpecified = pas.PassengerGender.HasValue; + _nsw.conveyance.PAS.Passengers[i].PassengerIdentityDocumentId = pas.PassengerIdentityDocumentId; + if (pas.PassengerIdentityDocumentType.HasValue) + _nsw.conveyance.PAS.Passengers[i].PassengerIdentityDocumentType = (documenttype)pas.PassengerIdentityDocumentType.Value; + if (pas.PassengerInTransit.HasValue) + _nsw.conveyance.PAS.Passengers[i].PassengerInTransit = pas.PassengerInTransit.Value ? yorntype.Y : yorntype.N; + _nsw.conveyance.PAS.Passengers[i].PassengerLastName = pas.PassengerLastName; + _nsw.conveyance.PAS.Passengers[i].PassengerNationality = pas.PassengerNationality; + _nsw.conveyance.PAS.Passengers[i].PassengerPlaceOfBirth = pas.PassengerPlaceOfBirth; + _nsw.conveyance.PAS.Passengers[i].PassengerPortOfDisembarkation = pas.PassengerPortOfDisembarkation; + _nsw.conveyance.PAS.Passengers[i].PassengerPortOfEmbarkation = pas.PassengerPortOfEmbarkation; + _nsw.conveyance.PAS.Passengers[i].PassengerVisaNumber = pas.PassengerVisaNumber; } } - } - break; - #endregion + break; + #endregion - #region BPOL - case Message.NotificationClass.BPOL: - if (message.Elements.Count > 0) - { - BPOL bpol = message.Elements[0] as BPOL; - _nsw.conveyance.BPOL = new bpol(); - _nsw.conveyance.BPOL.StowawayOnBoard = (bpol.StowawaysOnBoard ?? false) ? yorntype.Y : yorntype.N; - if(!bpol.PortOfItineraries.IsNullOrEmpty()) + #region POBA + case Message.NotificationClass.POBA: + if (message.MessageCore.Incoming) { - _nsw.conveyance.BPOL.PortsOfItinery = new portofitinery[bpol.PortOfItineraries.Count]; - for (int i = 0; i < bpol.PortOfItineraries.Count; i++) + POBA poba = message.Elements[0] as POBA; + _nsw.conveyance.PersonsOnBoard = new pob(); + if (poba.TotalCrewMembersOnBoardUponArrival.HasValue) + _nsw.conveyance.PersonsOnBoard.TotalCrewMembersOnBoard = poba.TotalCrewMembersOnBoardUponArrival.Value.ToString(); + if (poba.TotalPassengersOnBoardUponArrival.HasValue) + _nsw.conveyance.PersonsOnBoard.TotalPassengersOnBoard = poba.TotalPassengersOnBoardUponArrival.Value.ToString(); + if (poba.TotalPersonsOnBoardUponArrival.HasValue) + _nsw.conveyance.PersonsOnBoard.TotalPersonsOnBoard = poba.TotalPersonsOnBoardUponArrival.Value.ToString(); + if (poba.TotalStowawaysOnBoardUponArrival.HasValue) + _nsw.conveyance.PersonsOnBoard.TotalStowawaysOnBoard = poba.TotalStowawaysOnBoardUponArrival.Value.ToString(); + } + break; + #endregion + + #region POBD + case Message.NotificationClass.POBD: + if (!message.MessageCore.Incoming) + { + POBD pobd = message.Elements[0] as POBD; + _nsw.conveyance.PersonsOnBoard = new pob(); + if (pobd.TotalCrewMembersOnBoardUponDeparture.HasValue) + _nsw.conveyance.PersonsOnBoard.TotalCrewMembersOnBoard = pobd.TotalCrewMembersOnBoardUponDeparture.Value.ToString(); + if (pobd.TotalPassengersOnBoardUponDeparture.HasValue) + _nsw.conveyance.PersonsOnBoard.TotalPassengersOnBoard = pobd.TotalPassengersOnBoardUponDeparture.Value.ToString(); + if (pobd.TotalPersonsOnBoardUponDeparture.HasValue) + _nsw.conveyance.PersonsOnBoard.TotalPersonsOnBoard = pobd.TotalPersonsOnBoardUponDeparture.Value.ToString(); + if (pobd.TotalStowawaysOnBoardUponDeparture.HasValue) + _nsw.conveyance.PersonsOnBoard.TotalStowawaysOnBoard = pobd.TotalStowawaysOnBoardUponDeparture.Value.ToString(); + + } + break; + #endregion + + #region PRE72H + case Message.NotificationClass.PRE72H: + PRE72H pre72h = message.Elements[0] as PRE72H; + _nsw.conveyance.Pre72H = new pre72(); + if (pre72h.DateOfLastExpandedInspection.HasValue) + _nsw.conveyance.Pre72H.DateOfLastExpandedInspection = pre72h.DateOfLastExpandedInspection.Value; + _nsw.conveyance.Pre72H.PlannedOperations = pre72h.PlannedOperations; + if (pre72h.PlannedPeriodOfStay_HUR.HasValue) + _nsw.conveyance.Pre72H.PlannedPeriodOfStay_HUR = (float)pre72h.PlannedPeriodOfStay_HUR.Value; + _nsw.conveyance.Pre72H.PlannedWorks = pre72h.PlannedWorks; + if (pre72h.Tanker.HasValue) + _nsw.conveyance.Pre72H.Tanker = pre72h.Tanker.Value ? yorntype.Y : yorntype.N; + _nsw.conveyance.Pre72H.TankerDetails = new tankerdetails(); + if (pre72h.ConditionCargoBallastTanks.HasValue) + _nsw.conveyance.Pre72H.TankerDetails.ConditionCargoBallastTanks = (cargoconditiontype)pre72h.ConditionCargoBallastTanks.Value; + _nsw.conveyance.Pre72H.TankerDetails.NatureOfCargo = pre72h.NatureOfCargo; + if (pre72h.TankerHullConfiguration.HasValue) + _nsw.conveyance.Pre72H.TankerDetails.TankerHullConfiguration = (hullconfigtype)pre72h.TankerHullConfiguration.Value; + if (pre72h.VolumeOfCargo.HasValue) + _nsw.conveyance.Pre72H.TankerDetails.VolumeOfCargo_TNE = (float)pre72h.VolumeOfCargo.Value; + _nsw.conveyance.Pre72H.TankerDetails.VolumeOfCargo_TNESpecified = pre72h.VolumeOfCargo.HasValue; + break; + #endregion + + #region SEC + case Message.NotificationClass.SEC: + SEC sec = message.Elements[0] as SEC; + if (sec.SECSimplification.HasValue) + { + if (sec.SECSimplification.Value) { - _nsw.conveyance.BPOL.PortsOfItinery[i] = new portofitinery(); - _nsw.conveyance.BPOL.PortsOfItinery[i].PortOfItineryName = bpol.PortOfItineraries[i].PortOfItineraryName; - if (bpol.PortOfItineraries[i].PortOfItineraryETA.HasValue) - _nsw.conveyance.BPOL.PortsOfItinery[i].PortOfItineryETA = bpol.PortOfItineraries[i].PortOfItineraryETA.Value; + _nsw.conveyance.Items2 = new object[2]; + _nsw.conveyance.Items2[0] = ytype.Y; + _nsw.conveyance.Items2[1] = sec.PortOfCallWhereCompleteSECNotified; } - } - } - break; - #endregion - - #region CREW - case Message.NotificationClass.CREW: - if (message.Elements.Count > 0) - { - _nsw.conveyance.CREW = new crew(); - _nsw.conveyance.CREW.CrewMembers = new crewmember[message.Elements.Count]; - for(int i=0;i 0) { - _nsw.conveyance.GeneralCargo = new loadunit[message.Elements.Count]; - for (int i = 0; i < message.Elements.Count; i++) - { - LADG ladg = message.Elements[i] as LADG; - loadunit lu = new loadunit(); - lu.CargoCodeNST = ladg.CargoCodeNST; - if (ladg.CargoGrossQuantity_TNE.HasValue) - lu.CargoGrossQuantity_TNE = (float) ladg.CargoGrossQuantity_TNE.Value; - if (ladg.CargoNumberOfItems.HasValue) - lu.CargoNumberOfItems = ladg.CargoNumberOfItems.Value.ToString(); - if (ladg.CargoHandlingType.HasValue) - lu.HandlingCode = (handlingcodetype)ladg.CargoHandlingType.Value; - _nsw.conveyance.GeneralCargo[i] = lu; - } - } - break; - #endregion - - #region MDH - case Message.NotificationClass.MDH: - MDH mdh = message.Elements[0] as MDH; - if (mdh.MDHSimplification.HasValue && mdh.MDHSimplification.Value) - { - _nsw.conveyance.Items3 = new object[2]; - _nsw.conveyance.Items3[0] = ytype.Y; - _nsw.conveyance.Items3[1] = mdh.PortOfCallWhereCompleteMDHNotified; - } - else - { - _nsw.conveyance.Items3 = new object[1]; - mdh _mdh = new mdh(); - if(mdh.AwareOfFurtherInfections.HasValue) - _mdh.AwareOfConditionsForFurtherInfections = mdh.AwareOfFurtherInfections.Value ? yorntype.Y : yorntype.N; - _mdh.InfectedArea = new infectedarea(); - if(mdh.InfectedAreaDate.HasValue) - _mdh.InfectedArea.InfectedAreaDate = mdh.InfectedAreaDate.Value; - _mdh.InfectedArea.InfectedAreaPort = mdh.InfectedAreaPort; - if(mdh.InfectedAreaVisited.HasValue) - _mdh.InfectedAreaVisited = mdh.InfectedAreaVisited.Value ? yorntype.Y : yorntype.N; - if (mdh.MedicalConsulted.HasValue) - _mdh.MedicalConsulted = mdh.MedicalConsulted.Value ? yorntype.Y : yorntype.N; - if (mdh.NonAccidentalDeathsDuringVoyage.HasValue) - _mdh.NonAccidentialDeathsDuringVoyage = mdh.NonAccidentalDeathsDuringVoyage.Value ? yorntype.Y : yorntype.N; - if (mdh.NonAccidentalDeathsDuringVoyageCount.HasValue) - _mdh.NonAccidentialDeathsDuringVoyageCount = mdh.NonAccidentalDeathsDuringVoyageCount.Value.ToString(); - if (mdh.NumberOfIllPersons.HasValue) - _mdh.NumberOfIllPersons = mdh.NumberOfIllPersons.Value.ToString(); - if(mdh.NumberOfIllPersonsHigherThanExpected.HasValue) - _mdh.NumberOfIllPersonsHigherThanExpected = mdh.NumberOfIllPersonsHigherThanExpected.Value ? yorntype.Y : yorntype.N; - if (mdh.PortOfCallLast30Days.Count > 0) - { - _mdh.PortsOfCallLast30Days = new portofcallmdh[mdh.PortOfCallLast30Days.Count]; - for (int i = 0; i < mdh.PortOfCallLast30Days.Count; i++) + else { - _mdh.PortsOfCallLast30Days[i] = new portofcallmdh(); - _mdh.PortsOfCallLast30Days[i].Index = i.ToString(); - if(mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count > 0) { - _mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip = new string[mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count]; - for (int j = 0; j < mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count; j++) + _nsw.conveyance.Items2 = new object[1]; + sec _sec = new sec(); + if (sec.ApprovedSecurityPlanOnBoard.HasValue) + _sec.ApprovedSecurityPlanOnBoard = sec.ApprovedSecurityPlanOnBoard.Value ? yorntype.Y : yorntype.N; + _sec.CSOEMail = sec.CSOEMail; + _sec.CSOFax = sec.CSOFax; + _sec.CSOFirstName = sec.CSOFirstName; + _sec.CSOLastName = sec.CSOLastName; + _sec.CSOPhone = sec.CSOPhone; + if (sec.CurrentShipSecurityLevel.HasValue) + _sec.CurrentShipSecurityLevel = (posint13type)sec.CurrentShipSecurityLevel.Value; + if (sec.GeneralDescriptionOfCargo.HasValue) + _sec.GeneralDescriptionOfCargo = (cargodescriptiontype)sec.GeneralDescriptionOfCargo.Value; + if (sec.ISSCDateOfExpiration.HasValue) + _sec.ISSCDateOfExpiration = sec.ISSCDateOfExpiration.Value; + _sec.ISSCIssuerName = sec.ISSCIssuerName; + if (sec.ISSCIssuerType.HasValue) + _sec.ISSCIssuerType = (isscissuertype)sec.ISSCIssuerType; + if (sec.ISSCType.HasValue) + _sec.ISSCType = (issctype)sec.ISSCType; + _sec.PortFacilityOfArrival = sec.PortFacilityOfArrival; + _sec.ReasonsForNoValidISSC = sec.ReasonsForNoValidISSC; + if (sec.ValidISSCOnBoard.HasValue) + _sec.ValidISSCOnBoard = sec.ValidISSCOnBoard.Value ? yorntype.Y : yorntype.N; + if (!sec.LastTenPortFacilitesCalled.IsNullOrEmpty()) + { + _sec.Last10Ports = new last10port[sec.LastTenPortFacilitesCalled.Count]; + for (int i = 0; i < sec.LastTenPortFacilitesCalled.Count; i++) { - _mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip[j] = mdh.PortOfCallLast30Days[i].CrewJoinedShip[j].PortOfCallLast30DaysCrewJoinedShipName; + _sec.Last10Ports[i] = new last10port(); + _sec.Last10Ports[i].Index = i.ToString(); + if (sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.HasValue) + _sec.Last10Ports[i].PortFacilityDateOfArrival = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.Value; + if (sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.HasValue) + _sec.Last10Ports[i].PortFacilityDateOfDeparture = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.Value; + _sec.Last10Ports[i].PortFacilityGISISCode = sec.LastTenPortFacilitesCalled[i].PortFacilityGISISCode; + _sec.Last10Ports[i].PortFacilityPortCountry = sec.LastTenPortFacilitesCalled[i].PortFacilityPortCountry; + _sec.Last10Ports[i].PortFacilityPortLoCode = sec.LastTenPortFacilitesCalled[i].PortFacilityPortLoCode; + _sec.Last10Ports[i].PortFacilityPortName = sec.LastTenPortFacilitesCalled[i].PortFacilitySecurityMattersToReport; + _sec.Last10Ports[i].PortFacilitySecurityMattersToReport = sec.LastTenPortFacilitesCalled[i].PortFacilitySecurityMattersToReport; + if (sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.HasValue) + _sec.Last10Ports[i].PortFacilityShipSecurityLevel = (posint13type)sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.Value; } } - if (mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined.HasValue) - _mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined.Value ? yorntype.Y : yorntype.N; - if (mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.HasValue) - _mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.Value; - _mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysLocode = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysLocode; + + if (!sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.IsNullOrEmpty()) + { + _sec.LastActivities = new lastactivity[sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count]; + for (int i = 0; i < sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count; i++) + { + _sec.LastActivities[i] = new lastactivity(); + if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.HasValue) + _sec.LastActivities[i].ShipToShipActivityDateFrom = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.Value; + if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.HasValue) + _sec.LastActivities[i].ShipToShipActivityDateTo = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.Value; + _sec.LastActivities[i].ShipToShipActivityLocation = new location(); + _sec.LastActivities[i].ShipToShipActivityLocation.Items = new object[3]; + + coordinates coords = new coordinates(); + if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude.HasValue) + coords.ShipToShipActivityLocationCoordinatesLatitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude.Value.ToString(); + if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude.HasValue) + coords.ShipToShipActivityLocationCoordinatesLongitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude.Value.ToString(); + _sec.LastActivities[i].ShipToShipActivityLocation.Items[0] = coords; + _sec.LastActivities[i].ShipToShipActivityLocation.Items[1] = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationLoCode; + _sec.LastActivities[i].ShipToShipActivityLocation.Items[2] = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationName; + _sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName = new ItemsChoiceType2[3]; + _sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName[0] = ItemsChoiceType2.ShipToShipActivityLocationCoordinates; + _sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName[1] = ItemsChoiceType2.ShipToShipActivityLocationLoCode; + _sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName[2] = ItemsChoiceType2.ShipToShipActivityLocationName; + _sec.LastActivities[i].ShipToShipActivitySecurityMattersToReportOf = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivitySecurityMattersToReport; + _sec.LastActivities[i].ShipToShipActivityType = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityType; + } + } + _nsw.conveyance.Items2[0] = _sec; } } - if (mdh.SanitaryControlReinspectionRequired.HasValue) - _mdh.SanitaryControlReinspectionRequired = mdh.SanitaryControlReinspectionRequired.Value ? yorntype.Y : yorntype.N; - if (mdh.SanitaryMeasuresApplied.HasValue) - _mdh.SanitaryMeasuresApplied = mdh.SanitaryMeasuresApplied.Value ? yorntype.Y : yorntype.N; - _mdh.SanitaryMeasuresDetails = new sanitarydetails(); - if (mdh.SanitaryMeasuresDate.HasValue) - _mdh.SanitaryMeasuresDetails.SanitaryMeasuresDate = mdh.SanitaryMeasuresDate.Value; - _mdh.SanitaryMeasuresDetails.SanitaryMeasuresLocation = mdh.SanitaryMeasuresLocation; - _mdh.SanitaryMeasuresDetails.SanitaryMeasuresType = mdh.SanitaryMeasuresType; - if (mdh.SickAnimalOrPetOnBoard.HasValue) - _mdh.SickAnimalOrPetOnBoard = mdh.SickAnimalOrPetOnBoard.Value ? yorntype.Y : yorntype.N; - if (mdh.SickPersonsOnBoard.HasValue) - _mdh.SickPersonOnBoard = mdh.SickPersonsOnBoard.Value ? yorntype.Y : yorntype.N; - _mdh.StowawayJoiningLocation = mdh.StowawaysJoiningLocation; - if (mdh.StowawaysDetected.HasValue) - _mdh.StowawaysDetected = mdh.StowawaysDetected.Value ? yorntype.Y : yorntype.N; - if (mdh.SuspisionInfectiousNature.HasValue) - _mdh.SuspisionInfectiousNature = mdh.SuspisionInfectiousNature.Value ? yorntype.Y : yorntype.N; - if (mdh.ValidSanitaryControlExemptionOrCertificateOnBoard.HasValue) - _mdh.ValidSanitaryControlExemptionOrCertificateOnBoard = mdh.ValidSanitaryControlExemptionOrCertificateOnBoard.Value ? yorntype.Y : yorntype.N; - _mdh.ValidSanitaryControlExemptionOrCertificate = new sanitarycertificate(); - if (mdh.DateOfIssue.HasValue) - _mdh.ValidSanitaryControlExemptionOrCertificate.DateOfIssue = mdh.DateOfIssue.Value; - _mdh.ValidSanitaryControlExemptionOrCertificate.PlaceOfIssue = mdh.PlaceOfIssue; + break; + #endregion - _nsw.conveyance.Items3[0] = mdh; - } - break; - #endregion - - #region NAME - case Message.NotificationClass.NAME: - NAME name = message.Elements[0] as NAME; - _nsw.conveyance.NameOfMaster = name.NameOfMaster; - break; - #endregion - - #region NOA_NOD - case Message.NotificationClass.NOA_NOD: - NOA_NOD noa_nod = message.Elements[0] as NOA_NOD; - - if (message.MessageCore.IsTransit) - { - transit _transit = _nsw.conveyance.Item as transit; - - _transit.LastPort = new lastport(); - if (noa_nod.ETDFromLastPort.HasValue) - _transit.LastPort.ETD = noa_nod.ETDFromLastPort.Value; - _transit.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue; - _transit.LastPort.Locode = noa_nod.LastPort; - - _transit.NextPort = new nextporthazmat(); - if (noa_nod.ETAToNextPort.HasValue) - _transit.NextPort.ETA = noa_nod.ETAToNextPort.Value; - _transit.NextPort.ETASpecified = noa_nod.ETAToNextPort.HasValue; - _transit.NextPort.Locode = noa_nod.NextPort; - } - else if(message.MessageCore.Incoming) // einlaufend - { - import _import = _nsw.conveyance.Item as import; - _import.LastPort = new lastport(); - if (noa_nod.ETDFromLastPort.HasValue) - _import.LastPort.ETD = noa_nod.ETDFromLastPort.Value; - _import.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue; - _import.LastPort.Locode = noa_nod.LastPort; - _import.PortOfCall = new portofcallhazmat(); - if (noa_nod.ETAToPortOfCall.HasValue) - _import.PortOfCall.ETA = noa_nod.ETAToPortOfCall.Value; - if (noa_nod.ETDFromPortOfCall.HasValue) - _import.PortOfCall.ETD = noa_nod.ETDFromPortOfCall.Value; - _import.PortOfCall.Locode = message.MessageCore.PoC; - - } - else // auslaufend - { - export _export = _nsw.conveyance.Item as export; - _export.NextPort = new nextporthazmat(); - if (noa_nod.ETAToNextPort.HasValue) - _export.NextPort.ETA = noa_nod.ETAToNextPort.Value; - _export.NextPort.ETASpecified = noa_nod.ETAToNextPort.HasValue; - _export.NextPort.Locode = noa_nod.NextPort; - _export.PortOfCall = new portofcallhazmat(); - if (noa_nod.ETAToPortOfCall.HasValue) - _export.PortOfCall.ETA = noa_nod.ETAToPortOfCall.Value; - if (noa_nod.ETDFromPortOfCall.HasValue) - _export.PortOfCall.ETD = noa_nod.ETDFromPortOfCall.Value; - _export.PortOfCall.Locode = message.MessageCore.PoC; - } - - break; - #endregion - - #region PAS - case Message.NotificationClass.PAS: - if (message.Elements.Count > 0) - { - _nsw.conveyance.PAS = new pas(); - _nsw.conveyance.PAS.Passengers = new passenger[message.Elements.Count]; - for (int i = 0; i < message.Elements.Count; i++) + #region SERV + case Message.NotificationClass.SERV: + if (!message.Elements.IsNullOrEmpty()) { - PAS pas = message.Elements[i] as PAS; - _nsw.conveyance.PAS.Passengers[i] = new passenger(); - if(pas.PassengerDateOfBirth.HasValue) - _nsw.conveyance.PAS.Passengers[i].PassengerDateOfBirth = pas.PassengerDateOfBirth.Value; - _nsw.conveyance.PAS.Passengers[i].PassengerFirstName = pas.PassengerFirstName; - if(pas.PassengerGender.HasValue) - _nsw.conveyance.PAS.Passengers[i].PassengerGender = (gendertype)pas.PassengerGender.Value; - _nsw.conveyance.PAS.Passengers[i].PassengerGenderSpecified = pas.PassengerGender.HasValue; - _nsw.conveyance.PAS.Passengers[i].PassengerIdentityDocumentId = pas.PassengerIdentityDocumentId; - if (pas.PassengerIdentityDocumentType.HasValue) - _nsw.conveyance.PAS.Passengers[i].PassengerIdentityDocumentType = (documenttype)pas.PassengerIdentityDocumentType.Value; - if(pas.PassengerInTransit.HasValue) - _nsw.conveyance.PAS.Passengers[i].PassengerInTransit = pas.PassengerInTransit.Value ? yorntype.Y : yorntype.N; - _nsw.conveyance.PAS.Passengers[i].PassengerLastName = pas.PassengerLastName; - _nsw.conveyance.PAS.Passengers[i].PassengerNationality = pas.PassengerNationality; - _nsw.conveyance.PAS.Passengers[i].PassengerPlaceOfBirth = pas.PassengerPlaceOfBirth; - _nsw.conveyance.PAS.Passengers[i].PassengerPortOfDisembarkation = pas.PassengerPortOfDisembarkation; - _nsw.conveyance.PAS.Passengers[i].PassengerPortOfEmbarkation = pas.PassengerPortOfEmbarkation; - _nsw.conveyance.PAS.Passengers[i].PassengerVisaNumber = pas.PassengerVisaNumber; + _nsw.conveyance.Serv = new serv(); + _nsw.conveyance.Serv.Services = new service[message.Elements.Count]; + for (int i = 0; i < message.Elements.Count; i++) + { + SERV serv = message.Elements[i] as SERV; + _nsw.conveyance.Serv.Services[i] = new service(); + _nsw.conveyance.Serv.Services[i].ServiceBeneficiary = serv.ServiceBeneficiary; + _nsw.conveyance.Serv.Services[i].ServiceInvoiced = serv.ServiceName; + _nsw.conveyance.Serv.Services[i].ServiceInvoiceRecipient = serv.ServiceInvoiceRecipient; + } } - } - break; - #endregion + break; + #endregion - #region POBA - case Message.NotificationClass.POBA: - if (message.MessageCore.Incoming) - { - POBA poba = message.Elements[0] as POBA; - _nsw.conveyance.PersonsOnBoard = new pob(); - if (poba.TotalCrewMembersOnBoardUponArrival.HasValue) - _nsw.conveyance.PersonsOnBoard.TotalCrewMembersOnBoard = poba.TotalCrewMembersOnBoardUponArrival.Value.ToString(); - if (poba.TotalPassengersOnBoardUponArrival.HasValue) - _nsw.conveyance.PersonsOnBoard.TotalPassengersOnBoard = poba.TotalPassengersOnBoardUponArrival.Value.ToString(); - if (poba.TotalPersonsOnBoardUponArrival.HasValue) - _nsw.conveyance.PersonsOnBoard.TotalPersonsOnBoard = poba.TotalPersonsOnBoardUponArrival.Value.ToString(); - if (poba.TotalStowawaysOnBoardUponArrival.HasValue) - _nsw.conveyance.PersonsOnBoard.TotalStowawaysOnBoard = poba.TotalStowawaysOnBoardUponArrival.Value.ToString(); - } - break; - #endregion + #region STAT + case Message.NotificationClass.STAT: + STAT stat = message.Elements[0] as STAT; + if (stat.Beam_MTR.HasValue) + _nsw.conveyance.vessel.Beam_MTR = (float)stat.Beam_MTR.Value; + _nsw.conveyance.vessel.CallSign = stat.CallSign; + _nsw.conveyance.vessel.Flag = stat.Flag; + if (stat.GrossTonnage.HasValue) + _nsw.conveyance.vessel.GrossTonnage = stat.GrossTonnage.Value.ToString(); + _nsw.conveyance.vessel.InmarsatCallNumber = stat.InmarsatCallNumber; + _nsw.conveyance.vessel.ISMCompany = new ismcompany(); + _nsw.conveyance.vessel.ISMCompany.ISMCompanyCity = stat.ISMCompanyCity; + _nsw.conveyance.vessel.ISMCompany.ISMCompanyCountry = stat.ISMCompanyCountry; + _nsw.conveyance.vessel.ISMCompany.ISMCompanyId = stat.ISMCompanyId; + _nsw.conveyance.vessel.ISMCompany.ISMCompanyName = stat.ISMCompanyName; + _nsw.conveyance.vessel.ISMCompany.ISMCompanyPostalCode = stat.ISMCompanyPostalCode; + _nsw.conveyance.vessel.ISMCompany.ISMCompanyStreetAndNumber = stat.ISMCompanyStreetAndNumber; + if (stat.LengthOverall_MTR.HasValue) + _nsw.conveyance.vessel.LengthOverall_MTR = (float)stat.LengthOverall_MTR.Value; + _nsw.conveyance.vessel.MMSINumber = stat.MMSINumber; + _nsw.conveyance.vessel.PortOfRegistry = stat.PortOfRegistry; + _nsw.conveyance.vessel.ShipName = stat.ShipName; + _nsw.conveyance.vessel.ShipType = stat.ShipType; + break; + #endregion - #region POBD - case Message.NotificationClass.POBD: - if (!message.MessageCore.Incoming) - { - POBD pobd = message.Elements[0] as POBD; - _nsw.conveyance.PersonsOnBoard = new pob(); - if (pobd.TotalCrewMembersOnBoardUponDeparture.HasValue) - _nsw.conveyance.PersonsOnBoard.TotalCrewMembersOnBoard = pobd.TotalCrewMembersOnBoardUponDeparture.Value.ToString(); - if (pobd.TotalPassengersOnBoardUponDeparture.HasValue) - _nsw.conveyance.PersonsOnBoard.TotalPassengersOnBoard = pobd.TotalPassengersOnBoardUponDeparture.Value.ToString(); - if (pobd.TotalPersonsOnBoardUponDeparture.HasValue) - _nsw.conveyance.PersonsOnBoard.TotalPersonsOnBoard = pobd.TotalPersonsOnBoardUponDeparture.Value.ToString(); - if (pobd.TotalStowawaysOnBoardUponDeparture.HasValue) - _nsw.conveyance.PersonsOnBoard.TotalStowawaysOnBoard = pobd.TotalStowawaysOnBoardUponDeparture.Value.ToString(); - - } - break; - #endregion - - #region PRE72H - case Message.NotificationClass.PRE72H: - PRE72H pre72h = message.Elements[0] as PRE72H; - _nsw.conveyance.Pre72H = new pre72(); - if(pre72h.DateOfLastExpandedInspection.HasValue) - _nsw.conveyance.Pre72H.DateOfLastExpandedInspection = pre72h.DateOfLastExpandedInspection.Value; - _nsw.conveyance.Pre72H.PlannedOperations = pre72h.PlannedOperations; - if (pre72h.PlannedPeriodOfStay_HUR.HasValue) - _nsw.conveyance.Pre72H.PlannedPeriodOfStay_HUR = (float)pre72h.PlannedPeriodOfStay_HUR.Value; - _nsw.conveyance.Pre72H.PlannedWorks = pre72h.PlannedWorks; - if (pre72h.Tanker.HasValue) - _nsw.conveyance.Pre72H.Tanker = pre72h.Tanker.Value ? yorntype.Y : yorntype.N; - _nsw.conveyance.Pre72H.TankerDetails = new tankerdetails(); - if (pre72h.ConditionCargoBallastTanks.HasValue) - _nsw.conveyance.Pre72H.TankerDetails.ConditionCargoBallastTanks = (cargoconditiontype)pre72h.ConditionCargoBallastTanks.Value; - _nsw.conveyance.Pre72H.TankerDetails.NatureOfCargo = pre72h.NatureOfCargo; - if(pre72h.TankerHullConfiguration.HasValue) - _nsw.conveyance.Pre72H.TankerDetails.TankerHullConfiguration = (hullconfigtype)pre72h.TankerHullConfiguration.Value; - if(pre72h.VolumeOfCargo.HasValue) - _nsw.conveyance.Pre72H.TankerDetails.VolumeOfCargo_TNE = (float)pre72h.VolumeOfCargo.Value; - _nsw.conveyance.Pre72H.TankerDetails.VolumeOfCargo_TNESpecified = pre72h.VolumeOfCargo.HasValue; - break; - #endregion - - #region SEC - case Message.NotificationClass.SEC: - SEC sec = message.Elements[0] as SEC; - if (sec.SECSimplification.HasValue) - { - if (sec.SECSimplification.Value) + #region TIEFA + case Message.NotificationClass.TIEFA: + TIEFA tiefa = message.Elements[0] as TIEFA; + if (tiefa != null) { - _nsw.conveyance.Items2 = new object[2]; - _nsw.conveyance.Items2[0] = ytype.Y; - _nsw.conveyance.Items2[1] = sec.PortOfCallWhereCompleteSECNotified; + if (tiefa.DraughtUponArrival_DMT.HasValue) + _nsw.conveyance.Draught_DMT = (float)tiefa.DraughtUponArrival_DMT.Value; + _nsw.conveyance.Draught_DMTSpecified = tiefa.DraughtUponArrival_DMT.HasValue; + } + break; + case Message.NotificationClass.TIEFD: + TIEFD tiefd = message.Elements[0] as TIEFD; + if (tiefd != null) + { + if (tiefd.DraughtUponDeparture_DMT.HasValue) + _nsw.conveyance.Draught_DMT = (float)tiefd.DraughtUponDeparture_DMT.Value; + _nsw.conveyance.Draught_DMTSpecified = tiefd.DraughtUponDeparture_DMT.HasValue; + } + break; + #endregion + + #region TOWA/TOWD + case Message.NotificationClass.TOWA: + if (message.MessageCore.Incoming) + { + if (message.Elements.Count > 0) + { + _nsw.conveyance.TOWS = new tow[message.Elements.Count]; + for (int i = 0; i < message.Elements.Count; i++) + { + tow _tow = new tow(); + _nsw.conveyance.TOWS[i] = _tow; + TOWA towa = message.Elements[0] as TOWA; + if (towa.TowageOnArrivalBeam_MTR.HasValue) + _tow.TowageBeam_MTR = (float)towa.TowageOnArrivalBeam_MTR.Value; + if (towa.TowageOnArrivalDraught_DMT.HasValue) + _tow.TowageDraught_DMT = (float)towa.TowageOnArrivalDraught_DMT.Value; + _tow.TowageFlag = towa.TowageOnArrivalFlag; + if (towa.TowageOnArrivalGrossTonnage.HasValue) + _tow.TowageGrossTonnage = towa.TowageOnArrivalGrossTonnage.Value.ToString(); + if (towa.TowageOnArrivalLengthOverall_MTR.HasValue) + _tow.TowageLengthOverall_MTR = (float)towa.TowageOnArrivalLengthOverall_MTR.Value; + _tow.TowageName = towa.TowageOnArrivalName; + _tow.TowageOperator = new towageoperator(); + _tow.TowageOperator.Address = new address(); + _tow.TowageOperator.Address.TowageOperatorCity = towa.TowageOnArrivalOperatorCity; + _tow.TowageOperator.Address.TowageOperatorCountry = towa.TowageOnArrivalOperatorCountry; + _tow.TowageOperator.Address.TowageOperatorPostalCode = towa.TowageOnArrivalOperatorPostalCode; + _tow.TowageOperator.Address.TowageOperatorStreetAndNumber = towa.TowageOnArrivalOperatorStreetNameAndNumber; + _tow.TowageOperator.Contact = new contact(); + _tow.TowageOperator.Contact.TowageOperatorFax = towa.TowageOnArrivalOperatorFax; + _tow.TowageOperator.Contact.TowageOperatorPhone = towa.TowageOnArrivalOperatorPhone; + _tow.TowageOperator.Contact.TowareOperatorEMail = towa.TowageOnArrivalOperatorEmail; + _tow.TowageOperator.TowageOperatorCompanyName = towa.TowageOnArrivalOperatorCompanyName; + _tow.TowagePurposeOfCall = towa.TowageOnArrivalPurposeOfCall; + _tow.TowageRemarks = towa.TowageOnArrivalRemarks; + } + } + } + break; + case Message.NotificationClass.TOWD: + if (!message.MessageCore.Incoming) + { + if (message.Elements.Count > 0) + { + _nsw.conveyance.TOWS = new tow[message.Elements.Count]; + for (int i = 0; i < message.Elements.Count; i++) + { + tow _tow = new tow(); + _nsw.conveyance.TOWS[i] = _tow; + TOWD towd = message.Elements[0] as TOWD; + if (towd.TowageOnDepartureBeam_MTR.HasValue) + _tow.TowageBeam_MTR = (float)towd.TowageOnDepartureBeam_MTR.Value; + if (towd.TowageOnDepartureDraught_DMT.HasValue) + _tow.TowageDraught_DMT = (float)towd.TowageOnDepartureDraught_DMT.Value; + _tow.TowageFlag = towd.TowageOnDepartureFlag; + _tow.TowageName = towd.TowageOnDepartureName; + _tow.TowageOperator = new towageoperator(); + _tow.TowageOperator.Address = new address(); + _tow.TowageOperator.Address.TowageOperatorCity = towd.TowageOnDepartureOperatorCity; + _tow.TowageOperator.Address.TowageOperatorCountry = towd.TowageOnDepartureOperatorCountry; + _tow.TowageOperator.Address.TowageOperatorPostalCode = towd.TowageOnDepartureOperatorPostalCode; + _tow.TowageOperator.Address.TowageOperatorStreetAndNumber = towd.TowageOnDepartureOperatorStreetNameAndNumber; + _tow.TowageOperator.Contact = new contact(); + _tow.TowageOperator.Contact.TowageOperatorFax = towd.TowageOnDepartureOperatorFax; + _tow.TowageOperator.Contact.TowageOperatorPhone = towd.TowageOnDepartureOperatorPhone; + _tow.TowageOperator.Contact.TowareOperatorEMail = towd.TowageOnDepartureOperatorEmail; + _tow.TowageOperator.TowageOperatorCompanyName = towd.TowageOnDepartureOperatorCompanyName; + _tow.TowageRemarks = towd.TowageOnDepartureRemarks; + } + } + } + break; + #endregion + + #region WAS + case Message.NotificationClass.WAS: + WAS was = message.Elements[0] as WAS; + if (was.WasteDisposalValidExemption ?? false) + { + _nsw.conveyance.Item1 = new object(); + _nsw.conveyance.Item1 = ytype.Y; } else { - _nsw.conveyance.Items2 = new object[1]; - sec _sec = new sec(); - if (sec.ApprovedSecurityPlanOnBoard.HasValue) - _sec.ApprovedSecurityPlanOnBoard = sec.ApprovedSecurityPlanOnBoard.Value ? yorntype.Y : yorntype.N; - _sec.CSOEMail = sec.CSOEMail; - _sec.CSOFax = sec.CSOFax; - _sec.CSOFirstName = sec.CSOFirstName; - _sec.CSOLastName = sec.CSOLastName; - _sec.CSOPhone = sec.CSOPhone; - if (sec.CurrentShipSecurityLevel.HasValue) - _sec.CurrentShipSecurityLevel = (posint13type)sec.CurrentShipSecurityLevel.Value; - if(sec.GeneralDescriptionOfCargo.HasValue) - _sec.GeneralDescriptionOfCargo = (cargodescriptiontype)sec.GeneralDescriptionOfCargo.Value; - if(sec.ISSCDateOfExpiration.HasValue) - _sec.ISSCDateOfExpiration = sec.ISSCDateOfExpiration.Value; - _sec.ISSCIssuerName = sec.ISSCIssuerName; - if(sec.ISSCIssuerType.HasValue) - _sec.ISSCIssuerType = (isscissuertype)sec.ISSCIssuerType; - if(sec.ISSCType.HasValue) - _sec.ISSCType = (issctype)sec.ISSCType; - _sec.PortFacilityOfArrival = sec.PortFacilityOfArrival; - _sec.ReasonsForNoValidISSC = sec.ReasonsForNoValidISSC; - if(sec.ValidISSCOnBoard.HasValue) - _sec.ValidISSCOnBoard = sec.ValidISSCOnBoard.Value ? yorntype.Y : yorntype.N; - if(!sec.LastTenPortFacilitesCalled.IsNullOrEmpty()) + was _waste = new was(); + _waste.ConfirmationOfCorrectness = (was.ConfirmationOfCorrectness ?? false) ? yorntype.Y : yorntype.N; + if (was.LastWasteDisposalDate.HasValue) + _waste.LastWasteDisposalDate = was.LastWasteDisposalDate.Value; + _waste.LastWasteDisposalPort = was.LastWasteDisposalPort; + if (was.WasteDisposalDelivery.HasValue) + _waste.WasteDisposalDelivery = (wastedeliverytype)was.WasteDisposalDelivery.Value; + if (was.WasteDisposalServiceProvider.Count > 0) + _waste.WasteDisposalServiceProviderName = new string[was.WasteDisposalServiceProvider.Count]; + for (int i = 0; i < was.WasteDisposalServiceProvider.Count; i++) { - _sec.Last10Ports = new last10port[sec.LastTenPortFacilitesCalled.Count]; - for (int i = 0; i < sec.LastTenPortFacilitesCalled.Count; i++) + _waste.WasteDisposalServiceProviderName[i] = was.WasteDisposalServiceProvider[i].WasteDisposalServiceProviderName; + } + if (was.Waste.Count > 0) + { + _waste.Wastes = new waste[was.Waste.Count]; + for (int i = 0; i < was.Waste.Count; i++) { - _sec.Last10Ports[i] = new last10port(); - _sec.Last10Ports[i].Index = i.ToString(); - if (sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.HasValue) - _sec.Last10Ports[i].PortFacilityDateOfArrival = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.Value; - if(sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.HasValue) - _sec.Last10Ports[i].PortFacilityDateOfDeparture = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.Value; - _sec.Last10Ports[i].PortFacilityGISISCode = sec.LastTenPortFacilitesCalled[i].PortFacilityGISISCode; - _sec.Last10Ports[i].PortFacilityPortCountry = sec.LastTenPortFacilitesCalled[i].PortFacilityPortCountry; - _sec.Last10Ports[i].PortFacilityPortLoCode = sec.LastTenPortFacilitesCalled[i].PortFacilityPortLoCode; - _sec.Last10Ports[i].PortFacilityPortName = sec.LastTenPortFacilitesCalled[i].PortFacilitySecurityMattersToReport; - _sec.Last10Ports[i].PortFacilitySecurityMattersToReport = sec.LastTenPortFacilitesCalled[i].PortFacilitySecurityMattersToReport; - if(sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.HasValue) - _sec.Last10Ports[i].PortFacilityShipSecurityLevel = (posint13type)sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.Value; + waste _aWaste = new waste(); + _aWaste.WasteDescription = was.Waste[i].WasteDescription; + _aWaste.WasteDetails = new wastedetails(); + _aWaste.WasteDetails.WasteAmountGeneratedTillNextPort_MTQSpecified = was.Waste[i].WasteAmountGeneratedTillNextPort_MTQ.HasValue; + if (was.Waste[i].WasteAmountGeneratedTillNextPort_MTQ.HasValue) + _aWaste.WasteDetails.WasteAmountGeneratedTillNextPort_MTQ = (float)was.Waste[i].WasteAmountGeneratedTillNextPort_MTQ.Value; + _aWaste.WasteDetails.WasteAmountRetained_MTQSpecified = was.Waste[i].WasteAmountRetained_MTQ.HasValue; + if (was.Waste[i].WasteAmountRetained_MTQ.HasValue) + _aWaste.WasteDetails.WasteAmountRetained_MTQ = (float)was.Waste[i].WasteAmountRetained_MTQ.Value; + _aWaste.WasteDetails.WasteCapacity_MTQSpecified = was.Waste[i].WasteCapacity_MTQ.HasValue; + if (was.Waste[i].WasteCapacity_MTQ.HasValue) + _aWaste.WasteDetails.WasteCapacity_MTQ = (float)was.Waste[i].WasteCapacity_MTQ.Value; + _aWaste.WasteDetails.WasteDisposalPort = was.Waste[i].WasteDisposalPort; + if (was.Waste[i].WasteDisposalAmount_MTQ.HasValue) + _aWaste.WasteDisposalAmount_MTQ = (float)was.Waste[i].WasteDisposalAmount_MTQ.Value; + if (was.Waste[i].WasteType.HasValue) + _aWaste.WasteType = (wastetype)was.Waste[i].WasteType.Value; + _waste.Wastes[i] = _aWaste; } } - - if(!sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.IsNullOrEmpty()) - { - _sec.LastActivities = new lastactivity[sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count]; - for (int i = 0; i < sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count; i++) - { - _sec.LastActivities[i] = new lastactivity(); - if(sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.HasValue) - _sec.LastActivities[i].ShipToShipActivityDateFrom = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.Value; - if(sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.HasValue) - _sec.LastActivities[i].ShipToShipActivityDateTo = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.Value; - _sec.LastActivities[i].ShipToShipActivityLocation = new location(); - _sec.LastActivities[i].ShipToShipActivityLocation.Items = new object[3]; - - coordinates coords = new coordinates(); - if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude.HasValue) - coords.ShipToShipActivityLocationCoordinatesLatitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude.Value.ToString(); - if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude.HasValue) - coords.ShipToShipActivityLocationCoordinatesLongitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude.Value.ToString(); - _sec.LastActivities[i].ShipToShipActivityLocation.Items[0] = coords; - _sec.LastActivities[i].ShipToShipActivityLocation.Items[1] = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationLoCode; - _sec.LastActivities[i].ShipToShipActivityLocation.Items[2] = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationName; - _sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName = new ItemsChoiceType2[3]; - _sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName[0] = ItemsChoiceType2.ShipToShipActivityLocationCoordinates; - _sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName[1] = ItemsChoiceType2.ShipToShipActivityLocationLoCode; - _sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName[2] = ItemsChoiceType2.ShipToShipActivityLocationName; - _sec.LastActivities[i].ShipToShipActivitySecurityMattersToReportOf = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivitySecurityMattersToReport; - _sec.LastActivities[i].ShipToShipActivityType = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityType; - } - } - _nsw.conveyance.Items2[0] = _sec; + _nsw.conveyance.Item1 = _waste; } - } - break; - #endregion + break; + #endregion - #region SERV - case Message.NotificationClass.SERV: - if (!message.Elements.IsNullOrEmpty()) - { - _nsw.conveyance.Serv = new serv(); - _nsw.conveyance.Serv.Services = new service[message.Elements.Count]; - for (int i = 0; i < message.Elements.Count; i++) - { - SERV serv = message.Elements[i] as SERV; - _nsw.conveyance.Serv.Services[i] = new service(); - _nsw.conveyance.Serv.Services[i].ServiceBeneficiary = serv.ServiceBeneficiary; - _nsw.conveyance.Serv.Services[i].ServiceInvoiced = serv.ServiceName; - _nsw.conveyance.Serv.Services[i].ServiceInvoiceRecipient = serv.ServiceInvoiceRecipient; - } - } - break; - #endregion - - #region STAT - case Message.NotificationClass.STAT: - STAT stat = message.Elements[0] as STAT; - if (stat.Beam_MTR.HasValue) - _nsw.conveyance.vessel.Beam_MTR = (float) stat.Beam_MTR.Value; - _nsw.conveyance.vessel.CallSign = stat.CallSign; - _nsw.conveyance.vessel.Flag = stat.Flag; - if (stat.GrossTonnage.HasValue) - _nsw.conveyance.vessel.GrossTonnage = stat.GrossTonnage.Value.ToString(); - _nsw.conveyance.vessel.InmarsatCallNumber = stat.InmarsatCallNumber; - _nsw.conveyance.vessel.ISMCompany = new ismcompany(); - _nsw.conveyance.vessel.ISMCompany.ISMCompanyCity = stat.ISMCompanyCity; - _nsw.conveyance.vessel.ISMCompany.ISMCompanyCountry = stat.ISMCompanyCountry; - _nsw.conveyance.vessel.ISMCompany.ISMCompanyId = stat.ISMCompanyId; - _nsw.conveyance.vessel.ISMCompany.ISMCompanyName = stat.ISMCompanyName; - _nsw.conveyance.vessel.ISMCompany.ISMCompanyPostalCode = stat.ISMCompanyPostalCode; - _nsw.conveyance.vessel.ISMCompany.ISMCompanyStreetAndNumber = stat.ISMCompanyStreetAndNumber; - if (stat.LengthOverall_MTR.HasValue) - _nsw.conveyance.vessel.LengthOverall_MTR = (float)stat.LengthOverall_MTR.Value; - _nsw.conveyance.vessel.MMSINumber = stat.MMSINumber; - _nsw.conveyance.vessel.PortOfRegistry = stat.PortOfRegistry; - _nsw.conveyance.vessel.ShipName = stat.ShipName; - _nsw.conveyance.vessel.ShipType = stat.ShipType; - break; - #endregion - - #region TIEFA - case Message.NotificationClass.TIEFA: - TIEFA tiefa = message.Elements[0] as TIEFA; - if (tiefa != null) - { - if (tiefa.DraughtUponArrival_DMT.HasValue) - _nsw.conveyance.Draught_DMT = (float)tiefa.DraughtUponArrival_DMT.Value; - _nsw.conveyance.Draught_DMTSpecified = tiefa.DraughtUponArrival_DMT.HasValue; - } - break; - case Message.NotificationClass.TIEFD: - TIEFD tiefd = message.Elements[0] as TIEFD; - if(tiefd != null) - { - if (tiefd.DraughtUponDeparture_DMT.HasValue) - _nsw.conveyance.Draught_DMT = (float)tiefd.DraughtUponDeparture_DMT.Value; - _nsw.conveyance.Draught_DMTSpecified = tiefd.DraughtUponDeparture_DMT.HasValue; - } - break; - #endregion - - #region TOWA/TOWD - case Message.NotificationClass.TOWA: - if (message.MessageCore.Incoming) - { - if (message.Elements.Count > 0) - { - _nsw.conveyance.TOWS = new tow[message.Elements.Count]; - for (int i = 0; i < message.Elements.Count; i++) - { - tow _tow = new tow(); - _nsw.conveyance.TOWS[i] = _tow; - TOWA towa = message.Elements[0] as TOWA; - if (towa.TowageOnArrivalBeam_MTR.HasValue) - _tow.TowageBeam_MTR = (float)towa.TowageOnArrivalBeam_MTR.Value; - if (towa.TowageOnArrivalDraught_DMT.HasValue) - _tow.TowageDraught_DMT = (float)towa.TowageOnArrivalDraught_DMT.Value; - _tow.TowageFlag = towa.TowageOnArrivalFlag; - if (towa.TowageOnArrivalGrossTonnage.HasValue) - _tow.TowageGrossTonnage = towa.TowageOnArrivalGrossTonnage.Value.ToString(); - if (towa.TowageOnArrivalLengthOverall_MTR.HasValue) - _tow.TowageLengthOverall_MTR = (float)towa.TowageOnArrivalLengthOverall_MTR.Value; - _tow.TowageName = towa.TowageOnArrivalName; - _tow.TowageOperator = new towageoperator(); - _tow.TowageOperator.Address = new address(); - _tow.TowageOperator.Address.TowageOperatorCity = towa.TowageOnArrivalOperatorCity; - _tow.TowageOperator.Address.TowageOperatorCountry = towa.TowageOnArrivalOperatorCountry; - _tow.TowageOperator.Address.TowageOperatorPostalCode = towa.TowageOnArrivalOperatorPostalCode; - _tow.TowageOperator.Address.TowageOperatorStreetAndNumber = towa.TowageOnArrivalOperatorStreetNameAndNumber; - _tow.TowageOperator.Contact = new contact(); - _tow.TowageOperator.Contact.TowageOperatorFax = towa.TowageOnArrivalOperatorFax; - _tow.TowageOperator.Contact.TowageOperatorPhone = towa.TowageOnArrivalOperatorPhone; - _tow.TowageOperator.Contact.TowareOperatorEMail = towa.TowageOnArrivalOperatorEmail; - _tow.TowageOperator.TowageOperatorCompanyName = towa.TowageOnArrivalOperatorCompanyName; - _tow.TowagePurposeOfCall = towa.TowageOnArrivalPurposeOfCall; - _tow.TowageRemarks = towa.TowageOnArrivalRemarks; - } - } - } - break; - case Message.NotificationClass.TOWD: - if(!message.MessageCore.Incoming) { - if (message.Elements.Count > 0) - { - _nsw.conveyance.TOWS = new tow[message.Elements.Count]; - for (int i = 0; i < message.Elements.Count; i++) - { - tow _tow = new tow(); - _nsw.conveyance.TOWS[i] = _tow; - TOWD towd = message.Elements[0] as TOWD; - if (towd.TowageOnDepartureBeam_MTR.HasValue) - _tow.TowageBeam_MTR = (float)towd.TowageOnDepartureBeam_MTR.Value; - if (towd.TowageOnDepartureDraught_DMT.HasValue) - _tow.TowageDraught_DMT = (float)towd.TowageOnDepartureDraught_DMT.Value; - _tow.TowageFlag = towd.TowageOnDepartureFlag; - _tow.TowageName = towd.TowageOnDepartureName; - _tow.TowageOperator = new towageoperator(); - _tow.TowageOperator.Address = new address(); - _tow.TowageOperator.Address.TowageOperatorCity = towd.TowageOnDepartureOperatorCity; - _tow.TowageOperator.Address.TowageOperatorCountry = towd.TowageOnDepartureOperatorCountry; - _tow.TowageOperator.Address.TowageOperatorPostalCode = towd.TowageOnDepartureOperatorPostalCode; - _tow.TowageOperator.Address.TowageOperatorStreetAndNumber = towd.TowageOnDepartureOperatorStreetNameAndNumber; - _tow.TowageOperator.Contact = new contact(); - _tow.TowageOperator.Contact.TowageOperatorFax = towd.TowageOnDepartureOperatorFax; - _tow.TowageOperator.Contact.TowageOperatorPhone = towd.TowageOnDepartureOperatorPhone; - _tow.TowageOperator.Contact.TowareOperatorEMail = towd.TowageOnDepartureOperatorEmail; - _tow.TowageOperator.TowageOperatorCompanyName = towd.TowageOnDepartureOperatorCompanyName; - _tow.TowageRemarks = towd.TowageOnDepartureRemarks; - } - } - } - break; - #endregion - - case Message.NotificationClass.WAS: - - break; + } } #endregion + #region serialize and save message + + string filename = string.Format("{0}-{1}.xml", DateTime.Now.ToString("yyyyMMddHHmmss"), messages[0].MessageCore.Id.Value); + _log.InfoFormat("saving {0} to output directory", filename); + + string filePath = Path.Combine(Properties.Settings.Default.OutputDir, filename); + XmlSerializer serializer = new XmlSerializer(typeof(nsw)); + using(TextWriter tw = new StreamWriter(filePath)) { + serializer.Serialize(tw, _nsw); + } + + #endregion + + #region send message and store result + + transmitter.result theResult = transmitter.transmit(filePath); + + #endregion + } catch (Exception ex) { diff --git a/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj b/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj index 6687c0c8..3feb2723 100644 --- a/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj +++ b/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj @@ -59,6 +59,11 @@ + + True + True + Settings.settings + @@ -68,6 +73,16 @@ bsmd.database + + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + +