git_bsmd/nsw/Source/bsmd.dbh/Request.cs

1403 lines
92 KiB
C#

//
// 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 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
{
public class Request
{
private static ILog _log = LogManager.GetLogger(typeof(Request));
public static bool SendMessage(Message message)
{
if (message == null) return false;
RootType rootType = 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;
}
// map message to dbh NSWRequest object
Dbh_Osis_Answ_Ws client = new Dbh_Osis_Answ_Ws();
bsmd.dbh.DBHWebReference.ReportingParty rp = new bsmd.dbh.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;
string version = "1.0";
object item = null;
string senderReference = message.Id.Value.ToString("N");
ItemChoiceType2 itemChoiceType2 = ItemChoiceType2.Visit; // ?
switch (message.MessageNotificationClass)
{
#region VISIT
case Message.NotificationClass.VISIT:
{
RootVisit rootVisit = new RootVisit();
rootType = RootType.VISIT;
if (message.MessageCore.IMO != null)
{
rootVisit.ItemElementName = ItemChoiceType.IMONumber;
rootVisit.Item = message.MessageCore.IMO;
}
else
{
rootVisit.ItemElementName = ItemChoiceType.ENINumber;
rootVisit.Item = message.MessageCore.ENI;
}
rootVisit.PortOfCall = message.MessageCore.PoC;
rootVisit.ETAPortOfCall = message.MessageCore.ETA.Value;
item = rootVisit;
break;
}
#endregion
#region TRANSIT
case Message.NotificationClass.TRANSIT:
{
RootTransit rootTransit = new RootTransit();
rootType = RootType.TRANSIT;
if (message.MessageCore.IMO != null)
{
rootTransit.ItemElementName = ItemChoiceType1.IMONumber;
rootTransit.Item = message.MessageCore.IMO;
}
else
{
rootTransit.ItemElementName = ItemChoiceType1.ENINumber;
rootTransit.Item = message.MessageCore.ENI;
}
rootTransit.ETAKielCanal = message.MessageCore.ETA.Value;
item = rootTransit;
break;
}
#endregion
#region NOA_NOD
case Message.NotificationClass.NOA_NOD:
{
NOA_NOD noa_nod = message.Elements[0] as NOA_NOD;
if (noa_nod != null)
{
RootNOA_NOD rootNoaNod = new RootNOA_NOD();
if (noa_nod.ETAToNextPort.HasValue)
rootNoaNod.ETAToNextPort = noa_nod.ETAToNextPort.Value;
rootNoaNod.ETAToNextPortSpecified = noa_nod.ETAToNextPort.HasValue;
if (noa_nod.ETDFromLastPort.HasValue)
rootNoaNod.ETDFromLastPort = noa_nod.ETDFromLastPort.Value;
rootNoaNod.ETDFromLastPortSpecified = noa_nod.ETDFromLastPort.HasValue;
rootNoaNod.LastPort = noa_nod.LastPort;
rootNoaNod.NextPort = noa_nod.NextPort;
int numItems = 2 + noa_nod.CallPurposes.Count;
ItemsChoiceType[] choiceArray = new ItemsChoiceType[numItems];
object[] choices = new object[numItems];
if (noa_nod.ETAToKielCanal.HasValue)
{
choiceArray[0] = ItemsChoiceType.ETAToKielCanal;
choices[0] = noa_nod.ETAToKielCanal.Value;
}
if (noa_nod.ETAToPortOfCall.HasValue)
{
choiceArray[0] = ItemsChoiceType.ETAToPortOfCall;
choices[0] = noa_nod.ETAToPortOfCall.Value;
}
if (noa_nod.ETDFromKielCanal.HasValue)
{
choiceArray[1] = ItemsChoiceType.ETDFromKielCanal;
choices[1] = noa_nod.ETDFromKielCanal.Value;
}
if (noa_nod.ETDFromPortOfCall.HasValue)
{
choiceArray[1] = ItemsChoiceType.ETDFromPortOfCall;
choices[1] = noa_nod.ETDFromPortOfCall.Value;
}
for (int i = 0; i < noa_nod.CallPurposes.Count; i++)
{
choiceArray[i + 2] = ItemsChoiceType.CallPurpose;
RootNOA_NODCallPurpose rnncp = new RootNOA_NODCallPurpose();
rnncp.CallPurposeCode = noa_nod.CallPurposes[i].CallPurposeCode;
rnncp.CallPurposeDescription = noa_nod.CallPurposes[i].CallPurposeDescription;
choices[i+2] = rnncp;
}
rootNoaNod.Items = choices;
rootNoaNod.ItemsElementName = choiceArray;
item = rootNoaNod;
}
break;
}
#endregion
#region ATA
case Message.NotificationClass.ATA:
{
ATA ata = message.Elements[0] as ATA;
if (ata != null)
{
RootATA rootATA = new RootATA();
if (ata.ATAPortOfCall.HasValue)
rootATA.ATAPortOfCall = ata.ATAPortOfCall.Value;
item = rootATA;
}
break;
}
#endregion
#region ATD
case Message.NotificationClass.ATD:
{
ATD atd = message.Elements[0] as ATD;
if (atd != null)
{
RootATD rootATD = new RootATD();
rootATD.ATDPortOfCall = atd.ATDPortOfCall.Value;
item = rootATD;
}
break;
}
#endregion
#region SEC
case Message.NotificationClass.SEC:
{
RootSEC rootSEC = new RootSEC();
SEC sec = message.Elements[0] as SEC;
int numFields = (sec.SECSimplification ?? false) ?
2 : (15 + sec.LastTenPortFacilitesCalled.Count + sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count);
rootSEC.Items = new object[numFields];
rootSEC.ItemsElementName = new ItemsChoiceType1[numFields];
if (sec.SECSimplification ?? false)
{
rootSEC.ItemsElementName[0] = ItemsChoiceType1.SECSimplification;
rootSEC.Items[0] = RootSECSECSimplification.Y;
rootSEC.ItemsElementName[1] = ItemsChoiceType1.PortOfCallWhereCompleteSECNotified;
rootSEC.Items[1] = sec.PortOfCallWhereCompleteSECNotified;
}
else
{
rootSEC.ItemsElementName[0] = ItemsChoiceType1.CSOLastName;
rootSEC.Items[0] = sec.CSOLastName;
rootSEC.ItemsElementName[1] = ItemsChoiceType1.CSOFirstName;
rootSEC.Items[1] = sec.CSOFirstName;
rootSEC.ItemsElementName[2] = ItemsChoiceType1.CSOPhone;
rootSEC.Items[2] = sec.CSOPhone;
rootSEC.ItemsElementName[3] = ItemsChoiceType1.CSOFax;
rootSEC.Items[3] = sec.CSOFax;
rootSEC.ItemsElementName[4] = ItemsChoiceType1.ValidISSCOnBoard;
rootSEC.Items[4] = sec.ValidISSCOnBoard ?? false ? RootSECValidISSCOnBoard.Y : RootSECValidISSCOnBoard.N;
rootSEC.ItemsElementName[5] = ItemsChoiceType1.ISSCType;
rootSEC.Items[5] = (RootSECISSCType) (sec.ISSCType ?? 0);
rootSEC.ItemsElementName[6] = ItemsChoiceType1.ISSCIssuerName;
rootSEC.Items[6] = sec.ISSCIssuerName;
rootSEC.ItemsElementName[7] = ItemsChoiceType1.ISSCDateOfExpiration;
if(sec.ISSCDateOfExpiration.HasValue)
rootSEC.Items[7] = sec.ISSCDateOfExpiration.Value;
rootSEC.ItemsElementName[8] = ItemsChoiceType1.ApprovedSecurityPlanOnBoard;
rootSEC.Items[8] = sec.ApprovedSecurityPlanOnBoard ?? false ? RootSECApprovedSecurityPlanOnBoard.Y : RootSECApprovedSecurityPlanOnBoard.N;
rootSEC.ItemsElementName[9] = ItemsChoiceType1.CurrentShipSecurityLevel;
if (sec.CurrentShipSecurityLevel.HasValue) rootSEC.Items[9] = (int)sec.CurrentShipSecurityLevel.Value;
rootSEC.ItemsElementName[10] = ItemsChoiceType1.PortFacilityOfArrival;
rootSEC.Items[10] = sec.PortFacilityOfArrival;
rootSEC.ItemsElementName[11] = ItemsChoiceType1.GeneralDescriptionOfCargo;
if (sec.GeneralDescriptionOfCargo.HasValue)
rootSEC.Items[11] = (RootSECGeneralDescriptionOfCargo)sec.GeneralDescriptionOfCargo.Value;
rootSEC.ItemsElementName[12] = ItemsChoiceType1.ReasonsForNoValidISSC;
rootSEC.Items[12] = sec.ReasonsForNoValidISSC;
rootSEC.ItemsElementName[13] = ItemsChoiceType1.ISSCIssuerType;
rootSEC.Items[13] = (RootSECISSCIssuerType) (sec.ISSCIssuerType ?? 0);
rootSEC.ItemsElementName[14] = ItemsChoiceType1.CSOEMail;
rootSEC.Items[14] = sec.CSOEMail;
int index = 15;
for (int i=0; i < sec.LastTenPortFacilitesCalled.Count; index++, i++)
{
rootSEC.ItemsElementName[index] = ItemsChoiceType1.LastTenPortFacilitiesCalled;
RootSECLastTenPortFacilitiesCalled lastTen = new RootSECLastTenPortFacilitiesCalled();
rootSEC.Items[index] = lastTen;
lastTen.PortFacilityPortName = sec.LastTenPortFacilitesCalled[i].PortFacilityPortName;
lastTen.PortFacilityPortCountry = sec.LastTenPortFacilitesCalled[i].PortFacilityPortCountry;
lastTen.PortFacilityPortLoCode = sec.LastTenPortFacilitesCalled[i].PortFacilityPortLoCode;
if (sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.HasValue)
lastTen.PortFacilityDateOfArrival = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.Value;
if (sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.HasValue)
lastTen.PortFacilityDateOfDeparture = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.Value;
if (sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.HasValue)
lastTen.PortFacilityShipSecurityLevel = sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.Value;
lastTen.PortFacilitySecurityMattersToReport = sec.LastTenPortFacilitesCalled[i].PortFacilitySecurityMattersToReport;
lastTen.PortFacilityGISISCode = sec.LastTenPortFacilitesCalled[i].PortFacilityGISISCode;
}
for (int i = 0; i < sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count; index++, i++ )
{
rootSEC.ItemsElementName[index] = ItemsChoiceType1.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled;
RootSECShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2s = new RootSECShipToShipActivitiesDuringLastTenPortFacilitiesCalled();
rootSEC.Items[index] = s2s;
s2s.ShipToShipActivityLocation = new RootSECShipToShipActivitiesDuringLastTenPortFacilitiesCalledShipToShipActivityLocation();
s2s.ShipToShipActivityLocation.ShipToShipActivityLocationName = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationName;
s2s.ShipToShipActivityLocation.ShipToShipActivityLocationLoCode = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationLoCode;
s2s.ShipToShipActivityLocation.ShipToShipActivityLocationCoordinates = new RootSECShipToShipActivitiesDuringLastTenPortFacilitiesCalledShipToShipActivityLocationShipToShipActivityLocationCoordinates();
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude.HasValue)
s2s.ShipToShipActivityLocation.ShipToShipActivityLocationCoordinates.ShipToShipActivityLocationCoordinatesLatitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude.Value;
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude.HasValue)
s2s.ShipToShipActivityLocation.ShipToShipActivityLocationCoordinates.ShipToShipActivityLocationCoordinatesLongitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude.Value;
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.HasValue)
s2s.ShipToShipActivityDateFrom = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.Value;
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.HasValue)
s2s.ShipToShipActivityDateTo = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.Value;
s2s.ShipToShipActivityType = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityType;
s2s.ShipToShipActivitySecurityMattersToReport = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivitySecurityMattersToReport;
}
}
item = rootSEC;
}
break;
#endregion
#region BPOL
case Message.NotificationClass.BPOL:
{
BPOL bpol = message.Elements[0] as BPOL;
if (bpol != null)
{
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();
if (bpol.PortOfItineraries[i].PortOfItineraryETA.HasValue)
port.PortOfItineraryETA = bpol.PortOfItineraries[i].PortOfItineraryETA.Value;
port.PortOfItineraryName = bpol.PortOfItineraries[i].PortOfItineraryName;
poiArray[i] = port;
}
if (bpol.StowawaysOnBoard.HasValue)
rootBPOL.StowawayOnBoard = bpol.StowawaysOnBoard.Value ?
RootBPOLStowawayOnBoard.Y : RootBPOLStowawayOnBoard.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 = (RootCREWCrewMemberCrewMemberGender)crew.CrewMemberGender.Value;
rootCREW.CrewMember[i].CrewMemberIdentityDocumentId = crew.CrewMemberIdentityDocumentId;
if (crew.CrewMemberIdentityDocumentType.HasValue)
rootCREW.CrewMember[i].CrewMemberIdentityDocumentType = (RootCREWCrewMemberCrewMemberIdentityDocumentType)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;
}
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<message.Elements.Count;i++)
{
PAS pas = message.Elements[i] as PAS;
rootPAS.Passenger[i] = new RootPASPassenger();
rootPAS.Passenger[i].PassengerLastName = pas.PassengerLastName;
rootPAS.Passenger[i].PassengerFirstName = pas.PassengerFirstName;
rootPAS.Passenger[i].PassengerPlaceOfBirth = pas.PassengerPlaceOfBirth;
if (pas.PassengerDateOfBirth.HasValue)
rootPAS.Passenger[i].PassengerDateOfBirth = pas.PassengerDateOfBirth.Value;
rootPAS.Passenger[i].PassengerGenderSpecified = pas.PassengerGender.HasValue;
if (pas.PassengerGender.HasValue)
rootPAS.Passenger[i].PassengerGender = (RootPASPassengerPassengerGender) pas.PassengerGender.Value;
rootPAS.Passenger[i].PassengerNationality = pas.PassengerNationality;
if (pas.PassengerIdentityDocumentType.HasValue)
rootPAS.Passenger[i].PassengerIdentityDocumentType = (RootPASPassengerPassengerIdentityDocumentType)pas.PassengerIdentityDocumentType.Value;
rootPAS.Passenger[i].PassengerIdentityDocumentId = pas.PassengerIdentityDocumentId;
rootPAS.Passenger[i].PassengerVisaNumber = pas.PassengerVisaNumber;
rootPAS.Passenger[i].PassengerPortOfEmbarkation = pas.PassengerPortOfEmbarkation;
rootPAS.Passenger[i].PassengerPortOfDisembarkation = pas.PassengerPortOfDisembarkation;
rootPAS.Passenger[i].PassengerInTransit = pas.PassengerInTransit ?? false ? RootPASPassengerPassengerInTransit.Y : RootPASPassengerPassengerInTransit.N;
}
item = rootPAS;
}
break;
#endregion
#region BKRA
case Message.NotificationClass.BKRA:
{
RootBKRA rootBKRA = new RootBKRA();
rootBKRA.BunkerFuelArrival = new RootBKRABunkerFuelArrival[message.Elements.Count];
for (int i = 0; i < message.Elements.Count; i++)
{
BRKA bkra = message.Elements[i] as BRKA;
rootBKRA.BunkerFuelArrival[i] = new RootBKRABunkerFuelArrival();
rootBKRA.BunkerFuelArrival[i].BunkerFuelQuantity_TNE = (float) (bkra.BunkerFuelQuantity_TNE ?? 0);
rootBKRA.BunkerFuelArrival[i].BunkerFuelType = bkra.BunkerFuelType;
}
item = rootBKRA;
}
break;
#endregion
#region BKRD
case Message.NotificationClass.BKRD:
{
RootBKRD rootBKRD = new RootBKRD();
rootBKRD.BunkerFuelDeparture = new RootBKRDBunkerFuelDeparture[message.Elements.Count];
for (int i = 0; i < message.Elements.Count; i++)
{
BRKD bkrd = message.Elements[i] as BRKD;
rootBKRD.BunkerFuelDeparture[i] = new RootBKRDBunkerFuelDeparture();
rootBKRD.BunkerFuelDeparture[i].BunkerFuelQuantity_TNE = (float) (bkrd.BunkerFuelQuantity_TNE ?? 0);
rootBKRD.BunkerFuelDeparture[i].BunkerFuelType = bkrd.BunkerFuelType;
}
item = rootBKRD;
}
break;
#endregion
#region TIEFA
case Message.NotificationClass.TIEFA:
{
RootTIEFA rootTIEFA = new RootTIEFA();
TIEFA tiefa = message.Elements[0] as TIEFA;
rootTIEFA.DraughtUponArrival_DMT = (float) (tiefa.DraughtUponArrival_DMT ?? 0);
item = rootTIEFA;
}
break;
#endregion
#region TIEFD
case Message.NotificationClass.TIEFD:
{
RootTIEFD rootTIEFD = new RootTIEFD();
TIEFD tiefd = message.Elements[0] as TIEFD;
rootTIEFD.DraughtUponDeparture_DMT = (float) (tiefd.DraughtUponDeparture_DMT ?? 0);
item = rootTIEFD;
}
break;
#endregion
#region NAME
case Message.NotificationClass.NAME:
{
RootNAME rootName = new RootNAME();
NAME name = message.Elements[0] as NAME;
rootName.NameOfMaster = name.NameOfMaster;
item = rootName;
}
break;
#endregion
#region POBA
case Message.NotificationClass.POBA:
{
RootPOBA rootPoba = new RootPOBA();
POBA poba = message.Elements[0] as POBA;
rootPoba.TotalCrewMembersOnBoardUponArrival = poba.TotalCrewMembersOnBoardUponArrival ?? 0;
rootPoba.TotalPassengersOnBoardUponArrival = poba.TotalPassengersOnBoardUponArrival ?? 0;
rootPoba.TotalPersonsOnBoardUponArrival = poba.TotalPersonsOnBoardUponArrival ?? 0;
rootPoba.TotalStowawaysOnBoardUponArrival = poba.TotalStowawaysOnBoardUponArrival ?? 0;
item = rootPoba;
}
break;
#endregion
#region POBD
case Message.NotificationClass.POBD:
{
RootPOBD rootPobd = new RootPOBD();
POBD pobd = message.Elements[0] as POBD;
rootPobd.TotalCrewMembersOnBoardUponDeparture = pobd.TotalCrewMembersOnBoardUponDeparture ?? 0;
rootPobd.TotalPassengersOnBoardUponDeparture = pobd.TotalPassengersOnBoardUponDeparture ?? 0;
rootPobd.TotalPersonsOnBoardUponDeparture = pobd.TotalPersonsOnBoardUponDeparture ?? 0;
rootPobd.TotalStowawaysOnBoardUponDeparture = pobd.TotalStowawaysOnBoardUponDeparture ?? 0;
item = rootPobd;
}
break;
#endregion
#region STAT
case Message.NotificationClass.STAT:
{
RootSTAT rootStat = new RootSTAT();
STAT stat = message.Elements[0] as STAT;
rootStat.ShipName = stat.ShipName;
rootStat.CallSign = stat.CallSign;
rootStat.MMSINumber = stat.MMSINumber;
rootStat.Flag = stat.Flag;
if (stat.LengthOverall_MTR.HasValue) rootStat.LengthOverall_MTR = (float) (stat.LengthOverall_MTR.Value);
if (stat.Beam_MTR.HasValue) rootStat.Beam_MTR = (float) (stat.Beam_MTR.Value);
if (stat.GrossTonnage.HasValue) rootStat.GrossTonnage = stat.GrossTonnage.Value;
rootStat.PortOfRegistry = stat.PortOfRegistry;
rootStat.ShipType = stat.ShipType;
if (!stat.ISMCompanyName.IsNullOrEmpty())
{
rootStat.ISMCompany = new RootSTATISMCompany();
rootStat.ISMCompany.ISMCompanyName = stat.ISMCompanyName;
rootStat.ISMCompany.ISMCompanyId = stat.ISMCompanyId;
rootStat.ISMCompany.ISMCompanyStreetAndNumber = stat.ISMCompanyStreetAndNumber;
rootStat.ISMCompany.ISMCompanyPostalCode = stat.ISMCompanyPostalCode;
rootStat.ISMCompany.ISMCompanyCity = stat.ISMCompanyCity;
rootStat.ISMCompany.ISMCompanyCountry = stat.ISMCompanyCountry;
}
item = rootStat;
}
break;
#endregion
#region LADG
case Message.NotificationClass.LADG:
{
RootLADG rootLADG = new RootLADG();
rootLADG.Cargo = new RootLADGCargo[message.Elements.Count];
for (int i = 0; i < message.Elements.Count; i++ )
{
LADG ladg = message.Elements[i] as LADG;
rootLADG.Cargo[i] = new RootLADGCargo();
if(ladg.CargoHandlingType.HasValue)
rootLADG.Cargo[i].CargoHandlingType = (RootLADGCargoCargoHandlingType)(ladg.CargoHandlingType);
rootLADG.Cargo[i].CargoCodeNST = ladg.CargoCodeNST;
if (ladg.CargoGrossQuantity_TNE.HasValue)
rootLADG.Cargo[i].CargoGrossQuantity_TNE = (float) ladg.CargoGrossQuantity_TNE.Value;
rootLADG.Cargo[i].CargoNumberOfItemsSpecified = ladg.CargoNumberOfItems.HasValue;
if (ladg.CargoNumberOfItems.HasValue)
rootLADG.Cargo[i].CargoNumberOfItems = ladg.CargoNumberOfItems.Value;
}
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 = (RootINFOShippingArea)info.ShippingArea.Value;
rootInfo.RequestedPositionInPortOfCall = info.RequestedPositionInPortOfCall;
rootInfo.SpecialRequirementsOfShipAtBerth = info.SpecialRequirementsOfShipAtBerth;
if(info.SpecialRequirementsOfShipAtBerth.IsNullOrEmpty())
{
// Name des Agenten eintragen
}
rootInfo.ConstructionCharacteristicsOfShip = info.ConstructionCharacteristicsOfShip;
if (info.FumigatedBulkCargo.HasValue)
rootInfo.FumigatedBulkCargo = (info.FumigatedBulkCargo.Value == 0) ? RootINFOFumigatedBulkCargo.Y : RootINFOFumigatedBulkCargo.N;
rootInfo.DeadWeightSummer_TNESpecified = info.DeplacementSummerDraught_TNE.HasValue;
if (info.DeplacementSummerDraught_TNE.HasValue)
rootInfo.DeadWeightSummer_TNE = (float) info.DeplacementSummerDraught_TNE.Value;
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 ? RootPRE72HTanker.Y : RootPRE72HTanker.N;
if (pre72h.Tanker ?? false)
{
rootPre.TankerDetails = new RootPRE72HTankerDetails();
if (pre72h.TankerHullConfiguration.HasValue)
rootPre.TankerDetails.TankerHullConfiguration = (RootPRE72HTankerDetailsTankerHullConfiguration)pre72h.TankerHullConfiguration.Value;
if (pre72h.ConditionCargoBallastTanks.HasValue)
rootPre.TankerDetails.ConditionCargoBallastTanks = (RootPRE72HTankerDetailsConditionCargoBallastTanks)pre72h.ConditionCargoBallastTanks.Value;
rootPre.TankerDetails.NatureOfCargo = pre72h.NatureOfCargo;
rootPre.TankerDetails.VolumeOfCargo_TNESpecified = pre72h.VolumeOfCargo.HasValue;
}
if (pre72h.VolumeOfCargo.HasValue)
rootPre.TankerDetails.VolumeOfCargo_TNE = (float) (pre72h.VolumeOfCargo.Value);
rootPre.PlannedOperations = pre72h.PlannedOperations;
rootPre.PlannedWorks = pre72h.PlannedWorks;
if (pre72h.DateOfLastExpandedInspection.HasValue)
rootPre.DateOfLastExpandedInspection = pre72h.DateOfLastExpandedInspection.Value;
if (pre72h.PlannedPeriodOfStay_HUR.HasValue)
rootPre.PlannedPeriodOfStay_HUR = (float) (pre72h.PlannedPeriodOfStay_HUR.Value);
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);
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] = RootMDHMDHSimplification.Y;
rootMDH.ItemsElementName[1] = ItemsChoiceType2.PortOfCallWhereCompleteMDHNotified;
rootMDH.Items[1] = mdh.PortOfCallWhereCompleteMDHNotified;
}
else
{ // der blöde Teil
rootMDH.Items = new object[19];
rootMDH.ItemsElementName = new ItemsChoiceType2[26];
rootMDH.ItemsElementName[0] = ItemsChoiceType2.NonAccidentialDeathsDuringVoyage;
rootMDH.Items[0] = mdh.NonAccidentalDeathsDuringVoyage ?? false ? RootMDHNonAccidentialDeathsDuringVoyage.Y : RootMDHNonAccidentialDeathsDuringVoyage.N;
rootMDH.ItemsElementName[1] = ItemsChoiceType2.NonAccidentialDeathsDuringVoyageCount;
if (mdh.NonAccidentalDeathsDuringVoyageCount.HasValue)
rootMDH.Items[1] = mdh.NonAccidentalDeathsDuringVoyageCount.Value;
rootMDH.ItemsElementName[2] = ItemsChoiceType2.SuspisionInfectiousNature;
rootMDH.Items[2] = mdh.SuspisionInfectiousNature ?? false ? RootMDHSuspisionInfectiousNature.Y : RootMDHSuspisionInfectiousNature.N;
rootMDH.ItemsElementName[3] = ItemsChoiceType2.NumberOfIllPersonsHigherThanExpected;
rootMDH.Items[3] = mdh.NumberOfIllPersonsHigherThanExpected ?? false ? RootMDHNumberOfIllPersonsHigherThanExpected.Y : RootMDHNumberOfIllPersonsHigherThanExpected.N;
rootMDH.ItemsElementName[4] = ItemsChoiceType2.NumberOfIllPersons;
if (mdh.NumberOfIllPersons.HasValue)
rootMDH.Items[4] = mdh.NumberOfIllPersons.Value;
rootMDH.ItemsElementName[5] = ItemsChoiceType2.SickPersonsOnBoard;
rootMDH.Items[5] = mdh.SickPersonsOnBoard ?? false ? RootMDHSickPersonsOnBoard.Y : RootMDHSickPersonsOnBoard.N;
rootMDH.ItemsElementName[6] = ItemsChoiceType2.MedicalConsulted;
rootMDH.Items[6] = mdh.MedicalConsulted ?? false ? RootMDHMedicalConsulted.Y : RootMDHMedicalConsulted.N;
rootMDH.ItemsElementName[7] = ItemsChoiceType2.AwareOfConditionsForFurtherInfections;
rootMDH.Items[7] = mdh.AwareOfFurtherInfections ?? false ? RootMDHAwareOfConditionsForFurtherInfections.Y : RootMDHAwareOfConditionsForFurtherInfections.N;
rootMDH.ItemsElementName[8] = ItemsChoiceType2.SanitaryMeasuresApplied;
rootMDH.Items[8] = mdh.SanitaryMeasuresApplied ?? false ? RootMDHSanitaryMeasuresApplied.Y : RootMDHSanitaryMeasuresApplied.N;
if (mdh.SanitaryMeasuresApplied ?? false)
{
rootMDH.ItemsElementName[9] = ItemsChoiceType2.SanitaryMeasuresDetails;
RootMDHSanitaryMeasuresDetails smDet = new RootMDHSanitaryMeasuresDetails();
if (mdh.SanitaryMeasuresDate.HasValue)
smDet.SanitaryMeasuresDate = mdh.SanitaryMeasuresDate.Value;
smDet.SanitaryMeasuresType = mdh.SanitaryMeasuresType;
smDet.SanitaryMeasuresLocation = mdh.SanitaryMeasuresLocation;
rootMDH.Items[9] = smDet;
}
rootMDH.ItemsElementName[10] = ItemsChoiceType2.StowawaysDetected;
rootMDH.Items[10] = mdh.StowawaysDetected ?? false ? RootMDHStowawaysDetected.Y : RootMDHStowawaysDetected.N;
rootMDH.ItemsElementName[11] = ItemsChoiceType2.StowawaysJoiningLocation;
rootMDH.Items[11] = mdh.StowawaysJoiningLocation;
rootMDH.ItemsElementName[12] = ItemsChoiceType2.SickAnimalOrPetOnBoard;
rootMDH.Items[12] = mdh.SickAnimalOrPetOnBoard ?? false ? RootMDHSickAnimalOrPetOnBoard.Y : RootMDHSickAnimalOrPetOnBoard.N;
rootMDH.ItemsElementName[13] = ItemsChoiceType2.ValidSanitaryControlExemptionOrCertificateOnBoard;
rootMDH.Items[13] = mdh.ValidSanitaryControlExemptionOrCertificateOnBoard ?? false ? RootMDHValidSanitaryControlExemptionOrCertificateOnBoard.Y : RootMDHValidSanitaryControlExemptionOrCertificateOnBoard.N;
rootMDH.ItemsElementName[14] = ItemsChoiceType2.ValidSanitaryControlExemptionOrCertificate;
RootMDHValidSanitaryControlExemptionOrCertificate cert = new RootMDHValidSanitaryControlExemptionOrCertificate();
rootMDH.Items[14] = cert;
if (mdh.DateOfIssue.HasValue) cert.DateOfIssue = mdh.DateOfIssue.Value;
cert.PlaceOfIssue = mdh.PlaceOfIssue;
rootMDH.ItemsElementName[15] = ItemsChoiceType2.SanitaryControlReinspectionRequired;
rootMDH.Items[15] = mdh.SanitaryControlReinspectionRequired ?? false ? RootMDHSanitaryControlReinspectionRequired.Y : RootMDHSanitaryControlReinspectionRequired.N;
rootMDH.ItemsElementName[16] = ItemsChoiceType2.InfectedAreaVisited;
rootMDH.Items[16] = mdh.InfectedAreaVisited ?? false ? RootMDHInfectedAreaVisited.Y : RootMDHInfectedAreaVisited.N;
if (!mdh.InfectedAreaPort.IsNullOrEmpty() && mdh.InfectedAreaDate.HasValue)
{
rootMDH.ItemsElementName[17] = ItemsChoiceType2.InfectedArea;
RootMDHInfectedArea infected = new RootMDHInfectedArea();
rootMDH.Items[17] = infected;
infected.InfectedAreaPort = mdh.InfectedAreaPort;
if (mdh.InfectedAreaDate.HasValue) infected.InfectedAreaDate = mdh.InfectedAreaDate.Value;
}
rootMDH.ItemsElementName[18] = ItemsChoiceType2.PortsOfCallLast30Days;
RootMDHPortsOfCallLast30Days l30d = new RootMDHPortsOfCallLast30Days();
rootMDH.Items[18] = l30d;
if (mdh.PortOfCallLast30Days.Count > 0)
{
l30d.PortOfCallLast30Days = new RootMDHPortsOfCallLast30DaysPortOfCallLast30Days[mdh.PortOfCallLast30Days.Count];
for (int i = 0; i < mdh.PortOfCallLast30Days.Count; i++)
{
l30d.PortOfCallLast30Days[i] = new RootMDHPortsOfCallLast30DaysPortOfCallLast30Days();
l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip = new RootMDHPortsOfCallLast30DaysPortOfCallLast30DaysPortOfCallLast30DaysCrewJoinedShip();
if (mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count > 0)
{
l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip.PortOfCallLast30DaysCrewJoinedShipName = new string[mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count];
for (int j = 0; j < mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count; j++)
{
l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip.PortOfCallLast30DaysCrewJoinedShipName[j] = mdh.PortOfCallLast30Days[i].CrewJoinedShip[j].PortOfCallLast30DaysCrewJoinedShipName;
}
}
l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined ?? false ? RootMDHPortsOfCallLast30DaysPortOfCallLast30DaysPortOfCallLast30DaysCrewMembersJoined.Y : RootMDHPortsOfCallLast30DaysPortOfCallLast30DaysPortOfCallLast30DaysCrewMembersJoined.N;
if (mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.HasValue)
l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.Value;
l30d.PortOfCallLast30Days[i].PortOfCallLast30DaysLocode = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysLocode;
}
}
}
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] = RootWASWasteDisposalValidExemption.Y;
}
else
{
rootWAS.Items = new object[14];
rootWAS.ItemsElementName = new ItemsChoiceType3[14];
rootWAS.ItemsElementName[0] = ItemsChoiceType3.ConfirmationOfCorrectness;
rootWAS.Items[0] = was.ConfirmationOfCorrectness ?? false ? RootWASConfirmationOfCorrectness.Y : RootWASConfirmationOfCorrectness.N;
rootWAS.ItemsElementName[1] = ItemsChoiceType3.LastWasteDisposalDate;
if (was.LastWasteDisposalDate.HasValue)
rootWAS.Items[1] = was.LastWasteDisposalDate.Value;
rootWAS.ItemsElementName[2] = ItemsChoiceType3.LastWasteDisposalPort;
rootWAS.Items[2] = was.LastWasteDisposalPort;
rootWAS.ItemsElementName[2] = ItemsChoiceType3.WasteDisposalServiceProviderName;
rootWAS.ItemsElementName[3] = ItemsChoiceType3.WasteDisposalDelivery;
if (was.WasteDisposalDelivery.HasValue)
rootWAS.Items[3] = (RootWASWasteDisposalDelivery)was.WasteDisposalDelivery.Value;
rootWAS.ItemsElementName[4] = ItemsChoiceType3.WasteDisposalServiceProviderName;
if (was.WasteDisposalServiceProvider.Count > 0)
{
// TODO: Klären wie es nun genau hier aussieht!
string serviceProviderName = "";
for (int i = 0; i < was.WasteDisposalServiceProvider.Count; i++)
{
serviceProviderName = string.Format("{0}{1}", serviceProviderName, was.WasteDisposalServiceProvider[i].WasteDisposalServiceProviderName);
}
rootWAS.Items[4] = serviceProviderName;
}
/*
{"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 = 5; j < 14; j++)
{
if (was.Waste.Count > 0)
{
rootWAS.ItemsElementName[j] = ItemsChoiceType3.Waste;
RootWASWaste rww = new RootWASWaste();
rootWAS.Items[j] = rww;
if(was.Waste.Count > (j - 5))
{
rww.WasteDescription = was.Waste[j-5].WasteDescription;
if (was.Waste[j - 5].WasteType.HasValue)
rww.WasteType = (RootWASWasteWasteType)was.Waste[j - 5].WasteType.Value;
if (was.Waste[j - 5].WasteDisposalAmount_MTQ.HasValue)
rww.WasteDisposalAmount_MTQ = (float)was.Waste[j - 5].WasteDisposalAmount_MTQ.Value;
rww.WasteDetails = new RootWASWasteWasteDetails();
if (was.Waste[j - 5].WasteCapacity_MTQ.HasValue)
rww.WasteDetails.WasteCapacity_MTQ = (float)was.Waste[j - 5].WasteCapacity_MTQ.Value;
if (was.Waste[j - 5].WasteAmountRetained_MTQ.HasValue)
rww.WasteDetails.WasteAmountRetained_MTQ = (float)was.Waste[j - 5].WasteAmountRetained_MTQ.Value;
rww.WasteDetails.WasteDisposalPort = was.Waste[j - 5].WasteDisposalPort;
if (was.Waste[j - 5].WasteAmountGeneratedTillNextPort_MTQ.HasValue)
rww.WasteDetails.WasteAmountGeneratedTillNextPort_MTQ = (float)was.Waste[j - 5].WasteAmountGeneratedTillNextPort_MTQ.Value;
}
}
}
}
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 = (float) towa.TowageOnArrivalLengthOverall_MTR.Value;
if (towa.TowageOnArrivalBeam_MTR.HasValue)
rootTowa.TowageOnArrival[i].TowageOnArrivalBeam_MTR = (float) towa.TowageOnArrivalBeam_MTR.Value;
rootTowa.TowageOnArrival[i].TowageOnArrivalPurposeOfCall = towa.TowageOnArrivalPurposeOfCall;
if (towa.TowageOnArrivalDraught_DMT.HasValue)
rootTowa.TowageOnArrival[i].TowageOnArrivalDraught_DMT = (float) towa.TowageOnArrivalDraught_DMT.Value;
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 = (float) towd.TowageOnDepartureLengthOverall_MTR.Value;
if (towd.TowageOnDepartureBeam_MTR.HasValue)
rootTowd.TowageOnDeparture[i].TowageOnDepartureBeam_MTR = (float) towd.TowageOnDepartureBeam_MTR.Value;
if (towd.TowageOnDepartureDraught_DMT.HasValue)
rootTowd.TowageOnDeparture[i].TowageOnDepartureDraught_DMT = (float) towd.TowageOnDepartureDraught_DMT.Value;
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] = RootHAZANoDPGOnBoardOnArrival.Y;
}
else
{
rootHAZA.Items = new object[3];
// if(haz.DPGManifestOnBoardOnArrival.HasValue)
rootHAZA.Items[0] = (haz.DPGManifestOnBoardOnArrival ?? false) ? RootHAZADPGManifestOnBoardOnArrival.Y : RootHAZADPGManifestOnBoardOnArrival.N;
#region HAZ positions
RootHAZADPGOnArrival dpgOnArrival = new RootHAZADPGOnArrival();
#region IMDG
if (haz.IMDGPositions.Count > 0)
{
dpgOnArrival.DPGItemIMDG = new RootHAZADPGOnArrivalDPGItemIMDG[haz.IMDGPositions.Count];
for (int i = 0; i < haz.IMDGPositions.Count; i++)
{
IMDGPosition imdgPos = haz.IMDGPositions[i];
RootHAZADPGOnArrivalDPGItemIMDG rootIMDG = new RootHAZADPGOnArrivalDPGItemIMDG();
rootIMDG.UNNumber = imdgPos.UNNumber;
if (imdgPos.PackingGroup.HasValue)
rootIMDG.PackingGroup = (RootHAZADPGOnArrivalDPGItemIMDGPackingGroup)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 = (float)imdgPos.NetExplosiveMass_KGM.Value;
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 = (float)imdgPos.Class7MaxActivity_BQL.Value;
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 = (float)imdgPos.Class7TransportIndex.Value;
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 = (float)imdgPos.ControlTemperature_CEL.Value;
rootIMDG.EmergencyTemperature_CELSpecified = imdgPos.EmergencyTemperature_CEL.HasValue;
if (imdgPos.EmergencyTemperature_CEL.HasValue)
rootIMDG.EmergencyTemperature_CEL = (float)imdgPos.EmergencyTemperature_CEL.Value;
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 ? RootHAZADPGOnArrivalDPGItemIMDGMarinePollutant.Y : RootHAZADPGOnArrivalDPGItemIMDGMarinePollutant.N;
if (imdgPos.NumberOfPackages.HasValue)
rootIMDG.NumberOfPackages = imdgPos.NumberOfPackages.Value;
rootIMDG.PackageType = imdgPos.PackageType;
if (imdgPos.LimitedQuantities.HasValue)
rootIMDG.LimitedQuantities = imdgPos.LimitedQuantities.Value ? RootHAZADPGOnArrivalDPGItemIMDGLimitedQuantities.Y : RootHAZADPGOnArrivalDPGItemIMDGLimitedQuantities.N;
if (imdgPos.ExceptedQuantities.HasValue)
rootIMDG.ExceptedQuantities = imdgPos.ExceptedQuantities.Value ? RootHAZADPGOnArrivalDPGItemIMDGExceptedQuantities.Y : RootHAZADPGOnArrivalDPGItemIMDGExceptedQuantities.N;
rootIMDG.NetQuantity_KGMSpecified = imdgPos.NetQuantity_KGM.HasValue;
if (imdgPos.NetQuantity_KGM.HasValue)
rootIMDG.NetQuantity_KGM = (float)imdgPos.NetQuantity_KGM.Value;
rootIMDG.GrossQuantity_KGMSpecified = imdgPos.GrossQuantity_KGM.HasValue;
if (imdgPos.GrossQuantity_KGM.HasValue)
rootIMDG.GrossQuantity_KGM = (float)imdgPos.GrossQuantity_KGM.Value;
rootIMDG.Volume_MTQSpecified = imdgPos.Volume_MTQ.HasValue;
if (imdgPos.Volume_MTQ.HasValue)
rootIMDG.Volume_MTQ = (float)imdgPos.Volume_MTQ.Value;
rootIMDG.GeneralCargoIBCSpecified = imdgPos.GeneralCargoIBC.HasValue;
if (imdgPos.GeneralCargoIBC.HasValue)
rootIMDG.GeneralCargoIBC = imdgPos.GeneralCargoIBC.Value ? RootHAZADPGOnArrivalDPGItemIMDGGeneralCargoIBC.Y : RootHAZADPGOnArrivalDPGItemIMDGGeneralCargoIBC.N;
rootIMDG.ContainerNumber = imdgPos.ContainerNumber;
rootIMDG.VehicleLicenseNumber = imdgPos.VehicleLicenseNumber;
rootIMDG.StowagePosition = imdgPos.StowagePosition;
rootIMDG.PortOfLoading = imdgPos.PortOfLoading;
rootIMDG.PortOfDischarge = imdgPos.PortOfDischarge;
rootIMDG.Remarks = imdgPos.Remarks;
dpgOnArrival.DPGItemIMDG[i] = rootIMDG;
}
}
#endregion
#region IBC
if (haz.IBCPositions.Count > 0)
{
dpgOnArrival.DPGItemIBC = new RootHAZADPGOnArrivalDPGItemIBC[haz.IBCPositions.Count];
for (int i = 0; i < haz.IBCPositions.Count; i++)
{
RootHAZADPGOnArrivalDPGItemIBC rootIBC = new RootHAZADPGOnArrivalDPGItemIBC();
IBCPosition ibcPos = haz.IBCPositions[i];
rootIBC.ProductName = ibcPos.ProductName;
if (ibcPos.PollutionCategory.HasValue)
rootIBC.PollutionCategory = (RootHAZADPGOnArrivalDPGItemIBCPollutionCategory)ibcPos.PollutionCategory.Value;
rootIBC.HazardsSpecified = ibcPos.Hazards.HasValue;
if (ibcPos.Hazards.HasValue)
rootIBC.Hazards = (RootHAZADPGOnArrivalDPGItemIBCHazards)ibcPos.Hazards.Value;
if (ibcPos.FlashpointInformation.HasValue)
rootIBC.FlashpointInformation = (RootHAZADPGOnArrivalDPGItemIBCFlashpointInformation)ibcPos.FlashpointInformation.Value;
rootIBC.Flashpoint_CEL = ibcPos.Flashpoint_CEL;
if (ibcPos.Quantity_KGM.HasValue)
rootIBC.Quantity_KGM = (float)ibcPos.Quantity_KGM.Value;
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 ? RootHAZADPGOnArrivalDPGItemIBCSpecRef15_19.Y : RootHAZADPGOnArrivalDPGItemIBCSpecRef15_19.N;
rootIBC.Remarks = ibcPos.Remarks;
dpgOnArrival.DPGItemIBC[i] = rootIBC;
}
}
#endregion
#region IGC
if (haz.IGCPositions.Count > 0)
{
dpgOnArrival.DPGItemIGC = new RootHAZADPGOnArrivalDPGItemIGC[haz.IGCPositions.Count];
for (int i = 0; i < haz.IGCPositions.Count; i++)
{
RootHAZADPGOnArrivalDPGItemIGC rootIGC = new RootHAZADPGOnArrivalDPGItemIGC();
IGCPosition igcPos = haz.IGCPositions[i];
rootIGC.UNNumber = igcPos.UNNumber;
rootIGC.IMOClass = igcPos.IMOClass;
rootIGC.ProductName = igcPos.ProductName;
if (igcPos.Quantity_KGM.HasValue)
rootIGC.Quantity_KGM = (float)igcPos.Quantity_KGM.Value;
rootIGC.StowagePosition = igcPos.StowagePosition;
rootIGC.PortOfLoading = igcPos.PortOfLoading;
rootIGC.PortOfDischarge = igcPos.PortOfDischarge;
rootIGC.Remarks = igcPos.Remarks;
dpgOnArrival.DPGItemIGC[i] = rootIGC;
}
}
#endregion
#region IMSBC
if (haz.IMSBCPositions.Count > 0)
{
dpgOnArrival.DPGItemIMSBC = new RootHAZADPGOnArrivalDPGItemIMSBC[haz.IMSBCPositions.Count];
for (int i = 0; i < haz.IMSBCPositions.Count; i++)
{
RootHAZADPGOnArrivalDPGItemIMSBC rootIMSBC = new RootHAZADPGOnArrivalDPGItemIMSBC();
IMSBCPosition imsbcPos = haz.IMSBCPositions[i];
rootIMSBC.BulkCargoShippingName = imsbcPos.BulkCargoShippingName;
if (imsbcPos.MHB.HasValue)
rootIMSBC.MHB = imsbcPos.MHB.Value ? RootHAZADPGOnArrivalDPGItemIMSBCMHB.Y : RootHAZADPGOnArrivalDPGItemIMSBCMHB.N;
rootIMSBC.UNNumber = imsbcPos.UNNumber;
rootIMSBC.IMOClass = imsbcPos.IMOClass;
if (imsbcPos.Quantity_KGM.HasValue)
rootIMSBC.Quantity_KGM = (float)imsbcPos.Quantity_KGM.Value;
rootIMSBC.StowagePosition = imsbcPos.StowagePosition;
rootIMSBC.PortOfLoading = imsbcPos.PortOfLoading;
rootIMSBC.PortOfDischarge = imsbcPos.PortOfDischarge;
rootIMSBC.Remarks = imsbcPos.Remarks;
dpgOnArrival.DPGItemIMSBC[i] = rootIMSBC;
}
}
#endregion
#region MARPOL_ANNEX_I
if (haz.MARPOLPositions.Count > 0)
{
dpgOnArrival.DPGItemMARPOLAnnexI = new RootHAZADPGOnArrivalDPGItemMARPOLAnnexI[haz.MARPOLPositions.Count];
for (int i = 0; i < haz.MARPOLPositions.Count; i++)
{
RootHAZADPGOnArrivalDPGItemMARPOLAnnexI rootMarpol = new RootHAZADPGOnArrivalDPGItemMARPOLAnnexI();
MARPOL_Annex_I_Position marpolPos = haz.MARPOLPositions[i];
rootMarpol.Name = marpolPos.Name;
if (marpolPos.FlashpointInformation.HasValue)
rootMarpol.FlashpointInformation = (RootHAZADPGOnArrivalDPGItemMARPOLAnnexIFlashpointInformation)marpolPos.FlashpointInformation.Value;
rootMarpol.Flashpoint_CEL = marpolPos.Flashpoint_CEL;
if (marpolPos.Quantity_KGM.HasValue)
rootMarpol.Quantity_KGM = (float)marpolPos.Quantity_KGM.Value;
rootMarpol.StowagePosition = marpolPos.StowagePosition;
rootMarpol.PortOfLoading = marpolPos.PortOfLoading;
rootMarpol.PortOfDischarge = marpolPos.PortOfDischarge;
rootMarpol.Remarks = marpolPos.Remarks;
dpgOnArrival.DPGItemMARPOLAnnexI[i] = rootMarpol;
}
}
#endregion
rootHAZA.Items[1] = dpgOnArrival;
#endregion
if (haz.INFShipClass.HasValue)
{
RootHAZAINFShipClass infShipClass = (RootHAZAINFShipClass)haz.INFShipClass.Value;
rootHAZA.Items[2] = infShipClass;
}
}
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.Items = new object[1];
rootHAZD.Items[3] = RootHAZDNoDPGOnBoardOnDeparture.Y;
}
else
{
rootHAZD.Items = new object[3];
if (haz.DPGManifestOnBoardOnArrival.HasValue)
rootHAZD.Items[0] = haz.DPGManifestOnBoardOnArrival.Value ? RootHAZDDPGManifestOnBoardOnDeparture.Y : RootHAZDDPGManifestOnBoardOnDeparture.N;
#region HAZ positions
RootHAZDDPGOnDeparture dpgOnDeparture = new RootHAZDDPGOnDeparture();
#region IMDG
if (haz.IMDGPositions.Count > 0)
{
dpgOnDeparture.DPGItemIMDG = new RootHAZDDPGOnDepartureDPGItemIMDG[haz.IMDGPositions.Count];
for (int i = 0; i < haz.IMDGPositions.Count; i++)
{
IMDGPosition imdgPos = haz.IMDGPositions[i];
RootHAZDDPGOnDepartureDPGItemIMDG rootIMDG = new RootHAZDDPGOnDepartureDPGItemIMDG();
rootIMDG.UNNumber = imdgPos.UNNumber;
if (imdgPos.PackingGroup.HasValue)
rootIMDG.PackingGroup = (RootHAZDDPGOnDepartureDPGItemIMDGPackingGroup)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 = (float)imdgPos.NetExplosiveMass_KGM.Value;
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 = (float)imdgPos.Class7MaxActivity_BQL.Value;
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 = (float)imdgPos.Class7TransportIndex.Value;
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 = (float)imdgPos.ControlTemperature_CEL.Value;
rootIMDG.EmergencyTemperature_CELSpecified = imdgPos.EmergencyTemperature_CEL.HasValue;
if (imdgPos.EmergencyTemperature_CEL.HasValue)
rootIMDG.EmergencyTemperature_CEL = (float)imdgPos.EmergencyTemperature_CEL.Value;
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 ? RootHAZDDPGOnDepartureDPGItemIMDGMarinePollutant.Y : RootHAZDDPGOnDepartureDPGItemIMDGMarinePollutant.N;
if (imdgPos.NumberOfPackages.HasValue)
rootIMDG.NumberOfPackages = imdgPos.NumberOfPackages.Value;
rootIMDG.PackageType = imdgPos.PackageType;
if (imdgPos.LimitedQuantities.HasValue)
rootIMDG.LimitedQuantities = imdgPos.LimitedQuantities.Value ? RootHAZDDPGOnDepartureDPGItemIMDGLimitedQuantities.Y : RootHAZDDPGOnDepartureDPGItemIMDGLimitedQuantities.N;
if (imdgPos.ExceptedQuantities.HasValue)
rootIMDG.ExceptedQuantities = imdgPos.ExceptedQuantities.Value ? RootHAZDDPGOnDepartureDPGItemIMDGExceptedQuantities.Y : RootHAZDDPGOnDepartureDPGItemIMDGExceptedQuantities.N;
rootIMDG.NetQuantity_KGMSpecified = imdgPos.NetQuantity_KGM.HasValue;
if (imdgPos.NetQuantity_KGM.HasValue)
rootIMDG.NetQuantity_KGM = (float)imdgPos.NetQuantity_KGM.Value;
rootIMDG.GrossQuantity_KGMSpecified = imdgPos.GrossQuantity_KGM.HasValue;
if (imdgPos.GrossQuantity_KGM.HasValue)
rootIMDG.GrossQuantity_KGM = (float)imdgPos.GrossQuantity_KGM.Value;
rootIMDG.Volume_MTQSpecified = imdgPos.Volume_MTQ.HasValue;
if (imdgPos.Volume_MTQ.HasValue)
rootIMDG.Volume_MTQ = (float)imdgPos.Volume_MTQ.Value;
rootIMDG.GeneralCargoIBCSpecified = imdgPos.GeneralCargoIBC.HasValue;
if (imdgPos.GeneralCargoIBC.HasValue)
rootIMDG.GeneralCargoIBC = imdgPos.GeneralCargoIBC.Value ? RootHAZDDPGOnDepartureDPGItemIMDGGeneralCargoIBC.Y : RootHAZDDPGOnDepartureDPGItemIMDGGeneralCargoIBC.N;
rootIMDG.ContainerNumber = imdgPos.ContainerNumber;
rootIMDG.VehicleLicenseNumber = imdgPos.VehicleLicenseNumber;
rootIMDG.StowagePosition = imdgPos.StowagePosition;
rootIMDG.PortOfLoading = imdgPos.PortOfLoading;
rootIMDG.PortOfDischarge = imdgPos.PortOfDischarge;
rootIMDG.Remarks = imdgPos.Remarks;
dpgOnDeparture.DPGItemIMDG[i] = rootIMDG;
}
}
#endregion
#region IBC
if (haz.IBCPositions.Count > 0)
{
dpgOnDeparture.DPGItemIBC = new RootHAZDDPGOnDepartureDPGItemIBC[haz.IBCPositions.Count];
for (int i = 0; i < haz.IBCPositions.Count; i++)
{
RootHAZDDPGOnDepartureDPGItemIBC rootIBC = new RootHAZDDPGOnDepartureDPGItemIBC();
IBCPosition ibcPos = haz.IBCPositions[i];
rootIBC.ProductName = ibcPos.ProductName;
if (ibcPos.PollutionCategory.HasValue)
rootIBC.PollutionCategory = (RootHAZDDPGOnDepartureDPGItemIBCPollutionCategory)ibcPos.PollutionCategory.Value;
rootIBC.HazardsSpecified = ibcPos.Hazards.HasValue;
if (ibcPos.Hazards.HasValue)
rootIBC.Hazards = (RootHAZDDPGOnDepartureDPGItemIBCHazards)ibcPos.Hazards.Value;
if (ibcPos.FlashpointInformation.HasValue)
rootIBC.FlashpointInformation = (RootHAZDDPGOnDepartureDPGItemIBCFlashpointInformation)ibcPos.FlashpointInformation.Value;
rootIBC.Flashpoint_CEL = ibcPos.Flashpoint_CEL;
if (ibcPos.Quantity_KGM.HasValue)
rootIBC.Quantity_KGM = (float)ibcPos.Quantity_KGM.Value;
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 ? RootHAZDDPGOnDepartureDPGItemIBCSpecRef15_19.Y : RootHAZDDPGOnDepartureDPGItemIBCSpecRef15_19.N;
rootIBC.Remarks = ibcPos.Remarks;
dpgOnDeparture.DPGItemIBC[i] = rootIBC;
}
}
#endregion
#region IGC
if (haz.IGCPositions.Count > 0)
{
dpgOnDeparture.DPGItemIGC = new RootHAZDDPGOnDepartureDPGItemIGC[haz.IGCPositions.Count];
for (int i = 0; i < haz.IGCPositions.Count; i++)
{
RootHAZDDPGOnDepartureDPGItemIGC rootIGC = new RootHAZDDPGOnDepartureDPGItemIGC();
IGCPosition igcPos = haz.IGCPositions[i];
rootIGC.UNNumber = igcPos.UNNumber;
rootIGC.IMOClass = igcPos.IMOClass;
rootIGC.ProductName = igcPos.ProductName;
if (igcPos.Quantity_KGM.HasValue)
rootIGC.Quantity_KGM = (float)igcPos.Quantity_KGM.Value;
rootIGC.StowagePosition = igcPos.StowagePosition;
rootIGC.PortOfLoading = igcPos.PortOfLoading;
rootIGC.PortOfDischarge = igcPos.PortOfDischarge;
rootIGC.Remarks = igcPos.Remarks;
dpgOnDeparture.DPGItemIGC[i] = rootIGC;
}
}
#endregion
#region IMSBC
if (haz.IMSBCPositions.Count > 0)
{
dpgOnDeparture.DPGItemIMSBC = new RootHAZDDPGOnDepartureDPGItemIMSBC[haz.IMSBCPositions.Count];
for (int i = 0; i < haz.IMSBCPositions.Count; i++)
{
RootHAZDDPGOnDepartureDPGItemIMSBC rootIMSBC = new RootHAZDDPGOnDepartureDPGItemIMSBC();
IMSBCPosition imsbcPos = haz.IMSBCPositions[i];
rootIMSBC.BulkCargoShippingName = imsbcPos.BulkCargoShippingName;
if (imsbcPos.MHB.HasValue)
rootIMSBC.MHB = imsbcPos.MHB.Value ? RootHAZDDPGOnDepartureDPGItemIMSBCMHB.Y : RootHAZDDPGOnDepartureDPGItemIMSBCMHB.N;
rootIMSBC.UNNumber = imsbcPos.UNNumber;
rootIMSBC.IMOClass = imsbcPos.IMOClass;
if (imsbcPos.Quantity_KGM.HasValue)
rootIMSBC.Quantity_KGM = (float)imsbcPos.Quantity_KGM.Value;
rootIMSBC.StowagePosition = imsbcPos.StowagePosition;
rootIMSBC.PortOfLoading = imsbcPos.PortOfLoading;
rootIMSBC.PortOfDischarge = imsbcPos.PortOfDischarge;
rootIMSBC.Remarks = imsbcPos.Remarks;
dpgOnDeparture.DPGItemIMSBC[i] = rootIMSBC;
}
}
#endregion
#region MARPOL_ANNEX_I
if (haz.MARPOLPositions.Count > 0)
{
dpgOnDeparture.DPGItemMARPOLAnnexI = new RootHAZDDPGOnDepartureDPGItemMARPOLAnnexI[haz.MARPOLPositions.Count];
for (int i = 0; i < haz.MARPOLPositions.Count; i++)
{
RootHAZDDPGOnDepartureDPGItemMARPOLAnnexI rootMarpol = new RootHAZDDPGOnDepartureDPGItemMARPOLAnnexI();
MARPOL_Annex_I_Position marpolPos = haz.MARPOLPositions[i];
rootMarpol.Name = marpolPos.Name;
if (marpolPos.FlashpointInformation.HasValue)
rootMarpol.FlashpointInformation = (RootHAZDDPGOnDepartureDPGItemMARPOLAnnexIFlashpointInformation)marpolPos.FlashpointInformation.Value;
rootMarpol.Flashpoint_CEL = marpolPos.Flashpoint_CEL;
if (marpolPos.Quantity_KGM.HasValue)
rootMarpol.Quantity_KGM = (float)marpolPos.Quantity_KGM.Value;
rootMarpol.StowagePosition = marpolPos.StowagePosition;
rootMarpol.PortOfLoading = marpolPos.PortOfLoading;
rootMarpol.PortOfDischarge = marpolPos.PortOfDischarge;
rootMarpol.Remarks = marpolPos.Remarks;
dpgOnDeparture.DPGItemMARPOLAnnexI[i] = rootMarpol;
}
}
#endregion
rootHAZD.Items[1] = dpgOnDeparture;
#endregion
if (haz.INFShipClass.HasValue)
{
RootHAZDINFShipClass infShipClass = (RootHAZDINFShipClass)haz.INFShipClass.Value;
rootHAZD.Items[2] = infShipClass;
}
}
item = rootHAZD;
}
break;
#endregion
#region catch all
default:
{
_log.ErrorFormat("DBH send message: message type {0} not implemented", message.MessageNotificationClass);
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 = ItemChoiceType2.TransitId;
}
else
{
item = message.MessageCore.VisitId;
itemChoiceType2 = ItemChoiceType2.VisitId;
}
}
string result = client.Root(
version,
timestamp,
Properties.Settings.Default.Sender, // BSMD sender Kennung (festverdrahtet)
senderReference,
rootType,
item,
itemChoiceType2,
null, // sisnumbers (weglassen)
rp,
items,
null // violations (weglassen)
);
}
catch (Exception ex)
{
_log.ErrorFormat("exception on message send: {0}", ex.Message);
returnval = false;
}
return returnval;
}
}
}