diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index d122305f..c0fb6d30 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 9301d8e2..a1f588af 100644 --- a/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs +++ b/nsw/Source/bsmd.ExcelReadService/ExcelReadService.cs @@ -90,7 +90,7 @@ namespace bsmd.ExcelReadService while (bsmdPopClient.ReceiveSingleMail(out attachmentLocalPath, out messageId, out mailSender, out mailSubject)) { - bool readResult; + bool readResult = false; string readMessage = ""; string receiptText = ""; MessageCore messageCore = null; @@ -125,7 +125,15 @@ namespace bsmd.ExcelReadService // try to read/import attachment using (ExcelReader reader = new ExcelReader(attachmentLocalPath)) { - readResult = Util.ProcessSheet(reader, out readMessage, out messageCore); + try + { + readResult = Util.ProcessSheet(reader, out readMessage, out messageCore); + } + catch(Exception ex) + { + readMessage = string.Format("{0} Unerwartete Fehlersitutation:Bitte Info an Christin od. Daniel", ex.Message); + } + if (!readResult) { receiptText = string.Format("Incoming sheet could not be read: {0}", readMessage); diff --git a/nsw/Source/bsmd.ExcelReadService/Util.cs b/nsw/Source/bsmd.ExcelReadService/Util.cs index 8b28a554..a0d632b0 100644 --- a/nsw/Source/bsmd.ExcelReadService/Util.cs +++ b/nsw/Source/bsmd.ExcelReadService/Util.cs @@ -636,7 +636,19 @@ namespace bsmd.ExcelReadService reader.Conf.ConfirmText(marpol_name, name, ExcelReader.ReadState.OK); marpolPosition.Flashpoint_CEL = reader.ReadText(marpol_flash); reader.Conf.ConfirmText(marpol_flash, marpolPosition.Flashpoint_CEL, marpolPosition.Flashpoint_CEL.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); - marpolPosition.Quantity_KGM = reader.ReadNumber(marpol_quantity); + + if (marpolPosition.Flashpoint_CEL.IsNullOrEmpty()) { marpolPosition.FlashpointInformation = 0; } // NF // Ableitung Flashpoint-Info: Christin, 22.3.2017 + else + { + double flashval = 0; + if (double.TryParse(marpolPosition.Flashpoint_CEL, out flashval)) + { + if (flashval > 60) marpolPosition.FlashpointInformation = 1; // GT60CEL + else marpolPosition.FlashpointInformation = 2; // LE60CEL + } + } + + marpolPosition.Quantity_KGM = reader.ReadNumber(marpol_quantity); marpolPosition.StowagePosition = reader.ReadText(marpol_stowagePosition); reader.Conf.ConfirmText(marpol_stowagePosition, marpolPosition.StowagePosition, marpolPosition.StowagePosition.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); marpolPosition.PortOfLoading = reader.ReadText(marpol_portOfLoading); @@ -645,6 +657,13 @@ namespace bsmd.ExcelReadService reader.Conf.ConfirmText(marpol_portOfDischarge, marpolPosition.PortOfDischarge, marpolPosition.PortOfDischarge.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); } #endregion + + if(haza.HasPositions) // Christin 22.3.17: Felder bei Positionen immer fest ausfüllen + { + haza.NoDPGOnBoardOnArrival = false; + haza.DPGManifestOnBoardOnArrival = true; + } + } #endregion @@ -915,7 +934,19 @@ namespace bsmd.ExcelReadService reader.Conf.ConfirmText(marpol_name, name, ExcelReader.ReadState.OK); marpolPosition.Flashpoint_CEL = reader.ReadText(marpol_flash); reader.Conf.ConfirmText(marpol_flash, marpolPosition.Flashpoint_CEL, marpolPosition.Flashpoint_CEL.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); - marpolPosition.Quantity_KGM = reader.ReadNumber(marpol_quantity); + + if (marpolPosition.Flashpoint_CEL.IsNullOrEmpty()) { marpolPosition.FlashpointInformation = 0; } // NF // Ableitung Flashpoint-Info: Christin, 22.3.2017 + else + { + double flashval = 0; + if (double.TryParse(marpolPosition.Flashpoint_CEL, out flashval)) + { + if (flashval > 60) marpolPosition.FlashpointInformation = 1; // GT60CEL + else marpolPosition.FlashpointInformation = 2; // LE60CEL + } + } + + marpolPosition.Quantity_KGM = reader.ReadNumber(marpol_quantity); marpolPosition.StowagePosition = reader.ReadText(marpol_stowagePosition); reader.Conf.ConfirmText(marpol_stowagePosition, marpolPosition.StowagePosition, marpolPosition.StowagePosition.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); marpolPosition.PortOfLoading = reader.ReadText(marpol_portOfLoading); @@ -923,9 +954,14 @@ namespace bsmd.ExcelReadService marpolPosition.PortOfDischarge = reader.ReadText(marpol_portOfDischarge); reader.Conf.ConfirmText(marpol_portOfDischarge, marpolPosition.PortOfDischarge, marpolPosition.PortOfDischarge.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); } - #endregion + #endregion - } + if (hazd.HasPositions) // Christin 22.3.17: Felder bei Positionen immer fest ausfüllen + { + hazd.NoDPGOnBoardOnArrival = false; + hazd.DPGManifestOnBoardOnArrival = true; + } + } #endregion @@ -965,7 +1001,11 @@ namespace bsmd.ExcelReadService } STAT stat = statMessage.Elements[0] as STAT; Util.ScanMessage(stat, reader); - stat.MMSINumber = reader.ReadTextNoWhitespace("STAT.MMSINumber"); + + stat.PortOfRegistry = reader.ReadLoCode("STAT.PortOfRegistry"); + stat.Flag = reader.ReadNationality("STAT.Flag"); + + stat.MMSINumber = reader.ReadTextNoWhitespace("STAT.MMSINumber"); reader.Conf.ConfirmText("STAT.MMSINumber", stat.MMSINumber, (stat.MMSINumber.IsNullOrEmpty() || (stat.MMSINumber.Length != 9)) ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); stat.ISMCompanyId = reader.ReadTextNoWhitespace("STAT.ISMCompanyId"); @@ -974,20 +1014,7 @@ namespace bsmd.ExcelReadService while (stat.ISMCompanyId.Length < 7) stat.ISMCompanyId = "0" + stat.ISMCompanyId; } - reader.Conf.ConfirmText("STAT.ISMCompanyId", stat.ISMCompanyId, stat.ISMCompanyId.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK); - - - if (!stat.Flag.IsNullOrEmpty() && stat.Flag.Length > 2) - stat.Flag = LocodeDB.CountryCodeFromName(stat.Flag); - - if (!stat.Flag.IsNullOrEmpty() && stat.Flag.Length == 2) - { - if (!stat.PortOfRegistry.IsNullOrEmpty() && stat.PortOfRegistry.Length != 5) - stat.PortOfRegistry = LocodeDB.LocodeFromCity(stat.PortOfRegistry, stat.Flag); - } - - if (!stat.Flag.IsNullOrEmpty() && (stat.Flag.Length > 2)) - reader.Conf.ConfirmText("STAT.Flag", stat.Flag, ExcelReader.ReadState.FAIL); + reader.Conf.ConfirmText("STAT.ISMCompanyId", stat.ISMCompanyId, stat.ISMCompanyId.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK); string transportMode = reader.ReadText("STAT.TransportMode"); if(transportMode != null) @@ -997,6 +1024,9 @@ namespace bsmd.ExcelReadService } reader.Conf.ConfirmText("STAT.TransportMode", transportMode, stat.TransportMode.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK); + if (!stat.ShipType.IsNullOrEmpty() && stat.ShipType.Length > 3) + reader.Conf.ConfirmText("STAT.ShipType", stat.ShipType, ExcelReader.ReadState.WARN); + // Vessel Email as HerbergEmail sichern messageCore.HerbergEmailContactReportingVessel = reader.ReadText("ShipMail"); reader.Conf.ConfirmText("ShipMail", messageCore.HerbergEmailContactReportingVessel, messageCore.HerbergEmailContactReportingVessel.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); @@ -1276,6 +1306,15 @@ namespace bsmd.ExcelReadService waste.WasteAmountGeneratedTillNextPort_MTQ = 0; } + if(i==15) // falls letzte Zeile leer, entfernen: Christin 22.3.17 + { + if ((waste.WasteDescription.IsNullOrEmpty() || waste.WasteDescription == "-") && + ((waste.WasteDisposalAmount_MTQ ?? 0) == 0) && + ((waste.WasteType ?? 0) == 1300)) + was.Waste.Remove(waste); + } + + } /* try @@ -2500,7 +2539,12 @@ namespace bsmd.ExcelReadService else reader.SetConfirmation(Properties.Settings.Default.ConfirmationDE); } - } + else + { + message = "invalid PoC"; + return null; + } + } imo = reader.ReadText("Visit.IMONumber"); reader.Conf.ConfirmText("Visit.IMONumber", imo, imo.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK); diff --git a/nsw/Source/bsmd.database/HAZ.cs b/nsw/Source/bsmd.database/HAZ.cs index 55f0fb80..6fffc573 100644 --- a/nsw/Source/bsmd.database/HAZ.cs +++ b/nsw/Source/bsmd.database/HAZ.cs @@ -86,6 +86,19 @@ namespace bsmd.database [ShowReport] public string TransmissionType { get; set; } + public bool HasPositions + { + get + { + if (this.IMDGPositions.Count > 0) return true; + if (this.IBCPositions.Count > 0) return true; + if (this.IGCPositions.Count > 0) return true; + if (this.IMSBCPositions.Count > 0) return true; + if (this.MARPOLPositions.Count > 0) return true; + return false; + } + } + #endregion #region DatabaseEntity implementation diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs index d28b01ce..5615a91d 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.4.4")] +[assembly: AssemblyInformationalVersion("3.4.6")] [assembly: AssemblyCopyright("Copyright © 2014-2017 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 737ebda7..9cb094e8 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.4.4.*")] +[assembly: AssemblyVersion("3.4.6.*")] diff --git a/nsw/Source/bsmd.database/STAT.cs b/nsw/Source/bsmd.database/STAT.cs index 02c8c5dd..04542fba 100644 --- a/nsw/Source/bsmd.database/STAT.cs +++ b/nsw/Source/bsmd.database/STAT.cs @@ -42,8 +42,7 @@ namespace bsmd.database public string MMSINumber { get; set; } [ShowReport] - [Validation(ValidationCode.FLAG_CODE)] - [LookupName("STAT.Flag")] + [Validation(ValidationCode.FLAG_CODE)] [MaxLength(2)] public string Flag { get; set; } @@ -63,8 +62,7 @@ namespace bsmd.database public int? GrossTonnage { get; set; } [ShowReport] - [Validation(ValidationCode.LOCODE)] - [LookupName("STAT.PortOfRegistry")] + [Validation(ValidationCode.LOCODE)] [MaxLength(5)] public string PortOfRegistry { get; set; } diff --git a/nsw/Source/bsmd.dbh/Request.cs b/nsw/Source/bsmd.dbh/Request.cs index 0bef12aa..66d54539 100644 --- a/nsw/Source/bsmd.dbh/Request.cs +++ b/nsw/Source/bsmd.dbh/Request.cs @@ -261,9 +261,7 @@ namespace bsmd.dbh SEC sec = message.Elements[0] as SEC; List secItems = new List(); - List choiceType1s = new List(); - - rootSEC.CurrentShipSecurityLevel = (int)sec.CurrentShipSecurityLevel.Value; + List choiceType1s = new List(); if(!message.MessageCore.IsTransit) { @@ -278,6 +276,8 @@ namespace bsmd.dbh } } + rootSEC.CurrentShipSecurityLevel = (int)sec.CurrentShipSecurityLevel.Value; + if (sec.SECSimplification ?? false) { choiceType1s.Add(ItemsChoiceType1.SECSimplification); @@ -286,7 +286,7 @@ namespace bsmd.dbh secItems.Add(sec.PortOfCallWhereCompleteSECNotified); } else - { + { // ACHTUNG Reihenfolge muss exakt dem .xsd entsprechen! choiceType1s.Add(ItemsChoiceType1.CSOLastName); secItems.Add(sec.CSOLastName); choiceType1s.Add(ItemsChoiceType1.CSOFirstName); @@ -295,10 +295,16 @@ namespace bsmd.dbh secItems.Add(sec.CSOPhone); choiceType1s.Add(ItemsChoiceType1.CSOFax); secItems.Add(sec.CSOFax); + choiceType1s.Add(ItemsChoiceType1.CSOEMail); + secItems.Add(sec.CSOEMail); choiceType1s.Add(ItemsChoiceType1.ValidISSCOnBoard); secItems.Add(sec.ValidISSCOnBoard ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); + choiceType1s.Add(ItemsChoiceType1.ReasonsForNoValidISSC); + secItems.Add(sec.ReasonsForNoValidISSC); choiceType1s.Add(ItemsChoiceType1.ISSCType); secItems.Add((ISSCType)(sec.ISSCType ?? 0)); + choiceType1s.Add(ItemsChoiceType1.ISSCIssuerType); + secItems.Add((ISSCIssuerType)(sec.ISSCIssuerType ?? 0)); choiceType1s.Add(ItemsChoiceType1.ISSCIssuerName); secItems.Add(sec.ISSCIssuerName); if (sec.ISSCDateOfExpiration.HasValue) @@ -316,13 +322,6 @@ namespace bsmd.dbh choiceType1s.Add(ItemsChoiceType1.GeneralDescriptionOfCargo); secItems.Add((CargoDescription)sec.GeneralDescriptionOfCargo.Value); } - choiceType1s.Add(ItemsChoiceType1.ReasonsForNoValidISSC); - secItems.Add(sec.ReasonsForNoValidISSC); - choiceType1s.Add(ItemsChoiceType1.ISSCIssuerType); - secItems.Add((ISSCIssuerType) (sec.ISSCIssuerType ?? 0)); - choiceType1s.Add(ItemsChoiceType1.CSOEMail); - secItems.Add(sec.CSOEMail); - for (int i=0; i < sec.LastTenPortFacilitesCalled.Count; i++) { @@ -909,11 +908,13 @@ namespace bsmd.dbh } else { + // ACHTUNG hier ist die Reihenfolge entscheidend! (siehe XSD) + List wasteItems = new List(); List choiceType3s = new List(); - choiceType3s.Add(ItemsChoiceType3.ConfirmationOfCorrectnessAndSufficiency); - wasteItems.Add(was.ConfirmationOfCorrectness ?? false ? "Y" : "N"); + choiceType3s.Add(ItemsChoiceType3.LastWasteDisposalPort); + wasteItems.Add(was.LastWasteDisposalPort); if (was.LastWasteDisposalDate.HasValue) { @@ -921,15 +922,6 @@ namespace bsmd.dbh wasteItems.Add(was.LastWasteDisposalDate.Value); } - choiceType3s.Add(ItemsChoiceType3.LastWasteDisposalPort); - wasteItems.Add(was.LastWasteDisposalPort); - - if (was.WasteDisposalDelivery.HasValue) - { - choiceType3s.Add(ItemsChoiceType3.WasteDisposalDelivery); - wasteItems.Add((DisposalType)was.WasteDisposalDelivery.Value); - } - for (int i = 0; i < was.WasteDisposalServiceProvider.Count; i++) { choiceType3s.Add(ItemsChoiceType3.WasteDisposalServiceProviderName); @@ -937,6 +929,12 @@ namespace bsmd.dbh } + if (was.WasteDisposalDelivery.HasValue) + { + choiceType3s.Add(ItemsChoiceType3.WasteDisposalDelivery); + wasteItems.Add((DisposalType)was.WasteDisposalDelivery.Value); + } + /* {"Wert von 'ItemsElementName' stimmt nicht mit dem Typ von 'bsmd.dbh.DBHWebReference.RootWASWaste' überein. * Sie müssen ihn auf 'bsmd.dbh.DBHWebReference.ItemsChoiceType3.@Waste' festlegen."} @@ -950,6 +948,7 @@ namespace bsmd.dbh if ((waste.WasteType ?? 0) == 0) continue; // not a valid waste type rww.WasteType = new RootWASWasteWasteType(); rww.WasteType.WasteCode = waste.WasteType ?? 0; + if (rww.WasteType.WasteCode == 2313) rww.WasteType.WasteCode = 2600; // Christin, 22.3.17 rww.WasteType.WasteDescription = waste.WasteDescription; rww.WasteDisposedAtLastPort_MTQ = decimal.Round((decimal) (waste.WasteDisposedAtLastPort_MTQ ?? 0), 3); @@ -962,7 +961,10 @@ namespace bsmd.dbh rww.WasteDetails.WasteDisposalPort = waste.WasteDisposalPort; if (rww.WasteDetails.WasteDisposalPort.IsNullOrEmpty()) rww.WasteDetails.WasteDisposalPort = "ZZUKN"; wasteItems.Add(rww); - } + } + + choiceType3s.Add(ItemsChoiceType3.ConfirmationOfCorrectnessAndSufficiency); + wasteItems.Add(was.ConfirmationOfCorrectness ?? false ? "Y" : "N"); rootWAS.ItemsElementName = choiceType3s.ToArray(); rootWAS.Items = wasteItems.ToArray();