diff --git a/nsw/Source/SQL/Update_2.4.14_To_3.0.sql b/nsw/Source/SQL/Update_2.4.14_To_3.0.sql index 6a5452c5..ce50ea4c 100644 --- a/nsw/Source/SQL/Update_2.4.14_To_3.0.sql +++ b/nsw/Source/SQL/Update_2.4.14_To_3.0.sql @@ -1,3 +1,9 @@ +------------------------------------------------------------------------------------------------- +-- AGNT + +PRINT N'new table AGNT'; +GO + CREATE TABLE [dbo].[AGNT] ( [Id] UNIQUEIDENTIFIER CONSTRAINT [DF_AGNT_Id] DEFAULT (newid()) ROWGUIDCOL NOT NULL, [MessageHeaderId] UNIQUEIDENTIFIER NULL, @@ -14,4 +20,98 @@ CREATE TABLE [dbo].[AGNT] ( CONSTRAINT [PK_AGNT] PRIMARY KEY CLUSTERED ([Id] ASC), CONSTRAINT [FK_AGNT_MessageHeader] FOREIGN KEY ([MessageHeaderId]) REFERENCES [dbo].[MessageHeader] ([Id]) -); \ No newline at end of file +); + +------------------------------------------------------------------------------------------------- +-- INFO + +PRINT N'Altering [dbo].[INFO]...'; + +GO +ALTER TABLE [dbo].[INFO] + ADD [PortArea] NVARCHAR (50) NULL, + [BowThrusterPower] NVARCHAR (50) NULL, + [SternThrusterPower] NVARCHAR (50) NULL; +GO + +------------------------------------------------------------------------------------------------- +-- INFO + +PRINT N'Altering [dbo].[STAT]...'; + +ALTER TABLE [dbo].[STAT] + ADD [TransportMode] NCHAR (1) NULL; +GO + + +------------------------------------------------------------------------------------------------- +-- IMDGPosition + +PRINT N'Altering [dbo].[IMDGPosition]...'; + + +GO +ALTER TABLE [dbo].[IMDGPosition] + ADD [Bay] NVARCHAR (5) NULL, + [Row] NVARCHAR (5) NULL, + [Tier] NVARCHAR (5) NULL; + +GO + +------------------------------------------------------------------------------------------------- +-- SanitaryMeasuresDetail + +PRINT N'New table [dbo].[SanitaryMeasuresDetail]...'; + + +CREATE TABLE [dbo].[SanitaryMeasuresDetail] ( + [Id] UNIQUEIDENTIFIER CONSTRAINT [DF_SanitaryMeasuresDetail_Id] DEFAULT (newid()) ROWGUIDCOL NOT NULL, + [MDH_Id] UNIQUEIDENTIFIER NULL, + [SanitaryMeasuresType] NVARCHAR (255) NULL, + [SanitaryMeasuresLocation] NVARCHAR (255) NULL, + [SanitaryMeasuresDate] DATE NULL, + [Identifier] NVARCHAR (50) NULL, + CONSTRAINT [PK_SanitaryMeasuresDetail] PRIMARY KEY CLUSTERED ([Id] ASC), + CONSTRAINT [FK_SanitaryMeasuresDetail_MDH] FOREIGN KEY ([MDH_Id]) REFERENCES [dbo].[MDH] ([Id]) +); + +GO + +------------------------------------------------------------------------------------------------- +-- StowawaysJoiningLocation + +PRINT N'New table [dbo].[StowawaysJoiningLocation]...'; + + +CREATE TABLE [dbo].[StowawaysJoiningLocation] ( + [Id] UNIQUEIDENTIFIER CONSTRAINT [DF_StowawaysJoiningLocation_Id] DEFAULT (newid()) ROWGUIDCOL NOT NULL, + [MDH_Id] UNIQUEIDENTIFIER NULL, + [StowawaysJoiningLocation] NVARCHAR (255) NULL, + [Identifier] NVARCHAR (50) NULL, + CONSTRAINT [PK_StowawaysJoiningLocation] PRIMARY KEY CLUSTERED ([Id] ASC), + CONSTRAINT [FK_StowawaysJoiningLocation_MDH] FOREIGN KEY ([MDH_Id]) REFERENCES [dbo].[MDH] ([Id]) +); + +GO + +------------------------------------------------------------------------------------------------- +-- InfectedArea + +PRINT N'New table [dbo].[InfectedArea]...'; + + +CREATE TABLE [dbo].[InfectedArea] ( + [Id] UNIQUEIDENTIFIER CONSTRAINT [DF_InfectedArea_Id] DEFAULT (newid()) ROWGUIDCOL NOT NULL, + [MDH_Id] UNIQUEIDENTIFIER NULL, + [InfectedAreaPort] NVARCHAR (255) NULL, + [InfectedAreaDate] DATE NULL, + [Identifier] NVARCHAR (50) NULL, + CONSTRAINT [PK_InfectedArea] PRIMARY KEY CLUSTERED ([Id] ASC), + CONSTRAINT [FK_SInfectedArea_MDH] FOREIGN KEY ([MDH_Id]) REFERENCES [dbo].[MDH] ([Id]) +); + +GO + + + + diff --git a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs index 2fc29cb7..39bad43d 100644 --- a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs +++ b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs @@ -7,14 +7,13 @@ // // Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved. +using log4net; +using Microsoft.Office.Interop.Excel; using System; using System.Collections.Generic; using System.Data; using System.Globalization; -using System.IO; - -using log4net; -using Microsoft.Office.Interop.Excel; +using System.Linq; namespace bsmd.ExcelReadService { @@ -37,7 +36,7 @@ namespace bsmd.ExcelReadService } } - public string ReadText(string lookup) + internal string ReadText(string lookup) { if (!_nameDict.ContainsKey(lookup)) return null; var val = _nameDict[lookup].RefersToRange.Value; @@ -48,7 +47,72 @@ namespace bsmd.ExcelReadService return val2.ToString(); return null; } - + + internal string ReadTextNoWhitespace(string lookup) + { + string val = this.ReadText(lookup); + if (val == null) return val; + return new string(val.Where(c => !Char.IsWhiteSpace(c)).ToArray()); + } + + internal byte? ReadGender(string lookup) + { + string val = this.ReadText(lookup); + if (val == null) return null; + if (val.Equals("m", StringComparison.CurrentCultureIgnoreCase) || val.Equals("male", StringComparison.CurrentCultureIgnoreCase)) return 0; + if (val.Equals("f", StringComparison.CurrentCultureIgnoreCase) || val.Equals("female", StringComparison.CurrentCultureIgnoreCase)) return 1; + return 2; // whatever + } + + internal byte? ReadIdentityDocumentType(string lookup) + { + string val = this.ReadText(lookup); + if (val == null) return null; + if (val.Equals("identity_card", StringComparison.CurrentCultureIgnoreCase)) return 0; + if (val.Equals("passport", StringComparison.CurrentCultureIgnoreCase)) return 1; + if (val.Equals("muster_book", StringComparison.CurrentCultureIgnoreCase)) return 2; + if (val.Equals("picture_id", StringComparison.CurrentCultureIgnoreCase)) return 3; + if (val.Equals("residental_permit", StringComparison.CurrentCultureIgnoreCase)) return 4; + if (val.Equals("other_legal_identity_document", StringComparison.CurrentCultureIgnoreCase)) return 5; + + return 5; // default? + } + + internal byte? ReadShippingArea(string lookup) + { + string val = this.ReadText(lookup); + if (val.IndexOf("baltic", StringComparison.OrdinalIgnoreCase) >= 0) return 0; + if (val.IndexOf("europe", StringComparison.OrdinalIgnoreCase) >= 0) return 1; + if (val.IndexOf("overseas", StringComparison.OrdinalIgnoreCase) >= 0) return 2; + return null; + } + + internal byte? ReadHullConfiguration(string lookup) + { + string val = this.ReadText(lookup); + if (val.IndexOf("sbt", StringComparison.OrdinalIgnoreCase) >= 0) return 1; + if (val.IndexOf("single", StringComparison.OrdinalIgnoreCase) >= 0) return 0; + if (val.IndexOf("double", StringComparison.OrdinalIgnoreCase) >= 0) return 2; + return null; + } + + internal byte? ReadConditionTanks(string lookup) + { + string val = this.ReadText(lookup); + if (val.IndexOf("full", StringComparison.OrdinalIgnoreCase) >= 0) return 0; + if (val.IndexOf("empty", StringComparison.OrdinalIgnoreCase) >= 0) return 1; + if (val.IndexOf("inerted", StringComparison.OrdinalIgnoreCase) >= 0) return 2; + return null; + } + + internal byte? ReadDelivery(string lookup) + { + string val = this.ReadText(lookup); + if (val.IndexOf("all", StringComparison.OrdinalIgnoreCase) >= 0) return 0; + if (val.IndexOf("some", StringComparison.OrdinalIgnoreCase) >= 0) return 1; + if (val.IndexOf("none", StringComparison.OrdinalIgnoreCase) >= 0) return 2; + return null; + } public void Dispose() { @@ -80,6 +144,22 @@ namespace bsmd.ExcelReadService } } + internal DateTime? ReadDateTime(string dateField, string timeField) + { + DateTime? result = null; + DateTime? etaDate = this.ReadDate(dateField); + DateTime? etaTime = this.ReadTime(timeField); + if (etaDate != null) + { + result = new DateTime(etaDate.Value.Year, etaDate.Value.Month, etaDate.Value.Day); + if (etaTime != null) + { + result = new DateTime(etaDate.Value.Year, etaDate.Value.Month, etaDate.Value.Day, etaTime.Value.Hour, etaTime.Value.Minute, etaTime.Value.Second); + } + } + return result; + } + internal DateTime? ReadTime(string lookup) { try @@ -124,6 +204,15 @@ namespace bsmd.ExcelReadService return null; } } + + internal bool? ReadBoolean(string lookup) + { + string val = this.ReadText(lookup); + if (val == null) return null; + if ((val == "y") || (val == "Y") || (val == "yes") || (val == "YES") || (val == "1") || (val == "x") || (val == "X")) + return true; + return false; + } } } diff --git a/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs b/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs index 3bb397b5..4e56b544 100644 --- a/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs +++ b/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs @@ -56,6 +56,21 @@ namespace bsmd.ExcelReadService return result; } + public static List AllLocodesForCityName(string city) + { + List results = new List(); + string query = string.Format("SELECT city_code, countries.code FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE locodes.port='t' AND locodes.name like '{1}'", city); + SQLiteCommand cmd = new SQLiteCommand(query, _con); + IDataReader reader = cmd.ExecuteReader(); + while (reader.Read()) + { + if (!reader.IsDBNull(0) && !reader.IsDBNull(1)) + results.Add(string.Format("{0}{1}", reader.GetString(1), reader.GetString(0))); + } + reader.Close(); + return results; + } + /// /// Lookup 2CHAR Country Code from country name (like search). Hopefully this will result in many hits /// diff --git a/nsw/Source/bsmd.ExcelReadService/Util.cs b/nsw/Source/bsmd.ExcelReadService/Util.cs index 9e175f60..89ba59fb 100644 --- a/nsw/Source/bsmd.ExcelReadService/Util.cs +++ b/nsw/Source/bsmd.ExcelReadService/Util.cs @@ -10,7 +10,6 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Linq.Expressions; using System.Reflection; using log4net; using bsmd.database; @@ -39,9 +38,9 @@ namespace bsmd.ExcelReadService ScanAGNT(messages, messageCore, reader); - // NOA_NOD + ScanNOA_NOD(messages, messageCore, reader); - // SEC + ScanSEC(messages, messageCore, reader); ScanPOBA(messages, messageCore, reader); @@ -53,15 +52,15 @@ namespace bsmd.ExcelReadService ScanSTAT(messages, messageCore, reader); - // MDH + ScanMDH(messages, messageCore, reader); - // CREW + ScanCREW(messages, messageCore, reader); - // PAS + ScanPAS(messages, messageCore, reader); - // BPOL + // BPOL nicht im sheet - // TOWA + ScanTOWA(messages, messageCore, reader); // HAZA @@ -74,13 +73,13 @@ namespace bsmd.ExcelReadService ScanAGNT(messages, messageCore, reader); - // NOA_NOD + ScanNOA_NOD(messages, messageCore, reader); ScanATA(messages, messageCore, reader); ScanATD(messages, messageCore, reader); - // SEC + ScanSEC(messages, messageCore, reader); ScanPOBA(messages, messageCore, reader); @@ -98,27 +97,27 @@ namespace bsmd.ExcelReadService ScanSTAT(messages, messageCore, reader); - // LADG + ScanLADG(messages, messageCore, reader); - // INFO - - // SERV + ScanINFO(messages, messageCore, reader); - // PRE72H + ScanSERV(messages, messageCore, reader); - // MDH + ScanPRE72H(messages, messageCore, reader); - // WAS + ScanMDH(messages, messageCore, reader); - // CREW + ScanWAS(messages, messageCore, reader); - // PAS + ScanCREW(messages, messageCore, reader); - // BPOL + ScanPAS(messages, messageCore, reader); - // TOWA + // BPOL nicht im Sheet - // TOWD + ScanTOWA(messages, messageCore, reader); + + ScanTOWD(messages, messageCore, reader); // HAZA @@ -279,6 +278,27 @@ namespace bsmd.ExcelReadService #endregion + #region INFO + + static void ScanINFO(List messages, MessageCore messageCore, ExcelReader reader) + { + Message infoMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.INFO); + if(infoMessage.Elements.Count == 0) + { + INFO newINFO = new INFO(); + newINFO.MessageHeader = infoMessage; + infoMessage.Elements.Add(newINFO); + } + INFO info = infoMessage.Elements[0] as INFO; + Util.ScanMessage(info, reader); + + info.ShippingArea = reader.ReadShippingArea(@"INFO.ShippingArea"); // enum read func + + // wird nicht wieder entfernt + } + + #endregion + #region STAT static void ScanSTAT(List messages, MessageCore messageCore, ExcelReader reader) @@ -307,6 +327,56 @@ namespace bsmd.ExcelReadService #endregion + #region NOA_NOD + + static void ScanNOA_NOD(List messages, MessageCore messageCore, ExcelReader reader) + { + Message noa_nodMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.NOA_NOD); + if (noa_nodMessage.Elements.Count == 0) + { + NOA_NOD newNoa_nod = new NOA_NOD(); + newNoa_nod.MessageHeader = noa_nodMessage; + noa_nodMessage.Elements.Add(newNoa_nod); + } + + NOA_NOD noa_nod = noa_nodMessage.Elements[0] as NOA_NOD; + if (messageCore.IsTransit) + noa_nod.ETAToKielCanal = messageCore.ETAKielCanal; + else { + noa_nod.ETAToPortOfCall = messageCore.ETA; + + string callPurposeDescription = reader.ReadText("NOA_NOD.CallPuposeDescription"); + if (!callPurposeDescription.IsNullOrEmpty()) + { + CallPurpose callPurpose = new CallPurpose(); + callPurpose.CallPurposeCode = noa_nod.getCallPurposeCodeFromDescription(callPurposeDescription) ?? 0; + callPurpose.CallPurposeDescription = callPurposeDescription; + noa_nod.CallPurposes.Add(callPurpose); + } + } + + string lastPort = reader.ReadText("NOA_NOD.LastPort").Trim(); + List lastPorts = LocodeDB.AllLocodesForCityName(lastPort); + if (lastPorts.Count == 1) + noa_nod.LastPort = lastPorts[0]; + else + _log.WarnFormat("{0} results in {1} possible LOCODES", lastPort, lastPorts.Count); + + string nextPort = reader.ReadText("NOA_NOD.NextPort").Trim(); + List nextPorts = LocodeDB.AllLocodesForCityName(nextPort); + if (nextPorts.Count == 1) + noa_nod.NextPort = nextPorts[0]; + else + _log.WarnFormat("{0} results in {1} possible LOCODES", nextPort, nextPorts.Count); + + noa_nod.ETDFromPortOfCall = reader.ReadDateTime("NOA_NOD.ETDDateFromPortOfCall", "NOA_NOD.ETDTimeFromPortOfCall"); + noa_nod.ETDFromLastPort = reader.ReadDateTime("NOA_NOD.ETDDateFromLastPort", "NOA_NOD.ETDTimeFromLastPort"); + noa_nod.ETAToNextPort = reader.ReadDateTime("NOA_NOD.ETADateToNextPort", "NOA_NOD.ETATimeToNextPort"); + + } + + #endregion + #region AGNT static void ScanAGNT(List messages, MessageCore messageCore, ExcelReader reader) @@ -325,6 +395,58 @@ namespace bsmd.ExcelReadService #endregion + #region WAS + + static void ScanWAS(List messages, MessageCore messageCore, ExcelReader reader) + { + Message wasMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.WAS); + if (wasMessage.Elements.Count == 0) + { + WAS newWAS = new WAS(); + newWAS.MessageHeader = wasMessage; + wasMessage.Elements.Add(newWAS); + } + WAS was = wasMessage.Elements[0] as WAS; + Util.ScanMessage(was, reader); + was.WasteDisposalDelivery = reader.ReadDelivery("WAS.WasteDisposalDelivery"); + List deliveryLocodes = LocodeDB.AllLocodesForCityName(reader.ReadText("WAS.LastWasteDisposalPort")); + if (deliveryLocodes.Count == 1) + was.LastWasteDisposalPort = deliveryLocodes[0]; + + // Waste 1 - 9 + for (int i = 1; i <= was.NumberOfExcelRows; i++) + { + // string wastetype = string.Format("WAS.WasteType_{0}", i); + string wasteDescription = string.Format("WAS.WasteDescription_{0}", i); + string wasteAmount = string.Format("WAS.WasteDisposalAmount_MTQ_{0}", i); + string wasteCapacity = string.Format("WAS.WasteCapacity_MTQ_{0}", i); + string wasteRetained = string.Format("WAS.WasteAmountRetained_MTQ_{0}", i); + string wastePort = string.Format("WAS.WasteDisposalPort_{0}", i); + string amountGen = string.Format("WAS.WasteAmountGeneratedTillNextPort_MTQ_{0}", i); + + Waste waste = was.GetSublistElementWithIdentifier(i.ToString()) as Waste; + if(waste == null) + { + waste = new Waste(); + waste.Identifier = i.ToString(); + waste.WAS = was; + was.Waste.Add(waste); + } + + waste.WasteType = (byte)i; + waste.WasteDescription = reader.ReadText(wasteDescription); + waste.WasteDisposalAmount_MTQ = reader.ReadNumber(wasteAmount); + waste.WasteCapacity_MTQ = reader.ReadNumber(wasteCapacity); + waste.WasteAmountRetained_MTQ = reader.ReadNumber(wasteRetained); + waste.WasteDisposalPort = reader.ReadText(wastePort); // TODO: check for LOCODE? + waste.WasteAmountGeneratedTillNextPort_MTQ = reader.ReadNumber(amountGen); + + // empty wastes not removed, are required elements! + } + + } + #endregion + #region MDH static void ScanMDH(List messages, MessageCore messageCore, ExcelReader reader) @@ -340,7 +462,7 @@ namespace bsmd.ExcelReadService Util.ScanMessage(mdh, reader); // POC last 30 days - for (int i = 0; i < 15; i++) + for (int i = 0; i < mdh.NumberOfExcelRows; i++) { string portName = string.Format("MDH.PortOfCallLast30DaysPort_{0}", i + 1); string portCountry = string.Format("MDH.PortOfCallLast30DaysCountry_{0}", i + 1); @@ -354,37 +476,123 @@ namespace bsmd.ExcelReadService { poc30d = new PortOfCallLast30Days(); poc30d.Identifier = (i + 1).ToString(); - poc30d.MessageHeader = mdhMessage; + poc30d.MDH = mdh; mdh.PortOfCallLast30Days.Add(poc30d); } - // TODO! geht nicht weil sich der Index ändert und das Namensattribut konstant ist + poc30d.PortOfCallLast30DaysDateOfDeparture = reader.ReadDate(depDate); + poc30d.PortOfCallLast30DaysLocode = reader.ReadTextNoWhitespace(locode); + poc30d.PortOfCallLast30DaysCrewMembersJoined = reader.ReadBoolean(crewJoined); - + if (poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false) + { + string crewNameString = reader.ReadText(crewName); + if (!crewName.IsNullOrEmpty()) + { + // try different separators + string[] crew = crewNameString.Split(';'); + if (crew.Length == 1) + crew = crewNameString.Split(','); - // Util.ScanMessage(poc30d, reader); + for (int j = 0; j < crew.Length; j++) + { + PortOfCallLast30DaysCrewJoinedShip poc30dCrew = poc30d.GetSublistElementWithIdentifier((j + 1).ToString()) as PortOfCallLast30DaysCrewJoinedShip; + if (poc30dCrew == null) + { + poc30dCrew = new PortOfCallLast30DaysCrewJoinedShip(); + poc30dCrew.Identifier = (j + 1).ToString(); + poc30dCrew.PortOfCallLast30Days = poc30d; + poc30d.CrewJoinedShip.Add(poc30dCrew); + } + + poc30dCrew.PortOfCallLast30DaysCrewJoinedShipName = crew[j]; + } + } + } // Leer/def. Zeilen entfernen if (!poc30d.PortOfCallLast30DaysDateOfDeparture.HasValue && (poc30d.PortOfCallLast30DaysLocode == null)) mdh.PortOfCallLast30Days.Remove(poc30d); + } - string crewJoinedText = reader.ReadText(crewName); - if (!crewJoinedText.IsNullOrEmpty()) + // wird nicht wieder entfernt falls keine Daten vorliegen + } + + #endregion + + #region SEC + + static void ScanSEC(List messages, MessageCore messageCore, ExcelReader reader) + { + Message secMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.SEC); + if (secMessage.Elements.Count == 0) + { + SEC newSEC = new SEC(); + newSEC.MessageHeader = secMessage; + secMessage.Elements.Add(newSEC); + } + SEC sec = secMessage.Elements[0] as SEC; + Util.ScanMessage(sec, reader); + + // Last10PortFacilitesCalled + for (int i = 1; i <= 10; i++) + { + string portName = string.Format("SEC.PortFacilityPortName_{0}", i); + string portCountry = string.Format("SEC.PortFacilityPortCountry_{0}", i); + string portLocode = string.Format("SEC.PortFacilityPortLoCode_{0}", i); + string portDateOfArrival = string.Format("SEC.PortFacilityDateOfArrival_{0}", i); + string portDateOfDeparture = string.Format("SEC.PortFacilityDateOfDeparture_{0}", i); + string portShipSecLevel = string.Format("SEC.PortFacilityShipSecurityLevel_{0}", i); + string portGISISCode = string.Format("SEC.PortFacilityGISISCode_{0}", i); + + LastTenPortFacilitiesCalled l10fc = sec.GetPortFacilityWithIdentifier(i.ToString()) as LastTenPortFacilitiesCalled; + if (l10fc == null) { - PortOfCallLast30DaysCrewJoinedShip poc30C = mdh.GetSublistElementWithIdentifier("1") as PortOfCallLast30DaysCrewJoinedShip; - if (poc30C == null) - { - poc30C = new PortOfCallLast30DaysCrewJoinedShip(); - poc30C.PortOfCallLast30Days = poc30d; - poc30d.CrewJoinedShip.Add(poc30C); - } - poc30C.PortOfCallLast30DaysCrewJoinedShipName = crewJoinedText; + l10fc = new LastTenPortFacilitiesCalled(); + l10fc.Identifier = i.ToString(); + l10fc.SEC = sec; + sec.LastTenPortFacilitesCalled.Add(l10fc); } + l10fc.PortFacilityPortName = reader.ReadText(portName); + l10fc.PortFacilityPortCountry = reader.ReadText(portCountry); + l10fc.PortFacilityPortLoCode = reader.ReadTextNoWhitespace(portLocode); + l10fc.PortFacilityDateOfArrival = reader.ReadDate(portDateOfArrival); + l10fc.PortFacilityDateOfDeparture = reader.ReadDate(portDateOfDeparture); + l10fc.PortFacilityShipSecurityLevel = (byte) reader.ReadNumber(portShipSecLevel); + l10fc.PortFacilityGISISCode = reader.ReadTextNoWhitespace(portGISISCode); + } + // Ship2ShipActivities + for (int i = 1; i <= 10; i++) + { + string s2sName = string.Format("SEC.ShipToShipActivityLocationName_{0}", i); + string s2sLocode = string.Format("SEC.ShipToShipActivityLocationLoCode_{0}", i); + string s2sLatitude = string.Format("SEC.ShipToShipActivityLocationCoordinatesLatitude_{0}", i); + string s2sLongitude = string.Format("SEC.ShipToShipActivityLocationCoordinatesLongitude_{0}", i); + string s2sFromDate = string.Format("SEC.ShipToShipActivityDateFrom_{0}", i); + string s2sToDate = string.Format("SEC.ShipToShipActivityDateTo_{0}", i); + string s2sActivityString = string.Format("SEC.ShipToShipActivityType_{0}", i); + + ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2sActivity = sec.GetShipToShipWithIdentifier(i.ToString()) as ShipToShipActivitiesDuringLastTenPortFacilitiesCalled; + if (s2sActivity == null) + { + s2sActivity = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled(); + s2sActivity.Identifier = i.ToString(); + s2sActivity.SEC = sec; + sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Add(s2sActivity); + } + + s2sActivity.ShipToShipActivityLocationName = reader.ReadText(s2sName); + s2sActivity.ShipToShipActivityLocationLoCode = reader.ReadTextNoWhitespace(s2sLocode); + s2sActivity.ShipToShipActivityLocationCoordinatesLatitude = (int)reader.ReadNumber(s2sLatitude); + s2sActivity.ShipToShipActivityLocationCoordinatesLongitude = (int)reader.ReadNumber(s2sLongitude); + s2sActivity.ShipToShipActivityDateFrom = reader.ReadDate(s2sFromDate); + s2sActivity.ShipToShipActivityDateTo = reader.ReadDate(s2sToDate); + s2sActivity.ShipToShipActivityType = reader.ReadText(s2sActivityString); + } - // wird nicht wieder entfernt falls keine Daten vorliegen } #endregion @@ -447,6 +655,92 @@ namespace bsmd.ExcelReadService #endregion + #region TOWA + + static void ScanTOWA(List messages, MessageCore messageCore, ExcelReader reader) + { + // TOWA ist eigentlich 1:n, es ist aber keine Liste im Sheet! + Message towaMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.TOWA); + + string towageName = reader.ReadText("TOWA.TowageOnArrivalName"); + if (!towageName.IsNullOrEmpty()) + { + if (towaMessage.Elements.Count == 0) + { + TOWA newTOWA = new TOWA(); + newTOWA.MessageHeader = towaMessage; + towaMessage.Elements.Add(newTOWA); + } + + TOWA towa = towaMessage.Elements[0] as TOWA; + Util.ScanMessage(towa, reader); + } + } + + #endregion + + #region TOWD + + static void ScanTOWD(List messages, MessageCore messageCore, ExcelReader reader) + { + // TOWD ist 1:n, es ist aber keine Liste im Sheet! + Message towdMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.TOWD); + string towageName = reader.ReadText("TOWD.TowageOnDepartureName"); + if(!towageName.IsNullOrEmpty()) + { + if(towdMessage.Elements.Count == 0) + { + TOWD newTOWD = new TOWD(); + newTOWD.MessageHeader = towdMessage; + towdMessage.Elements.Add(newTOWD); + } + + TOWD towd = towdMessage.Elements[0] as TOWD; + Util.ScanMessage(towd, reader); + } + } + + #endregion + + #region PRE72H + + static void ScanPRE72H(List messages, MessageCore messageCore, ExcelReader reader) + { + Message pre72hMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.PRE72H); + if (pre72hMessage.Elements.Count == 0) + { + PRE72H newPRE72H = new PRE72H(); + newPRE72H.MessageHeader = pre72hMessage; + pre72hMessage.Elements.Add(newPRE72H); + } + PRE72H pre72h = pre72hMessage.Elements[0] as PRE72H; + Util.ScanMessage(pre72h, reader); + // diese Nachricht bleibt auch wenn sie leer ist + pre72h.ConditionCargoBallastTanks = reader.ReadConditionTanks("PRE72H.ConditionCargoBallastTanks"); + pre72h.TankerHullConfiguration = reader.ReadHullConfiguration("PRE72H.TankerHullConfiguration"); + } + + #endregion + + #region SERV + + static void ScanSERV(List messages, MessageCore messageCore, ExcelReader reader) + { + Message servMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.SERV); + if(servMessage.Elements.Count == 0) + { + SERV newSERV = new SERV(); + newSERV.MessageHeader = servMessage; + servMessage.Elements.Add(newSERV); + } + SERV serv = servMessage.Elements[0] as SERV; + Util.ScanMessage(serv, reader); + if (serv.ServiceBeneficiary.IsNullOrEmpty() && serv.ServiceInvoiceRecipient.IsNullOrEmpty()) + servMessage.Elements.Remove(serv); + } + + #endregion + #region LADG static void ScanLADG(List messages, MessageCore messageCore, ExcelReader reader) @@ -486,10 +780,107 @@ namespace bsmd.ExcelReadService } } + #endregion + + #region CREW + + static void ScanCREW(List messages, MessageCore messageCore, ExcelReader reader) + { + Message crewMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.CREW); + for (int i = 0; i < crewMessage.NumberOfExcelRows; i++) + { + string crewLastName = string.Format("CREW.CrewMemberLastName_{0}", i + 1); + string crewFirstName = string.Format("CREW.CrewMemberFirstName_{0}", i + 1); + string crewGender = string.Format("CREW.CrewMemberGender_{0}", i + 1); + string crewNationality = string.Format("CREW.CrewMemberNationality_{0}", i + 1); + string crewDuty = string.Format("CREW.CrewMemberDuty_{0}", i + 1); + string crewPlaceOfBirth = string.Format("CREW.CrewMemberPlaceOfBirth_{0}", i + 1); + string crewDateOfBirth = string.Format("CREW.CrewMemberDateOfBirth_{0}", i + 1); + string crewIdentDocType = string.Format("CREW.CrewMemberIdentityDocumentType_{0}", i + 1); + string crewIdentDocId = string.Format("CREW.CrewMemberIdentityDocumentId_{0}", i + 1); + string crewVisaNo = string.Format("CREW.CrewMemberVisaNumber_{0}", i + 1); + + string lastName = reader.ReadText(crewLastName); + if (!lastName.IsNullOrEmpty()) + { + CREW crew = crewMessage.GetSublistElementWithIdentifier((i + 1).ToString()) as CREW; + if (crew == null) + { + crew = new CREW(); + crew.Identifier = (i + 1).ToString(); + crew.MessageHeader = crewMessage; + crewMessage.Elements.Add(crew); + } + + crew.CrewMemberLastName = lastName; + crew.CrewMemberFirstName = reader.ReadText(crewFirstName); + crew.CrewMemberGender = reader.ReadGender(crewGender); + crew.CrewMemberDuty = reader.ReadText(crewDuty); + crew.CrewMemberPlaceOfBirth = reader.ReadText(crewPlaceOfBirth); + crew.CrewMemberDateOfBirth = reader.ReadDate(crewDateOfBirth); + crew.CrewMemberIdentityDocumentType = reader.ReadIdentityDocumentType(crewIdentDocType); + crew.CrewMemberIdentityDocumentId = reader.ReadText(crewIdentDocId); + crew.CrewMemberVisaNumber = reader.ReadText(crewVisaNo); + + } + } + } #endregion + #region PAS + static void ScanPAS(List messages, MessageCore messageCore, ExcelReader reader) + { + Message pasMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.PAS); + for (int i = 0; i < pasMessage.NumberOfExcelRows; i++) + { + string pasLastName = string.Format("PAS.PassengerLastName_{0}", i + 1); + string pasFirstName = string.Format("PAS.PassengerFirstName_{0}", i + 1); + string pasGender = string.Format("PAS.PassengerGender_{0}", i + 1); + string pasNationality = string.Format("PAS.PassengerNationality_{0}", i + 1); + string pasEmbarkation = string.Format("PAS.PassengerPortOfEmbarkation_{0}", i + 1); + string pasDebarkation = string.Format("PAS.PassengerPortOfDisembarkation_{0}", i + 1); + string pasTransit = string.Format("PAS.PassengerInTransit_{0}", i + 1); + string pasPlaceOfBirth = string.Format("PAS.PassengerPlaceOfBirth_{0}", i + 1); + string pasDateOfBirth = string.Format("PAS.PassengerDateOfBirth_{0}", i + 1); + string pasIdentDocType = string.Format("PAS.PassengerIdentityDocumentType_{0}", i + 1); + string pasIdentDocId = string.Format("PAS.PassengerIdentityDocumentId_{0}", i + 1); + string pasVisaNo = string.Format("PAS.PassengerVisaNumber_{0}", i + 1); + + string lastName = reader.ReadText(pasLastName); + if (!lastName.IsNullOrEmpty()) + { + PAS pas = pasMessage.GetSublistElementWithIdentifier((i + 1).ToString()) as PAS; + if (pas == null) + { + pas = new PAS(); + pas.Identifier = (i + 1).ToString(); + pas.MessageHeader = pasMessage; + pasMessage.Elements.Add(pas); + } + + pas.PassengerLastName = lastName; + pas.PassengerFirstName = reader.ReadText(pasFirstName); + pas.PassengerGender = reader.ReadGender(pasGender); + pas.PassengerNationality = reader.ReadText(pasNationality); + // TODO: Nicht klar ob hier LOCODEs kommen oder nicht + pas.PassengerPortOfEmbarkation = reader.ReadTextNoWhitespace(pasEmbarkation); + pas.PassengerPortOfDisembarkation = reader.ReadTextNoWhitespace(pasDebarkation); + pas.PassengerInTransit = reader.ReadBoolean(pasTransit); + pas.PassengerPlaceOfBirth = reader.ReadText(pasPlaceOfBirth); + pas.PassengerDateOfBirth = reader.ReadDate(pasDateOfBirth); + pas.PassengerIdentityDocumentType = reader.ReadIdentityDocumentType(pasIdentDocType); + pas.PassengerIdentityDocumentId = reader.ReadText(pasIdentDocId); + pas.PassengerVisaNumber = reader.ReadText(pasVisaNo); + + } + } + } + + #endregion + + #region ScanMessage (generic) private static void ScanMessage(DatabaseEntity dbEntity, ExcelReader reader) { @@ -529,6 +920,8 @@ namespace bsmd.ExcelReadService } + #endregion + /// /// Check with cell values if this message core is already in our DB @@ -580,17 +973,7 @@ namespace bsmd.ExcelReadService imo = reader.ReadText("Visit.IMONumber"); // ETA - - DateTime? etaDate = reader.ReadDate("NOA_NOD.ETADateToPortOfCall"); - DateTime? etaTime = reader.ReadTime("NOA_NOD.ETATimeToPortOfCall"); - if (etaDate != null) - { - eta = new DateTime(etaDate.Value.Year, etaDate.Value.Month, etaDate.Value.Day); - if (etaTime != null) - { - eta = new DateTime(etaDate.Value.Year, etaDate.Value.Month, etaDate.Value.Day, etaTime.Value.Hour, etaTime.Value.Minute, etaTime.Value.Second); - } - } + eta = reader.ReadDateTime("NOA_NOD.ETADateToPortOfCall", "NOA_NOD.ETATimeToPortOfCall"); result = DBManager.Instance.GetMessageCoreByShipInfos(imo, eta.Value, poc); if (result.IsNew) diff --git a/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs b/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs index d4feb872..9eb99d56 100644 --- a/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs +++ b/nsw/Source/bsmd.ReportGenerator/BSMDDocument.cs @@ -669,6 +669,14 @@ namespace bsmd.ReportGenerator column.Width = Unit.FromCentimeter(6); Row row = table.AddRow(); + + row.Cells[0].AddParagraph("Valid exemption?"); + row.Cells[1].AddParagraph("Confirmation of correctness"); + row = table.AddRow(); + row.Cells[0].AddParagraph(was.WasteDisposalValidExemption ?? false ? "YES" : "NO"); + row.Cells[1].AddParagraph(was.ConfirmationOfCorrectness ?? false ? "YES" : "NO"); + + row = table.AddRow(); row.Cells[0].AddParagraph("Last port where waste or cargo residues were discharged"); row.Cells[1].AddParagraph("Date of last disposal"); row = table.AddRow(); @@ -677,12 +685,12 @@ namespace bsmd.ReportGenerator row.Cells[1].AddParagraph(was.LastWasteDisposalDate.ToString()); row = table.AddRow(); row.Cells[0].AddParagraph("Name of waste disposal service provider"); - row.Cells[1].AddParagraph("Waste disposal order (all, some, none"); + row.Cells[1].AddParagraph("Waste disposal order (all, some, none)"); row = table.AddRow(); for (int i = 0; i < was.WasteDisposalServiceProvider.Count; i++) row.Cells[0].AddParagraph(was.WasteDisposalServiceProvider[i].WasteDisposalServiceProviderName); if (was.WasteDisposalDelivery.HasValue) - row.Cells[1].AddParagraph((was.WasteDisposalDelivery.Value == 0) ? "ALL" : (was.WasteDisposalDelivery == 1) ? "SOME" : "NONE"); + row.Cells[1].AddParagraph((was.WasteDisposalDelivery.Value == 0) ? "ALL" : (was.WasteDisposalDelivery == 1) ? "SOME" : "NONE"); table = document.LastSection.AddTable(); table.Rows.VerticalAlignment = VerticalAlignment.Top; diff --git a/nsw/Source/bsmd.database/CREW.cs b/nsw/Source/bsmd.database/CREW.cs index df5e2800..9ada25e9 100644 --- a/nsw/Source/bsmd.database/CREW.cs +++ b/nsw/Source/bsmd.database/CREW.cs @@ -79,6 +79,7 @@ namespace bsmd.database [ShowReport] [ReportDisplayName("Visa number")] + [Validation(ValidationCode.NOT_NULL)] public string CrewMemberVisaNumber { get; set; } [ShowReport] diff --git a/nsw/Source/bsmd.database/DBManager.cs b/nsw/Source/bsmd.database/DBManager.cs index 86129906..b1320528 100644 --- a/nsw/Source/bsmd.database/DBManager.cs +++ b/nsw/Source/bsmd.database/DBManager.cs @@ -564,6 +564,7 @@ namespace bsmd.database if (databaseEntity.GetType().IsAssignableFrom(typeof(MDH))) { MDH mdh = databaseEntity as MDH; + PortOfCallLast30Days poc30 = new PortOfCallLast30Days(); poc30.PrepareLoadCommand(cmd, Message.LoadFilter.MDH_ID, mdh.Id); SqlDataReader reader = this.PerformCommand(cmd); @@ -574,6 +575,37 @@ namespace bsmd.database apoc30.MDH = mdh; this.LoadDependingLists(apoc30); } + + SanitaryMeasuresDetail smd = new SanitaryMeasuresDetail(); + smd.PrepareLoadCommand(cmd, Message.LoadFilter.MDH_ID, mdh.Id); + reader = this.PerformCommand(cmd); + List smds = smd.LoadList(reader); + foreach(SanitaryMeasuresDetail aSmd in smds) + { + mdh.SanitaryMeasuresDetails.Add(aSmd); + aSmd.MDH = mdh; + } + + StowawaysJoiningLocation sjl = new StowawaysJoiningLocation(); + sjl.PrepareLoadCommand(cmd, Message.LoadFilter.MDH_ID, mdh.Id); + reader = this.PerformCommand(cmd); + List sjls = sjl.LoadList(reader); + foreach(StowawaysJoiningLocation aSjl in sjls) + { + mdh.StowawaysJoiningLocations.Add(aSjl); + aSjl.MDH = mdh; + } + + InfectedArea ia = new InfectedArea(); + ia.PrepareLoadCommand(cmd, Message.LoadFilter.MDH_ID, mdh.Id); + reader = this.PerformCommand(cmd); + List ias = ia.LoadList(reader); + foreach(InfectedArea aIa in ias) + { + mdh.InfectedAreas.Add(aIa); + aIa.MDH = mdh; + } + } #endregion diff --git a/nsw/Source/bsmd.database/IMDGPosition.cs b/nsw/Source/bsmd.database/IMDGPosition.cs index 37a0a971..5108dcd3 100644 --- a/nsw/Source/bsmd.database/IMDGPosition.cs +++ b/nsw/Source/bsmd.database/IMDGPosition.cs @@ -90,6 +90,13 @@ namespace bsmd.database [ShowReport] [Validation(ValidationCode.NOT_NULL)] public string StowagePosition { get; set; } + + public string Bay { get; set; } + + public string Row { get; set; } + + public string Tier { get; set; } + [ShowReport] [Validation(ValidationCode.LOCODE)] public string PortOfLoading { get; set; } @@ -143,6 +150,9 @@ namespace bsmd.database scmd.Parameters.AddWithNullableValue("@P30", this.PortOfDischarge); scmd.Parameters.AddWithNullableValue("@P31", this.Remarks); scmd.Parameters.AddWithNullableValue("@P32", this.Identifier); + scmd.Parameters.AddWithNullableValue("@P33", this.Bay); + scmd.Parameters.AddWithNullableValue("@P34", this.Row); + scmd.Parameters.AddWithNullableValue("@P35", this.Tier); if (this.IsNew) { @@ -154,9 +164,9 @@ namespace bsmd.database "Class7CSI, ControlTemperature_CEL, EmergencyTemperature_CEL, MarinePollutant, NumberOfPackages, " + "PackageType, LimitedQuantities, ExceptedQuantities, NetQuantity_KGM, GrossQuantity_KGM, Volume_MTQ, " + "GeneralCargoIBC, ContainerNumber, VehicleLicenseNumber, StowagePosition, PortOfLoading, PortOfDischarge, " + - "Remarks, Identifier) VALUES (@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, " + + "Remarks, Identifier, Bay, [Row], Tier) VALUES (@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, " + "@P14, @P15, @P16, @P17, @P18, @P19, @P20, @P21, @P22, @P23, @P24, @P25, @P26, @P27, @P28, @P29, @P30, " + - "@P31, @P32)", this.Tablename); + "@P31, @P32, @P33, @P34, @P35)", this.Tablename); } else { @@ -168,7 +178,7 @@ namespace bsmd.database "MarinePollutant = @P17, NumberOfPackages = @P18, PackageType = @P19, LimitedQuantities = @P20, ExceptedQuantities = @P21, " + "NetQuantity_KGM = @P22, GrossQuantity_KGM = @P23, Volume_MTQ = @P24, GeneralCargoIBC = @P25, ContainerNumber = @P26, " + "VehicleLicenseNumber = @P27, StowagePosition = @P28, PortOfLoading = @P29, PortOfDischarge = @P30, Remarks = @P31, " + - "Identifier = @P32 WHERE Id = @ID", this.Tablename); + "Identifier = @P32, Bay = @P33, [Row] = @P34, Tier = @P35 WHERE Id = @ID", this.Tablename); } } @@ -179,7 +189,7 @@ namespace bsmd.database "TechnicalName, NetExplosiveMass_KGM, Flashpoint_CEL, Class7NuclideName, Class7MaxActivity_BQL, Class7Category, " + "Class7TransportIndex, Class7CSI, ControlTemperature_CEL, EmergencyTemperature_CEL, MarinePollutant, NumberOfPackages, " + "PackageType, LimitedQuantities, ExceptedQuantities, NetQuantity_KGM, GrossQuantity_KGM, Volume_MTQ, GeneralCargoIBC, " + - "ContainerNumber, VehicleLicenseNumber, StowagePosition, PortOfLoading, PortOfDischarge, Remarks, Identifier " + + "ContainerNumber, VehicleLicenseNumber, StowagePosition, PortOfLoading, PortOfDischarge, Remarks, Identifier, Bay, [Row], Tier " + "FROM {0} ", this.Tablename); switch (filter) @@ -237,6 +247,9 @@ namespace bsmd.database if (!reader.IsDBNull(29)) imdg.PortOfDischarge = reader.GetString(29); if (!reader.IsDBNull(30)) imdg.Remarks = reader.GetString(30); if (!reader.IsDBNull(31)) imdg.Identifier = reader.GetString(31); + if (!reader.IsDBNull(32)) imdg.Bay = reader.GetString(32); + if (!reader.IsDBNull(33)) imdg.Row = reader.GetString(33); + if (!reader.IsDBNull(34)) imdg.Tier = reader.GetString(34); result.Add(imdg); } diff --git a/nsw/Source/bsmd.database/INFO.cs b/nsw/Source/bsmd.database/INFO.cs index 0cdd98d8..d84ec11a 100644 --- a/nsw/Source/bsmd.database/INFO.cs +++ b/nsw/Source/bsmd.database/INFO.cs @@ -30,6 +30,7 @@ namespace bsmd.database [ShowReport] [Validation(ValidationCode.NOT_NULL)] + [LookupName("INFO.RequestedPositionInPortOfCall")] public string RequestedPositionInPortOfCall { get; set; } [ShowReport] @@ -40,11 +41,20 @@ namespace bsmd.database [ShowReport] [Validation(ValidationCode.NOT_NULL)] + [LookupName("INFO.FumigatedBulkCargo")] public byte? FumigatedBulkCargo { get; set; } [ShowReport] public double? DeplacementSummerDraught_TNE { get; set; } + [ShowReport] + [LookupName("INFO.PortArea")] + public string PortArea { get; set; } + + public string BowThrusterPower { get; set; } + + public string SternThrusterPower { get; set; } + #endregion #region DatabaseEntity implementation @@ -69,26 +79,29 @@ namespace bsmd.database scmd.Parameters.AddWithNullableValue("@P5", this.ConstructionCharacteristicsOfShip); scmd.Parameters.AddWithNullableValue("@P6", this.FumigatedBulkCargo); scmd.Parameters.AddWithNullableValue("@P7", this.DeplacementSummerDraught_TNE); + scmd.Parameters.AddWithNullableValue("@P8", this.PortArea); + scmd.Parameters.AddWithNullableValue("@P9", this.BowThrusterPower); + scmd.Parameters.AddWithNullableValue("@P10", this.SternThrusterPower); if (this.IsNew) { scmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, ShippingArea, RequestedPositionInPortOfCall, " + - "SpecialRequirementsOfShipAtBerth, ConstructionCharacteristicsOfShip, FumigatedBulkCargo, DeplacementSummerDraught_TNE) " + - "VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7 )", this.Tablename); + "SpecialRequirementsOfShipAtBerth, ConstructionCharacteristicsOfShip, FumigatedBulkCargo, DeplacementSummerDraught_TNE, " + + "PortArea, BowThrusterPower, SternThrusterPower) VALUES ( @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10 )", this.Tablename); } else { scmd.Parameters.AddWithValue(@"ID", this.Id); scmd.CommandText = string.Format("UPDATE {0} SET ShippingArea = @P2, RequestedPositionInPortOfCall = @P3, " + "SpecialRequirementsOfShipAtBerth = @P4, ConstructionCharacteristicsOfShip = @P5, FumigatedBulkCargo = @P6," + - "DeplacementSummerDraught_TNE = @P7 WHERE Id = @ID", this.Tablename); + "DeplacementSummerDraught_TNE = @P7, PortArea = @P8, BowThrusterPower = @P9, SternThrusterPower = @P10 WHERE Id = @ID", this.Tablename); } } public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria) { string query = string.Format("SELECT Id, ShippingArea, RequestedPositionInPortOfCall, SpecialRequirementsOfShipAtBerth, " + - "ConstructionCharacteristicsOfShip, FumigatedBulkCargo, DeplacementSummerDraught_TNE FROM {0}", + "ConstructionCharacteristicsOfShip, FumigatedBulkCargo, DeplacementSummerDraught_TNE, PortArea, BowThrusterPower, SternThrusterPower FROM {0}", this.Tablename); switch (filter) @@ -121,6 +134,9 @@ namespace bsmd.database if (!reader.IsDBNull(4)) info.ConstructionCharacteristicsOfShip = reader.GetString(4); if (!reader.IsDBNull(5)) info.FumigatedBulkCargo = reader.GetByte(5); if (!reader.IsDBNull(6)) info.DeplacementSummerDraught_TNE = (float) reader.GetDouble(6); + if (!reader.IsDBNull(7)) info.PortArea = reader.GetString(7); + if (!reader.IsDBNull(8)) info.BowThrusterPower = reader.GetString(8); + if (!reader.IsDBNull(9)) info.SternThrusterPower = reader.GetString(9); result.Add(info); } reader.Close(); diff --git a/nsw/Source/bsmd.database/MDH.cs b/nsw/Source/bsmd.database/MDH.cs index 133f65d5..85104937 100644 --- a/nsw/Source/bsmd.database/MDH.cs +++ b/nsw/Source/bsmd.database/MDH.cs @@ -19,6 +19,12 @@ namespace bsmd.database private List portOfCallLast30Days = new List(); + private List sanitaryMeasuresDetails = new List(); + + private List stowawaysJoiningLocations = new List(); + + private List infectedAreas = new List(); + public MDH() { this.tablename = "[dbo].[MDH]"; @@ -27,6 +33,13 @@ namespace bsmd.database #region Properties public List PortOfCallLast30Days { get { return this.portOfCallLast30Days; } } + + public List SanitaryMeasuresDetails { get { return this.sanitaryMeasuresDetails; } } + + public List StowawaysJoiningLocations { get { return this.stowawaysJoiningLocations; } } + + public List InfectedAreas { get { return this.infectedAreas; } } + [ShowReport] [Validation1(ValidationCode.NOT_NULL)] [LookupName("MDH.ValidSanitaryControlExemptionOrCertificateOnBoard")] @@ -264,6 +277,22 @@ namespace bsmd.database DBManager.Instance.Save(poc30d); ((ISublistContainer)poc30d).SaveElements(); } + + foreach(SanitaryMeasuresDetail smd in this.SanitaryMeasuresDetails) + { + DBManager.Instance.Save(smd); + } + + foreach(StowawaysJoiningLocation sjl in this.stowawaysJoiningLocations) + { + DBManager.Instance.Save(sjl); + } + + foreach(InfectedArea ia in this.InfectedAreas) + { + DBManager.Instance.Save(ia); + } + } #endregion diff --git a/nsw/Source/bsmd.database/Message.cs b/nsw/Source/bsmd.database/Message.cs index 524a7e35..b000d5e3 100644 --- a/nsw/Source/bsmd.database/Message.cs +++ b/nsw/Source/bsmd.database/Message.cs @@ -421,6 +421,8 @@ namespace bsmd.database case NotificationClass.BKRA: return 5; case NotificationClass.BKRD: return 5; case NotificationClass.LADG: return 5; + case NotificationClass.CREW: return 30; + case NotificationClass.PAS: return 30; default: return 0; diff --git a/nsw/Source/bsmd.database/NOA_NOD.cs b/nsw/Source/bsmd.database/NOA_NOD.cs index 3d662e7a..91d907e3 100644 --- a/nsw/Source/bsmd.database/NOA_NOD.cs +++ b/nsw/Source/bsmd.database/NOA_NOD.cs @@ -215,5 +215,37 @@ namespace bsmd.database #endregion + #region public methods + + /// + /// Hilfsmethode (Heuristik) wenn nur der Text verfügbar ist (Excel) + /// Quelle: http://www.unece.org/trade/untdid/d01a/tred/tred8025.htm + /// + /// Code nach NSW Spec, null on failure + public int? getCallPurposeCodeFromDescription(string description) + { + if (description.IsNullOrEmpty()) return null; + + if (description.Contains("cargo", StringComparison.CurrentCultureIgnoreCase)) return 1; + if (description.Contains("passenger", StringComparison.CurrentCultureIgnoreCase)) return 2; + if (description.Contains("bunker", StringComparison.CurrentCultureIgnoreCase)) return 3; + if (description.Contains("crew", StringComparison.CurrentCultureIgnoreCase)) return 4; + if (description.Contains("visit", StringComparison.CurrentCultureIgnoreCase)) return 5; + if (description.Contains("supplies", StringComparison.CurrentCultureIgnoreCase)) return 6; + if (description.Contains("repair", StringComparison.CurrentCultureIgnoreCase)) return 7; + if (description.Contains("laid-up", StringComparison.CurrentCultureIgnoreCase)) return 8; + if (description.Contains("order", StringComparison.CurrentCultureIgnoreCase)) return 9; + if (description.Contains("miscellaneous", StringComparison.CurrentCultureIgnoreCase)) return 10; + if (description.Contains("movement", StringComparison.CurrentCultureIgnoreCase)) return 11; + if (description.Contains("cruise", StringComparison.CurrentCultureIgnoreCase)) return 12; + if (description.Contains("government", StringComparison.CurrentCultureIgnoreCase)) return 13; + if (description.Contains("quarantine", StringComparison.CurrentCultureIgnoreCase)) return 14; + if (description.Contains("refuge", StringComparison.CurrentCultureIgnoreCase)) return 15; + + return 0; + } + + #endregion + } } diff --git a/nsw/Source/bsmd.database/PRE72H.cs b/nsw/Source/bsmd.database/PRE72H.cs index b191efa7..ff4eab86 100644 --- a/nsw/Source/bsmd.database/PRE72H.cs +++ b/nsw/Source/bsmd.database/PRE72H.cs @@ -26,26 +26,32 @@ namespace bsmd.database [ShowReport] [Validation(ValidationCode.NOT_NULL)] + [LookupName("PRE72H.Tanker")] public bool? Tanker { get; set; } - [ShowReport] + [ShowReport] public byte? TankerHullConfiguration { get; set; } [ShowReport] public byte? ConditionCargoBallastTanks { get; set; } [ShowReport] + [LookupName("PRE72H.NaturOfCargo")] public string NatureOfCargo { get; set; } [ShowReport] + [LookupName("PRE72H.VolumeOfCargo_TNE")] public double? VolumeOfCargo { get; set; } [ShowReport] [Validation(ValidationCode.NOT_NULL)] + [LookupName("PRE72H.PlannedOperations")] public string PlannedOperations { get; set; } [ShowReport] [Validation(ValidationCode.NOT_NULL)] + [LookupName("PRE72H.PlannedWorks")] public string PlannedWorks { get; set; } - [ShowReport] - [Validation(ValidationCode.NOT_NULL)] + [ShowReport] + [LookupName("PRE72H.DateOfLastExpandedInspection")] public DateTime? DateOfLastExpandedInspection { get; set; } [ShowReport] [Validation(ValidationCode.DOUBLE_GT_ZERO)] + [LookupName("PRE72H.PlannedPeriodOfStay_HUR")] public double? PlannedPeriodOfStay_HUR { get; set; } public override string Subtitle diff --git a/nsw/Source/bsmd.database/PortOfCallLast30Days.cs b/nsw/Source/bsmd.database/PortOfCallLast30Days.cs index 4cae6533..d0274102 100644 --- a/nsw/Source/bsmd.database/PortOfCallLast30Days.cs +++ b/nsw/Source/bsmd.database/PortOfCallLast30Days.cs @@ -80,7 +80,8 @@ namespace bsmd.database { case Message.LoadFilter.MDH_ID: query += "WHERE MDH_Id = @MDHID"; - ((SqlCommand)cmd).Parameters.AddWithValue("@MDHID", criteria[0]); + if (!cmd.Parameters.Contains("@MDHID")) + ((SqlCommand)cmd).Parameters.AddWithValue("@MDHID", criteria[0]); break; case Message.LoadFilter.ALL: default: diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs index eb32ebc2..47d6f7a3 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.4.18")] -[assembly: AssemblyCopyright("Copyright © 2014-2015 Informatikbüro Daniel Schick. All rights reserved.")] +[assembly: AssemblyInformationalVersion("3.0.0")] +[assembly: AssemblyCopyright("Copyright © 2014-2016 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 452ed2a9..a15a53c6 100644 --- a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs +++ b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("2.4.18.*")] +[assembly: AssemblyVersion("3.0.0.*")] diff --git a/nsw/Source/bsmd.database/SEC.cs b/nsw/Source/bsmd.database/SEC.cs index 972347bc..628e8bb7 100644 --- a/nsw/Source/bsmd.database/SEC.cs +++ b/nsw/Source/bsmd.database/SEC.cs @@ -35,11 +35,13 @@ namespace bsmd.database public string PortOfCallWhereCompleteSECNotified { get; set; } [ShowReport] [Validation2(ValidationCode.NOT_NULL)] + [LookupName("SEC.CSOLastName")] public string CSOLastName { get; set; } [ShowReport] public string CSOFirstName { get; set; } [ShowReport] [Validation2(ValidationCode.NOT_NULL)] + [LookupName("SEC.CSOPhone")] public string CSOPhone { get; set; } [ShowReport] public string CSOFax { get; set; } @@ -47,16 +49,21 @@ namespace bsmd.database public string CSOEMail { get; set; } [ShowReport] [Validation2(ValidationCode.NOT_NULL)] + [LookupName("SEC.ValidISSCOnBoard")] public bool? ValidISSCOnBoard { get; set; } [ShowReport] + [LookupName("SEC.ReasonsForNoValidISSC")] public string ReasonsForNoValidISSC { get; set; } [Validation2(ValidationCode.NOT_NULL)] + [LookupName("SEC.ISSCType")] public byte? ISSCType { get; set; } [ShowReport] [ReportDisplayName("ISSC type")] public string ISSCTypeDisplay { get { return Util.GetISSCTypeDisplay(this.ISSCType); } } [Validation2(ValidationCode.NOT_NULL)] + [LookupName("SEC.ISSCIssuerType")] + public byte? ISSCIssuerType { get; set; } [ShowReport] [ReportDisplayName("ISSC issuer type")] @@ -64,20 +71,25 @@ namespace bsmd.database [ShowReport] [Validation2(ValidationCode.NOT_NULL)] + [LookupName("SEC.ISSCIssuerName")] public string ISSCIssuerName { get; set; } [ShowReport] [Validation2(ValidationCode.NOT_NULL)] + [LookupName("SEC.ISSCDateOfExpiration")] public DateTime? ISSCDateOfExpiration { get; set; } [ShowReport] [Validation2(ValidationCode.NOT_NULL)] + [LookupName("SEC.ApprovedSecurityPlanOnBoard")] public bool? ApprovedSecurityPlanOnBoard { get; set; } [ShowReport] - [Validation2(ValidationCode.NOT_NULL)] + [Validation(ValidationCode.NOT_NULL)] + [LookupName("SEC.CurrentShipSecurityLevel")] public byte? CurrentShipSecurityLevel { get; set; } [ShowReport] public string PortFacilityOfArrival { get; set; } [ShowReport] [Validation2(ValidationCode.NOT_NULL)] + [LookupName("SEC.GeneralDescriptionOfCargo")] public byte? GeneralDescriptionOfCargo { get; set; } public List LastTenPortFacilitesCalled { get { return this.ltpfc; } } diff --git a/nsw/Source/bsmd.database/SERV.cs b/nsw/Source/bsmd.database/SERV.cs index 287c79b0..0109fec3 100644 --- a/nsw/Source/bsmd.database/SERV.cs +++ b/nsw/Source/bsmd.database/SERV.cs @@ -27,9 +27,11 @@ namespace bsmd.database public string ServiceName { get; set; } [ShowReport] [Validation1(ValidationCode.NOT_NULL)] + [LookupName("SERV.ServiceBeneficiary")] public string ServiceBeneficiary { get; set; } [ShowReport] [Validation1(ValidationCode.NOT_NULL)] + [LookupName("SERV.ServiceInvoiceRecipient")] public string ServiceInvoiceRecipient { get; set; } public string Identifier { get; set; } diff --git a/nsw/Source/bsmd.database/STAT.cs b/nsw/Source/bsmd.database/STAT.cs index 57d9db1a..8e8f1e91 100644 --- a/nsw/Source/bsmd.database/STAT.cs +++ b/nsw/Source/bsmd.database/STAT.cs @@ -67,6 +67,26 @@ namespace bsmd.database [ShowReport] public string InmarsatCallNumber { get; set; } + /// + /// UNECE Rec.19 Code (http://www.unece.org/fileadmin/DAM/cefact/recommendations/rec19/rec19_ecetrd138.pdf) + /// + [Validation(ValidationCode.NOT_NULL)] + public string TransportMode { get; set; } + + [ShowReport] + public string TransportModeDisplay + { + get + { + if (!this.TransportMode.IsNullOrEmpty()) + { + if (this.TransportMode == "1") return "Maritime transport"; + if (this.TransportMode == "8") return "Inland water transport"; + } + return string.Empty; + } + } + [ShowReport] [Validation(ValidationCode.NOT_NULL)] [LookupName("STAT.ShipType")] @@ -109,7 +129,7 @@ namespace bsmd.database { string query = string.Format("SELECT Id, ShipName, Callsign, MMSINumber, Flag, LengthOverall_MTR, Beam_MTR, " + "GrossTonnage, PortOfRegistry, InmarsatCallNumber, ShipType, ISMCompanyName, ISMCompanyId, ISMCompanyStreetAndNumber, " + - "ISMCompanyPostalCode, ISMCompanyCity, ISMCompanyCountry FROM {0} ", this.Tablename); + "ISMCompanyPostalCode, ISMCompanyCity, ISMCompanyCountry, TransportMode FROM {0} ", this.Tablename); switch (filter) { @@ -151,6 +171,7 @@ namespace bsmd.database if (!reader.IsDBNull(14)) stat.ISMCompanyPostalCode = reader.GetString(14); if (!reader.IsDBNull(15)) stat.ISMCompanyCity = reader.GetString(15); if (!reader.IsDBNull(16)) stat.ISMCompanyCountry = reader.GetString(16); + if (!reader.IsDBNull(17)) stat.TransportMode = reader.GetString(17); result.Add(stat); } @@ -195,21 +216,24 @@ namespace bsmd.database else scmd.Parameters.AddWithValue("@P16", DBNull.Value); if (this.ISMCompanyCountry != null) scmd.Parameters.AddWithValue("@P17", this.ISMCompanyCountry); else scmd.Parameters.AddWithValue("@P17", DBNull.Value); + if (this.TransportMode != null) scmd.Parameters.AddWithValue("@P18", this.TransportMode); + else scmd.Parameters.AddWithValue("@P18", DBNull.Value); if (this.IsNew) { cmd.CommandText = string.Format("INSERT INTO {0} (MessageHeaderId, ShipName, CallSign, MMSINumber, " + "Flag, LengthOverall_MTR, Beam_MTR, GrossTonnage, PortOfRegistry, InmarsatCallNumber, ShipType, " + "ISMCompanyName, ISMCompanyId, ISMCompanyStreetAndNumber, ISMCompanyPostalCode, ISMCompanyCity, " + - "ISMCompanyCountry) VALUES (@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, @P14, " + - "@P15, @P16, @P17)", this.Tablename); + "ISMCompanyCountry, TransportMode) VALUES (@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, " + + " @P12, @P13, @P14, @P15, @P16, @P17, @P18)", this.Tablename); } else { cmd.CommandText = string.Format("UPDATE {0} SET ShipName = @P2, CallSign = @P3, MMSINumber = @P4, Flag = @P5, " + "LengthOverall_MTR = @P6, Beam_MTR = @P7, GrossTonnage = @P8, PortOfRegistry = @P9, InmarsatCallNumber = @P10, " + "ShipType = @P11, ISMCompanyName = @P12, ISMCompanyId = @P13, ISMCompanyStreetAndNumber = @P14, " + - "ISMCompanyPostalCode = @P15, ISMCompanyCity = @P16, ISMCompanyCountry = @P17 WHERE Id = @ID", this.Tablename); + "ISMCompanyPostalCode = @P15, ISMCompanyCity = @P16, ISMCompanyCountry = @P17, TransportMode = @P18 " + + "WHERE Id = @ID", this.Tablename); scmd.Parameters.AddWithValue("@ID", this.Id); } diff --git a/nsw/Source/bsmd.database/TOWA.cs b/nsw/Source/bsmd.database/TOWA.cs index eb6c7689..3a60ae70 100644 --- a/nsw/Source/bsmd.database/TOWA.cs +++ b/nsw/Source/bsmd.database/TOWA.cs @@ -25,10 +25,12 @@ namespace bsmd.database #region Properties [ShowReport] [Validation(ValidationCode.NOT_NULL)] + [LookupName("TOWA.TowageOnArrivalName")] public string TowageOnArrivalName { get; set; } [ShowReport] [Validation(ValidationCode.FLAG_CODE)] + [LookupName("TOWA.TowageOnArrivalFlag")] public string TowageOnArrivalFlag { get; set; } [ShowReport] @@ -57,22 +59,27 @@ namespace bsmd.database [ShowReport] [Validation(ValidationCode.INT_GT_ZERO)] + [LookupName("TOWA.TowageOnArrivalGrossTonnage")] public int? TowageOnArrivalGrossTonnage { get; set; } [ShowReport] [Validation(ValidationCode.DOUBLE_GT_ZERO)] + [LookupName("TOWA.TowageOnArrivalLengthOverall_MTR")] public double? TowageOnArrivalLengthOverall_MTR { get; set; } [ShowReport] [Validation(ValidationCode.DOUBLE_GT_ZERO)] + [LookupName("TOWA.TowageOnArrivalBeam_MTR")] public double? TowageOnArrivalBeam_MTR { get; set; } [ShowReport] [Validation(ValidationCode.NOT_NULL)] + [LookupName("TOWA.TowageOnArrivalPurposeOfCall")] public string TowageOnArrivalPurposeOfCall { get; set; } [ShowReport] [Validation(ValidationCode.DOUBLE_GT_ZERO)] + [LookupName("TOWA.TowageOnArrivalDraught_DMT")] public double? TowageOnArrivalDraught_DMT { get; set; } [ShowReport] diff --git a/nsw/Source/bsmd.database/TOWD.cs b/nsw/Source/bsmd.database/TOWD.cs index 0d55e472..57799e59 100644 --- a/nsw/Source/bsmd.database/TOWD.cs +++ b/nsw/Source/bsmd.database/TOWD.cs @@ -26,9 +26,11 @@ namespace bsmd.database [ShowReport] [Validation(ValidationCode.NOT_NULL)] + [LookupName("TOWD.TowageOnDepartureName")] public string TowageOnDepartureName { get; set; } [ShowReport] + [LookupName("TOWD.TowageOnDepartureFlag")] public string TowageOnDepartureFlag { get; set; } [ShowReport] @@ -56,13 +58,16 @@ namespace bsmd.database public string TowageOnDepartureOperatorEmail { get; set; } [ShowReport] + [LookupName("TOWD.TowageOnDepartureLengthOverall_MTR")] public double? TowageOnDepartureLengthOverall_MTR { get; set; } [ShowReport] + [LookupName("TOWD.TowageOnDepartureBeam_MTR")] public double? TowageOnDepartureBeam_MTR { get; set; } [ShowReport] [Validation(ValidationCode.DOUBLE_GT_ZERO)] + [LookupName("TOWD.TowageOnDepartureDraught_DMT")] public double? TowageOnDepartureDraught_DMT { get; set; } [ShowReport] diff --git a/nsw/Source/bsmd.database/WAS.cs b/nsw/Source/bsmd.database/WAS.cs index ffa5895a..57ab110b 100644 --- a/nsw/Source/bsmd.database/WAS.cs +++ b/nsw/Source/bsmd.database/WAS.cs @@ -30,13 +30,15 @@ namespace bsmd.database [ShowReport] public bool? WasteDisposalValidExemption { get; set; } [ShowReport] - [Validation2(ValidationCode.NOT_NULL)] + [Validation2(ValidationCode.NOT_NULL)] public string LastWasteDisposalPort { get; set; } [ShowReport] [Validation2(ValidationCode.NOT_NULL)] + [LookupName("WAS.ConfirmationOfCorrectness")] public bool? ConfirmationOfCorrectness { get; set; } [ShowReport] [Validation2(ValidationCode.NOT_NULL)] + [LookupName("WAS.LastWasteDisposalDate")] public DateTime? LastWasteDisposalDate { get; set; } [ShowReport] [Validation2(ValidationCode.NOT_NULL)] diff --git a/nsw/Source/bsmd.database/Waste.cs b/nsw/Source/bsmd.database/Waste.cs index f6ef7d66..f1043d20 100644 --- a/nsw/Source/bsmd.database/Waste.cs +++ b/nsw/Source/bsmd.database/Waste.cs @@ -51,6 +51,7 @@ namespace bsmd.database [Validation(ValidationCode.NOT_NULL)] public byte? WasteType { get; set; } [ShowReport] + [Validation(ValidationCode.NOT_NULL)] public string WasteDescription { get; set; } [ShowReport] [Validation(ValidationCode.NOT_NULL)] diff --git a/nsw/Source/bsmd.database/bsmd.database.csproj b/nsw/Source/bsmd.database/bsmd.database.csproj index db21b95f..5ccd669c 100644 --- a/nsw/Source/bsmd.database/bsmd.database.csproj +++ b/nsw/Source/bsmd.database/bsmd.database.csproj @@ -64,6 +64,7 @@ + @@ -98,12 +99,14 @@ + + diff --git a/nsw/Source/bsmd.email/BSMDMail.cs b/nsw/Source/bsmd.email/BSMDMail.cs index 0de013fb..326ba61c 100644 --- a/nsw/Source/bsmd.email/BSMDMail.cs +++ b/nsw/Source/bsmd.email/BSMDMail.cs @@ -14,6 +14,8 @@ using System.Net; using System.Net.Mime; using System.Net.Mail; using log4net; +using System.Security.Cryptography.X509Certificates; +using System.Net.Security; namespace bsmd.email { @@ -38,6 +40,10 @@ namespace bsmd.email smtpClient.Timeout = (60 * 5 * 1000); smtpClient.EnableSsl = true; + // evil workaround for invalid BSMD E-Mail certificate! + ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) + { return true; }; + message.From = fromAddress; message.Subject = string.Format(subject); message.IsBodyHtml = false; diff --git a/nsw/Source/bsmd.herberg.FormService/Util.cs b/nsw/Source/bsmd.herberg.FormService/Util.cs index a1fff81c..8063112b 100644 --- a/nsw/Source/bsmd.herberg.FormService/Util.cs +++ b/nsw/Source/bsmd.herberg.FormService/Util.cs @@ -1041,6 +1041,12 @@ namespace bsmd.herberg.FormService if (((waste.WasteType ?? 0) == 9) && waste.WasteDescription.IsNullOrEmpty()) waste.WasteDescription = "-"; + if(waste.WasteDisposalPort.Length == 7) + { + _log.WarnFormat("WasteDisposalPort format ERROR [{0}], truncating", was.LastWasteDisposalPort); + waste.WasteDisposalPort = waste.WasteDisposalPort.Substring(2); + } + if (waste.WasteType.HasValue) { saveMessages.Add(waste); diff --git a/nsw/Source/bsmd.hisnord/Request.cs b/nsw/Source/bsmd.hisnord/Request.cs index 51075ed2..56857b4b 100644 --- a/nsw/Source/bsmd.hisnord/Request.cs +++ b/nsw/Source/bsmd.hisnord/Request.cs @@ -256,7 +256,7 @@ namespace bsmd.hisnord _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; + _nsw.conveyance.CREW.CrewMembers[i].CrewMemberVisaNumber = crew.CrewMemberVisaNumber.IsNullOrEmpty() ? "-" : crew.CrewMemberVisaNumber; } } break; @@ -722,11 +722,16 @@ namespace bsmd.hisnord } _transit.LastPort = new lastport(); - if (noa_nod.ETDFromLastPort.HasValue) - _transit.LastPort.ETD = noa_nod.ETDFromLastPort.Value; - _transit.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue; + if((noa_nod.LastPort != null) && (noa_nod.LastPort.Trim() != "")) _transit.LastPort.Locode = noa_nod.LastPort; + if(!noa_nod.LastPort.IsNullOrEmpty() && !noa_nod.LastPort.Equals("ZZUKN")) + { + if (noa_nod.ETDFromLastPort.HasValue) + _transit.LastPort.ETD = noa_nod.ETDFromLastPort.Value; + _transit.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue; + } + _transit.NextPort = new nextporthazmat(); if (noa_nod.ETAToNextPort.HasValue) @@ -745,11 +750,16 @@ namespace bsmd.hisnord } _import.LastPort = new lastport(); - if (noa_nod.ETDFromLastPort.HasValue) - _import.LastPort.ETD = noa_nod.ETDFromLastPort.Value; - _import.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue; + if ((noa_nod.LastPort != null) && (noa_nod.LastPort.Trim() != "")) _import.LastPort.Locode = noa_nod.LastPort; + if (!noa_nod.LastPort.IsNullOrEmpty() && !noa_nod.LastPort.Equals("ZZUKN")) + { + if (noa_nod.ETDFromLastPort.HasValue) + _import.LastPort.ETD = noa_nod.ETDFromLastPort.Value; + _import.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue; + } + _import.PortOfCall = new portofcallhazmat(); if (noa_nod.ETAToPortOfCall.HasValue) _import.PortOfCall.ETA = noa_nod.ETAToPortOfCall.Value; @@ -757,7 +767,16 @@ namespace bsmd.hisnord _import.PortOfCall.ETD = noa_nod.ETDFromPortOfCall.Value; if ((message.MessageCore.PoC != null) && (message.MessageCore.PoC.Trim() != "")) _import.PortOfCall.Locode = message.MessageCore.PoC; - + if (noa_nod.CallPurposes.Count > 0) + { + _import.PortOfCall.CallPurposes = new callpurpose[noa_nod.CallPurposes.Count]; + for(int i=0;i + /// Extract Guid aus ConveyanceCode + /// + public Guid? MessageCoreId + { + get + { + Guid? result = null; + if (this.ConveyanceCode != null) + { + int startIndex = this.ConveyanceCode.IndexOf('-'); + if (startIndex > 0) + { + Guid tmpGuid; + if (Guid.TryParse(this.ConveyanceCode.Substring(startIndex + 1), out tmpGuid)) + result = tmpGuid; + else if (Guid.TryParse(this.ConveyanceCode, out tmpGuid)) + result = tmpGuid; + } + } + return result; + } + } + #endregion + + #region Deserialization + + public static TransitId ReadTransitId(string filename) + { + TransitId aTransitId = null; + try + { + XmlSerializer serializer = new XmlSerializer(typeof(bsmd.hisnord.TransitId)); + using (FileStream fs = new FileStream(filename, FileMode.Open)) + { + aTransitId = (TransitId)serializer.Deserialize(fs); + } + } + catch (Exception ex) + { + _log.ErrorFormat("Exception occurred during deserialization: {0}", ex.Message); + + } + return aTransitId; + } + + #endregion + + } + +} diff --git a/nsw/Source/bsmd.hisnord/VisitId.cs b/nsw/Source/bsmd.hisnord/VisitId.cs index 55c938fc..63174b04 100644 --- a/nsw/Source/bsmd.hisnord/VisitId.cs +++ b/nsw/Source/bsmd.hisnord/VisitId.cs @@ -59,6 +59,8 @@ namespace bsmd.hisnord Guid tmpGuid; if (Guid.TryParse(this.ConveyanceCode.Substring(startIndex + 1), out tmpGuid)) result = tmpGuid; + else if (Guid.TryParse(this.ConveyanceCode, out tmpGuid)) + result = tmpGuid; } } return result; diff --git a/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj b/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj index ae4196dd..01533d9b 100644 --- a/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj +++ b/nsw/Source/bsmd.hisnord/bsmd.hisnord.csproj @@ -65,6 +65,7 @@ Settings.settings +