diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index 25929d8c..ef924ff4 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ diff --git a/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs b/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs index b7a2c77e..608cf041 100644 --- a/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs +++ b/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs @@ -113,7 +113,7 @@ namespace bsmd.ExcelReadService if (!isValidSender) { - receiptText = string.Format("ignored e - mail from illegal sender: { 0}", mailSender); + receiptText = string.Format("ignored e - mail from illegal sender: {0}", mailSender); _log.Warn(receiptText); } else diff --git a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs index 086433bc..68e044bb 100644 --- a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs +++ b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs @@ -463,7 +463,7 @@ namespace bsmd.ExcelReadService this.HighlightLookup(lookup, ReadState.OK); - if ((val == "y") || (val == "Y") || (val == "yes") || (val == "YES") || (val == "1") || (val == "x") || (val == "X")) + if ((val == "y") || (val == "Y") || val.Equals("yes", StringComparison.OrdinalIgnoreCase) || (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 e881f7c9..b1916d50 100644 --- a/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs +++ b/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs @@ -96,9 +96,28 @@ namespace bsmd.ExcelReadService } reader.Close(); return result; - } + /// + /// Get Portname from LOCODE + /// + public static string PortNameFromLocode(string locode) + { + string result = null; + string query = string.Format("SELECT locodes.name FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE locodes.port='t' AND locodes.city_code = '{0}' AND countries.code = '{1}'", + locode.Substring(2), locode.Substring(0,2)); + SQLiteCommand cmd = new SQLiteCommand(query, _con); + IDataReader reader = cmd.ExecuteReader(); + while (reader.Read()) + { + result = reader.GetString(0); + break; + } + reader.Close(); + return result; + } + + public static void CloseDB() { _con.Close(); diff --git a/nsw/Source/bsmd.ExcelReadService/Util.cs b/nsw/Source/bsmd.ExcelReadService/Util.cs index af5a0f0e..3c3070c3 100644 --- a/nsw/Source/bsmd.ExcelReadService/Util.cs +++ b/nsw/Source/bsmd.ExcelReadService/Util.cs @@ -344,30 +344,55 @@ namespace bsmd.ExcelReadService else { noa_nod.ETAToPortOfCall = messageCore.ETA; - string callPurposeDescription = reader.ReadText("NOA_NOD.CallPuposeDescription"); - if (!callPurposeDescription.IsNullOrEmpty()) + for (int i = 1; i <= noa_nod.NumberOfExcelRows; i++) { - CallPurpose callPurpose = new CallPurpose(); - callPurpose.NOA_NOD = noa_nod; - callPurpose.CallPurposeCode = noa_nod.getCallPurposeCodeFromDescription(callPurposeDescription) ?? 0; - callPurpose.CallPurposeDescription = callPurposeDescription; - noa_nod.CallPurposes.Add(callPurpose); + string callPurposeDescriptionKey = string.Format("NOA_NOD.CallPuposeDescription_{0}", i); + string callPurposeCodeKey = string.Format("NOA_NOD.CallPurposeCode_{0}", i); + string callPurposeDescription = reader.ReadText(callPurposeDescriptionKey); + string callPurposeCode = reader.ReadText(callPurposeCodeKey); + + if (!callPurposeCode.IsNullOrEmpty()) + { + CallPurpose callPurpose = new CallPurpose(); + callPurpose.NOA_NOD = noa_nod; + callPurpose.CallPurposeCode = ((int?) reader.ReadNumber(callPurposeCodeKey)) ?? 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]; + + if (LocodeDB.PortNameFromLocode(lastPort) != null) + { + noa_nod.LastPort = lastPort; + } else - _log.WarnFormat("{0} results in {1} possible LOCODES", lastPort, lastPorts.Count); + { + 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]; + + if (LocodeDB.PortNameFromLocode(nextPort) != null) + { + noa_nod.NextPort = nextPort; + } else - _log.WarnFormat("{0} results in {1} possible LOCODES", nextPort, nextPorts.Count); + { + 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"); @@ -409,9 +434,13 @@ namespace bsmd.ExcelReadService 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]; + if ((was.LastWasteDisposalPort != null) && (was.LastWasteDisposalPort.Length > 5)) + { + string lastWasteDisposalPort = reader.ReadText("WAS.LastWasteDisposalPort"); + List deliveryLocodes = LocodeDB.AllLocodesForCityName(lastWasteDisposalPort); + if (deliveryLocodes.Count == 1) + was.LastWasteDisposalPort = deliveryLocodes[0]; + } // Waste 1 - 9 for (int i = 1; i <= was.NumberOfExcelRows; i++) @@ -478,7 +507,7 @@ namespace bsmd.ExcelReadService poc30d.Identifier = (i + 1).ToString(); poc30d.MDH = mdh; mdh.PortOfCallLast30Days.Add(poc30d); - } + } poc30d.PortOfCallLast30DaysDateOfDeparture = reader.ReadDate(depDate); poc30d.PortOfCallLast30DaysLocode = reader.ReadTextNoWhitespace(locode); @@ -534,6 +563,15 @@ namespace bsmd.ExcelReadService SEC sec = secMessage.Elements[0] as SEC; Util.ScanMessage(sec, reader); + string isscType = reader.ReadText("SEC.ISSCType"); + if(isscType != null) + { + if (isscType.Equals("full", StringComparison.OrdinalIgnoreCase)) + sec.ISSCType = 0; + if (isscType.Equals("interim", StringComparison.OrdinalIgnoreCase)) + sec.ISSCType = 1; + } + // Last10PortFacilitesCalled for (int i = 1; i <= 10; i++) { @@ -544,6 +582,7 @@ namespace bsmd.ExcelReadService string portDateOfDeparture = string.Format("SEC.PortFacilityDateOfDeparture_{0}", i); string portShipSecLevel = string.Format("SEC.PortFacilityShipSecurityLevel_{0}", i); string portGISISCode = string.Format("SEC.PortFacilityGISISCode_{0}", i); + string portSecMatters = string.Format("SEC.PortFacilitySecurityMattersToReport_{0}", i); LastTenPortFacilitiesCalled l10fc = sec.GetPortFacilityWithIdentifier(i.ToString()) as LastTenPortFacilitiesCalled; if (l10fc == null) @@ -561,6 +600,7 @@ namespace bsmd.ExcelReadService l10fc.PortFacilityDateOfDeparture = reader.ReadDate(portDateOfDeparture); l10fc.PortFacilityShipSecurityLevel = (byte) reader.ReadNumber(portShipSecLevel); l10fc.PortFacilityGISISCode = reader.ReadTextNoWhitespace(portGISISCode); + l10fc.PortFacilitySecurityMattersToReport = reader.ReadText(portSecMatters); } @@ -574,6 +614,7 @@ namespace bsmd.ExcelReadService 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) @@ -816,6 +857,7 @@ namespace bsmd.ExcelReadService crew.CrewMemberFirstName = reader.ReadText(crewFirstName); crew.CrewMemberGender = reader.ReadGender(crewGender); crew.CrewMemberDuty = reader.ReadText(crewDuty); + crew.CrewMemberNationality = reader.ReadText(crewNationality); crew.CrewMemberPlaceOfBirth = reader.ReadText(crewPlaceOfBirth); crew.CrewMemberDateOfBirth = reader.ReadDate(crewDateOfBirth); crew.CrewMemberIdentityDocumentType = reader.ReadIdentityDocumentType(crewIdentDocType); @@ -912,8 +954,16 @@ namespace bsmd.ExcelReadService string sheetValue = reader.ReadText(lookupNameAttribute.LookupName); if (sheetValue != null) property.SetValue(dbEntity, sheetValue); - } else { - + } + else if(property.PropertyType == typeof(int?)) + { + double? sheetValue = reader.ReadNumber(lookupNameAttribute.LookupName); + if (sheetValue.HasValue) + property.SetValue(dbEntity, (int)sheetValue.Value); + } + else + { + _log.DebugFormat("unhandled property type: {0}", property.PropertyType); } } @@ -958,7 +1008,7 @@ namespace bsmd.ExcelReadService if (poc != null) { // Prüfen auf Transit - if (poc.ToUpper().Contains("CANAL")) + if (poc.ToUpper().Contains("CANAL") || poc.ToUpper().Equals("ZZNOK")) { poc = "ZZNOK"; isTransit = true; @@ -980,7 +1030,7 @@ namespace bsmd.ExcelReadService else { // somehow lookup LOCODE from the port's name! - poc = LocodeDB.LocodeGERFromCity(aGermanPortName); + poc = LocodeDB.LocodeGERFromCity(aGermanPortName); } } } @@ -1031,7 +1081,9 @@ namespace bsmd.ExcelReadService result.IsTransit = isTransit; result.ReportStatus = MessageCore.ReportStatusEnum.COMPLETE; result.BSMDStatusInternal = MessageCore.BSMDStatus.PREPARE; - result.Portname = poc; + result.PoC = poc; + result.Portname = LocodeDB.PortNameFromLocode(poc); + result.ETA = eta; if (result.IMO.Length > 7) { @@ -1041,10 +1093,10 @@ namespace bsmd.ExcelReadService if(visitTransitId != null) { - if (bsmd.database.Util.IsVisitId(visitTransitId)) - result.VisitId = visitTransitId; - else + if (bsmd.database.Util.IsTransitId(visitTransitId)) result.TransitId = visitTransitId; + else + result.VisitId = visitTransitId; } DBManager.Instance.Save(result); diff --git a/nsw/Source/bsmd.database/INFO.cs b/nsw/Source/bsmd.database/INFO.cs index 1c4c6c5e..e48080f2 100644 --- a/nsw/Source/bsmd.database/INFO.cs +++ b/nsw/Source/bsmd.database/INFO.cs @@ -34,10 +34,12 @@ namespace bsmd.database public string RequestedPositionInPortOfCall { get; set; } [ShowReport] + [LookupName("INFO.SpecialRequirementsOfShipAtBerth")] [MaxLength(255)] public string SpecialRequirementsOfShipAtBerth { get; set; } [ShowReport] + [LookupName("INFO.ConstructionCharacteristicsOfShip")] [MaxLength(100)] public string ConstructionCharacteristicsOfShip { get; set; } @@ -47,6 +49,7 @@ namespace bsmd.database public byte? FumigatedBulkCargo { get; set; } [ShowReport] + [LookupName("INFO.DeadWeightSummer_TNE")] public double? DeplacementSummerDraught_TNE { get; set; } [ShowReport] diff --git a/nsw/Source/bsmd.database/MDH.cs b/nsw/Source/bsmd.database/MDH.cs index e53650ff..0b45dfd4 100644 --- a/nsw/Source/bsmd.database/MDH.cs +++ b/nsw/Source/bsmd.database/MDH.cs @@ -295,7 +295,7 @@ namespace bsmd.database public int NumberOfExcelRows { - get { return 15; } + get { return 37; } } public void SaveElements() diff --git a/nsw/Source/bsmd.database/NOA_NOD.cs b/nsw/Source/bsmd.database/NOA_NOD.cs index 1165eaff..4ba1060d 100644 --- a/nsw/Source/bsmd.database/NOA_NOD.cs +++ b/nsw/Source/bsmd.database/NOA_NOD.cs @@ -152,7 +152,7 @@ namespace bsmd.database public int NumberOfExcelRows { - get { return 1; } + get { return 3; } } public void SaveElements() @@ -236,6 +236,8 @@ namespace bsmd.database /// /// Hilfsmethode (Heuristik) wenn nur der Text verfügbar ist (Excel) /// Quelle: http://www.unece.org/trade/untdid/d01a/tred/tred8025.htm + /// Nach Nachricht von Christin doch nicht erforderlich, da der Code führend ist (wird vom Melder + /// eingetragen) /// /// Code nach NSW Spec, null on failure public int? getCallPurposeCodeFromDescription(string description) diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs index a70f98fd..81926017 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("3.2.2")] +[assembly: AssemblyInformationalVersion("3.2.4")] [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 c1ad8c62..ea4c06b2 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("3.2.2.*")] +[assembly: AssemblyVersion("3.2.4.*")] diff --git a/nsw/Source/bsmd.database/SEC.cs b/nsw/Source/bsmd.database/SEC.cs index ede5a286..1f968393 100644 --- a/nsw/Source/bsmd.database/SEC.cs +++ b/nsw/Source/bsmd.database/SEC.cs @@ -44,6 +44,7 @@ namespace bsmd.database public string CSOLastName { get; set; } [ShowReport] + [LookupName("SEC.CSOFirstName")] [MaxLength(100)] public string CSOFirstName { get; set; } @@ -54,10 +55,12 @@ namespace bsmd.database public string CSOPhone { get; set; } [ShowReport] + [LookupName("SEC.CSOFax")] [MaxLength(100)] public string CSOFax { get; set; } [ShowReport] + [LookupName("SEC.CSOEMail")] [MaxLength(100)] public string CSOEMail { get; set; } @@ -71,11 +74,10 @@ namespace bsmd.database [MaxLength(255)] public string ReasonsForNoValidISSC { get; set; } - [Validation2(ValidationCode.NOT_NULL)] - [LookupName("SEC.ISSCType")] + [Validation2(ValidationCode.NOT_NULL)] public byte? ISSCType { get; set; } - [ShowReport] + [ShowReport] [ReportDisplayName("ISSC type")] public string ISSCTypeDisplay { get { return Util.GetISSCTypeDisplay(this.ISSCType); } } diff --git a/nsw/Source/bsmd.database/STAT.cs b/nsw/Source/bsmd.database/STAT.cs index 294d34d5..292f517e 100644 --- a/nsw/Source/bsmd.database/STAT.cs +++ b/nsw/Source/bsmd.database/STAT.cs @@ -70,6 +70,7 @@ namespace bsmd.database public string PortOfRegistry { get; set; } [ShowReport] + [LookupName("STAT.InmarsatCallNumber")] [MaxLength(100)] public string InmarsatCallNumber { get; set; } @@ -112,18 +113,22 @@ namespace bsmd.database public string ISMCompanyId { get; set; } [ShowReport] + [LookupName("STAT.ISMCompanyStreetAndNumber")] [MaxLength(100)] public string ISMCompanyStreetAndNumber { get; set; } [ShowReport] + [LookupName("STAT.ISMCompanyPostalCode")] [MaxLength(24)] public string ISMCompanyPostalCode { get; set; } [ShowReport] + [LookupName("STAT.ISMCompanyCity")] [MaxLength(100)] public string ISMCompanyCity { get; set; } [ShowReport] + [LookupName("STAT.ISMCompanyCountry")] [MaxLength(100)] public string ISMCompanyCountry { get; set; } diff --git a/nsw/Source/bsmd.database/WAS.cs b/nsw/Source/bsmd.database/WAS.cs index 8754a345..6142b500 100644 --- a/nsw/Source/bsmd.database/WAS.cs +++ b/nsw/Source/bsmd.database/WAS.cs @@ -33,6 +33,7 @@ namespace bsmd.database [ShowReport] [Validation2(ValidationCode.NOT_NULL)] + [LookupName("WAS.LastWasteDisposalPort")] [MaxLength(5)] public string LastWasteDisposalPort { get; set; } diff --git a/nsw/Source/bsmd.database/Waste.cs b/nsw/Source/bsmd.database/Waste.cs index 7c88dcd3..bb1d1878 100644 --- a/nsw/Source/bsmd.database/Waste.cs +++ b/nsw/Source/bsmd.database/Waste.cs @@ -66,7 +66,7 @@ namespace bsmd.database [ShowReport] public double? WasteAmountRetained_MTQ { get; set; } - [ShowReport] + [ShowReport] [MaxLength(5)] public string WasteDisposalPort { get; set; }