// // Class: Util // Current CLR: 4.0.30319.34209 // System: Microsoft Visual Studio 10.0 // Author: dani // Created: 3/1/2015 8:05:05 PM // // Copyright (c) 2015-present Informatikbüro Daniel Schick. All rights reserved. using System; using System.Collections.Generic; using log4net; using bsmd.database; using bsmd.dbh.DBHWebReference; namespace bsmd.dbh { /// /// This class implements the "oldschool" approach of sending classes via the SOAP interface. /// It has been superseded by a file-based approach that transmits classes via SFTP. /// [Obsolete] public class RequestWeb { private static readonly ILog _log = LogManager.GetLogger(typeof(RequestWeb)); public static bool SendCancelCore(MessageCore core) { if ((core == null) || !(core.Cancelled ?? false)) return false; if (!core.DefaultReportingPartyId.HasValue || !DBManager.Instance.GetReportingPartyDict().ContainsKey(core.DefaultReportingPartyId.Value)) { _log.ErrorFormat("Default reporting party not set / found on core {0}, aborting CANCEL", core.Id); return false; } const RootType rootType = RootType.CANCEL; Dbh_Osis_Answ_Ws client = new Dbh_Osis_Answ_Ws(); //if (useTest) // client.Url = "https://edi-gate.dbh.de/test/bsmd-soap"; bsmd.database.ReportingParty reportingParty = DBManager.Instance.GetReportingPartyDict()[core.DefaultReportingPartyId.Value]; DBHWebReference.ReportingParty rp = new DBHWebReference.ReportingParty(); rp.RPCity = reportingParty.City; rp.RPCountry = reportingParty.Country; rp.RPEMail = reportingParty.EMail; rp.RPFax = reportingParty.Fax; rp.RPFirstName = reportingParty.FirstName; rp.RPLastName = reportingParty.LastName; rp.RPName = reportingParty.Name; rp.RPPhone = reportingParty.Phone; rp.RPPostalCode = reportingParty.PostalCode; rp.RPStreetAndNumber = reportingParty.StreetAndNumber; rp.RPTypeSpecified = reportingParty.ReportingPartyType.HasValue; if (rp.RPTypeSpecified) rp.RPType = (ReportingPartyRPType)reportingParty.ReportingPartyType.Value; try { object[] items = new object[1]; DateTime timestamp = DateTime.Now; const string version = "3.0"; object item = null; string senderReference = core.Id.Value.ToString("N"); items[0] = item; ItemChoiceType2 itemChoiceType2; if (core.IsTransit) { item = core.TransitId; itemChoiceType2 = DBHWebReference.ItemChoiceType2.TransitId; } else { item = core.VisitId; itemChoiceType2 = DBHWebReference.ItemChoiceType2.VisitId; } _log.InfoFormat("Send Url: {0}", client.Url); const RootVersion rootVersion = RootVersion.Item60; string result = client.Root( rootVersion, version, timestamp, Properties.Settings.Default.Sender, // BSMD sender Kennung (festverdrahtet) senderReference, (bsmd.dbh.DBHWebReference.RootType) rootType, item, itemChoiceType2, null, // sisnumbers (weglassen) rp, items, null // violations (weglassen) ); } catch (Exception ex) { _log.ErrorFormat("Exception on dbh message send: {0}", ex.Message); if (ex.InnerException != null) _log.ErrorFormat("Inner exception: {0}", ex.InnerException.Message); return false; } finally { client.Dispose(); } return true; } public static bool SendMessage(Message message) { if (message == null) return false; RootType rootType = message.Reset ? RootType.RESET : RootType.DATA; if (message.ReportingParty == null) { _log.ErrorFormat("Reporting party not set on message {0}", message.Id); return false; } if ((message.MessageNotificationClass != Message.NotificationClass.VISIT) && (message.MessageNotificationClass != Message.NotificationClass.TRANSIT) && (message.Elements.Count == 0)) { _log.ErrorFormat("trying to send message {0} class {1} but there are no depending record elements", message.Id, message.MessageNotificationClass); return false; } // message.StatusInfo = ""; // zurücksetzen analog zu HIS-Nord (5.10.17) // message.ChangedBy = ""; // map message to dbh NSWRequest object Dbh_Osis_Answ_Ws client = new Dbh_Osis_Answ_Ws(); //if (useTest) // client.Url = "https://edi-gate.dbh.de/test/bsmd-soap"; DBHWebReference.ReportingParty rp = new DBHWebReference.ReportingParty(); rp.RPCity = message.ReportingParty.City; rp.RPCountry = message.ReportingParty.Country; rp.RPEMail = message.ReportingParty.EMail; rp.RPFax = message.ReportingParty.Fax; rp.RPFirstName = message.ReportingParty.FirstName; rp.RPLastName = message.ReportingParty.LastName; rp.RPName = message.ReportingParty.Name; rp.RPPhone = message.ReportingParty.Phone; rp.RPPostalCode = message.ReportingParty.PostalCode; rp.RPStreetAndNumber = message.ReportingParty.StreetAndNumber; rp.RPTypeSpecified = message.ReportingParty.ReportingPartyType.HasValue; if (rp.RPTypeSpecified) rp.RPType = (ReportingPartyRPType) message.ReportingParty.ReportingPartyType.Value; DateTime timestamp = DateTime.Now; const string version = "3.0"; object item = null; string senderReference = message.Id.Value.ToString("N"); ItemChoiceType2 itemChoiceType2 = ItemChoiceType2.Visit; switch (message.MessageNotificationClass) { #region VISIT case Message.NotificationClass.VISIT: { DBHWebReference.RootVisit rootVisit = new DBHWebReference.RootVisit(); rootType = RootType.VISIT; if (!message.MessageCore.IMO.IsNullOrEmpty()) { rootVisit.ItemElementName = DBHWebReference.ItemChoiceType.IMONumber; rootVisit.Item = message.MessageCore.IMO; } else { rootVisit.ItemElementName = DBHWebReference.ItemChoiceType.ENINumber; rootVisit.Item = message.MessageCore.ENI; } rootVisit.PortOfCall = message.MessageCore.PoC; if (message.MessageCore.ETA.HasValue) rootVisit.ETAPortOfCall = message.MessageCore.ETA.Value.ToDBHDateString(); else rootVisit.ETAPortOfCall = null; item = rootVisit; break; } #endregion #region TRANSIT case Message.NotificationClass.TRANSIT: { DBHWebReference.RootTransit rootTransit = new DBHWebReference.RootTransit(); rootType = RootType.TRANSIT; itemChoiceType2 = DBHWebReference.ItemChoiceType2.Transit; if (!message.MessageCore.IMO.IsNullOrEmpty()) { rootTransit.ItemElementName = DBHWebReference.ItemChoiceType1.IMONumber; rootTransit.Item = message.MessageCore.IMO; } else { rootTransit.ItemElementName = DBHWebReference.ItemChoiceType1.ENINumber; rootTransit.Item = message.MessageCore.ENI; } if (message.MessageCore.ETAKielCanal.HasValue) rootTransit.ETAKielCanal = message.MessageCore.ETAKielCanal.Value.ToDBHDateString(); else rootTransit.ETAKielCanal = null; item = rootTransit; break; } #endregion #region NOA_NOD case Message.NotificationClass.NOA_NOD: { if (message.Elements[0] is NOA_NOD noa_nod) { RootNOA_NOD rootNoaNod = new RootNOA_NOD(); if (noa_nod.ETAToNextPort.HasValue) rootNoaNod.ETAToNextPort = noa_nod.ETAToNextPort.Value.ToDBHDateString(); // rootNoaNod.ETAToNextPortSpecified = noa_nod.ETAToNextPort.HasValue; if ((noa_nod.ETDFromLastPort.HasValue) && (!noa_nod.LastPort.Equals("ZZUKN", StringComparison.OrdinalIgnoreCase))) rootNoaNod.ETDFromLastPort = noa_nod.ETDFromLastPort.Value.ToDBHDateString(); // rootNoaNod.ETDFromLastPortSpecified = noa_nod.ETDFromLastPort.HasValue; rootNoaNod.LastPort = noa_nod.LastPort; rootNoaNod.NextPort = noa_nod.NextPort; List choiceList = new List(); List choices = new List(); if (message.MessageCore.IsTransit) { if (noa_nod.ETAToKielCanal.HasValue) { choiceList.Add(ItemsChoiceType.ETAToKielCanal); choices.Add(noa_nod.ETAToKielCanal.Value.ToDBHDateString()); } if (noa_nod.ETDFromKielCanal.HasValue) { choiceList.Add(ItemsChoiceType.ETDFromKielCanal); choices.Add(noa_nod.ETDFromKielCanal.Value.ToDBHDateString()); } } else { if (noa_nod.ETAToPortOfCall.HasValue) { choiceList.Add(ItemsChoiceType.ETAToPortOfCall); choices.Add(noa_nod.ETAToPortOfCall.Value.ToDBHDateString()); } if (noa_nod.ETDFromPortOfCall.HasValue) { choiceList.Add(ItemsChoiceType.ETDFromPortOfCall); choices.Add(noa_nod.ETDFromPortOfCall.Value.ToDBHDateString()); } for (int i = 0; i < noa_nod.CallPurposes.Count; i++) { choiceList.Add(ItemsChoiceType.CallPurpose); RootNOA_NODCallPurpose rnncp = new RootNOA_NODCallPurpose(); CallPurpose callPurpose = noa_nod.CallPurposes[i] as CallPurpose; rnncp.CallPurposeCode = callPurpose.CallPurposeCode; if (callPurpose.CallPurposeDescription != string.Empty) rnncp.CallPurposeDescription = callPurpose.CallPurposeDescription; choices.Add(rnncp); } } rootNoaNod.Items = choices.ToArray(); rootNoaNod.ItemsElementName = choiceList.ToArray(); item = rootNoaNod; } break; } #endregion #region AGNT case Message.NotificationClass.AGNT: { if (message.Elements[0] is AGNT agnt) { RootAGNT rootAGNT = new RootAGNT(); rootAGNT.AgentCity = agnt.AgentCity; rootAGNT.AgentCompanyName = agnt.AgentCompanyName; rootAGNT.AgentCountry = agnt.AgentCountry; rootAGNT.AgentEMail = agnt.AgentEMail; rootAGNT.AgentFax = agnt.AgentFax; rootAGNT.AgentFirstName = agnt.AgentFirstName; rootAGNT.AgentLastName = agnt.AgentLastName; rootAGNT.AgentPhone = agnt.AgentPhone; rootAGNT.AgentPostalCode = agnt.AgentPostalCode; rootAGNT.AgentStreetAndNumber = agnt.AgentStreetAndNumber; item = rootAGNT; } break; } #endregion #region ATA case Message.NotificationClass.ATA: { if (message.Elements[0] is ATA ata) { RootATA rootATA = new RootATA(); if (ata.ATAPortOfCall.HasValue) rootATA.ATAPortOfCall = ata.ATAPortOfCall.Value.ToDBHDateString(); item = rootATA; } break; } #endregion #region ATD case Message.NotificationClass.ATD: { if (message.Elements[0] is ATD atd) { RootATD rootATD = new RootATD(); rootATD.ATDPortOfCall = atd.ATDPortOfCall.Value.ToDBHDateString(); item = rootATD; } break; } #endregion #region SEC case Message.NotificationClass.SEC: { RootSEC rootSEC = new RootSEC(); SEC sec = message.Elements[0] as SEC; List secItems = new List(); List choiceType1s = new List(); if(!message.MessageCore.IsTransit) { if(sec.KielCanalPassagePlanned ?? false) { rootSEC.KielCanalPassage = new RootSECKielCanalPassage(); rootSEC.KielCanalPassage.KielCanalPassagePlanned = "Y"; if (sec.KielCanalPassagePlannedIncomming.HasValue) rootSEC.KielCanalPassage.KielCanalPassagePlannedIncoming = sec.KielCanalPassagePlannedIncomming.Value.ToDBHDateString(); if (sec.KielCanalPassagePlannedOutgoing.HasValue) rootSEC.KielCanalPassage.KielCanalPassagePlannedOutgoing = sec.KielCanalPassagePlannedOutgoing.Value.ToDBHDateString(); } } rootSEC.CurrentShipSecurityLevel = (int)sec.CurrentShipSecurityLevel.Value; if (sec.SECSimplification ?? false) { choiceType1s.Add(ItemsChoiceType1.SECSimplification); secItems.Add("Y"); choiceType1s.Add(ItemsChoiceType1.PortOfCallWhereCompleteSECNotified); secItems.Add(sec.PortOfCallWhereCompleteSECNotified); } else { // ACHTUNG Reihenfolge muss exakt dem .xsd entsprechen! choiceType1s.Add(ItemsChoiceType1.CSOLastName); secItems.Add(sec.CSOLastName); choiceType1s.Add(ItemsChoiceType1.CSOFirstName); secItems.Add(sec.CSOFirstName); choiceType1s.Add(ItemsChoiceType1.CSOPhone); 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); if (!(sec.ValidISSCOnBoard ?? false) && !sec.ReasonsForNoValidISSC.IsNullOrEmpty()) { 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) { choiceType1s.Add(ItemsChoiceType1.ISSCDateOfExpiration); secItems.Add(sec.ISSCDateOfExpiration.Value); } choiceType1s.Add(ItemsChoiceType1.ApprovedSecurityPlanOnBoard); secItems.Add(sec.ApprovedSecurityPlanOnBoard ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); choiceType1s.Add(ItemsChoiceType1.PortFacilityOfArrival); secItems.Add(sec.PortFacilityOfArrival); if (sec.GeneralDescriptionOfCargo.HasValue) { choiceType1s.Add(ItemsChoiceType1.GeneralDescriptionOfCargo); secItems.Add((CargoDescription)sec.GeneralDescriptionOfCargo.Value); } for (int i=0; i < sec.LastTenPortFacilitesCalled.Count; i++) { choiceType1s.Add(ItemsChoiceType1.LastTenPortFacilitiesCalled); RootSECLastTenPortFacilitiesCalled lastTen = new RootSECLastTenPortFacilitiesCalled(); secItems.Add(lastTen); LastTenPortFacilitiesCalled lastTenPortFacilitiesCalled = sec.LastTenPortFacilitesCalled[i] as LastTenPortFacilitiesCalled; lastTen.PortFacilityPortName = lastTenPortFacilitiesCalled.PortFacilityPortName; lastTen.PortFacilityPortCountry = lastTenPortFacilitiesCalled.PortFacilityPortCountry; lastTen.PortFacilityPortLoCode = lastTenPortFacilitiesCalled.PortFacilityPortLoCode; if (lastTenPortFacilitiesCalled.PortFacilityDateOfArrival.HasValue) lastTen.PortFacilityDateOfArrival = lastTenPortFacilitiesCalled.PortFacilityDateOfArrival.Value; if (lastTenPortFacilitiesCalled.PortFacilityDateOfDeparture.HasValue) lastTen.PortFacilityDateOfDeparture = lastTenPortFacilitiesCalled.PortFacilityDateOfDeparture.Value; if (lastTenPortFacilitiesCalled.PortFacilityShipSecurityLevel.HasValue) lastTen.PortFacilityShipSecurityLevel = lastTenPortFacilitiesCalled.PortFacilityShipSecurityLevel.Value; lastTen.PortFacilitySecurityMattersToReport = lastTenPortFacilitiesCalled.PortFacilitySecurityMattersToReport; lastTen.PortFacilityGISISCode = lastTenPortFacilitiesCalled.PortFacilityGISISCode; if (!lastTenPortFacilitiesCalled.PortFacilityGISISCodeLocode.IsNullOrEmpty()) lastTen.PortFacilityGISISCodeLoCode = lastTenPortFacilitiesCalled.PortFacilityGISISCodeLocode; } for (int i = 0; i < sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count; i++) { choiceType1s.Add(ItemsChoiceType1.ShipToShipActivities); RootSECShipToShipActivities s2s = new RootSECShipToShipActivities(); secItems.Add(s2s); ShipToShipActivitiesDuringLastTenPortFacilitiesCalled shipToShip = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i] as ShipToShipActivitiesDuringLastTenPortFacilitiesCalled; s2s.ShipToShipActivityLocation = new RootSECShipToShipActivitiesShipToShipActivityLocation(); s2s.ShipToShipActivityLocation.ShipToShipActivityLocationName = shipToShip.ShipToShipActivityLocationName; s2s.ShipToShipActivityLocation.ShipToShipActivityLocationLoCode = shipToShip.ShipToShipActivityLocationLoCode; s2s.ShipToShipActivityLocation.ShipToShipActivityLocationCoordinates = new RootSECShipToShipActivitiesShipToShipActivityLocationShipToShipActivityLocationCoordinates(); if (shipToShip.ShipToShipActivityLocationCoordinatesLatitude.HasValue) s2s.ShipToShipActivityLocation.ShipToShipActivityLocationCoordinates.ShipToShipActivityLocationCoordinatesLatitude = shipToShip.ShipToShipActivityLocationCoordinatesLatitude.Value; if (shipToShip.ShipToShipActivityLocationCoordinatesLongitude.HasValue) s2s.ShipToShipActivityLocation.ShipToShipActivityLocationCoordinates.ShipToShipActivityLocationCoordinatesLongitude = shipToShip.ShipToShipActivityLocationCoordinatesLongitude.Value; if (shipToShip.ShipToShipActivityDateFrom.HasValue) s2s.ShipToShipActivityDateFrom = shipToShip.ShipToShipActivityDateFrom.Value; if (shipToShip.ShipToShipActivityDateTo.HasValue) s2s.ShipToShipActivityDateTo = shipToShip.ShipToShipActivityDateTo.Value; //int activityType; //if (!Int32.TryParse(shipToShip.ShipToShipActivityType, out activityType)) //activityType = NOA_NOD.getCallPurposeCodeFromDescription(shipToShip.ShipToShipActivityType) ?? 0; //s2s.ShipToShipActivityType = activityType; if (shipToShip.ShipToShipActivityTypeCode.HasValue) s2s.ShipToShipActivityType = shipToShip.ShipToShipActivityTypeCode.Value; s2s.ShipToShipActivitySecurityMattersToReport = shipToShip.ShipToShipActivitySecurityMattersToReport; } } rootSEC.Items = secItems.ToArray(); rootSEC.ItemsElementName = choiceType1s.ToArray(); item = rootSEC; } break; #endregion #region BPOL case Message.NotificationClass.BPOL: { if (message.Elements[0] is BPOL bpol) { RootBPOL rootBPOL = new RootBPOL(); RootBPOLPortOfItinerary[] poiArray = new RootBPOLPortOfItinerary[bpol.PortOfItineraries.Count]; rootBPOL.PortOfItinerary = poiArray; for (int i = 0; i < bpol.PortOfItineraries.Count; i++) { RootBPOLPortOfItinerary port = new RootBPOLPortOfItinerary(); PortOfItinerary portOfItinerary = bpol.PortOfItineraries[i] as PortOfItinerary; if (portOfItinerary.PortOfItineraryETA.HasValue) port.PortOfItineraryETA = portOfItinerary.PortOfItineraryETA.Value.ToDBHDateString(); port.PortOfItineraryName = portOfItinerary.PortOfItineraryName; poiArray[i] = port; } if (bpol.StowawaysOnBoard.HasValue) rootBPOL.StowawayOnBoard = bpol.StowawaysOnBoard.Value ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; else rootBPOL.StowawayOnBoard = RootSECValidISSCOnBoard.N; item = rootBPOL; } break; } #endregion #region CREW case Message.NotificationClass.CREW: { RootCREW rootCREW = new RootCREW(); rootCREW.CrewMember = new RootCREWCrewMember[message.Elements.Count]; for (int i = 0; i < message.Elements.Count; i++) { CREW crew = message.Elements[i] as CREW; rootCREW.CrewMember[i] = new RootCREWCrewMember(); if (crew.CrewMemberDateOfBirth.HasValue) rootCREW.CrewMember[i].CrewMemberDateOfBirth = crew.CrewMemberDateOfBirth.Value; rootCREW.CrewMember[i].CrewMemberDuty = crew.CrewMemberDuty; rootCREW.CrewMember[i].CrewMemberFirstName = crew.CrewMemberFirstName; rootCREW.CrewMember[i].CrewMemberGenderSpecified = crew.CrewMemberGender.HasValue; if (crew.CrewMemberGender.HasValue) rootCREW.CrewMember[i].CrewMemberGender = (Gender)crew.CrewMemberGender.Value; rootCREW.CrewMember[i].CrewMemberIdentityDocumentId = crew.CrewMemberIdentityDocumentId; if (crew.CrewMemberIdentityDocumentType.HasValue) rootCREW.CrewMember[i].CrewMemberIdentityDocumentType = (IdDocType)crew.CrewMemberIdentityDocumentType.Value; rootCREW.CrewMember[i].CrewMemberLastName = crew.CrewMemberLastName; rootCREW.CrewMember[i].CrewMemberNationality = crew.CrewMemberNationality; rootCREW.CrewMember[i].CrewMemberPlaceOfBirth = crew.CrewMemberPlaceOfBirth; rootCREW.CrewMember[i].CrewMemberVisaNumber = crew.CrewMemberVisaNumber; if(crew.CrewMemberIdentityDocumentIssuingState.Trim().Length == 2) rootCREW.CrewMember[i].CrewMemberIdentityDocumentIssuingState = crew.CrewMemberIdentityDocumentIssuingState; rootCREW.CrewMember[i].CrewMemberIdentityDocumentExpiryDateSpecified = crew.CrewMemberIdentityDocumentExpiryDate.HasValue; if (crew.CrewMemberIdentityDocumentExpiryDate.HasValue) rootCREW.CrewMember[i].CrewMemberIdentityDocumentExpiryDate = crew.CrewMemberIdentityDocumentExpiryDate.Value; } item = rootCREW; } break; #endregion #region PAS case Message.NotificationClass.PAS: { RootPAS rootPAS = new RootPAS(); rootPAS.Passenger = new RootPASPassenger[message.Elements.Count]; for(int i=0;i cargoList = new List(); for (int i = 0; i < message.Elements.Count; i++ ) { LADG ladg = message.Elements[i] as LADG; RootLADGCargo cargo = new RootLADGCargo(); if (ladg.CargoHandlingType.HasValue) { if (ladg.CargoHandlingType > 1) continue; cargo.CargoHandlingType = (ladg.CargoHandlingType == 0) ? HandlingType.LOAD : HandlingType.DISCHARGE; } cargo.CargoCodeNST = ladg.CargoCodeNST; if (!ladg.CargoCodeNST.IsNullOrEmpty()) { if (cargo.CargoCodeNST.Length > 2) { cargo.CargoCodeNST = ladg.CargoCodeNST.Substring(0, 2); } } if (!ladg.CargoCodeNST_3.IsNullOrEmpty()) cargo.CargoCodeNST_3 = ladg.CargoCodeNST_3.Substring(0, 1); if (ladg.CargoLACode.HasValue) cargo.CargoLACode = ladg.CargoLACode.Value; cargo.CargoLACodeSpecified = ladg.CargoLACode.HasValue; if (ladg.CargoGrossQuantity_TNE.HasValue) cargo.CargoGrossQuantity_TNE = Decimal.Round((decimal) ladg.CargoGrossQuantity_TNE.Value, 3); cargo.CargoNumberOfItemsSpecified = ladg.CargoNumberOfItems.HasValue; if (ladg.CargoNumberOfItems.HasValue) cargo.CargoNumberOfItems = ladg.CargoNumberOfItems.Value; if (ladg.PortOfLoading.IsNullOrEmpty()) cargo.CargoPortOfLoading = "ZZUKN"; else cargo.CargoPortOfLoading = ladg.PortOfLoading; if (ladg.PortOfDischarge.IsNullOrEmpty()) cargo.CargoPortOfDischarge = "ZZUKN"; else cargo.CargoPortOfDischarge = ladg.PortOfDischarge; cargoList.Add(cargo); } rootLADG.Cargo = cargoList.ToArray(); item = rootLADG; } break; #endregion #region INFO case Message.NotificationClass.INFO: { RootINFO rootInfo = new RootINFO(); INFO info = message.Elements[0] as INFO; if (info.ShippingArea.HasValue) rootInfo.ShippingArea = (ShippingArea)info.ShippingArea.Value; rootInfo.PortArea = info.PortArea; rootInfo.RequestedPositionInPortOfCall = info.RequestedPositionInPortOfCall; if(!info.SpecialRequirementsOfShipAtBerth.IsNullOrEmpty()) rootInfo.SpecialRequirementsOfShipAtBerth = info.SpecialRequirementsOfShipAtBerth; if(info.SpecialRequirementsOfShipAtBerth.IsNullOrEmpty()) { _log.Info("dbh INFO send: SpecialRequirementsOfShipAtBerth is empty."); // Name des Agenten eintragen } rootInfo.ConstructionCharacteristicsOfShip = info.ConstructionCharacteristicsOfShip; rootInfo.BowThrusterPower = info.BowThrusterPower; rootInfo.SternThrusterPower = info.SternThrusterPower; if (info.FumigatedBulkCargo.HasValue) rootInfo.FumigatedBulkCargo = (info.FumigatedBulkCargo.Value == 0) ? RootINFOFumigatedBulkCargo.N : RootINFOFumigatedBulkCargo.Y; else rootInfo.FumigatedBulkCargo = RootINFOFumigatedBulkCargo.N; rootInfo.DeadWeightSummer_TNESpecified = info.DeplacementSummerDraught_TNE.HasValue; if (info.DeplacementSummerDraught_TNE.HasValue) rootInfo.DeadWeightSummer_TNE = Decimal.Round((decimal) info.DeplacementSummerDraught_TNE.Value, 3); item = rootInfo; } break; #endregion #region SERV case Message.NotificationClass.SERV: { RootSERV rootServ = new RootSERV(); rootServ.Service = new RootSERVService[message.Elements.Count]; for (int i = 0; i < message.Elements.Count;i++ ) { rootServ.Service[i] = new RootSERVService(); SERV serv = message.Elements[i] as SERV; rootServ.Service[i].ServiceName = serv.ServiceName; rootServ.Service[i].ServiceBeneficiary = serv.ServiceBeneficiary; rootServ.Service[i].ServiceInvoiceRecipient = serv.ServiceInvoiceRecipient; } item = rootServ; } break; #endregion #region PRE72H case Message.NotificationClass.PRE72H: { RootPRE72H rootPre = new RootPRE72H(); PRE72H pre72h = message.Elements[0] as PRE72H; rootPre.Tanker = pre72h.Tanker ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; if (pre72h.Tanker ?? false) { rootPre.TankerDetails = new RootPRE72HTankerDetails(); if (pre72h.TankerHullConfiguration.HasValue) rootPre.TankerDetails.TankerHullConfiguration = (HullConfiguration)pre72h.TankerHullConfiguration.Value; if (pre72h.ConditionCargoBallastTanks.HasValue) rootPre.TankerDetails.ConditionCargoBallastTanks = (TankCondition)pre72h.ConditionCargoBallastTanks.Value; if(pre72h.NatureOfCargo != string.Empty) rootPre.TankerDetails.TypeOfCargo = pre72h.NatureOfCargo; bool sendVolume = pre72h.VolumeOfCargo.HasValue && (pre72h.VolumeOfCargo.Value > 0); rootPre.TankerDetails.VolumeOfCargo_TNESpecified = sendVolume; if (sendVolume) rootPre.TankerDetails.VolumeOfCargo_TNE = Decimal.Round((decimal)(pre72h.VolumeOfCargo.Value), 3); } rootPre.PlannedOperations = pre72h.PlannedOperations; rootPre.PlannedWorks = pre72h.PlannedWorks; rootPre.DateOfLastExpandedInspectionSpecified = pre72h.DateOfLastExpandedInspection.HasValue; if (pre72h.DateOfLastExpandedInspection.HasValue) rootPre.DateOfLastExpandedInspection = pre72h.DateOfLastExpandedInspection.Value; if (pre72h.PlannedPeriodOfStay_HUR.HasValue) rootPre.PlannedPeriodOfStay_HUR = Decimal.Round((decimal) (pre72h.PlannedPeriodOfStay_HUR.Value), 2); item = rootPre; } break; #endregion #region MDH case Message.NotificationClass.MDH: { RootMDH rootMDH = new RootMDH(); MDH mdh = message.Elements[0] as MDH; if (!mdh.MDHSimplification.HasValue) { _log.ErrorFormat("MDH {0} doesnt have MDHSimplification field set, aborting message", mdh.Id); client.Dispose(); return false; } if (mdh.MDHSimplification.Value) { // der angenehme Teil rootMDH.Items = new object[2]; rootMDH.ItemsElementName = new ItemsChoiceType2[2]; rootMDH.ItemsElementName[0] = ItemsChoiceType2.MDHSimplification; rootMDH.Items[0] = "Y"; rootMDH.ItemsElementName[1] = ItemsChoiceType2.PortOfCallWhereCompleteMDHNotified; rootMDH.Items[1] = mdh.PortOfCallWhereCompleteMDHNotified; } else { // der blöde Teil List mdhItems = new List(); List choiceTypes2 = new List { ItemsChoiceType2.NonAccidentialDeathsDuringVoyage }; mdhItems.Add((mdh.NonAccidentalDeathsDuringVoyage ?? false) ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); if (mdh.NonAccidentalDeathsDuringVoyage ?? false) { choiceTypes2.Add(ItemsChoiceType2.NonAccidentialDeathsDuringVoyageCount); mdhItems.Add(mdh.NonAccidentalDeathsDuringVoyageCount ?? 0); } choiceTypes2.Add(ItemsChoiceType2.SuspisionInfectiousNature); mdhItems.Add(mdh.SuspisionInfectiousNature ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); choiceTypes2.Add(ItemsChoiceType2.NumberOfIllPersonsHigherThanExpected); mdhItems.Add(mdh.NumberOfIllPersonsHigherThanExpected ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); if (mdh.NumberOfIllPersonsHigherThanExpected ?? false) { choiceTypes2.Add(ItemsChoiceType2.NumberOfIllPersons); mdhItems.Add(mdh.NumberOfIllPersons ?? 0); } choiceTypes2.Add(ItemsChoiceType2.SickPersonsOnBoard); mdhItems.Add(mdh.SickPersonsOnBoard ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); choiceTypes2.Add(ItemsChoiceType2.MedicalConsulted); mdhItems.Add(mdh.MedicalConsulted ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); choiceTypes2.Add(ItemsChoiceType2.AwareOfConditionsForFurtherInfections); mdhItems.Add(mdh.AwareOfFurtherInfections ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); choiceTypes2.Add(ItemsChoiceType2.SanitaryMeasuresApplied); mdhItems.Add(mdh.SanitaryMeasuresApplied ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); if (mdh.SanitaryMeasuresApplied ?? false) { foreach (SanitaryMeasuresDetail smd in mdh.SanitaryMeasuresDetails) { choiceTypes2.Add(ItemsChoiceType2.SanitaryMeasuresDetails); RootMDHSanitaryMeasuresDetails smDet = new RootMDHSanitaryMeasuresDetails(); if (mdh.SanitaryMeasuresDate.HasValue) smDet.SanitaryMeasuresDate = smd.SanitaryMeasuresDate.Value; smDet.SanitaryMeasuresType = smd.SanitaryMeasuresType; smDet.SanitaryMeasuresLocation = smd.SanitaryMeasuresLocation; mdhItems.Add(smDet); } } choiceTypes2.Add(ItemsChoiceType2.StowawaysDetected); mdhItems.Add(mdh.StowawaysDetected ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); choiceTypes2.Add(ItemsChoiceType2.StowawaysJoiningLocation); string concatLocations = ""; foreach (StowawaysJoiningLocation sjl in mdh.StowawaysJoiningLocations) { if(!sjl.StowawayJoiningLocation.IsNullOrEmpty()) concatLocations = string.Format("{0} {1}", concatLocations, sjl.StowawayJoiningLocation); } mdhItems.Add(concatLocations); choiceTypes2.Add(ItemsChoiceType2.SickAnimalOrPetOnBoard); mdhItems.Add(mdh.SickAnimalOrPetOnBoard ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); choiceTypes2.Add(ItemsChoiceType2.ValidSanitaryControlExemptionOrCertificateOnBoard); mdhItems.Add(mdh.ValidSanitaryControlExemptionOrCertificateOnBoard ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); if (mdh.ValidSanitaryControlExemptionOrCertificateOnBoard ?? false) { choiceTypes2.Add(ItemsChoiceType2.ValidSanitaryControlExemptionOrCertificate); RootMDHValidSanitaryControlExemptionOrCertificate cert = new RootMDHValidSanitaryControlExemptionOrCertificate(); mdhItems.Add(cert); cert.DateOfIssue = mdh.DateOfIssue.Value; cert.PlaceOfIssue = mdh.PlaceOfIssue; } choiceTypes2.Add(ItemsChoiceType2.SanitaryControlReinspectionRequired); mdhItems.Add(mdh.SanitaryControlReinspectionRequired ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); choiceTypes2.Add(ItemsChoiceType2.InfectedAreaVisited); mdhItems.Add(mdh.InfectedAreaVisited ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N); foreach (InfectedArea ia in mdh.InfectedAreas) { if (!mdh.InfectedAreaPort.IsNullOrEmpty() && mdh.InfectedAreaDate.HasValue) { choiceTypes2.Add(ItemsChoiceType2.InfectedArea); RootMDHInfectedArea infected = new RootMDHInfectedArea(); mdhItems.Add(infected); infected.InfectedAreaPort = ia.InfectedAreaPort; infected.InfectedAreaDate = ia.InfectedAreaDate.Value; } } if (mdh.PortOfCallLast30Days.Count > 0) { choiceTypes2.Add(ItemsChoiceType2.PortsOfCallLast30Days); RootMDHPortsOfCallLast30Days l30d = new RootMDHPortsOfCallLast30Days(); mdhItems.Add(l30d); l30d.PortOfCallLast30Days = new RootMDHPortsOfCallLast30DaysPortOfCallLast30Days[mdh.PortOfCallLast30Days.Count]; for (int i = 0; i < mdh.PortOfCallLast30Days.Count; i++) { l30d.PortOfCallLast30Days[i] = new RootMDHPortsOfCallLast30DaysPortOfCallLast30Days(); PortOfCallLast30Days portOfCallLast30Days = mdh.PortOfCallLast30Days[i] as PortOfCallLast30Days; l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip = new RootMDHPortsOfCallLast30DaysPortOfCallLast30DaysPortOfCallLast30DaysCrewJoinedShip(); if (portOfCallLast30Days.CrewJoinedShip.Count > 0) { l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip.PortOfCallLast30DaysCrewJoinedShipName = new string[portOfCallLast30Days.CrewJoinedShip.Count]; for (int j = 0; j < portOfCallLast30Days.CrewJoinedShip.Count; j++) { l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip.PortOfCallLast30DaysCrewJoinedShipName[j] = ((PortOfCallLast30DaysCrewJoinedShip) portOfCallLast30Days.CrewJoinedShip[j]).PortOfCallLast30DaysCrewJoinedShipName; } } l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined = portOfCallLast30Days.PortOfCallLast30DaysCrewMembersJoined ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; if (portOfCallLast30Days.PortOfCallLast30DaysDateOfDeparture.HasValue) l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture = portOfCallLast30Days.PortOfCallLast30DaysDateOfDeparture.Value; l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysLocode = portOfCallLast30Days.PortOfCallLast30DaysLocode; } } rootMDH.Items = mdhItems.ToArray(); rootMDH.ItemsElementName = choiceTypes2.ToArray(); } item = rootMDH; } break; #endregion #region WAS case Message.NotificationClass.WAS: { RootWAS rootWAS = new RootWAS(); WAS was = message.Elements[0] as WAS; if (was.WasteDisposalValidExemption ?? false) { rootWAS.Items = new object[1]; rootWAS.ItemsElementName = new ItemsChoiceType3[1]; rootWAS.ItemsElementName[0] = ItemsChoiceType3.WasteDisposalValidExemption; rootWAS.Items[0] = "Y"; } else { // ACHTUNG hier ist die Reihenfolge entscheidend! (siehe XSD) List wasteItems = new List(); List choiceType3s = new List { ItemsChoiceType3.LastWasteDisposalPort }; wasteItems.Add(was.LastWasteDisposalPort); if (was.LastWasteDisposalDate.HasValue) { choiceType3s.Add(ItemsChoiceType3.LastWasteDisposalDate); wasteItems.Add(was.LastWasteDisposalDate.Value); } for (int i = 0; i < was.WasteDisposalServiceProvider.Count; i++) { if (((WasteDisposalServiceProvider) was.WasteDisposalServiceProvider[i]).WasteDisposalServiceProviderName.Trim().IsNullOrEmpty()) continue; choiceType3s.Add(ItemsChoiceType3.WasteDisposalServiceProviderName); wasteItems.Add(((WasteDisposalServiceProvider) was.WasteDisposalServiceProvider[i]).WasteDisposalServiceProviderName); } 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."} */ for (int j = 0; j < was.Waste.Count; j++) { choiceType3s.Add(ItemsChoiceType3.Waste); RootWASWaste rww = new RootWASWaste(); Waste waste = was.Waste[j] as Waste; 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); rww.WasteDisposalAmount_MTQ = decimal.Round((decimal)(waste.WasteDisposalAmount_MTQ ?? 0), 3); rww.WasteDetails = new RootWASWasteWasteDetails(); rww.WasteDetails.WasteCapacity_MTQ = decimal.Round((decimal)(waste.WasteCapacity_MTQ ?? 0), 3); rww.WasteDetails.WasteAmountRetained_MTQ = decimal.Round((decimal)(waste.WasteAmountRetained_MTQ ?? 0), 3); rww.WasteDetails.WasteAmountGeneratedTillNextPort_MTQ = decimal.Round((decimal)(waste.WasteAmountGeneratedTillNextPort_MTQ ?? 0), 3); 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(); } item = rootWAS; } break; #endregion #region TOWA case Message.NotificationClass.TOWA: { RootTOWA rootTowa = new RootTOWA(); rootTowa.TowageOnArrival = new RootTOWATowageOnArrival[message.Elements.Count]; for (int i = 0; i < message.Elements.Count; i++) { TOWA towa = message.Elements[i] as TOWA; rootTowa.TowageOnArrival[i] = new RootTOWATowageOnArrival(); rootTowa.TowageOnArrival[i].TowageOnArrivalName = towa.TowageOnArrivalName; rootTowa.TowageOnArrival[i].TowageOnArrivalFlag = towa.TowageOnArrivalFlag; rootTowa.TowageOnArrival[i].TowageOnArrivalOperator = new RootTOWATowageOnArrivalTowageOnArrivalOperator(); rootTowa.TowageOnArrival[i].TowageOnArrivalOperator.TowageOnArrivalOperatorCompanyName = towa.TowageOnArrivalOperatorCompanyName; rootTowa.TowageOnArrival[i].TowageOnArrivalOperator.TowageOnArrivalOperatorStreetAndNumber = towa.TowageOnArrivalOperatorStreetNameAndNumber; rootTowa.TowageOnArrival[i].TowageOnArrivalOperator.TowageOnArrivalOperatorPostalCode = towa.TowageOnArrivalOperatorPostalCode; rootTowa.TowageOnArrival[i].TowageOnArrivalOperator.TowageOnArrivalOperatorCity = towa.TowageOnArrivalOperatorCity; rootTowa.TowageOnArrival[i].TowageOnArrivalOperator.TowageOnArrivalOperatorCountry = towa.TowageOnArrivalOperatorCountry; rootTowa.TowageOnArrival[i].TowageOnArrivalOperator.TowageOnArrivalOperatorPhone = towa.TowageOnArrivalOperatorPhone; rootTowa.TowageOnArrival[i].TowageOnArrivalOperator.TowageOnArrivalOperatorFax = towa.TowageOnArrivalOperatorFax; rootTowa.TowageOnArrival[i].TowageOnArrivalOperator.TowageOnArrivalOperatorEMail = towa.TowageOnArrivalOperatorEmail; if (towa.TowageOnArrivalGrossTonnage.HasValue) rootTowa.TowageOnArrival[i].TowageOnArrivalGrossTonnage = towa.TowageOnArrivalGrossTonnage.Value; if (towa.TowageOnArrivalLengthOverall_MTR.HasValue) rootTowa.TowageOnArrival[i].TowageOnArrivalLengthOverall_MTR = decimal.Round((decimal) towa.TowageOnArrivalLengthOverall_MTR.Value, 2); if (towa.TowageOnArrivalBeam_MTR.HasValue) rootTowa.TowageOnArrival[i].TowageOnArrivalBeam_MTR = decimal.Round((decimal) towa.TowageOnArrivalBeam_MTR.Value, 2); rootTowa.TowageOnArrival[i].TowageOnArrivalPurposeOfCall = towa.TowageOnArrivalPurposeOfCall; if (towa.TowageOnArrivalDraught_DMT.HasValue) rootTowa.TowageOnArrival[i].TowageOnArrivalDraught_DMT = decimal.Round((decimal) towa.TowageOnArrivalDraught_DMT.Value, 1); rootTowa.TowageOnArrival[i].TowageOnArrivalRemarks = towa.TowageOnArrivalRemarks; } item = rootTowa; } break; #endregion #region TOWD case Message.NotificationClass.TOWD: { RootTOWD rootTowd = new RootTOWD(); rootTowd.TowageOnDeparture = new RootTOWDTowageOnDeparture[message.Elements.Count]; for (int i = 0; i < message.Elements.Count; i++) { TOWD towd = message.Elements[i] as TOWD; rootTowd.TowageOnDeparture[i] = new RootTOWDTowageOnDeparture(); rootTowd.TowageOnDeparture[i].TowageOnDepartureName = towd.TowageOnDepartureName; rootTowd.TowageOnDeparture[i].TowageOnDepartureFlag = towd.TowageOnDepartureFlag; rootTowd.TowageOnDeparture[i].TowageOnDepartureOperator = new RootTOWDTowageOnDepartureTowageOnDepartureOperator(); rootTowd.TowageOnDeparture[i].TowageOnDepartureOperator.TowageOnDepartureOperatorCompanyName = towd.TowageOnDepartureOperatorCompanyName; rootTowd.TowageOnDeparture[i].TowageOnDepartureOperator.TowageOnDepartureOperatorStreetAndNumber = towd.TowageOnDepartureOperatorStreetNameAndNumber; rootTowd.TowageOnDeparture[i].TowageOnDepartureOperator.TowageOnDepartureOperatorPostalCode = towd.TowageOnDepartureOperatorPostalCode; rootTowd.TowageOnDeparture[i].TowageOnDepartureOperator.TowageOnDepartureOperatorCity = towd.TowageOnDepartureOperatorCity; rootTowd.TowageOnDeparture[i].TowageOnDepartureOperator.TowageOnDepartureOperatorCountry = towd.TowageOnDepartureOperatorCountry; rootTowd.TowageOnDeparture[i].TowageOnDepartureOperator.TowageOnDepartureOperatorPhone = towd.TowageOnDepartureOperatorPhone; rootTowd.TowageOnDeparture[i].TowageOnDepartureOperator.TowageOnDepartureOperatorFax = towd.TowageOnDepartureOperatorFax; rootTowd.TowageOnDeparture[i].TowageOnDepartureOperator.TowageOnDepartureOperatorEMail = towd.TowageOnDepartureOperatorEmail; if (towd.TowageOnDepartureLengthOverall_MTR.HasValue) rootTowd.TowageOnDeparture[i].TowageOnDepartureLengthOverall_MTR = decimal.Round((decimal) towd.TowageOnDepartureLengthOverall_MTR.Value, 2); if (towd.TowageOnDepartureBeam_MTR.HasValue) rootTowd.TowageOnDeparture[i].TowageOnDepartureBeam_MTR = decimal.Round((decimal) towd.TowageOnDepartureBeam_MTR.Value, 2); if (towd.TowageOnDepartureDraught_DMT.HasValue) rootTowd.TowageOnDeparture[i].TowageOnDepartureDraught_DMT = decimal.Round((decimal) towd.TowageOnDepartureDraught_DMT.Value, 1); rootTowd.TowageOnDeparture[i].TowageOnDepartureRemarks = towd.TowageOnDepartureRemarks; } item = rootTowd; } break; #endregion #region HAZA //Felderreihenfolge wegen einfacher Test/Impl. entspricht genau dem XLS Sheet case Message.NotificationClass.HAZA: { RootHAZA rootHAZA = new RootHAZA(); HAZ haz = message.Elements[0] as HAZ; if (haz.NoDPGOnBoardOnArrival ?? false) { rootHAZA.Items = new object[1]; rootHAZA.Items[0] = "Y"; rootHAZA.ItemsElementName = new ItemsChoiceType5[1]; rootHAZA.ItemsElementName[0] = ItemsChoiceType5.NoDPGOnBoardOnArrival; } else { rootHAZA.Items = new object[4]; rootHAZA.ItemsElementName = new ItemsChoiceType5[4]; // if(haz.DPGManifestOnBoardOnArrival.HasValue) rootHAZA.ItemsElementName[0] = ItemsChoiceType5.DPGManifestOnBoardOnArrival; rootHAZA.Items[0] = (haz.DPGManifestOnBoardOnArrival ?? false) ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; rootHAZA.ItemsElementName[1] = ItemsChoiceType5.INFShipClass; if (haz.INFShipClass.HasValue) { INFClassType infShipClass = (INFClassType)haz.INFShipClass.Value; rootHAZA.Items[1] = infShipClass; } rootHAZA.ItemsElementName[2] = ItemsChoiceType5.MOUBaltic; rootHAZA.Items[2] = (haz.MOUBaltic ?? false) ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; #region HAZ positions rootHAZA.ItemsElementName[3] = ItemsChoiceType5.DPGOnArrival; DBHWebReference.RootHAZADPGOnArrival dpgOnArrival = new DBHWebReference.RootHAZADPGOnArrival(); #region IMDG if (haz.IMDGPositions.Count > 0) { dpgOnArrival.DPGItemIMDG = new bsmd.dbh.DBHWebReference.IMDGPosition[haz.IMDGPositions.Count]; for (int i = 0; i < haz.IMDGPositions.Count; i++) { bsmd.database.IMDGPosition imdgPos = haz.IMDGPositions[i] as bsmd.database.IMDGPosition; bsmd.dbh.DBHWebReference.IMDGPosition rootIMDG = new bsmd.dbh.DBHWebReference.IMDGPosition(); rootIMDG.UNNumber = imdgPos.UNNumber; if (imdgPos.PackingGroup.HasValue) rootIMDG.PackingGroup = (DBHWebReference.PackingGroupType) imdgPos.PackingGroup.Value; rootIMDG.ProperShippingName = imdgPos.ProperShippingName; rootIMDG.IMOClass = imdgPos.IMOClass; // rootIMDG.CompatibilityGroup = imdgPos.CompatibilityGroup; rootIMDG.TechnicalName = imdgPos.TechnicalName; rootIMDG.NetExplosiveMass_KGMSpecified = imdgPos.NetExplosiveMass_KGM.HasValue; if (imdgPos.NetExplosiveMass_KGM.HasValue) rootIMDG.NetExplosiveMass_KGM = decimal.Round((decimal)imdgPos.NetExplosiveMass_KGM.Value, 3); rootIMDG.Flashpoint_CEL = imdgPos.Flashpoint_CEL; rootIMDG.Class7NuclideName = imdgPos.Class7NuclideName; rootIMDG.Class7MaxActivity_BQLSpecified = imdgPos.Class7MaxActivity_BQL.HasValue; if (imdgPos.Class7MaxActivity_BQL.HasValue) rootIMDG.Class7MaxActivity_BQL = decimal.Round((decimal)imdgPos.Class7MaxActivity_BQL.Value, 6); rootIMDG.Class7CategorySpecified = imdgPos.Class7Category.HasValue; if (imdgPos.Class7Category.HasValue) rootIMDG.Class7Category = imdgPos.Class7Category.Value; rootIMDG.Class7TransportIndexSpecified = imdgPos.Class7TransportIndex.HasValue; if (imdgPos.Class7TransportIndex.HasValue) rootIMDG.Class7TransportIndex = decimal.Round((decimal)imdgPos.Class7TransportIndex.Value, 1); rootIMDG.Class7CSISpecified = imdgPos.Class7CSI.HasValue; if (imdgPos.Class7CSI.HasValue) rootIMDG.Class7CSI = imdgPos.Class7CSI.Value; rootIMDG.ControlTemperature_CELSpecified = imdgPos.ControlTemperature_CEL.HasValue; if (imdgPos.ControlTemperature_CEL.HasValue) rootIMDG.ControlTemperature_CEL = decimal.Round((decimal)imdgPos.ControlTemperature_CEL.Value, 2); rootIMDG.EmergencyTemperature_CELSpecified = imdgPos.EmergencyTemperature_CEL.HasValue; if (imdgPos.EmergencyTemperature_CEL.HasValue) rootIMDG.EmergencyTemperature_CEL = decimal.Round((decimal)imdgPos.EmergencyTemperature_CEL.Value, 2); if (imdgPos.SubsidiaryRiskList.Count > 0) { rootIMDG.SubsidiaryRisks = new string[imdgPos.SubsidiaryRiskList.Count]; for (int sCount = 0; sCount < imdgPos.SubsidiaryRiskList.Count; sCount++) rootIMDG.SubsidiaryRisks[sCount] = imdgPos.SubsidiaryRiskList[sCount].SubsidiaryRisk; } if (imdgPos.MarinePollutant.HasValue) rootIMDG.MarinePollutant = imdgPos.MarinePollutant.Value ? DBHWebReference.RootSECValidISSCOnBoard.Y : DBHWebReference.RootSECValidISSCOnBoard.N; if (imdgPos.NumberOfPackages.HasValue) rootIMDG.NumberOfPackages = imdgPos.NumberOfPackages.Value; rootIMDG.PackageType = imdgPos.PackageType; if (imdgPos.LimitedQuantities.HasValue) rootIMDG.LimitedQuantities = imdgPos.LimitedQuantities.Value ? DBHWebReference.RootSECValidISSCOnBoard.Y : DBHWebReference.RootSECValidISSCOnBoard.N; if (imdgPos.ExceptedQuantities.HasValue) rootIMDG.ExceptedQuantities = imdgPos.ExceptedQuantities.Value ? DBHWebReference.RootSECValidISSCOnBoard.Y : DBHWebReference.RootSECValidISSCOnBoard.N; rootIMDG.NetQuantity_KGMSpecified = imdgPos.NetQuantity_KGM.HasValue; if (imdgPos.NetQuantity_KGM.HasValue) rootIMDG.NetQuantity_KGM = decimal.Round((decimal)imdgPos.NetQuantity_KGM.Value, 3); rootIMDG.GrossQuantity_KGMSpecified = imdgPos.GrossQuantity_KGM.HasValue; if (imdgPos.GrossQuantity_KGM.HasValue) rootIMDG.GrossQuantity_KGM = decimal.Round((decimal)imdgPos.GrossQuantity_KGM.Value, 3); rootIMDG.Volume_MTQSpecified = imdgPos.Volume_MTQ.HasValue; if (imdgPos.Volume_MTQ.HasValue) rootIMDG.Volume_MTQ = decimal.Round((decimal)imdgPos.Volume_MTQ.Value, 3); rootIMDG.GeneralCargoIBCSpecified = imdgPos.GeneralCargoIBC.HasValue; if (imdgPos.GeneralCargoIBC.HasValue) rootIMDG.GeneralCargoIBC = imdgPos.GeneralCargoIBC.Value ? DBHWebReference.RootSECValidISSCOnBoard.Y : DBHWebReference.RootSECValidISSCOnBoard.N; if(!imdgPos.ContainerNumber.IsNullOrEmpty()) rootIMDG.ContainerNumber = imdgPos.ContainerNumber; if(!imdgPos.VehicleLicenseNumber.IsNullOrEmpty()) rootIMDG.VehicleLicenseNumber = imdgPos.VehicleLicenseNumber; if (imdgPos.StowagePosition.IsNullOrEmpty()) { rootIMDG.Items = new string[3]; rootIMDG.ItemsElementName = new ItemsChoiceType4[3]; rootIMDG.Items[0] = imdgPos.Bay; rootIMDG.ItemsElementName[0] = ItemsChoiceType4.Bay; rootIMDG.Items[1] = imdgPos.Row; rootIMDG.ItemsElementName[1] = ItemsChoiceType4.Row; rootIMDG.Items[2] = imdgPos.Tier; rootIMDG.ItemsElementName[2] = ItemsChoiceType4.Tier; } else { rootIMDG.Items = new string[1] { imdgPos.StowagePosition }; rootIMDG.ItemsElementName = new ItemsChoiceType4[1] { ItemsChoiceType4.StowagePosition }; } rootIMDG.PortOfLoading = imdgPos.PortOfLoading; rootIMDG.PortOfDischarge = imdgPos.PortOfDischarge; if(!imdgPos.Remarks.IsNullOrEmpty()) rootIMDG.Remarks = imdgPos.Remarks; dpgOnArrival.DPGItemIMDG[i] = rootIMDG; } } #endregion #region IBC if (haz.IBCPositions.Count > 0) { dpgOnArrival.DPGItemIBC = new bsmd.dbh.DBHWebReference.IBCPosition[haz.IBCPositions.Count]; for (int i = 0; i < haz.IBCPositions.Count; i++) { bsmd.dbh.DBHWebReference.IBCPosition rootIBC = new bsmd.dbh.DBHWebReference.IBCPosition(); bsmd.database.IBCPosition ibcPos = haz.IBCPositions[i] as bsmd.database.IBCPosition; rootIBC.ProductName = ibcPos.ProductName; if (ibcPos.PollutionCategory.HasValue) rootIBC.PollutionCategory = (DBHWebReference.PollutionCategoryType)ibcPos.PollutionCategory.Value; rootIBC.HazardsSpecified = ibcPos.Hazards.HasValue; if (ibcPos.Hazards.HasValue) rootIBC.Hazards = (DBHWebReference.HazardType) ibcPos.Hazards.Value; if (ibcPos.FlashpointInformation.HasValue) rootIBC.FlashpointInformation = (DBHWebReference.FlashpointInfoType) ibcPos.FlashpointInformation.Value; rootIBC.Flashpoint_CEL = ibcPos.Flashpoint_CEL; if (ibcPos.Quantity_KGM.HasValue) rootIBC.Quantity_KGM = decimal.Round((decimal)ibcPos.Quantity_KGM.Value, 3); rootIBC.StowagePosition = ibcPos.StowagePosition; rootIBC.PortOfLoading = ibcPos.PortOfLoading; rootIBC.PortOfDischarge = ibcPos.PortOfDischarge; rootIBC.SpecRef15_19Specified = ibcPos.SpecRef15_19.HasValue; if (ibcPos.SpecRef15_19.HasValue) rootIBC.SpecRef15_19 = ibcPos.SpecRef15_19.Value ? DBHWebReference.RootSECValidISSCOnBoard.Y : DBHWebReference.RootSECValidISSCOnBoard.N; if(!ibcPos.Remarks.IsNullOrEmpty() ) rootIBC.Remarks = ibcPos.Remarks; dpgOnArrival.DPGItemIBC[i] = rootIBC; } } #endregion #region IGC if (haz.IGCPositions.Count > 0) { dpgOnArrival.DPGItemIGC = new bsmd.dbh.DBHWebReference.IGCPosition[haz.IGCPositions.Count]; for (int i = 0; i < haz.IGCPositions.Count; i++) { bsmd.dbh.DBHWebReference.IGCPosition rootIGC = new bsmd.dbh.DBHWebReference.IGCPosition(); bsmd.database.IGCPosition igcPos = haz.IGCPositions[i] as bsmd.database.IGCPosition; rootIGC.UNNumber = igcPos.UNNumber; rootIGC.IMOClass = igcPos.IMOClass; rootIGC.ProductName = igcPos.ProductName; if (igcPos.Quantity_KGM.HasValue) rootIGC.Quantity_KGM = decimal.Round((decimal)igcPos.Quantity_KGM.Value, 3); rootIGC.StowagePosition = igcPos.StowagePosition; rootIGC.PortOfLoading = igcPos.PortOfLoading; rootIGC.PortOfDischarge = igcPos.PortOfDischarge; if(!igcPos.Remarks.IsNullOrEmpty()) rootIGC.Remarks = igcPos.Remarks; dpgOnArrival.DPGItemIGC[i] = rootIGC; } } #endregion #region IMSBC if (haz.IMSBCPositions.Count > 0) { dpgOnArrival.DPGItemIMSBC = new bsmd.dbh.DBHWebReference.IMSBCPosition[haz.IMSBCPositions.Count]; for (int i = 0; i < haz.IMSBCPositions.Count; i++) { bsmd.dbh.DBHWebReference.IMSBCPosition rootIMSBC = new bsmd.dbh.DBHWebReference.IMSBCPosition(); bsmd.database.IMSBCPosition imsbcPos = haz.IMSBCPositions[i] as bsmd.database.IMSBCPosition; rootIMSBC.BulkCargoShippingName = imsbcPos.BulkCargoShippingName; if (imsbcPos.MHB.HasValue) rootIMSBC.MHB = imsbcPos.MHB.Value ? DBHWebReference.RootSECValidISSCOnBoard.Y : DBHWebReference.RootSECValidISSCOnBoard.N; rootIMSBC.UNNumber = imsbcPos.UNNumber; rootIMSBC.IMOClass = imsbcPos.IMOClass; if (imsbcPos.Quantity_KGM.HasValue) rootIMSBC.Quantity_KGM = decimal.Round((decimal)imsbcPos.Quantity_KGM.Value, 3); rootIMSBC.StowagePosition = imsbcPos.StowagePosition; rootIMSBC.PortOfLoading = imsbcPos.PortOfLoading; rootIMSBC.PortOfDischarge = imsbcPos.PortOfDischarge; if(!imsbcPos.Remarks.IsNullOrEmpty()) rootIMSBC.Remarks = imsbcPos.Remarks; rootIMSBC.IMOHazardClassSpecified = imsbcPos.IMOHazardClass.HasValue; if (imsbcPos.IMOHazardClass.HasValue) rootIMSBC.IMOHazardClass = (IMOHazardClassType)imsbcPos.IMOHazardClass.Value ; dpgOnArrival.DPGItemIMSBC[i] = rootIMSBC; } } #endregion #region MARPOL_ANNEX_I if (haz.MARPOLPositions.Count > 0) { dpgOnArrival.DPGItemMARPOLAnnexI = new DBHWebReference.MARPOLPosition[haz.MARPOLPositions.Count]; for (int i = 0; i < haz.MARPOLPositions.Count; i++) { DBHWebReference.MARPOLPosition rootMarpol = new DBHWebReference.MARPOLPosition(); MARPOL_Annex_I_Position marpolPos = haz.MARPOLPositions[i] as MARPOL_Annex_I_Position; rootMarpol.Name = marpolPos.Name; if (marpolPos.FlashpointInformation.HasValue) rootMarpol.FlashpointInformation = (DBHWebReference.FlashpointInfoType) marpolPos.FlashpointInformation.Value; rootMarpol.Flashpoint_CEL = marpolPos.Flashpoint_CEL; if (marpolPos.Quantity_KGM.HasValue) rootMarpol.Quantity_KGM = decimal.Round((decimal)marpolPos.Quantity_KGM.Value, 3); rootMarpol.StowagePosition = marpolPos.StowagePosition; rootMarpol.PortOfLoading = marpolPos.PortOfLoading; rootMarpol.PortOfDischarge = marpolPos.PortOfDischarge; if(!marpolPos.Remarks.IsNullOrEmpty()) rootMarpol.Remarks = marpolPos.Remarks; dpgOnArrival.DPGItemMARPOLAnnexI[i] = rootMarpol; } } #endregion rootHAZA.Items[3] = dpgOnArrival; #endregion } item = rootHAZA; } break; #endregion #region HAZD //Felderreihenfolge wegen einfacher Test/Impl. entspricht genau dem XLS Sheet case Message.NotificationClass.HAZD: { RootHAZD rootHAZD = new RootHAZD(); HAZ haz = message.Elements[0] as HAZ; if (haz.NoDPGOnBoardOnArrival ?? false) { rootHAZD.ItemsElementName = new ItemsChoiceType6[1]; rootHAZD.ItemsElementName[0] = ItemsChoiceType6.NoDPGOnBoardOnDeparture; rootHAZD.Items = new object[1]; rootHAZD.Items[0] = "Y"; } else { rootHAZD.Items = new object[4]; rootHAZD.ItemsElementName = new ItemsChoiceType6[4]; rootHAZD.ItemsElementName[0] = ItemsChoiceType6.DPGManifestOnBoardOnDeparture; if (haz.DPGManifestOnBoardOnArrival.HasValue) rootHAZD.Items[0] = haz.DPGManifestOnBoardOnArrival.Value ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; rootHAZD.ItemsElementName[1] = ItemsChoiceType6.INFShipClass; if (haz.INFShipClass.HasValue) { INFClassType infShipClass = (INFClassType)haz.INFShipClass.Value; rootHAZD.Items[1] = infShipClass; } rootHAZD.ItemsElementName[2] = ItemsChoiceType6.MOUBaltic; rootHAZD.Items[2] = (haz.MOUBaltic ?? false) ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; #region HAZ positions RootHAZDDPGOnDeparture dpgOnDeparture = new RootHAZDDPGOnDeparture(); #region IMDG if (haz.IMDGPositions.Count > 0) { dpgOnDeparture.DPGItemIMDG = new bsmd.dbh.DBHWebReference.IMDGPosition[haz.IMDGPositions.Count]; for (int i = 0; i < haz.IMDGPositions.Count; i++) { bsmd.database.IMDGPosition imdgPos = haz.IMDGPositions[i] as bsmd.database.IMDGPosition; bsmd.dbh.DBHWebReference.IMDGPosition rootIMDG = new bsmd.dbh.DBHWebReference.IMDGPosition(); rootIMDG.UNNumber = imdgPos.UNNumber; if (imdgPos.PackingGroup.HasValue) rootIMDG.PackingGroup = (PackingGroupType)imdgPos.PackingGroup.Value; rootIMDG.ProperShippingName = imdgPos.ProperShippingName; rootIMDG.IMOClass = imdgPos.IMOClass; // rootIMDG.CompatibilityGroup = imdgPos.CompatibilityGroup; rootIMDG.TechnicalName = imdgPos.TechnicalName; rootIMDG.NetExplosiveMass_KGMSpecified = imdgPos.NetExplosiveMass_KGM.HasValue; if (imdgPos.NetExplosiveMass_KGM.HasValue) rootIMDG.NetExplosiveMass_KGM = decimal.Round((decimal)imdgPos.NetExplosiveMass_KGM.Value, 3); rootIMDG.Flashpoint_CEL = imdgPos.Flashpoint_CEL; rootIMDG.Class7NuclideName = imdgPos.Class7NuclideName; rootIMDG.Class7MaxActivity_BQLSpecified = imdgPos.Class7MaxActivity_BQL.HasValue; if (imdgPos.Class7MaxActivity_BQL.HasValue) rootIMDG.Class7MaxActivity_BQL = decimal.Round((decimal)imdgPos.Class7MaxActivity_BQL.Value, 6); rootIMDG.Class7CategorySpecified = imdgPos.Class7Category.HasValue; if (imdgPos.Class7Category.HasValue) rootIMDG.Class7Category = imdgPos.Class7Category.Value; rootIMDG.Class7TransportIndexSpecified = imdgPos.Class7TransportIndex.HasValue; if (imdgPos.Class7TransportIndex.HasValue) rootIMDG.Class7TransportIndex = decimal.Round((decimal)imdgPos.Class7TransportIndex.Value, 1); rootIMDG.Class7CSISpecified = imdgPos.Class7CSI.HasValue; if (imdgPos.Class7CSI.HasValue) rootIMDG.Class7CSI = imdgPos.Class7CSI.Value; rootIMDG.ControlTemperature_CELSpecified = imdgPos.ControlTemperature_CEL.HasValue; if (imdgPos.ControlTemperature_CEL.HasValue) rootIMDG.ControlTemperature_CEL = decimal.Round((decimal)imdgPos.ControlTemperature_CEL.Value, 2); rootIMDG.EmergencyTemperature_CELSpecified = imdgPos.EmergencyTemperature_CEL.HasValue; if (imdgPos.EmergencyTemperature_CEL.HasValue) rootIMDG.EmergencyTemperature_CEL = decimal.Round((decimal)imdgPos.EmergencyTemperature_CEL.Value, 2); if (imdgPos.SubsidiaryRiskList.Count > 0) { rootIMDG.SubsidiaryRisks = new string[imdgPos.SubsidiaryRiskList.Count]; for (int sCount = 0; sCount < imdgPos.SubsidiaryRiskList.Count; sCount++) rootIMDG.SubsidiaryRisks[sCount] = imdgPos.SubsidiaryRiskList[sCount].SubsidiaryRisk; } if (imdgPos.MarinePollutant.HasValue) rootIMDG.MarinePollutant = imdgPos.MarinePollutant.Value ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; if (imdgPos.NumberOfPackages.HasValue) rootIMDG.NumberOfPackages = imdgPos.NumberOfPackages.Value; rootIMDG.PackageType = imdgPos.PackageType; if (imdgPos.LimitedQuantities.HasValue) rootIMDG.LimitedQuantities = imdgPos.LimitedQuantities.Value ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; if (imdgPos.ExceptedQuantities.HasValue) rootIMDG.ExceptedQuantities = imdgPos.ExceptedQuantities.Value ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; rootIMDG.NetQuantity_KGMSpecified = imdgPos.NetQuantity_KGM.HasValue; if (imdgPos.NetQuantity_KGM.HasValue) rootIMDG.NetQuantity_KGM = decimal.Round((decimal)imdgPos.NetQuantity_KGM.Value, 3); rootIMDG.GrossQuantity_KGMSpecified = imdgPos.GrossQuantity_KGM.HasValue; if (imdgPos.GrossQuantity_KGM.HasValue) rootIMDG.GrossQuantity_KGM = decimal.Round((decimal)imdgPos.GrossQuantity_KGM.Value, 3); rootIMDG.Volume_MTQSpecified = imdgPos.Volume_MTQ.HasValue; if (imdgPos.Volume_MTQ.HasValue) rootIMDG.Volume_MTQ = decimal.Round((decimal)imdgPos.Volume_MTQ.Value, 3); rootIMDG.GeneralCargoIBCSpecified = imdgPos.GeneralCargoIBC.HasValue; if (imdgPos.GeneralCargoIBC.HasValue) rootIMDG.GeneralCargoIBC = imdgPos.GeneralCargoIBC.Value ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; if(!imdgPos.ContainerNumber.IsNullOrEmpty()) rootIMDG.ContainerNumber = imdgPos.ContainerNumber; if(!imdgPos.VehicleLicenseNumber.IsNullOrEmpty()) rootIMDG.VehicleLicenseNumber = imdgPos.VehicleLicenseNumber; if (imdgPos.StowagePosition.IsNullOrEmpty()) { rootIMDG.Items = new string[3]; rootIMDG.ItemsElementName = new ItemsChoiceType4[3]; rootIMDG.Items[0] = imdgPos.Bay; rootIMDG.ItemsElementName[0] = ItemsChoiceType4.Bay; rootIMDG.Items[1] = imdgPos.Row; rootIMDG.ItemsElementName[1] = ItemsChoiceType4.Row; rootIMDG.Items[2] = imdgPos.Tier; rootIMDG.ItemsElementName[2] = ItemsChoiceType4.Tier; } else { rootIMDG.Items = new string[1] { imdgPos.StowagePosition }; rootIMDG.ItemsElementName = new ItemsChoiceType4[1] { ItemsChoiceType4.StowagePosition }; } rootIMDG.PortOfLoading = imdgPos.PortOfLoading; rootIMDG.PortOfDischarge = imdgPos.PortOfDischarge; if(!imdgPos.Remarks.IsNullOrEmpty()) rootIMDG.Remarks = imdgPos.Remarks; dpgOnDeparture.DPGItemIMDG[i] = rootIMDG; } } #endregion #region IBC if (haz.IBCPositions.Count > 0) { dpgOnDeparture.DPGItemIBC = new bsmd.dbh.DBHWebReference.IBCPosition[haz.IBCPositions.Count]; for (int i = 0; i < haz.IBCPositions.Count; i++) { bsmd.dbh.DBHWebReference.IBCPosition rootIBC = new bsmd.dbh.DBHWebReference.IBCPosition(); bsmd.database.IBCPosition ibcPos = haz.IBCPositions[i] as bsmd.database.IBCPosition; rootIBC.ProductName = ibcPos.ProductName; if (ibcPos.PollutionCategory.HasValue) rootIBC.PollutionCategory = (PollutionCategoryType)ibcPos.PollutionCategory.Value; rootIBC.HazardsSpecified = ibcPos.Hazards.HasValue; if (ibcPos.Hazards.HasValue) rootIBC.Hazards = (HazardType)ibcPos.Hazards.Value; if (ibcPos.FlashpointInformation.HasValue) rootIBC.FlashpointInformation = (FlashpointInfoType)ibcPos.FlashpointInformation.Value; rootIBC.Flashpoint_CEL = ibcPos.Flashpoint_CEL; if (ibcPos.Quantity_KGM.HasValue) rootIBC.Quantity_KGM = decimal.Round((decimal) ibcPos.Quantity_KGM.Value, 3); rootIBC.StowagePosition = ibcPos.StowagePosition; rootIBC.PortOfLoading = ibcPos.PortOfLoading; rootIBC.PortOfDischarge = ibcPos.PortOfDischarge; rootIBC.SpecRef15_19Specified = ibcPos.SpecRef15_19.HasValue; if (ibcPos.SpecRef15_19.HasValue) rootIBC.SpecRef15_19 = ibcPos.SpecRef15_19.Value ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; if(!ibcPos.Remarks.IsNullOrEmpty()) rootIBC.Remarks = ibcPos.Remarks; dpgOnDeparture.DPGItemIBC[i] = rootIBC; } } #endregion #region IGC if (haz.IGCPositions.Count > 0) { dpgOnDeparture.DPGItemIGC = new bsmd.dbh.DBHWebReference.IGCPosition[haz.IGCPositions.Count]; for (int i = 0; i < haz.IGCPositions.Count; i++) { bsmd.dbh.DBHWebReference.IGCPosition rootIGC = new bsmd.dbh.DBHWebReference.IGCPosition(); bsmd.database.IGCPosition igcPos = haz.IGCPositions[i] as bsmd.database.IGCPosition; rootIGC.UNNumber = igcPos.UNNumber; rootIGC.IMOClass = igcPos.IMOClass; rootIGC.ProductName = igcPos.ProductName; if (igcPos.Quantity_KGM.HasValue) rootIGC.Quantity_KGM = decimal.Round((decimal)igcPos.Quantity_KGM.Value, 3); rootIGC.StowagePosition = igcPos.StowagePosition; rootIGC.PortOfLoading = igcPos.PortOfLoading; rootIGC.PortOfDischarge = igcPos.PortOfDischarge; if(!igcPos.Remarks.IsNullOrEmpty()) rootIGC.Remarks = igcPos.Remarks; dpgOnDeparture.DPGItemIGC[i] = rootIGC; } } #endregion #region IMSBC if (haz.IMSBCPositions.Count > 0) { dpgOnDeparture.DPGItemIMSBC = new bsmd.dbh.DBHWebReference.IMSBCPosition[haz.IMSBCPositions.Count]; for (int i = 0; i < haz.IMSBCPositions.Count; i++) { bsmd.dbh.DBHWebReference.IMSBCPosition rootIMSBC = new bsmd.dbh.DBHWebReference.IMSBCPosition(); bsmd.database.IMSBCPosition imsbcPos = haz.IMSBCPositions[i] as bsmd.database.IMSBCPosition; rootIMSBC.BulkCargoShippingName = imsbcPos.BulkCargoShippingName; if (imsbcPos.MHB.HasValue) rootIMSBC.MHB = imsbcPos.MHB.Value ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N; rootIMSBC.UNNumber = imsbcPos.UNNumber; rootIMSBC.IMOClass = imsbcPos.IMOClass; if (imsbcPos.Quantity_KGM.HasValue) rootIMSBC.Quantity_KGM = decimal.Round((decimal)imsbcPos.Quantity_KGM.Value, 3); rootIMSBC.StowagePosition = imsbcPos.StowagePosition; rootIMSBC.PortOfLoading = imsbcPos.PortOfLoading; rootIMSBC.PortOfDischarge = imsbcPos.PortOfDischarge; if(!imsbcPos.Remarks.IsNullOrEmpty()) rootIMSBC.Remarks = imsbcPos.Remarks; rootIMSBC.IMOHazardClassSpecified = imsbcPos.IMOHazardClass.HasValue; if (imsbcPos.IMOHazardClass.HasValue) rootIMSBC.IMOHazardClass = (IMOHazardClassType)imsbcPos.IMOHazardClass.Value; dpgOnDeparture.DPGItemIMSBC[i] = rootIMSBC; } } #endregion #region MARPOL_ANNEX_I if (haz.MARPOLPositions.Count > 0) { dpgOnDeparture.DPGItemMARPOLAnnexI = new MARPOLPosition[haz.MARPOLPositions.Count]; for (int i = 0; i < haz.MARPOLPositions.Count; i++) { MARPOLPosition rootMarpol = new MARPOLPosition(); MARPOL_Annex_I_Position marpolPos = haz.MARPOLPositions[i] as MARPOL_Annex_I_Position; rootMarpol.Name = marpolPos.Name; if (marpolPos.FlashpointInformation.HasValue) rootMarpol.FlashpointInformation = (FlashpointInfoType) marpolPos.FlashpointInformation.Value; rootMarpol.Flashpoint_CEL = marpolPos.Flashpoint_CEL; if (marpolPos.Quantity_KGM.HasValue) rootMarpol.Quantity_KGM = decimal.Round((decimal)marpolPos.Quantity_KGM.Value, 3); rootMarpol.StowagePosition = marpolPos.StowagePosition; rootMarpol.PortOfLoading = marpolPos.PortOfLoading; rootMarpol.PortOfDischarge = marpolPos.PortOfDischarge; if(!rootMarpol.Remarks.IsNullOrEmpty()) rootMarpol.Remarks = marpolPos.Remarks; dpgOnDeparture.DPGItemMARPOLAnnexI[i] = rootMarpol; } } #endregion rootHAZD.ItemsElementName[3] = ItemsChoiceType6.DPGOnDeparture; rootHAZD.Items[3] = dpgOnDeparture; #endregion } item = rootHAZD; } break; #endregion #region catch all default: { _log.ErrorFormat("DBH send message: message type {0} not implemented", message.MessageNotificationClass); client.Dispose(); return false; } #endregion } // send object bool returnval = true; try { object[] items = null; if ((rootType == RootType.CANCEL) || (rootType == RootType.DATA) || (rootType == RootType.RESET)) { items = new object[1]; items[0] = item; if (message.MessageCore.IsTransit) { item = message.MessageCore.TransitId; itemChoiceType2 = DBHWebReference.ItemChoiceType2.TransitId; } else { item = message.MessageCore.VisitId; itemChoiceType2 = DBHWebReference.ItemChoiceType2.VisitId; } } _log.InfoFormat("Send Url: {0}", client.Url); const RootVersion rootVersion = RootVersion.Item60; string result = client.Root( rootVersion, version, timestamp, Properties.Settings.Default.Sender, // BSMD sender Kennung (festverdrahtet) senderReference, (bsmd.dbh.DBHWebReference.RootType) rootType, item, itemChoiceType2, null, // sisnumbers (weglassen) rp, items, null // violations (weglassen) ); } catch (Exception ex) { _log.ErrorFormat("Exception on dbh message send: {0}", ex.Message); if (ex.InnerException != null) _log.ErrorFormat("Inner exception: {0}", ex.InnerException.Message); returnval = false; } finally { client.Dispose(); } return returnval; } } }