1047 lines
80 KiB
C#
1047 lines
80 KiB
C#
//
|
|
// Class: Request
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 4/29/2015 7:20:50 AM
|
|
//
|
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Xml;
|
|
using System.Xml.Serialization;
|
|
using log4net;
|
|
using bsmd.database;
|
|
|
|
namespace bsmd.dakosy
|
|
{
|
|
public class Request
|
|
{
|
|
private static ILog _log = LogManager.GetLogger(typeof(Request));
|
|
|
|
#region send single message
|
|
|
|
public static bool Send(Message aMessage, bool useTestSystem)
|
|
{
|
|
bool retval = true;
|
|
try
|
|
{
|
|
|
|
if (!XtraSendLogic.ShouldSendMessage(aMessage)) return false;
|
|
|
|
// fill eDeclaration class
|
|
eDeclarationMessage edm = new eDeclarationMessage();
|
|
edm.Version = "3.0"; // TODO
|
|
// edm.Version = "08.15"; // entfernt auf Anraten von Fr. Ebeling 30.6.15
|
|
edm.InterchangeHeader = new InterchangeHeaderType();
|
|
edm.InterchangeHeader.CreationTime = DateTime.UtcNow;
|
|
edm.InterchangeHeader.ExchangeNumber = "tbd";
|
|
edm.InterchangeHeader.TestIndicator = Properties.Settings.Default.TestMode;
|
|
edm.InterchangeHeader.Sender = new Participant();
|
|
edm.InterchangeHeader.Sender.ParticipantCode = new ParticipantCode();
|
|
edm.InterchangeHeader.Sender.ParticipantCode.AgencyID = "DAK";
|
|
edm.InterchangeHeader.Sender.ParticipantCode.Value = "BSM";
|
|
edm.InterchangeHeader.Recipient = new Participant();
|
|
edm.InterchangeHeader.Recipient.ParticipantCode = new ParticipantCode();
|
|
edm.InterchangeHeader.Recipient.ParticipantCode.AgencyID = "DAK";
|
|
edm.InterchangeHeader.Recipient.ParticipantCode.Value = "DAK";
|
|
|
|
eDeclarationMessageInterchangeBody b = new eDeclarationMessageInterchangeBody();
|
|
edm.InterchangeBody = b;
|
|
|
|
switch (aMessage.MessageNotificationClass)
|
|
{
|
|
case Message.NotificationClass.VISIT:
|
|
case Message.NotificationClass.TRANSIT:
|
|
Request.CreateVisitTransit(b, aMessage);
|
|
break;
|
|
|
|
default:
|
|
eDeclarationMessageInterchangeBodyVisitList vList = new eDeclarationMessageInterchangeBodyVisitList();
|
|
b.Item = vList;
|
|
|
|
vList.Visit = new Visit[1];
|
|
vList.Visit[0] = new Visit();
|
|
vList.Visit[0].MessageHeader = new MessageHeaderType();
|
|
vList.Visit[0].MessageHeader.CreationTime = DateTime.UtcNow;
|
|
vList.Visit[0].MessageHeader.CreationTimeSpecified = true;
|
|
vList.Visit[0].MessageHeader.MessageRecipient = new Participant();
|
|
vList.Visit[0].MessageHeader.MessageRecipient.ParticipantCode = new ParticipantCode();
|
|
vList.Visit[0].MessageHeader.MessageRecipient.ParticipantCode.AgencyID = "DAK";
|
|
vList.Visit[0].MessageHeader.MessageRecipient.ParticipantCode.Value = "NSW";
|
|
vList.Visit[0].MessageHeader.MessageSender = new Participant();
|
|
vList.Visit[0].MessageHeader.MessageSender.ParticipantCode = new ParticipantCode();
|
|
vList.Visit[0].MessageHeader.MessageSender.ParticipantCode.AgencyID = "DAK";
|
|
vList.Visit[0].MessageHeader.MessageSender.ParticipantCode.Value = "BSM";
|
|
vList.Visit[0].MessageHeader.MessageReferenceNumber = aMessage.Id.Value.ToString("N");
|
|
// bei DRAFT geht es nicht an das NSW
|
|
vList.Visit[0].MessageType = Properties.Settings.Default.TestMode ? MessageType.DRAFT : MessageType.FULL;
|
|
if (aMessage.MessageCore.IsTransit)
|
|
vList.Visit[0].TransitID = aMessage.MessageCore.TransitId;
|
|
else
|
|
vList.Visit[0].VisitID = aMessage.MessageCore.VisitId;
|
|
vList.Visit[0].RegisterAndAddTransitIdSpecified = false; // das machen wir erstmal nicht weil das so ein Spezialverfahren
|
|
vList.Visit[0].RegisterAndAddVisitIdSpecified = false; // von Dakosy zu sein scheint
|
|
vList.Visit[0].ImoNumber = aMessage.MessageCore.IMO;
|
|
vList.Visit[0].EniNumber = aMessage.MessageCore.ENI;
|
|
vList.Visit[0].LocalReferenceNumber = aMessage.MessageCore.Id.Value.ToString("N");
|
|
if (aMessage.Cancel)
|
|
{
|
|
vList.Visit[0].Cancelled = aMessage.Cancel;
|
|
vList.Visit[0].CancelledSpecified = true;
|
|
}
|
|
|
|
vList.Visit[0].RegularFerryRoute = false; // TBD, ist gar nicht bei uns bekannt?
|
|
vList.Visit[0].RegularFerryRouteSpecified = false;
|
|
|
|
vList.Visit[0].VesselOperator = new Participant();
|
|
vList.Visit[0].VesselOperator.ParticipantCode = new ParticipantCode();
|
|
vList.Visit[0].VesselOperator.ParticipantCode.AgencyID = "DAK";
|
|
vList.Visit[0].VesselOperator.ParticipantCode.Value = "NSW"; // TBD, das weiß ich auch nicht!
|
|
|
|
vList.Visit[0].ReportingParty = new ReportingParty();
|
|
vList.Visit[0].ReportingParty.City = aMessage.ReportingParty.City;
|
|
vList.Visit[0].ReportingParty.Country = aMessage.ReportingParty.Country;
|
|
vList.Visit[0].ReportingParty.EMail = aMessage.ReportingParty.EMail;
|
|
vList.Visit[0].ReportingParty.Fax = aMessage.ReportingParty.Fax;
|
|
vList.Visit[0].ReportingParty.FirstName = aMessage.ReportingParty.FirstName;
|
|
vList.Visit[0].ReportingParty.LastName = aMessage.ReportingParty.LastName;
|
|
vList.Visit[0].ReportingParty.Name = aMessage.ReportingParty.Name;
|
|
vList.Visit[0].ReportingParty.Phone = aMessage.ReportingParty.Phone;
|
|
vList.Visit[0].ReportingParty.PostalCode = aMessage.ReportingParty.PostalCode;
|
|
int aLastBlank = aMessage.ReportingParty.StreetAndNumber.LastIndexOf(' ');
|
|
if (aLastBlank > 0)
|
|
{
|
|
vList.Visit[0].ReportingParty.StreetName = aMessage.ReportingParty.StreetAndNumber.Substring(0, aLastBlank);
|
|
vList.Visit[0].ReportingParty.StreetNumber = aMessage.ReportingParty.StreetAndNumber.Substring(aLastBlank);
|
|
}
|
|
vList.Visit[0].ReportingParty.Type = ReportingPartyType.OTHERS; // TBD
|
|
vList.Visit[0].ReportingParty.TypeSpecified = true;
|
|
|
|
switch (aMessage.MessageNotificationClass)
|
|
{
|
|
case Message.NotificationClass.AGNT:
|
|
{
|
|
bsmd.database.AGNT agnt = aMessage.Elements[0] as bsmd.database.AGNT;
|
|
vList.Visit[0].AGNT = new AGNT();
|
|
vList.Visit[0].AGNT.CompanyName = agnt.AgentCompanyName;
|
|
|
|
if (agnt.AgentStreetAndNumber != null)
|
|
{
|
|
int lastBlank = agnt.AgentStreetAndNumber.LastIndexOf(' ');
|
|
string number = (lastBlank > 0) ? agnt.AgentStreetAndNumber.Substring(lastBlank) : "";
|
|
if ((lastBlank > 0) && (number.Length > 0) && (Char.IsNumber(number[0])))
|
|
{
|
|
vList.Visit[0].AGNT.StreetName = agnt.AgentStreetAndNumber.Substring(0, lastBlank);
|
|
vList.Visit[0].AGNT.StreetNumber = agnt.AgentStreetAndNumber.Substring(lastBlank);
|
|
}
|
|
else
|
|
{
|
|
vList.Visit[0].AGNT.StreetName = agnt.AgentStreetAndNumber;
|
|
// vList.Visit[0].AGNT.StreetNumber = "";
|
|
}
|
|
}
|
|
|
|
vList.Visit[0].AGNT.PostalCode = agnt.AgentPostalCode;
|
|
vList.Visit[0].AGNT.City = agnt.AgentCity;
|
|
vList.Visit[0].AGNT.Country = agnt.AgentCountry;
|
|
vList.Visit[0].AGNT.LastName = agnt.AgentLastName;
|
|
vList.Visit[0].AGNT.FirstName = agnt.AgentFirstName;
|
|
vList.Visit[0].AGNT.Phone = agnt.AgentPhone;
|
|
vList.Visit[0].AGNT.Fax = agnt.AgentFax;
|
|
vList.Visit[0].AGNT.EMail = agnt.AgentEMail;
|
|
}
|
|
break;
|
|
case Message.NotificationClass.NOA_NOD:
|
|
bsmd.database.NOA_NOD noa_nod = aMessage.Elements[0] as bsmd.database.NOA_NOD;
|
|
if (noa_nod == null) throw new ApplicationException("dbEntity is no NOA_NOD message!");
|
|
vList.Visit[0].NOA_NOD = new NOA_NOD();
|
|
//vList.Visit[0].NOA_NOD.CallPurpose
|
|
vList.Visit[0].NOA_NOD.EtaToKielCanalSpecified = noa_nod.ETAToKielCanal.HasValue;
|
|
if (noa_nod.ETAToKielCanal.HasValue) vList.Visit[0].NOA_NOD.EtaToKielCanal = noa_nod.ETAToKielCanal.Value;
|
|
vList.Visit[0].NOA_NOD.EtaToNextPortSpecified = noa_nod.ETAToNextPort.HasValue;
|
|
if (noa_nod.ETAToNextPort.HasValue) vList.Visit[0].NOA_NOD.EtaToNextPort = noa_nod.ETAToNextPort.Value;
|
|
vList.Visit[0].NOA_NOD.EtaToPortOfCallSpecified = noa_nod.ETAToPortOfCall.HasValue;
|
|
if (noa_nod.ETAToPortOfCall.HasValue) vList.Visit[0].NOA_NOD.EtaToPortOfCall = noa_nod.ETAToPortOfCall.Value;
|
|
vList.Visit[0].NOA_NOD.EtdFromKielCanalSpecified = noa_nod.ETDFromKielCanal.HasValue;
|
|
if (noa_nod.ETDFromKielCanal.HasValue) vList.Visit[0].NOA_NOD.EtdFromKielCanal = noa_nod.ETDFromKielCanal.Value;
|
|
vList.Visit[0].NOA_NOD.EtdFromLastPortSpecified = noa_nod.ETDFromLastPort.HasValue;
|
|
if (noa_nod.ETDFromLastPort.HasValue) vList.Visit[0].NOA_NOD.EtdFromLastPort = noa_nod.ETDFromLastPort.Value;
|
|
vList.Visit[0].NOA_NOD.EtdFromPortOfCallSpecified = noa_nod.ETDFromPortOfCall.HasValue;
|
|
if (noa_nod.ETDFromPortOfCall.HasValue) vList.Visit[0].NOA_NOD.EtdFromPortOfCall = noa_nod.ETDFromPortOfCall.Value;
|
|
vList.Visit[0].NOA_NOD.LastPort = noa_nod.LastPort;
|
|
vList.Visit[0].NOA_NOD.NextPort = noa_nod.NextPort;
|
|
int numCallPurpose = noa_nod.CallPurposes.Count;
|
|
if (numCallPurpose > 0)
|
|
{
|
|
vList.Visit[0].NOA_NOD.CallPurpose = new CallPurpose[numCallPurpose];
|
|
for (int i = 0; i < numCallPurpose; i++)
|
|
{
|
|
vList.Visit[0].NOA_NOD.CallPurpose[i] = new CallPurpose();
|
|
bsmd.database.CallPurpose callPurpose = noa_nod.CallPurposes[i] as bsmd.database.CallPurpose;
|
|
vList.Visit[0].NOA_NOD.CallPurpose[i].CallPurposeCode = callPurpose.CallPurposeCode;
|
|
vList.Visit[0].NOA_NOD.CallPurpose[i].CallPurposeDescription = callPurpose.CallPurposeDescription;
|
|
}
|
|
}
|
|
break;
|
|
case Message.NotificationClass.ATA:
|
|
bsmd.database.ATA ata = aMessage.Elements[0] as bsmd.database.ATA;
|
|
vList.Visit[0].ATA = new ATA();
|
|
if(ata.ATAPortOfCall.HasValue)
|
|
vList.Visit[0].ATA.AtaPortOfCall = ata.ATAPortOfCall.Value;
|
|
break;
|
|
case Message.NotificationClass.ATD:
|
|
bsmd.database.ATD atd = aMessage.Elements[0] as bsmd.database.ATD;
|
|
vList.Visit[0].ATD = new ATD();
|
|
if (atd.ATDPortOfCall.HasValue)
|
|
vList.Visit[0].ATD.AtdPortOfCall = atd.ATDPortOfCall.Value;
|
|
break;
|
|
case Message.NotificationClass.BPOL:
|
|
bsmd.database.BPOL bpol = aMessage.Elements[0] as bsmd.database.BPOL;
|
|
vList.Visit[0].BPOL = new BPOL();
|
|
if (bpol.PortOfItineraries.Count > 0)
|
|
{
|
|
vList.Visit[0].BPOL.PortOfItinerary = new PortOfItinerary[bpol.PortOfItineraries.Count];
|
|
for (int i = 0; i < bpol.PortOfItineraries.Count; i++)
|
|
{
|
|
vList.Visit[0].BPOL.PortOfItinerary[i] = new PortOfItinerary();
|
|
bsmd.database.PortOfItinerary portOfItinerary = bpol.PortOfItineraries[i] as bsmd.database.PortOfItinerary;
|
|
if (portOfItinerary.PortOfItineraryETA.HasValue)
|
|
vList.Visit[0].BPOL.PortOfItinerary[i].PortOfItineraryETA = portOfItinerary.PortOfItineraryETA.Value;
|
|
vList.Visit[0].BPOL.PortOfItinerary[i].PortOfItineraryName = portOfItinerary.PortOfItineraryName;
|
|
}
|
|
}
|
|
vList.Visit[0].BPOL.StowawayOnBoard = bpol.StowawaysOnBoard ?? false;
|
|
break;
|
|
case Message.NotificationClass.BKRA:
|
|
{
|
|
if (aMessage.Elements.Count > 0)
|
|
{
|
|
vList.Visit[0].BKRA = new BunkerFuel[aMessage.Elements.Count];
|
|
for (int i = 0; i < aMessage.Elements.Count; i++)
|
|
{
|
|
bsmd.database.BRKA bkra = aMessage.Elements[i] as bsmd.database.BRKA;
|
|
vList.Visit[0].BKRA[i] = new BunkerFuel();
|
|
vList.Visit[0].BKRA[i].BunkerFuelQuantityTNESpecified = bkra.BunkerFuelQuantity_TNE.HasValue;
|
|
vList.Visit[0].BKRA[i].BunkerFuelQuantityTNE = (double) (bkra.BunkerFuelQuantity_TNE ?? 0);
|
|
vList.Visit[0].BKRA[i].BunkerFuelType = bkra.BunkerFuelType;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case Message.NotificationClass.BKRD:
|
|
{
|
|
if (aMessage.Elements.Count > 0)
|
|
{
|
|
vList.Visit[0].BKRD = new BunkerFuel[aMessage.Elements.Count];
|
|
for (int i = 0; i < aMessage.Elements.Count; i++)
|
|
{
|
|
bsmd.database.BRKD bkrd = aMessage.Elements[i] as bsmd.database.BRKD;
|
|
vList.Visit[0].BKRD[i] = new BunkerFuel();
|
|
vList.Visit[0].BKRD[i].BunkerFuelQuantityTNESpecified = bkrd.BunkerFuelQuantity_TNE.HasValue;
|
|
vList.Visit[0].BKRD[i].BunkerFuelQuantityTNE = (double)(bkrd.BunkerFuelQuantity_TNE ?? 0);
|
|
vList.Visit[0].BKRD[i].BunkerFuelType = bkrd.BunkerFuelType;
|
|
}
|
|
}
|
|
}
|
|
|
|
break;
|
|
case Message.NotificationClass.LADG:
|
|
{
|
|
if (aMessage.Elements.Count > 0)
|
|
{
|
|
vList.Visit[0].LADG = new Cargo[aMessage.Elements.Count];
|
|
for (int i = 0; i < aMessage.Elements.Count; i++)
|
|
{
|
|
bsmd.database.LADG ladg = aMessage.Elements[i] as bsmd.database.LADG;
|
|
vList.Visit[0].LADG[i] = new Cargo();
|
|
vList.Visit[0].LADG[i].CargoCode = new CargoCode();
|
|
vList.Visit[0].LADG[i].CargoCode.CodeType = "NST_2007";
|
|
vList.Visit[0].LADG[i].CargoCode.Value = ladg.CargoCodeNST;
|
|
vList.Visit[0].LADG[i].CargoHandlingTypeSpecified = ladg.CargoHandlingType.HasValue;
|
|
byte ht = ladg.CargoHandlingType ?? 0;
|
|
vList.Visit[0].LADG[i].CargoHandlingType = CHTFromNSWEnumeration(ht);
|
|
vList.Visit[0].LADG[i].CargoGrossQuantityTNESpecified = ladg.CargoGrossQuantity_TNE.HasValue;
|
|
vList.Visit[0].LADG[i].CargoGrossQuantityTNE = (double) (ladg.CargoGrossQuantity_TNE ?? 0);
|
|
vList.Visit[0].LADG[i].CargoNumberOfItemsSpecified = ladg.CargoNumberOfItems.HasValue;
|
|
vList.Visit[0].LADG[i].CargoNumberOfItems = ladg.CargoNumberOfItems ?? 0;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case Message.NotificationClass.CREW:
|
|
{
|
|
if (aMessage.Elements.Count > 0)
|
|
{
|
|
vList.Visit[0].CREW = new CrewMember[aMessage.Elements.Count];
|
|
for (int i = 0; i < aMessage.Elements.Count; i++)
|
|
{
|
|
bsmd.database.CREW crew = aMessage.Elements[i] as bsmd.database.CREW;
|
|
vList.Visit[0].CREW[i] = new CrewMember();
|
|
vList.Visit[0].CREW[i].DateOfBirthSpecified = crew.CrewMemberDateOfBirth.HasValue;
|
|
if (vList.Visit[0].CREW[i].DateOfBirthSpecified)
|
|
vList.Visit[0].CREW[i].DateOfBirth = crew.CrewMemberDateOfBirth.Value;
|
|
vList.Visit[0].CREW[i].Duty = crew.CrewMemberDuty;
|
|
vList.Visit[0].CREW[i].FirstName = crew.CrewMemberFirstName;
|
|
vList.Visit[0].CREW[i].GenderSpecified = crew.CrewMemberGender.HasValue;
|
|
byte gender = crew.CrewMemberGender ?? 0;
|
|
vList.Visit[0].CREW[i].Gender = (gender == 1) ? GenderType.FEMALE : GenderType.MALE;
|
|
vList.Visit[0].CREW[i].IdentityDocumentId = crew.CrewMemberIdentityDocumentId;
|
|
vList.Visit[0].CREW[i].IdentityDocumentTypeSpecified = crew.CrewMemberIdentityDocumentType.HasValue;
|
|
byte dType = crew.CrewMemberIdentityDocumentType ?? 0;
|
|
vList.Visit[0].CREW[i].IdentityDocumentType = CrewDocumentFromNSWEnumeration(dType);
|
|
vList.Visit[0].CREW[i].LastName = crew.CrewMemberLastName;
|
|
vList.Visit[0].CREW[i].Nationality = crew.CrewMemberNationality;
|
|
vList.Visit[0].CREW[i].PlaceOfBirth = crew.CrewMemberPlaceOfBirth;
|
|
vList.Visit[0].CREW[i].VisaNumber = crew.CrewMemberVisaNumber;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case Message.NotificationClass.TIEFA:
|
|
bsmd.database.TIEFA tiefa = aMessage.Elements[0] as bsmd.database.TIEFA;
|
|
vList.Visit[0].TIEFA = new TIEFA();
|
|
if (tiefa.DraughtUponArrival_DMT.HasValue)
|
|
vList.Visit[0].TIEFA.DraughtUponArrivalDMT = tiefa.DraughtUponArrival_DMT.Value;
|
|
break;
|
|
case Message.NotificationClass.TIEFD:
|
|
bsmd.database.TIEFD tiefd = aMessage.Elements[0] as bsmd.database.TIEFD;
|
|
vList.Visit[0].TIEFD = new TIEFD();
|
|
if (tiefd.DraughtUponDeparture_DMT.HasValue)
|
|
vList.Visit[0].TIEFD.draughtUponDepartureDMT = tiefd.DraughtUponDeparture_DMT.Value;
|
|
break;
|
|
case Message.NotificationClass.INFO:
|
|
bsmd.database.INFO info = aMessage.Elements[0] as bsmd.database.INFO;
|
|
vList.Visit[0].INFO = new INFO();
|
|
if (info.ShippingArea.HasValue)
|
|
vList.Visit[0].INFO.ShippingArea = SATFromNSWEnumeration(info.ShippingArea.Value);
|
|
vList.Visit[0].INFO.RequestedPositionInPortOfCall = info.RequestedPositionInPortOfCall;
|
|
vList.Visit[0].INFO.SpecialRequirementsOfShipAtBerth = info.SpecialRequirementsOfShipAtBerth;
|
|
vList.Visit[0].INFO.ConstructionCharacteristicsOfShip = info.ConstructionCharacteristicsOfShip;
|
|
vList.Visit[0].INFO.FumigatedBulkCargoSpecified = info.FumigatedBulkCargo.HasValue;
|
|
if(info.FumigatedBulkCargo.HasValue)
|
|
vList.Visit[0].INFO.FumigatedBulkCargo = info.FumigatedBulkCargo.Value != 0;
|
|
vList.Visit[0].INFO.DeadWeightSummerTNESpecified = info.DeplacementSummerDraught_TNE.HasValue;
|
|
if (info.DeplacementSummerDraught_TNE.HasValue)
|
|
vList.Visit[0].INFO.DeadWeightSummerTNE = info.DeplacementSummerDraught_TNE.Value;
|
|
vList.Visit[0].INFO.PortArea = info.PortArea;
|
|
vList.Visit[0].INFO.BowThrusterPower = info.BowThrusterPower;
|
|
vList.Visit[0].INFO.SternThrusterPower = info.SternThrusterPower;
|
|
break;
|
|
case Message.NotificationClass.MDH:
|
|
bsmd.database.MDH mdh = aMessage.Elements[0] as bsmd.database.MDH;
|
|
vList.Visit[0].MDH = new MDH();
|
|
vList.Visit[0].MDH.MdhSimplificationSpecified = mdh.MDHSimplification.HasValue;
|
|
vList.Visit[0].MDH.MdhSimplification = mdh.MDHSimplification ?? false;
|
|
if(mdh.MDHSimplification ?? false)
|
|
vList.Visit[0].MDH.PortOfCallWhereCompleteMDHNotified = mdh.PortOfCallWhereCompleteMDHNotified;
|
|
vList.Visit[0].MDH.NonAccidentialDeathsDuringVoyageSpecified = mdh.NonAccidentalDeathsDuringVoyage.HasValue;
|
|
vList.Visit[0].MDH.NonAccidentialDeathsDuringVoyage = mdh.NonAccidentalDeathsDuringVoyage ?? false;
|
|
vList.Visit[0].MDH.NonAccidentialDeathsDuringVoyageCountSpecified = mdh.NonAccidentalDeathsDuringVoyageCount.HasValue;
|
|
vList.Visit[0].MDH.NonAccidentialDeathsDuringVoyageCount = mdh.NonAccidentalDeathsDuringVoyageCount ?? 0;
|
|
vList.Visit[0].MDH.SuspisionInfectiousNatureSpecified = mdh.SuspisionInfectiousNature.HasValue;
|
|
vList.Visit[0].MDH.SuspisionInfectiousNature = mdh.SuspisionInfectiousNature ?? false;
|
|
vList.Visit[0].MDH.NumberOfIllPersonsHigherThanExpectedSpecified = mdh.NumberOfIllPersonsHigherThanExpected.HasValue;
|
|
vList.Visit[0].MDH.NumberOfIllPersonsHigherThanExpected = mdh.NumberOfIllPersonsHigherThanExpected ?? false;
|
|
vList.Visit[0].MDH.NumberOfIllPersonsSpecified = mdh.NumberOfIllPersons.HasValue;
|
|
vList.Visit[0].MDH.NumberOfIllPersons = mdh.NumberOfIllPersons ?? 0;
|
|
vList.Visit[0].MDH.SickPersonsOnBoardSpecified = mdh.SickPersonsOnBoard.HasValue;
|
|
vList.Visit[0].MDH.SickPersonsOnBoard = mdh.SickPersonsOnBoard ?? false;
|
|
vList.Visit[0].MDH.MedicalConsultedSpecified = mdh.MedicalConsulted.HasValue;
|
|
vList.Visit[0].MDH.MedicalConsulted = mdh.MedicalConsulted ?? false;
|
|
vList.Visit[0].MDH.AwareOfConditionsForFurtherInfectionsSpecified = mdh.AwareOfFurtherInfections.HasValue;
|
|
vList.Visit[0].MDH.AwareOfConditionsForFurtherInfections = mdh.AwareOfFurtherInfections ?? false;
|
|
vList.Visit[0].MDH.SanitaryMeasuresAppliedSpecified = mdh.SanitaryMeasuresApplied.HasValue;
|
|
vList.Visit[0].MDH.SanitaryMeasuresApplied = mdh.SanitaryMeasuresApplied ?? false;
|
|
if (mdh.SanitaryMeasuresApplied ?? false && (mdh.SanitaryMeasuresDetails.Count > 0))
|
|
{
|
|
vList.Visit[0].MDH.SanitaryMeasuresDetails = new SanitaryMeasuresDetails[mdh.SanitaryMeasuresDetails.Count];
|
|
for (int smIndex = 0; smIndex < mdh.SanitaryMeasuresDetails.Count; smIndex++) {
|
|
SanitaryMeasuresDetails smDetails = new SanitaryMeasuresDetails();
|
|
bsmd.database.SanitaryMeasuresDetail sanitaryMeasuresDetail = mdh.SanitaryMeasuresDetails[smIndex] as bsmd.database.SanitaryMeasuresDetail;
|
|
if (sanitaryMeasuresDetail.SanitaryMeasuresDate.HasValue)
|
|
smDetails.SanitaryMeasuresDate = sanitaryMeasuresDetail.SanitaryMeasuresDate.Value;
|
|
smDetails.SanitaryMeasuresLocation = sanitaryMeasuresDetail.SanitaryMeasuresLocation;
|
|
smDetails.SanitaryMeasuresType = sanitaryMeasuresDetail.SanitaryMeasuresType;
|
|
vList.Visit[0].MDH.SanitaryMeasuresDetails[smIndex] = smDetails;
|
|
}
|
|
}
|
|
vList.Visit[0].MDH.StowawaysDetectedSpecified = mdh.StowawaysDetected.HasValue;
|
|
vList.Visit[0].MDH.StowawaysDetected = mdh.StowawaysDetected ?? false;
|
|
vList.Visit[0].MDH.StowawaysJoiningLocation = mdh.StowawaysJoiningLocation;
|
|
vList.Visit[0].MDH.SickAnimalOrPetOnBoardSpecified = mdh.SickAnimalOrPetOnBoard.HasValue;
|
|
vList.Visit[0].MDH.SickAnimalOrPetOnBoard = mdh.SickAnimalOrPetOnBoard ?? false;
|
|
vList.Visit[0].MDH.ValidSanitaryControlExemptionOrCertificateOnBoardSpecified = mdh.ValidSanitaryControlExemptionOrCertificateOnBoard.HasValue;
|
|
vList.Visit[0].MDH.ValidSanitaryControlExemptionOrCertificateOnBoard = mdh.ValidSanitaryControlExemptionOrCertificateOnBoard ?? false;
|
|
vList.Visit[0].MDH.ValidSanitaryControlExemptionOrCertificate = new ValidSanitaryControlExemptionOrCertificate();
|
|
vList.Visit[0].MDH.ValidSanitaryControlExemptionOrCertificate.PlaceOfIssue = mdh.PlaceOfIssue;
|
|
if (mdh.DateOfIssue.HasValue)
|
|
vList.Visit[0].MDH.ValidSanitaryControlExemptionOrCertificate.DateOfIssue = mdh.DateOfIssue.Value;
|
|
vList.Visit[0].MDH.SanitaryControlReinspectionRequiredSpecified = mdh.SanitaryControlReinspectionRequired.HasValue;
|
|
vList.Visit[0].MDH.SanitaryControlReinspectionRequired = mdh.SanitaryControlReinspectionRequired ?? false;
|
|
vList.Visit[0].MDH.InfectedAreaVisitedSpecified = mdh.InfectedAreaVisited.HasValue;
|
|
vList.Visit[0].MDH.InfectedAreaVisited = mdh.InfectedAreaVisited ?? false;
|
|
if (mdh.InfectedAreaVisited ?? false && (mdh.InfectedAreas.Count > 0))
|
|
{
|
|
vList.Visit[0].MDH.InfectedArea = new InfectedArea[mdh.InfectedAreas.Count];
|
|
for (int iaIndex = 0; iaIndex < mdh.InfectedAreas.Count; iaIndex++)
|
|
{
|
|
InfectedArea infectedArea = new InfectedArea();
|
|
bsmd.database.InfectedArea ia = mdh.InfectedAreas[iaIndex] as bsmd.database.InfectedArea;
|
|
if (ia.InfectedAreaDate.HasValue)
|
|
infectedArea.InfectedAreaDate = ia.InfectedAreaDate.Value;
|
|
infectedArea.InfectedAreaPort = ia.InfectedAreaPort;
|
|
vList.Visit[0].MDH.InfectedArea[iaIndex] = infectedArea;
|
|
}
|
|
}
|
|
if (mdh.PortOfCallLast30Days.Count > 0)
|
|
{
|
|
vList.Visit[0].MDH.PortsOfCallLast30Days = new PortOfCallLast30Days[mdh.PortOfCallLast30Days.Count];
|
|
for (int i = 0; i < mdh.PortOfCallLast30Days.Count; i++)
|
|
{
|
|
bsmd.database.PortOfCallLast30Days poc30d = mdh.PortOfCallLast30Days[i] as bsmd.database.PortOfCallLast30Days;
|
|
vList.Visit[0].MDH.PortsOfCallLast30Days[i] = new PortOfCallLast30Days();
|
|
vList.Visit[0].MDH.PortsOfCallLast30Days[i].Locode = poc30d.PortOfCallLast30DaysLocode;
|
|
if (poc30d.PortOfCallLast30DaysDateOfDeparture.HasValue)
|
|
vList.Visit[0].MDH.PortsOfCallLast30Days[i].DateOfDeparture = poc30d.PortOfCallLast30DaysDateOfDeparture.Value;
|
|
if (poc30d.PortOfCallLast30DaysCrewMembersJoined.HasValue)
|
|
{
|
|
vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewMembersJoined = poc30d.PortOfCallLast30DaysCrewMembersJoined.Value;
|
|
if(poc30d.CrewJoinedShip.Count > 0) {
|
|
vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewJoinedShipName = new CrewJoinedShipName[poc30d.CrewJoinedShip.Count];
|
|
for (int j = 0; j < vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewJoinedShipName.Length; j++)
|
|
{
|
|
vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewJoinedShipName[j] = new CrewJoinedShipName();
|
|
vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewJoinedShipName[j].Name = poc30d.CrewJoinedShip[j].PortOfCallLast30DaysCrewJoinedShipName;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case Message.NotificationClass.NAME:
|
|
bsmd.database.NAME name = aMessage.Elements[0] as bsmd.database.NAME;
|
|
vList.Visit[0].NAME = new NAME();
|
|
vList.Visit[0].NAME.NameOfMaster = name.NameOfMaster;
|
|
break;
|
|
case Message.NotificationClass.PAS:
|
|
{
|
|
if (aMessage.Elements.Count > 0)
|
|
{
|
|
vList.Visit[0].PAS = new Passenger[aMessage.Elements.Count];
|
|
for (int i = 0; i < aMessage.Elements.Count; i++)
|
|
{
|
|
bsmd.database.PAS pas = aMessage.Elements[i] as bsmd.database.PAS;
|
|
vList.Visit[0].PAS[i] = new Passenger();
|
|
vList.Visit[0].PAS[i].DateOfBirthSpecified = pas.PassengerDateOfBirth.HasValue;
|
|
if (pas.PassengerDateOfBirth.HasValue)
|
|
vList.Visit[0].PAS[i].DateOfBirth = pas.PassengerDateOfBirth.Value;
|
|
vList.Visit[0].PAS[i].FirstName = pas.PassengerFirstName;
|
|
vList.Visit[0].PAS[i].GenderSpecified = pas.PassengerGender.HasValue;
|
|
if (pas.PassengerGender.HasValue)
|
|
vList.Visit[0].PAS[i].Gender = (pas.PassengerGender.Value == 1) ? GenderType.FEMALE : GenderType.MALE;
|
|
vList.Visit[0].PAS[i].IdentityDocumentId = pas.PassengerIdentityDocumentId;
|
|
vList.Visit[0].PAS[i].IdentityDocumentTypeSpecified = pas.PassengerIdentityDocumentType.HasValue;
|
|
if (pas.PassengerIdentityDocumentType.HasValue)
|
|
vList.Visit[0].PAS[i].IdentityDocumentType = CrewDocumentFromNSWEnumeration(pas.PassengerIdentityDocumentType.Value);
|
|
vList.Visit[0].PAS[i].InTransitSpecified = pas.PassengerInTransit.HasValue;
|
|
if (pas.PassengerInTransit.HasValue)
|
|
vList.Visit[0].PAS[i].InTransit = pas.PassengerInTransit.Value;
|
|
vList.Visit[0].PAS[i].LastName = pas.PassengerLastName;
|
|
vList.Visit[0].PAS[i].Nationality = pas.PassengerNationality;
|
|
vList.Visit[0].PAS[i].PlaceOfBirth = pas.PassengerPlaceOfBirth;
|
|
vList.Visit[0].PAS[i].PortOfDisembarkation = pas.PassengerPortOfDisembarkation;
|
|
vList.Visit[0].PAS[i].PortOfEmbarkation = pas.PassengerPortOfEmbarkation;
|
|
vList.Visit[0].PAS[i].VisaNumber = pas.PassengerVisaNumber;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case Message.NotificationClass.POBA:
|
|
{
|
|
bsmd.database.POBA poba = aMessage.Elements[0] as bsmd.database.POBA;
|
|
vList.Visit[0].PoBA = new PoBA();
|
|
if (poba.TotalCrewMembersOnBoardUponArrival.HasValue)
|
|
vList.Visit[0].PoBA.TotalCrewMembersOnBoardUponArrival = poba.TotalCrewMembersOnBoardUponArrival.Value;
|
|
if (poba.TotalPassengersOnBoardUponArrival.HasValue)
|
|
vList.Visit[0].PoBA.TotalPassengersOnBoardUponArrival = poba.TotalPassengersOnBoardUponArrival.Value;
|
|
if (poba.TotalStowawaysOnBoardUponArrival.HasValue)
|
|
vList.Visit[0].PoBA.TotalStowawaysOnBoardUponArrival = poba.TotalStowawaysOnBoardUponArrival.Value;
|
|
vList.Visit[0].PoBA.TotalPersonsOnBoardUponArrivalSpecified = poba.TotalPersonsOnBoardUponArrival.HasValue;
|
|
vList.Visit[0].PoBA.TotalPersonsOnBoardUponArrival = poba.TotalPersonsOnBoardUponArrival ?? 0;
|
|
}
|
|
break;
|
|
case Message.NotificationClass.POBD:
|
|
{
|
|
bsmd.database.POBD pobd = aMessage.Elements[0] as bsmd.database.POBD;
|
|
vList.Visit[0].PoBD = new PoBD();
|
|
if (pobd.TotalCrewMembersOnBoardUponDeparture.HasValue)
|
|
vList.Visit[0].PoBD.TotalCrewMembersOnBoardUponDeparture = pobd.TotalCrewMembersOnBoardUponDeparture.Value;
|
|
if (pobd.TotalPassengersOnBoardUponDeparture.HasValue)
|
|
vList.Visit[0].PoBD.TotalPassengersOnBoardUponDeparture = pobd.TotalPassengersOnBoardUponDeparture.Value;
|
|
if (pobd.TotalStowawaysOnBoardUponDeparture.HasValue)
|
|
vList.Visit[0].PoBD.TotalStowawaysOnBoardUponDeparture = pobd.TotalStowawaysOnBoardUponDeparture.Value;
|
|
vList.Visit[0].PoBD.TotalPersonsOnBoardUponDepartureSpecified = pobd.TotalPersonsOnBoardUponDeparture.HasValue;
|
|
vList.Visit[0].PoBD.TotalPersonsOnBoardUponDeparture = pobd.TotalPersonsOnBoardUponDeparture ?? 0;
|
|
}
|
|
break;
|
|
case Message.NotificationClass.PRE72H:
|
|
{
|
|
bsmd.database.PRE72H pre72h = aMessage.Elements[0] as bsmd.database.PRE72H;
|
|
vList.Visit[0].PRE72H = new PRE72H();
|
|
vList.Visit[0].PRE72H.Tanker = pre72h.Tanker ?? false;
|
|
if (vList.Visit[0].PRE72H.Tanker)
|
|
{
|
|
vList.Visit[0].PRE72H.TankerDetails = new TankerDetails();
|
|
byte thc = pre72h.TankerHullConfiguration ?? 0;
|
|
vList.Visit[0].PRE72H.TankerDetails.TankerHullConfiguration = (TankerHullConfigurationType)thc;
|
|
byte ccbt = pre72h.ConditionCargoBallastTanks ?? 0;
|
|
vList.Visit[0].PRE72H.TankerDetails.ConditionCargoBallastTanks = (ConditionCargoBallastTanksType)ccbt;
|
|
vList.Visit[0].PRE72H.TankerDetails.NatureOfCargo = pre72h.NatureOfCargo;
|
|
vList.Visit[0].PRE72H.TankerDetails.VolumeOfCargoTNESpecified = pre72h.VolumeOfCargo.HasValue;
|
|
vList.Visit[0].PRE72H.TankerDetails.VolumeOfCargoTNE = pre72h.VolumeOfCargo ?? 0.0f;
|
|
}
|
|
vList.Visit[0].PRE72H.PlannedOperations = pre72h.PlannedOperations;
|
|
vList.Visit[0].PRE72H.PlannedWorks = pre72h.PlannedWorks;
|
|
if(pre72h.DateOfLastExpandedInspection.HasValue)
|
|
vList.Visit[0].PRE72H.DateOfLastExpandedInspection = pre72h.DateOfLastExpandedInspection.Value;
|
|
if (pre72h.PlannedPeriodOfStay_HUR.HasValue)
|
|
vList.Visit[0].PRE72H.PlannedPeriodOfStayHUR = (double)pre72h.PlannedPeriodOfStay_HUR.Value;
|
|
}
|
|
break;
|
|
case Message.NotificationClass.SEC:
|
|
{
|
|
bsmd.database.SEC sec = aMessage.Elements[0] as bsmd.database.SEC;
|
|
vList.Visit[0].SEC = new SEC();
|
|
vList.Visit[0].SEC.SecSimplificationSpecified = sec.SECSimplification.HasValue;
|
|
vList.Visit[0].SEC.SecSimplification = sec.SECSimplification ?? false;
|
|
if(sec.SECSimplification ?? false)
|
|
vList.Visit[0].SEC.PortOfCallWhereCompleteSECNotified = sec.PortOfCallWhereCompleteSECNotified;
|
|
vList.Visit[0].SEC.CsoLastName = sec.CSOLastName;
|
|
vList.Visit[0].SEC.CsoFirstName = sec.CSOFirstName;
|
|
vList.Visit[0].SEC.CsoPhone = sec.CSOPhone;
|
|
vList.Visit[0].SEC.CsoFax = sec.CSOFax;
|
|
vList.Visit[0].SEC.CsoeMail = sec.CSOEMail;
|
|
vList.Visit[0].SEC.ValidISSCOnBoardSpecified = sec.ValidISSCOnBoard.HasValue;
|
|
vList.Visit[0].SEC.ValidISSCOnBoard = sec.ValidISSCOnBoard ?? false;
|
|
vList.Visit[0].SEC.ReasonsForNoValidISSC = sec.ReasonsForNoValidISSC;
|
|
vList.Visit[0].SEC.IsscTypeSpecified = sec.ISSCType.HasValue;
|
|
byte isscType = sec.ISSCType ?? 0;
|
|
vList.Visit[0].SEC.IsscType = (IsscType)isscType;
|
|
vList.Visit[0].SEC.IsscIssuerTypeSpecified = sec.ISSCIssuerType.HasValue;
|
|
byte isscIssuerType = sec.ISSCIssuerType ?? 0;
|
|
vList.Visit[0].SEC.IsscIssuerType = (IsscIssuerType)isscIssuerType;
|
|
vList.Visit[0].SEC.IsscIssuerName = sec.ISSCIssuerName;
|
|
vList.Visit[0].SEC.IsscDateOfExpirationSpecified = sec.ISSCDateOfExpiration.HasValue;
|
|
if (sec.ISSCDateOfExpiration.HasValue)
|
|
vList.Visit[0].SEC.IsscDateOfExpiration = sec.ISSCDateOfExpiration.Value;
|
|
vList.Visit[0].SEC.ApprovedSecurityPlanOnBoardSpecified = sec.ApprovedSecurityPlanOnBoard.HasValue;
|
|
vList.Visit[0].SEC.ApprovedSecurityPlanOnBoard = sec.ApprovedSecurityPlanOnBoard ?? false;
|
|
vList.Visit[0].SEC.CurrentShipSecurityLevelSpecified = sec.CurrentShipSecurityLevel.HasValue;
|
|
vList.Visit[0].SEC.CurrentShipSecurityLevel = sec.CurrentShipSecurityLevel ?? 0;
|
|
vList.Visit[0].SEC.PortFacilityOfArrival = sec.PortFacilityOfArrival;
|
|
vList.Visit[0].SEC.GeneralDescriptionOfCargoSpecified = sec.GeneralDescriptionOfCargo.HasValue;
|
|
byte gdc = sec.GeneralDescriptionOfCargo ?? 0;
|
|
vList.Visit[0].SEC.GeneralDescriptionOfCargo = CargoTypeFromNSWEnumeration(gdc);
|
|
|
|
if (sec.LastTenPortFacilitesCalled.Count > 0)
|
|
{
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled = new LastTenPortFacilitiesCalled[sec.LastTenPortFacilitesCalled.Count];
|
|
for (int i = 0; i < sec.LastTenPortFacilitesCalled.Count; i++)
|
|
{
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i] = new LastTenPortFacilitiesCalled();
|
|
bsmd.database.LastTenPortFacilitiesCalled l10c = sec.LastTenPortFacilitesCalled[i] as bsmd.database.LastTenPortFacilitiesCalled;
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].PortName = l10c.PortFacilityPortName;
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].PortCountry = l10c.PortFacilityPortCountry;
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].PortLoCode = l10c.PortFacilityPortLoCode;
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfArrivalSpecified = l10c.PortFacilityDateOfArrival.HasValue;
|
|
if (l10c.PortFacilityDateOfArrival.HasValue)
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfArrival = l10c.PortFacilityDateOfArrival.Value;
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfDepartureSpecified = l10c.PortFacilityDateOfDeparture.HasValue;
|
|
if (l10c.PortFacilityDateOfDeparture.HasValue)
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfDeparture = l10c.PortFacilityDateOfDeparture.Value;
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].ShipSecurityLevelSpecified = l10c.PortFacilityShipSecurityLevel.HasValue;
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].ShipSecurityLevel = l10c.PortFacilityShipSecurityLevel ?? 0;
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].SecurityMattersToReport = l10c.PortFacilitySecurityMattersToReport;
|
|
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].GISISCode = l10c.PortFacilityGISISCode;
|
|
}
|
|
}
|
|
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count > 0)
|
|
{
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count];
|
|
for(int i=0;i<sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count;i++)
|
|
{
|
|
bsmd.database.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2sl = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i] as bsmd.database.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled;
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i] = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled();
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationName = s2sl.ShipToShipActivityLocationName;
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCode = s2sl.ShipToShipActivityLocationLoCode;
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLatitudeSpecified = s2sl.ShipToShipActivityLocationCoordinatesLatitude.HasValue;
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLatitude = s2sl.ShipToShipActivityLocationCoordinatesLatitude ?? 0;
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLongitudeSpecified = s2sl.ShipToShipActivityLocationCoordinatesLongitude.HasValue;
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLongitude = s2sl.ShipToShipActivityLocationCoordinatesLongitude ?? 0;
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateFromSpecified = s2sl.ShipToShipActivityDateFrom.HasValue;
|
|
if (s2sl.ShipToShipActivityDateFrom.HasValue)
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateFrom = s2sl.ShipToShipActivityDateFrom.Value;
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateToSpecified = s2sl.ShipToShipActivityDateTo.HasValue;
|
|
if (s2sl.ShipToShipActivityDateTo.HasValue)
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateTo = s2sl.ShipToShipActivityDateTo.Value;
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ActivityType = s2sl.ShipToShipActivityType;
|
|
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].SecurityMattersToReport = s2sl.ShipToShipActivitySecurityMattersToReport;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case Message.NotificationClass.SERV:
|
|
{
|
|
if (aMessage.Elements.Count > 0)
|
|
{
|
|
vList.Visit[0].SERV = new Service[aMessage.Elements.Count];
|
|
for (int i = 0; i < aMessage.Elements.Count; i++)
|
|
{
|
|
bsmd.database.SERV serv = aMessage.Elements[i] as bsmd.database.SERV;
|
|
vList.Visit[0].SERV[i] = new Service();
|
|
vList.Visit[0].SERV[i].Beneficiary = serv.ServiceBeneficiary;
|
|
vList.Visit[0].SERV[i].InvoiceRecipient = serv.ServiceInvoiceRecipient;
|
|
vList.Visit[0].SERV[i].Name = serv.ServiceName;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case Message.NotificationClass.TOWA:
|
|
{
|
|
if (aMessage.Elements.Count > 0)
|
|
{
|
|
vList.Visit[0].TOWA = new TowageArrival[aMessage.Elements.Count];
|
|
for (int i = 0; i < aMessage.Elements.Count; i++)
|
|
{
|
|
bsmd.database.TOWA towa = aMessage.Elements[i] as bsmd.database.TOWA;
|
|
vList.Visit[0].TOWA[i] = new TowageArrival();
|
|
vList.Visit[0].TOWA[i].BeamMTRSpecified = towa.TowageOnArrivalBeam_MTR.HasValue;
|
|
if (towa.TowageOnArrivalBeam_MTR.HasValue)
|
|
vList.Visit[0].TOWA[i].BeamMTR = towa.TowageOnArrivalBeam_MTR.Value;
|
|
vList.Visit[0].TOWA[i].DraughtDMTSpecified = towa.TowageOnArrivalDraught_DMT.HasValue;
|
|
if (towa.TowageOnArrivalDraught_DMT.HasValue)
|
|
vList.Visit[0].TOWA[i].DraughtDMT = towa.TowageOnArrivalDraught_DMT.Value;
|
|
vList.Visit[0].TOWA[i].Flag = towa.TowageOnArrivalFlag;
|
|
vList.Visit[0].TOWA[i].GrossTonnage = towa.TowageOnArrivalGrossTonnage ?? 0;
|
|
vList.Visit[0].TOWA[i].LengthOverallMTRSpecified = towa.TowageOnArrivalLengthOverall_MTR.HasValue;
|
|
if (towa.TowageOnArrivalLengthOverall_MTR.HasValue)
|
|
vList.Visit[0].TOWA[i].LengthOverallMTR = towa.TowageOnArrivalLengthOverall_MTR.Value;
|
|
vList.Visit[0].TOWA[i].Name = towa.TowageOnArrivalName;
|
|
vList.Visit[0].TOWA[i].PurposeOfCall = towa.TowageOnArrivalPurposeOfCall;
|
|
vList.Visit[0].TOWA[i].Remarks = towa.TowageOnArrivalRemarks;
|
|
vList.Visit[0].TOWA[i].TOWAOperator = new TOWAOperator();
|
|
vList.Visit[0].TOWA[i].TOWAOperator.OperatorCity = towa.TowageOnArrivalOperatorCity;
|
|
vList.Visit[0].TOWA[i].TOWAOperator.OperatorCompanyName = towa.TowageOnArrivalOperatorCompanyName;
|
|
vList.Visit[0].TOWA[i].TOWAOperator.OperatorCountry = towa.TowageOnArrivalOperatorCountry;
|
|
vList.Visit[0].TOWA[i].TOWAOperator.OperatorEMail = towa.TowageOnArrivalOperatorEmail;
|
|
vList.Visit[0].TOWA[i].TOWAOperator.OperatorFax = towa.TowageOnArrivalOperatorFax;
|
|
vList.Visit[0].TOWA[i].TOWAOperator.OperatorPhone = towa.TowageOnArrivalOperatorPhone;
|
|
vList.Visit[0].TOWA[i].TOWAOperator.OperatorPostalCode = towa.TowageOnArrivalOperatorPostalCode;
|
|
vList.Visit[0].TOWA[i].TOWAOperator.OperatorStreetAndNumber = towa.TowageOnArrivalOperatorStreetNameAndNumber;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case Message.NotificationClass.TOWD:
|
|
{
|
|
if (aMessage.Elements.Count > 0)
|
|
{
|
|
vList.Visit[0].TOWD = new TowageDeparture[aMessage.Elements.Count];
|
|
for (int i = 0; i < aMessage.Elements.Count; i++)
|
|
{
|
|
bsmd.database.TOWD towd = aMessage.Elements[i] as bsmd.database.TOWD;
|
|
vList.Visit[0].TOWD[i] = new TowageDeparture();
|
|
vList.Visit[0].TOWD[i].BeamMTRSpecified = towd.TowageOnDepartureBeam_MTR.HasValue;
|
|
if (towd.TowageOnDepartureBeam_MTR.HasValue)
|
|
vList.Visit[0].TOWD[i].BeamMTR = towd.TowageOnDepartureBeam_MTR.Value;
|
|
vList.Visit[0].TOWD[i].DraughtDMTSpecified = towd.TowageOnDepartureDraught_DMT.HasValue;
|
|
if (towd.TowageOnDepartureDraught_DMT.HasValue)
|
|
vList.Visit[0].TOWD[i].DraughtDMT = towd.TowageOnDepartureDraught_DMT.Value;
|
|
vList.Visit[0].TOWD[i].Flag = towd.TowageOnDepartureFlag;
|
|
//vList.Visit[0].TOWD[i].GrossTonnage = towd.TowageOnDepartureGrossTonnage ?? 0;
|
|
//vList.Visit[0].TOWD[i].LengthOverallMTRSpecified = towd.TowageOnDepartureLengthOverall_MTR.HasValue;
|
|
//if (towd.TowageOnDepartureLengthOverall_MTR.HasValue)
|
|
//vList.Visit[0].TOWD[i].LengthOverallMTR = towd.TowageOnDepartureLengthOverall_MTR.Value;
|
|
vList.Visit[0].TOWD[i].Name = towd.TowageOnDepartureName;
|
|
// vList.Visit[0].TOWD[i].PurposeOfCall = towd.TowageOnDeparturePurposeOfCall;
|
|
vList.Visit[0].TOWD[i].Remarks = towd.TowageOnDepartureRemarks;
|
|
vList.Visit[0].TOWD[i].TOWDOperator = new TOWDOperator();
|
|
vList.Visit[0].TOWD[i].TOWDOperator.OperatorCity = towd.TowageOnDepartureOperatorCity;
|
|
vList.Visit[0].TOWD[i].TOWDOperator.OperatorCountry = towd.TowageOnDepartureOperatorCountry;
|
|
vList.Visit[0].TOWD[i].TOWDOperator.OperatorEMail = towd.TowageOnDepartureOperatorEmail;
|
|
vList.Visit[0].TOWD[i].TOWDOperator.OperatorFax = towd.TowageOnDepartureOperatorFax;
|
|
vList.Visit[0].TOWD[i].TOWDOperator.OperatorPhone = towd.TowageOnDepartureOperatorPhone;
|
|
vList.Visit[0].TOWD[i].TOWDOperator.OperatorPostalCode = towd.TowageOnDepartureOperatorPostalCode;
|
|
vList.Visit[0].TOWD[i].TOWDOperator.OperatorStreetAndNumber = towd.TowageOnDepartureOperatorStreetNameAndNumber;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
case Message.NotificationClass.STAT:
|
|
{
|
|
bsmd.database.STAT stat = aMessage.Elements[0] as bsmd.database.STAT;
|
|
vList.Visit[0].STAT = new STAT();
|
|
vList.Visit[0].STAT.ShipName = stat.ShipName;
|
|
vList.Visit[0].STAT.CallSign = stat.CallSign;
|
|
if(!stat.MMSINumber.IsNullOrEmpty())
|
|
vList.Visit[0].STAT.MmsiNumber = stat.MMSINumber;
|
|
vList.Visit[0].STAT.Flag = stat.Flag;
|
|
vList.Visit[0].STAT.LengthOverallMTRSpecified = stat.LengthOverall_MTR.HasValue;
|
|
vList.Visit[0].STAT.LengthOverallMTR = stat.LengthOverall_MTR ?? 0;
|
|
vList.Visit[0].STAT.BeamMTRSpecified = stat.Beam_MTR.HasValue;
|
|
vList.Visit[0].STAT.BeamMTR = stat.Beam_MTR ?? 0;
|
|
vList.Visit[0].STAT.GrossTonnageSpecified = stat.GrossTonnage.HasValue;
|
|
vList.Visit[0].STAT.GrossTonnage = stat.GrossTonnage ?? 0;
|
|
vList.Visit[0].STAT.PortOfRegistry = stat.PortOfRegistry;
|
|
if(!stat.InmarsatCallNumber.IsNullOrEmpty())
|
|
vList.Visit[0].STAT.InmarsatCallNumber = stat.InmarsatCallNumber;
|
|
vList.Visit[0].STAT.ShipType = stat.ShipType;
|
|
vList.Visit[0].STAT.ISMCompany = new ISMCompany();
|
|
vList.Visit[0].STAT.ISMCompany.IsmCompanyName = stat.ISMCompanyName;
|
|
vList.Visit[0].STAT.ISMCompany.IsmCompanyId = stat.ISMCompanyId;
|
|
vList.Visit[0].STAT.ISMCompany.IsmCompanyPostalCode = stat.ISMCompanyPostalCode;
|
|
if (stat.ISMCompanyStreetAndNumber != null)
|
|
{
|
|
int lastBlank = stat.ISMCompanyStreetAndNumber.LastIndexOf(' ');
|
|
if (lastBlank > 0)
|
|
{
|
|
vList.Visit[0].STAT.ISMCompany.IsmCompanyStreetName = stat.ISMCompanyStreetAndNumber.Substring(0, lastBlank);
|
|
vList.Visit[0].STAT.ISMCompany.IsmCompanyStreetNumber = stat.ISMCompanyStreetAndNumber.Substring(lastBlank);
|
|
}
|
|
}
|
|
vList.Visit[0].STAT.ISMCompany.IsmCompanyCity = stat.ISMCompanyCity;
|
|
vList.Visit[0].STAT.ISMCompany.IsmCompanyCountry = stat.ISMCompanyCountry;
|
|
vList.Visit[0].STAT.TransportModeSpecified = !stat.TransportMode.IsNullOrEmpty();
|
|
if(vList.Visit[0].STAT.TransportModeSpecified)
|
|
vList.Visit[0].STAT.TransportMode = (stat.TransportMode == "1") ? TransportModeType.Item1 : TransportModeType.Item8;
|
|
}
|
|
break;
|
|
case Message.NotificationClass.WAS:
|
|
{
|
|
bsmd.database.WAS was = aMessage.Elements[0] as bsmd.database.WAS;
|
|
vList.Visit[0].WAS = new WAS();
|
|
vList.Visit[0].WAS.WasteDisposalValidExemptionSpecified = was.WasteDisposalValidExemption.HasValue;
|
|
vList.Visit[0].WAS.WasteDisposalValidExemption = was.WasteDisposalValidExemption ?? false;
|
|
vList.Visit[0].WAS.LastWasteDisposalPort = was.LastWasteDisposalPort;
|
|
vList.Visit[0].WAS.ConfirmationOfCorrectnessSpecified = was.ConfirmationOfCorrectness.HasValue;
|
|
vList.Visit[0].WAS.ConfirmationOfCorrectness = was.ConfirmationOfCorrectness ?? false;
|
|
vList.Visit[0].WAS.LastWasteDisposalDateSpecified = was.LastWasteDisposalDate.HasValue;
|
|
if (vList.Visit[0].WAS.LastWasteDisposalDateSpecified)
|
|
vList.Visit[0].WAS.LastWasteDisposalDate = was.LastWasteDisposalDate.Value;
|
|
if (was.WasteDisposalServiceProvider.Count > 0)
|
|
{
|
|
vList.Visit[0].WAS.WasteDisposalServiceProviderName = new WasteDisposalServiceProviderName[was.WasteDisposalServiceProvider.Count];
|
|
for (int i = 0; i < was.WasteDisposalServiceProvider.Count; i++)
|
|
{
|
|
vList.Visit[0].WAS.WasteDisposalServiceProviderName[i] = new WasteDisposalServiceProviderName();
|
|
vList.Visit[0].WAS.WasteDisposalServiceProviderName[i].ServiceProviderName = was.WasteDisposalServiceProvider[i].WasteDisposalServiceProviderName;
|
|
}
|
|
}
|
|
vList.Visit[0].WAS.WasteDisposalDeliverySpecified = was.WasteDisposalDelivery.HasValue;
|
|
byte wdd = was.WasteDisposalDelivery ?? 0;
|
|
vList.Visit[0].WAS.WasteDisposalDelivery = WDDTypeFromNSWEnumeration(wdd);
|
|
if (was.Waste.Count > 0)
|
|
{
|
|
vList.Visit[0].WAS.Waste = new Waste[was.Waste.Count];
|
|
for (int i = 0; i < was.Waste.Count; i++)
|
|
{
|
|
bsmd.database.Waste waste = was.Waste[i] as bsmd.database.Waste;
|
|
byte wt = (byte) (waste.WasteType ?? 0);
|
|
vList.Visit[0].WAS.Waste[i] = new Waste();
|
|
vList.Visit[0].WAS.Waste[i].WasteType = Request.setWasteType(wt);
|
|
vList.Visit[0].WAS.Waste[i].Description = waste.WasteDescription;
|
|
vList.Visit[0].WAS.Waste[i].DisposalAmountMTQSpecified = waste.WasteDisposalAmount_MTQ.HasValue;
|
|
vList.Visit[0].WAS.Waste[i].DisposalAmountMTQ = waste.WasteDisposalAmount_MTQ ?? 0;
|
|
vList.Visit[0].WAS.Waste[i].CapacityMTQSpecified = waste.WasteCapacity_MTQ.HasValue;
|
|
vList.Visit[0].WAS.Waste[i].CapacityMTQ = waste.WasteCapacity_MTQ ?? 0;
|
|
vList.Visit[0].WAS.Waste[i].AmountRetainedMTQSpecified = waste.WasteAmountRetained_MTQ.HasValue;
|
|
vList.Visit[0].WAS.Waste[i].AmountRetainedMTQ = waste.WasteAmountRetained_MTQ ?? 0;
|
|
vList.Visit[0].WAS.Waste[i].DisposalPort = waste.WasteDisposalPort;
|
|
vList.Visit[0].WAS.Waste[i].AmountGeneratedTillNextPortMTQSpecified = waste.WasteAmountGeneratedTillNextPort_MTQ.HasValue;
|
|
vList.Visit[0].WAS.Waste[i].AmountGeneratedTillNextPortMTQ = waste.WasteAmountGeneratedTillNextPort_MTQ ?? 0;
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
|
|
case Message.NotificationClass.HAZA:
|
|
case Message.NotificationClass.HAZD:
|
|
{
|
|
bsmd.database.HAZ was = aMessage.Elements[0] as bsmd.database.HAZ;
|
|
_log.InfoFormat("HAZ(A/D) cannot be sent via eDeclaration, skipping message {0}.", was.MessageHeader.Id);
|
|
}
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
// save to temp file
|
|
string fileName = string.Format(".{0}.xml", Guid.NewGuid().ToString());
|
|
string filePath = string.Format(@"{0}\{1}", Properties.Settings.Default.SFTPOutDir, fileName);
|
|
XmlSerializer serializer = new XmlSerializer(typeof(eDeclarationMessage));
|
|
bool serializationFailed = false;
|
|
|
|
using(TextWriter tw = new StreamWriter(filePath)) {
|
|
try
|
|
{
|
|
serializer.Serialize(tw, edm);
|
|
} catch (Exception serEx)
|
|
{
|
|
_log.ErrorFormat("serialization problem: {0}", serEx.ToString());
|
|
serializationFailed = true;
|
|
}
|
|
}
|
|
|
|
if (!serializationFailed)
|
|
{
|
|
// call sftp client to send
|
|
sftp.Put(fileName,
|
|
useTestSystem ? Properties.Settings.Default.RemoteTestIncomingDir : Properties.Settings.Default.RemoteProdIncomingDir);
|
|
}
|
|
|
|
// remove sent file if not test mode
|
|
if (!useTestSystem)
|
|
File.Delete(fileName);
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
_log.ErrorFormat("sending failed:{0}", ex.Message);
|
|
retval = false;
|
|
}
|
|
return retval;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region send complete message core
|
|
/// <summary>
|
|
/// Diese Methode ist aktuell nicht funktional. Beim Testen hat es durch Ändern der participant-Codes auf einmal
|
|
/// auch mit Einzelnachrichten funktioniert, ich behalte das also erstmal bei und verfolge diesen Ansatz (vorerst) nicht weiter.
|
|
/// </summary>
|
|
/// <param name="messages"></param>
|
|
/// <returns></returns>
|
|
public static bool SendAll(List<Message> messages)
|
|
{
|
|
bool result = true;
|
|
|
|
try
|
|
{
|
|
// fill eDeclaration class
|
|
eDeclarationMessage edm = new eDeclarationMessage();
|
|
// edm.Version = "08.15"; // entfernt auf Anraten von Fr. Ebeling 30.6.15
|
|
edm.InterchangeHeader = new InterchangeHeaderType();
|
|
edm.InterchangeHeader.CreationTime = DateTime.UtcNow;
|
|
edm.InterchangeHeader.ExchangeNumber = "tbd";
|
|
edm.InterchangeHeader.TestIndicator = Properties.Settings.Default.TestMode;
|
|
edm.InterchangeHeader.Sender = new Participant();
|
|
edm.InterchangeHeader.Sender.ParticipantCode = new ParticipantCode();
|
|
edm.InterchangeHeader.Sender.ParticipantCode.AgencyID = "DAK";
|
|
edm.InterchangeHeader.Sender.ParticipantCode.Value = "BSM";
|
|
edm.InterchangeHeader.Recipient = new Participant();
|
|
edm.InterchangeHeader.Recipient.ParticipantCode = new ParticipantCode();
|
|
edm.InterchangeHeader.Recipient.ParticipantCode.AgencyID = "DAK";
|
|
edm.InterchangeHeader.Recipient.ParticipantCode.Value = "DAK";
|
|
|
|
eDeclarationMessageInterchangeBody b = new eDeclarationMessageInterchangeBody();
|
|
edm.InterchangeBody = b;
|
|
|
|
// check if visit/transit apply or list of data messages
|
|
|
|
if((messages.Count == 1) && ((messages[0].MessageNotificationClass == Message.NotificationClass.VISIT) ||
|
|
(messages[0].MessageNotificationClass == Message.NotificationClass.TRANSIT))) {
|
|
Request.CreateVisitTransit(b, messages[0]);
|
|
} else {
|
|
|
|
}
|
|
|
|
// save to temp file
|
|
string fileName = string.Format(".{0}.xml", Guid.NewGuid().ToString());
|
|
string filePath = string.Format(@"{0}\{1}", Properties.Settings.Default.SFTPOutDir, fileName);
|
|
XmlSerializer serializer = new XmlSerializer(typeof(eDeclarationMessage));
|
|
using(TextWriter tw = new StreamWriter(filePath)) {
|
|
serializer.Serialize(tw, edm);
|
|
}
|
|
|
|
// call sftp client to send
|
|
sftp.Put(fileName,
|
|
Properties.Settings.Default.TestMode ?
|
|
Properties.Settings.Default.RemoteTestIncomingDir : Properties.Settings.Default.RemoteProdIncomingDir);
|
|
|
|
// remove sent file if not test mode
|
|
if (!Properties.Settings.Default.TestMode)
|
|
File.Delete(fileName);
|
|
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
_log.ErrorFormat("Exception on SendAll:{0}", ex.ToString());
|
|
result = false;
|
|
}
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
#region CreateVisitTransit
|
|
|
|
private static void CreateVisitTransit(eDeclarationMessageInterchangeBody b, Message aMessage)
|
|
{
|
|
eDeclarationMessageInterchangeBodyRequestIdList reqList = new eDeclarationMessageInterchangeBodyRequestIdList();
|
|
b.Item = reqList;
|
|
reqList.RequestId = new RequestId[1];
|
|
reqList.RequestId[0] = new RequestId();
|
|
reqList.RequestId[0].MessageHeader = new MessageHeaderType();
|
|
reqList.RequestId[0].MessageHeader.MessageReferenceNumber = aMessage.Id.Value.ToString("N");
|
|
//reqList.RequestId[0].MessageHeader.CreationTime = DateTime.UtcNow;
|
|
//reqList.RequestId[0].MessageHeader.CreationTimeSpecified = true;
|
|
reqList.RequestId[0].LocalReferenceNumber = aMessage.MessageCore.Id.Value.ToString("N");
|
|
reqList.RequestId[0].OriginatorsVoyageNumber = "tbd";
|
|
reqList.RequestId[0].MessageHeader.MessageRecipient = new Participant();
|
|
reqList.RequestId[0].MessageHeader.MessageRecipient.ParticipantCode = new ParticipantCode();
|
|
reqList.RequestId[0].MessageHeader.MessageRecipient.ParticipantCode.AgencyID = "DAK";
|
|
reqList.RequestId[0].MessageHeader.MessageRecipient.ParticipantCode.Value = "NSW";
|
|
reqList.RequestId[0].MessageHeader.MessageSender = new Participant();
|
|
reqList.RequestId[0].MessageHeader.MessageSender.ParticipantCode = new ParticipantCode();
|
|
reqList.RequestId[0].MessageHeader.MessageSender.ParticipantCode.AgencyID = "DAK";
|
|
reqList.RequestId[0].MessageHeader.MessageSender.ParticipantCode.Value = "BSM"; // TODO -> Absprache!
|
|
reqList.RequestId[0].ReportingParty = new ReportingParty();
|
|
reqList.RequestId[0].ReportingParty.City = aMessage.ReportingParty.City ?? "";
|
|
reqList.RequestId[0].ReportingParty.Country = aMessage.ReportingParty.Country ?? "";
|
|
reqList.RequestId[0].ReportingParty.EMail = aMessage.ReportingParty.EMail ?? "";
|
|
reqList.RequestId[0].ReportingParty.Fax = aMessage.ReportingParty.Fax ?? "";
|
|
reqList.RequestId[0].ReportingParty.FirstName = aMessage.ReportingParty.FirstName ?? "";
|
|
reqList.RequestId[0].ReportingParty.LastName = aMessage.ReportingParty.LastName ?? "";
|
|
reqList.RequestId[0].ReportingParty.Name = aMessage.ReportingParty.Name ?? "";
|
|
reqList.RequestId[0].ReportingParty.Phone = aMessage.ReportingParty.Phone ?? "";
|
|
reqList.RequestId[0].ReportingParty.PostalCode = aMessage.ReportingParty.PostalCode ?? "";
|
|
if (!aMessage.ReportingParty.StreetAndNumber.IsNullOrEmpty())
|
|
{
|
|
int lastBlank = aMessage.ReportingParty.StreetAndNumber.LastIndexOf(' ');
|
|
if (lastBlank > 0)
|
|
{
|
|
reqList.RequestId[0].ReportingParty.StreetName = aMessage.ReportingParty.StreetAndNumber.Substring(0, lastBlank);
|
|
reqList.RequestId[0].ReportingParty.StreetNumber = aMessage.ReportingParty.StreetAndNumber.Substring(lastBlank);
|
|
}
|
|
}
|
|
reqList.RequestId[0].ReportingParty.Type = ReportingPartyType.OTHERS; // TBD
|
|
reqList.RequestId[0].ReportingParty.TypeSpecified = false; // TBD
|
|
|
|
if (aMessage.MessageNotificationClass == Message.NotificationClass.TRANSIT)
|
|
{
|
|
reqList.RequestId[0].REG_TRANSIT = new REG_TRANSIT();
|
|
if(!aMessage.MessageCore.ENI.IsNullOrEmpty())
|
|
reqList.RequestId[0].REG_TRANSIT.EniNumber = aMessage.MessageCore.ENI;
|
|
reqList.RequestId[0].REG_TRANSIT.EtaKielCanal = aMessage.MessageCore.ETA ?? DateTime.Now; // DEBUG: der Fallback sollte nie passieren
|
|
reqList.RequestId[0].REG_TRANSIT.ImoNumber = aMessage.MessageCore.IMO;
|
|
}
|
|
else
|
|
{
|
|
reqList.RequestId[0].REG_VISIT = new REG_VISIT();
|
|
if(!aMessage.MessageCore.ENI.IsNullOrEmpty())
|
|
reqList.RequestId[0].REG_VISIT.EniNumber = aMessage.MessageCore.ENI;
|
|
reqList.RequestId[0].REG_VISIT.EtaPortOfCall = aMessage.MessageCore.ETA ?? DateTime.Now; // DEBUG: der Fallback sollte nie passieren
|
|
reqList.RequestId[0].REG_VISIT.ImoNumber = aMessage.MessageCore.IMO;
|
|
reqList.RequestId[0].REG_VISIT.PortOfCall = aMessage.MessageCore.PoC;
|
|
}
|
|
}
|
|
|
|
private static WasteType setWasteType(byte wasteTypeValue)
|
|
{
|
|
switch (wasteTypeValue)
|
|
{
|
|
case 1:
|
|
return WasteType.WASTE_OILS_SLUDGE_1;
|
|
case 2:
|
|
return WasteType.WASTE_OILS_BILGE_WATER_2;
|
|
case 3:
|
|
return WasteType.WASTE_OILS_OTHERS_3;
|
|
case 4:
|
|
return WasteType.GARBAGE_FOOD_WASTE_4;
|
|
case 5:
|
|
return WasteType.GARBAGE_PLASTIC_5;
|
|
case 6:
|
|
return WasteType.GARBAGE_OTHER_6;
|
|
case 7:
|
|
return WasteType.SEWAGE_7;
|
|
case 8:
|
|
return WasteType.CARGO_ASSOCIATED_WASTE_8;
|
|
default:
|
|
return WasteType.CARGO_RESIDUES_9;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region static enumeration correction funcs
|
|
|
|
// all das nur weil die Blödmänner andere Enums angelegt haben!!!
|
|
|
|
static IdentityDocumentType CrewDocumentFromNSWEnumeration(byte nswValue)
|
|
{
|
|
switch(nswValue)
|
|
{
|
|
case 0: return IdentityDocumentType.IDENTITY_CARD;
|
|
case 1: return IdentityDocumentType.PASSPORT;
|
|
case 2: return IdentityDocumentType.MUSTER_BOOK;
|
|
case 3: return IdentityDocumentType.PICTURE_ID;
|
|
case 4: return IdentityDocumentType.RESIDENTAL_PERMIT;
|
|
default:
|
|
return IdentityDocumentType.OTHER_LEGAL_IDENTITY_DOCUMENT;
|
|
}
|
|
}
|
|
|
|
static GeneralCargoType CargoTypeFromNSWEnumeration(byte nswValue)
|
|
{
|
|
switch(nswValue)
|
|
{
|
|
case 0: return GeneralCargoType.CONTAINER;
|
|
case 1: return GeneralCargoType.VEHICLES;
|
|
case 2: return GeneralCargoType.CONVENTIONAL_GENERAL_CARGO;
|
|
case 3: return GeneralCargoType.DRY_CARGO_IN_BULK;
|
|
case 4: return GeneralCargoType.LIQUID_CARGO_IN_BULK;
|
|
case 5:
|
|
default:
|
|
return GeneralCargoType.EMPTY;
|
|
}
|
|
}
|
|
|
|
static WasteDisposalDeliveryType WDDTypeFromNSWEnumeration(byte nswValue)
|
|
{
|
|
switch(nswValue)
|
|
{
|
|
case 0: return WasteDisposalDeliveryType.ALL;
|
|
case 1: return WasteDisposalDeliveryType.SOME;
|
|
case 2:
|
|
default:
|
|
return WasteDisposalDeliveryType.NONE;
|
|
}
|
|
}
|
|
|
|
static CargoHandlingType CHTFromNSWEnumeration(byte nswValue)
|
|
{
|
|
if (nswValue == 0) return CargoHandlingType.LOAD;
|
|
return CargoHandlingType.DISCHARGE;
|
|
}
|
|
|
|
static ShippingAreaType SATFromNSWEnumeration(byte nswValue)
|
|
{
|
|
switch (nswValue)
|
|
{
|
|
case 0: return ShippingAreaType.NORTH_BALTIC_SEA;
|
|
case 1: return ShippingAreaType.EUROPE;
|
|
default: return ShippingAreaType.OVERSEAS;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
}
|