diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index 489ebb06..67ab9049 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ diff --git a/nsw/HIS-NORD/Transmitter-Tool/.bsmdstore b/nsw/HIS-NORD/Transmitter-Tool/.bsmdstore new file mode 100644 index 00000000..70495673 Binary files /dev/null and b/nsw/HIS-NORD/Transmitter-Tool/.bsmdstore differ diff --git a/nsw/HIS-NORD/Transmitter-Tool/DD-ImportClient.jar b/nsw/HIS-NORD/Transmitter-Tool/DD-ImportClient.jar new file mode 100644 index 00000000..45bb3b07 Binary files /dev/null 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 new file mode 100644 index 00000000..69f07be6 Binary files /dev/null and b/nsw/HIS-NORD/Transmitter-Tool/Installation of DD-ImportClient.pdf differ diff --git a/nsw/HIS-NORD/Transmitter-Tool/client.bat.txt b/nsw/HIS-NORD/Transmitter-Tool/client.bat.txt new file mode 100644 index 00000000..f935586e --- /dev/null +++ b/nsw/HIS-NORD/Transmitter-Tool/client.bat.txt @@ -0,0 +1 @@ +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 new file mode 100644 index 00000000..c31b7b03 --- /dev/null +++ b/nsw/HIS-NORD/Transmitter-Tool/client.conf @@ -0,0 +1,23 @@ +# HISMV ImportClient Konfiguration +# Raute (#) zum auskommentieren +# Serveradresse +SERVER = 62.52.6.41 +# Paketgroesse (Standard ist 500, nur bei abreissender Verbindung veraendern) +#PACKETSIZE = 500 +PORT = 7283 +# Keystore-Datei die die Zertifikate des Clients und des Servers enthaelt +KEYSTORE = .bsmdstore +# Password of the Keystore-File +STOREPASS = ArwKy6m778WTs6iu +# Password of the Client-certificate +CERTPASS = ArwKy6m778WTs6iu +# Verzeichnis in dem sich die XML-Dateien befinden, welche exportiert werden sollen. +IMPDIR = IMP +# Verzeichnis in das die exportierten XML-Dateien verschoben werden sollen. +EXDIR = READY +# Verzeichnis in das die exportierten XML-Dateien verschoben werden sollen, welche fehlerhaft sind +CORDIR = CORRUPT +# Version des Protokolls +VERSION = NSW_V1-0 +MODE = ONCE +XMLRESULTDIR = RESULTS\ \ No newline at end of file diff --git a/nsw/HIS-NORD/Transmitter-Tool/client.log b/nsw/HIS-NORD/Transmitter-Tool/client.log new file mode 100644 index 00000000..e69de29b diff --git a/nsw/HIS-NORD/Transmitter-Tool/client.sh b/nsw/HIS-NORD/Transmitter-Tool/client.sh new file mode 100644 index 00000000..b86a779b --- /dev/null +++ b/nsw/HIS-NORD/Transmitter-Tool/client.sh @@ -0,0 +1,3 @@ +#!/bin/sh +#JAVA_HOME=Pfad zum installierten JDK +$JAVA_HOME/bin/java -jar DD-ImportClient.jar -log=client.log -cfg=client.conf diff --git a/nsw/HIS-NORD/xsd/his-nord.xsd b/nsw/HIS-NORD/xsd/his-nord.xsd index 83711d51..ec496ec9 100644 --- a/nsw/HIS-NORD/xsd/his-nord.xsd +++ b/nsw/HIS-NORD/xsd/his-nord.xsd @@ -1,5 +1,5 @@ - + @@ -48,7 +48,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -283,6 +283,10 @@ + + + + @@ -559,6 +563,20 @@ + + + + + + + + + + + + + + diff --git a/nsw/HIS-NORD/xsd/his-nord_nsw_v-1-0_all_reeder.xsd b/nsw/HIS-NORD/xsd/his-nord_nsw_v-1-0_all_reeder.xsd index 83711d51..ec496ec9 100644 --- a/nsw/HIS-NORD/xsd/his-nord_nsw_v-1-0_all_reeder.xsd +++ b/nsw/HIS-NORD/xsd/his-nord_nsw_v-1-0_all_reeder.xsd @@ -1,5 +1,5 @@ - + @@ -48,7 +48,7 @@ - + @@ -105,7 +105,7 @@ - + @@ -283,6 +283,10 @@ + + + + @@ -559,6 +563,20 @@ + + + + + + + + + + + + + + diff --git a/nsw/Listen_PDF_Reports.xlsx b/nsw/Listen_PDF_Reports.xlsx new file mode 100644 index 00000000..b58655e3 Binary files /dev/null and b/nsw/Listen_PDF_Reports.xlsx differ diff --git a/nsw/PREARRIVAL KOLDING - EU Single Window reporting template - AnnA project ....xlsx b/nsw/PREARRIVAL KOLDING - EU Single Window reporting template - AnnA project ....xlsx new file mode 100644 index 00000000..43c9c011 Binary files /dev/null and b/nsw/PREARRIVAL KOLDING - EU Single Window reporting template - AnnA project ....xlsx differ diff --git a/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs b/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs index e258eeb3..675fc607 100644 --- a/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs +++ b/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs @@ -22,7 +22,7 @@ using bsmd.database; namespace bsmd.ReportGenerator { public class BSMDDocument - { + { #region create document @@ -38,7 +38,7 @@ namespace bsmd.ReportGenerator BSMDDocument.DefineStyles(document); BSMDDocument.DefineCover(document, coverInfos); - BSMDDocument.DefineContentSection(document); + BSMDDocument.DefineContentSection(document, Orientation.Portrait, true); //TableOfContents.DefineTableOfContents(document); @@ -179,11 +179,13 @@ namespace bsmd.ReportGenerator /// /// Defines page setup, headers, and footers. /// - public static void DefineContentSection(Document document) + public static void DefineContentSection(Document document, Orientation orientation, bool isInitialSection) { Section section = document.AddSection(); section.PageSetup.OddAndEvenPagesHeaderFooter = true; - section.PageSetup.StartingNumber = 1; + if(isInitialSection) + section.PageSetup.StartingNumber = 1; + section.PageSetup.Orientation = orientation; HeaderFooter header = section.Headers.Primary; header.AddParagraph("\tEU-NOAD receive receipt"); @@ -209,10 +211,29 @@ namespace bsmd.ReportGenerator public static void AddNSWMessageParagraph(Document document, IMessageParagraph messageParagraph) { + Message message = messageParagraph as Message; + + // Einzelne Seite in Landscape für CREW Meldung + if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.CREW)) + { + // Landscape! + BSMDDocument.DefineContentSection(document, Orientation.Landscape, false); + + document.LastSection.AddParagraph(messageParagraph.Title, "Heading2"); + document.LastSection.AddParagraph(messageParagraph.Subtitle, "Heading3"); + + BSMDDocument.CreateCrewTable(document, message); + + BSMDDocument.DefineContentSection(document, Orientation.Portrait, false); + return; + } + + document.LastSection.AddParagraph(messageParagraph.Title, "Heading2"); document.LastSection.AddParagraph(messageParagraph.Subtitle, "Heading3"); - Message message = messageParagraph as Message; + + // Spezialbehandlung WAS Meldung if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.WAS)) @@ -237,7 +258,7 @@ namespace bsmd.ReportGenerator { BSMDDocument.CreateLADGTable(document, message); return; - } + } if (messageParagraph.MessageText != null) // komplette Nachricht (z.B. STAT) BSMDDocument.AddActualTableParagraph(document, messageParagraph.MessageText, false); @@ -248,15 +269,136 @@ namespace bsmd.ReportGenerator return; } + if((message != null) && (message.MessageNotificationClass == Message.NotificationClass.MDH)) + { + BSMDDocument.CreatePoCLast30DaysTable(document, message); + return; + } + if (messageParagraph.ChildParagraphs != null) // 1:n message (CREW, PAS,..) - { - foreach (IMessageParagraph childParagraph in messageParagraph.ChildParagraphs) - { - BSMDDocument.AddActualTableParagraph(document, childParagraph.MessageText, true); - } + { + foreach (IMessageParagraph childParagraph in messageParagraph.ChildParagraphs) + { + BSMDDocument.AddActualTableParagraph(document, childParagraph.MessageText, true); + } } } + #region CREW + private static void CreateCrewTable(Document document, Message message) + { + Table table = document.LastSection.AddTable(); + table.Rows.VerticalAlignment = VerticalAlignment.Center; + table.Borders.Visible = true; + + Column column = table.AddColumn(); + column.Width = Unit.FromCentimeter(1); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(3); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(3); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(3); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(2); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(2); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(1); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(2); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(3); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(2); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(3); + + Row hRow = table.AddRow(); + hRow.Cells[1].AddParagraph("Last name"); + hRow.Cells[2].AddParagraph("First name"); + hRow.Cells[3].AddParagraph("Place of birth"); + hRow.Cells[4].AddParagraph("Date of birth"); + hRow.Cells[5].AddParagraph("Gender"); + hRow.Cells[6].AddParagraph("Nat."); + hRow.Cells[7].AddParagraph("Id doc. type"); + hRow.Cells[8].AddParagraph("Id doc. number"); + hRow.Cells[9].AddParagraph("Visa number"); + hRow.Cells[10].AddParagraph("Duty"); + + for (int i = 0; i < message.Elements.Count; i++) + { + CREW crew = message.Elements[i] as CREW; + Row row = table.AddRow(); + row.Cells[0].AddParagraph((i + 1).ToString()); + row.Cells[1].AddParagraph(crew.CrewMemberLastName ?? ""); + row.Cells[2].AddParagraph(crew.CrewMemberFirstName ?? ""); + row.Cells[3].AddParagraph(crew.CrewMemberPlaceOfBirth); + row.Cells[4].AddParagraph(crew.CrewMemberDateOfBirthDisplay); + row.Cells[5].AddParagraph(crew.CrewMemberGenderDisplay); + row.Cells[6].AddParagraph(crew.CrewMemberNationality); + row.Cells[7].AddParagraph(crew.CrewMemberIdentityDocumentTypeDisplay); + row.Cells[8].AddParagraph(crew.CrewMemberIdentityDocumentId ?? ""); + row.Cells[9].AddParagraph(crew.CrewMemberVisaNumber ?? ""); + row.Cells[10].AddParagraph(crew.CrewMemberDuty ?? ""); + } + } + #endregion + + #region MDH + + private static void CreatePoCLast30DaysTable(Document document, Message message) + { + MDH mdh = message.Elements[0] as MDH; + if (mdh.PortOfCallLast30Days.Count > 0) + { + document.LastSection.AddParagraph("Port of call last 30 days", "Heading3"); + Table table = document.LastSection.AddTable(); + table.Rows.VerticalAlignment = VerticalAlignment.Center; + table.Borders.Visible = true; + + Column column = table.AddColumn(); + column.Width = Unit.FromCentimeter(1); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(2); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(2); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(2); + column = table.AddColumn(); + column.Width = Unit.FromCentimeter(9); + + Row hRow = table.AddRow(); + + hRow.Cells[1].AddParagraph("LoCode"); + hRow.Cells[2].AddParagraph("Date of departure"); + hRow.Cells[3].AddParagraph("Crew members joined"); + hRow.Cells[4].AddParagraph("Names of joining crew"); + + for (int i = 0; i < mdh.PortOfCallLast30Days.Count; i++) + { + Row row = table.AddRow(); + BSMDDocument.SetPoCLast30Days((i + 1), mdh.PortOfCallLast30Days[i], row); + } + } + } + + private static void SetPoCLast30Days(int p, PortOfCallLast30Days portOfCallLast30Days, Row row) + { + row.Cells[0].AddParagraph(p.ToString()); + row.Cells[1].AddParagraph(portOfCallLast30Days.PortOfCallLast30DaysLocode ?? ""); + row.Cells[2].AddParagraph(portOfCallLast30Days.PortOfCallLast30DaysDateOfDeparture.HasValue ? + portOfCallLast30Days.PortOfCallLast30DaysDateOfDeparture.Value.ToShortDateString() : ""); + row.Cells[3].AddParagraph(portOfCallLast30Days.PortOfCallLast30DaysCrewMembersJoined.HasValue ? + portOfCallLast30Days.PortOfCallLast30DaysCrewMembersJoined.Value ? "True" : "False" : ""); + for (int i = 0; i < portOfCallLast30Days.CrewJoinedShip.Count; i++) + { + row.Cells[4].AddParagraph(portOfCallLast30Days.CrewJoinedShip[i].PortOfCallLast30DaysCrewJoinedShipName ?? ""); + } + } + + #endregion + #region LADG private static void CreateLADGTable(Document document, Message message) @@ -305,6 +447,7 @@ namespace bsmd.ReportGenerator { document.LastSection.AddParagraph("Last 10 port facilites called", "Heading3"); Table table = document.LastSection.AddTable(); + table.Format.Font.Size = 8; table.Rows.VerticalAlignment = VerticalAlignment.Center; table.Borders.Visible = true; @@ -521,7 +664,8 @@ namespace bsmd.ReportGenerator { foreach (Waste waste in was.Waste) { - if (waste.Identifier == index.ToString()) + if (!waste.WasteType.HasValue) continue; // kaputt! + if (waste.WasteType.Value == index) { row.Cells[1].AddParagraph(waste.WasteDescription ?? ""); row.Cells[2].AddParagraph(waste.WasteDisposalAmount_MTQ.HasValue ? waste.WasteDisposalAmount_MTQ.Value.ToString("N2") : ""); diff --git a/nsw/Source/bsmd.ReportGenerator/CrewPasHelper.cs b/nsw/Source/bsmd.ReportGenerator/CrewPasHelper.cs new file mode 100644 index 00000000..53f084d7 --- /dev/null +++ b/nsw/Source/bsmd.ReportGenerator/CrewPasHelper.cs @@ -0,0 +1,118 @@ +// +// Class: CrewPasHelper +// Current CLR: 4.0.30319.34209 +// System: Microsoft Visual Studio 10.0 +// Author: dani +// Created: 7/10/2015 8:24:06 PM +// +// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using bsmd.database; + +namespace bsmd.ReportGenerator +{ + public class CrewPasHelper + { + public static string CreateCSV(Message message) + { + switch(message.MessageNotificationClass) + { + case Message.NotificationClass.CREW: + { + string filename = Path.Combine(Properties.Settings.Default.OutputDirectory, "crewlist.csv"); + + StringBuilder sb = new StringBuilder(); + foreach (CREW crew in message.Elements) + { + + string dateOfBirth = ""; + if (crew.CrewMemberDateOfBirth.HasValue) + dateOfBirth = crew.CrewMemberDateOfBirth.Value.ToString("yyyy-MM-dd"); + + sb.AppendLine(string.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9}", + crew.CrewMemberLastName ?? "", + crew.CrewMemberFirstName ?? "", + CrewPasHelper.GetGender(crew.CrewMemberGender), + crew.CrewMemberNationality ?? "", + crew.CrewMemberDuty ?? "", + crew.CrewMemberPlaceOfBirth ?? "", + dateOfBirth, + CrewPasHelper.GetDocumentType(crew.CrewMemberIdentityDocumentType), + crew.CrewMemberIdentityDocumentId ?? "", + crew.CrewMemberVisaNumber ?? "")); + } + + File.WriteAllText(filename, sb.ToString(), Encoding.UTF8); + return filename; + } + case Message.NotificationClass.PAS: + { + string filename = Path.Combine(Properties.Settings.Default.OutputDirectory, "passengerlist.csv"); + + StringBuilder sb = new StringBuilder(); + foreach (PAS pas in message.Elements) + { + string dateOfBirth = ""; + if (pas.PassengerDateOfBirth.HasValue) + dateOfBirth = pas.PassengerDateOfBirth.Value.ToString("yyyy-MM-dd"); + + sb.AppendLine(string.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8};{9};{10};{11}", + pas.PassengerLastName ?? "", + pas.PassengerFirstName ?? "", + CrewPasHelper.GetGender(pas.PassengerGender), + pas.PassengerNationality ?? "", + pas.PassengerPortOfEmbarkation ?? "", + pas.PassengerPortOfDisembarkation ?? "", + (pas.PassengerInTransit ?? false) ? "Y" : "N", + pas.PassengerPlaceOfBirth ?? "", + dateOfBirth, + CrewPasHelper.GetDocumentType(pas.PassengerIdentityDocumentType), + pas.PassengerIdentityDocumentId ?? "", + pas.PassengerVisaNumber ?? "")); + } + + File.WriteAllText(filename, sb.ToString(), Encoding.UTF8); + return filename; + } + default: + return null; + } + } + + private static string GetDocumentType(byte? type) + { + string documentType = ""; + if (type.HasValue) + { + switch (type.Value) + { + case 0: documentType = "IDENTITY_CARD"; break; + case 1: documentType = "PASSPORT"; break; + case 2: documentType = "MUSTER_BOOK"; break; + case 3: documentType = "PICTURE_ID"; break; + case 4: documentType = "RESIDENTAL_PERMIT"; break; + default: documentType = "OTHER_LEGAL_IDENTITY_DOCUMENT"; break; + } + } + return documentType; + } + + private static string GetGender(byte? gender) + { + string genders = ""; + if (gender.HasValue) + { + if (gender == 0) genders = "MALE"; + if (gender == 1) genders = "FEMALE"; + if (gender == 2) genders = "OTHER"; + } + return genders; + } + + + } +} diff --git a/nsw/Source/bsmd.ReportGenerator/ReportService.cs b/nsw/Source/bsmd.ReportGenerator/ReportService.cs index 2f8f657e..00d63880 100644 --- a/nsw/Source/bsmd.ReportGenerator/ReportService.cs +++ b/nsw/Source/bsmd.ReportGenerator/ReportService.cs @@ -5,7 +5,6 @@ using System.IO; using System.ServiceProcess; using System.Timers; - using log4net; using MigraDoc.DocumentObjectModel; diff --git a/nsw/Source/bsmd.hisnord/Request.cs b/nsw/Source/bsmd.hisnord/Request.cs new file mode 100644 index 00000000..987b6ca7 --- /dev/null +++ b/nsw/Source/bsmd.hisnord/Request.cs @@ -0,0 +1,762 @@ +// +// Class: Request +// Current CLR: 4.0.30319.34209 +// System: Microsoft Visual Studio 10.0 +// Author: dani +// Created: 7/6/2015 7:04:01 PM +// +// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved. + +using System; +using System.Collections.Generic; +using log4net; +using bsmd.database; + +namespace bsmd.hisnord +{ + public class Request + { + private static ILog _log = LogManager.GetLogger(typeof(Request)); + + public static bool Send(Message message) + { + bool retval = true; + + try + { + nsw _nsw = new nsw(); + _nsw.conveyance = new conveyance(); + + #region general info area + + _nsw.date_registration = DateTime.Now; // dient zur Sequenzierung der Nachrichten + _nsw.message_sender = "BSMD"; + _nsw.message_recipient = "HIS-NORD"; + _nsw.conveyance.owner_sender = new broker_owner(); + _nsw.conveyance.owner_sender.contact = new contacts(); + + // das hier ist der e-mail(!) Empfänger für Error/Violation Meldungen + _nsw.conveyance.owner_sender.contact.name = "BSMD"; + _nsw.conveyance.owner_sender.contact.email = "nsw@textbausteine.de"; + _nsw.conveyance.owner_sender.contact.firstname = "Daniel Schick"; + _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; + + _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.vessel = new vesseltype(); + _nsw.conveyance.vessel.ENINumber = message.MessageCore.ENI; + _nsw.conveyance.vessel.IMONumber = message.MessageCore.IMO; + + + + #endregion + + #region NSW message area + + + + switch (message.MessageNotificationClass) + { + case Message.NotificationClass.VISIT: + + break; + case Message.NotificationClass.TRANSIT: + + break; + + #region ATA/ATD + case Message.NotificationClass.ATA: + if (message.MessageCore.Incoming) + { + import _import = null; + portofcallhazmat _poc = null; + if (_nsw.conveyance.Item != null) + { + _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; + } + 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) + { + _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; + } + } + } + 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++) + { + _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; + #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++) + { + 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 + + #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 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.Items2 = new object[2]; + _nsw.conveyance.Items2[0] = ytype.Y; + _nsw.conveyance.Items2[1] = sec.PortOfCallWhereCompleteSECNotified; + } + 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()) + { + _sec.Last10Ports = new last10port[sec.LastTenPortFacilitesCalled.Count]; + for (int i = 0; i < sec.LastTenPortFacilitesCalled.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; + } + } + + 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; + } + } + 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 + + } + catch (Exception ex) + { + _log.ErrorFormat("Error sending message via hisnord: {0}", ex.Message); + retval = false; + } + + return retval; + } + } +} diff --git a/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj b/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj index f936390a..6687c0c8 100644 --- a/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj +++ b/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj @@ -60,6 +60,7 @@ + diff --git a/nsw/Source/bsmd.hisnord/his-nord.cs b/nsw/Source/bsmd.hisnord/his-nord.cs index d410dcc0..bfabfe81 100644 --- a/nsw/Source/bsmd.hisnord/his-nord.cs +++ b/nsw/Source/bsmd.hisnord/his-nord.cs @@ -14,6 +14,7 @@ using System.Xml.Serialization; // This source code was auto-generated by xsd, Version=4.0.30319.33440. // + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")] [System.SerializableAttribute()] @@ -4626,6 +4627,10 @@ public partial class portofcallhazmat { private callpurpose[] callPurposesField; + private string itemField; + + private ItemChoiceType itemElementNameField; + /// [System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] public string Locode { @@ -4714,6 +4719,30 @@ public partial class portofcallhazmat { this.callPurposesField = value; } } + + /// + [System.Xml.Serialization.XmlElementAttribute("GISIS", typeof(string), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlElementAttribute("Hafengebiet", typeof(string), Form=System.Xml.Schema.XmlSchemaForm.Unqualified)] + [System.Xml.Serialization.XmlChoiceIdentifierAttribute("ItemElementName")] + public string Item { + get { + return this.itemField; + } + set { + this.itemField = value; + } + } + + /// + [System.Xml.Serialization.XmlIgnoreAttribute()] + public ItemChoiceType ItemElementName { + get { + return this.itemElementNameField; + } + set { + this.itemElementNameField = value; + } + } } /// @@ -4750,6 +4779,19 @@ public partial class callpurpose { } } +/// +[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")] +[System.SerializableAttribute()] +[System.Xml.Serialization.XmlTypeAttribute(IncludeInSchema=false)] +public enum ItemChoiceType { + + /// + GISIS, + + /// + Hafengebiet, +} + /// [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.33440")] [System.SerializableAttribute()] diff --git a/nsw/Source/bsmd.hisnord/transmitter.cs b/nsw/Source/bsmd.hisnord/transmitter.cs new file mode 100644 index 00000000..f715b888 --- /dev/null +++ b/nsw/Source/bsmd.hisnord/transmitter.cs @@ -0,0 +1,57 @@ +// +// Class: transmitter +// Current CLR: 4.0.30319.34209 +// System: Microsoft Visual Studio 10.0 +// Author: dani +// Created: 7/14/2015 7:39:29 AM +// +// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Xml; +using System.Xml.Serialization; +using log4net; + +namespace bsmd.hisnord +{ + public class transmitter + { + private static ILog _log = LogManager.GetLogger(typeof(transmitter)); + /// + /// class to read transmitter result xml files + /// + [Serializable] + public class result + { + public result() { } + public int code { get; set; } + public string message { get; set; } + public string detail { get; set; } + + /// + /// create result items from file + /// + public static result ReadResult(string filename) + { + result aResult = null; + try + { + XmlSerializer serializer = new XmlSerializer(typeof(result)); + using (FileStream fs = new FileStream(filename, FileMode.Open)) + { + aResult = (result)serializer.Deserialize(fs); + } + } + catch (Exception ex) + { + _log.ErrorFormat("Exception deserializing transmitter result: {0}", ex.Message); + } + return aResult; + } + } + + } +}