git_bsmd/nsw/Source/bsmd.dakosy/Request.cs
2015-05-20 20:50:22 +00:00

778 lines
68 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));
public static bool Send(DatabaseEntity dbEntity)
{
bool retval = true;
try
{
Message aMessage = null;
if (dbEntity.GetType().IsAssignableFrom(typeof(Message)))
aMessage = (Message)dbEntity;
else
aMessage = dbEntity.MessageHeader;
// fill eDeclaration class
eDeclarationMessage edm = new eDeclarationMessage();
edm.Version = "08.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)
{
#region VISIT / TRANSIT
case Message.NotificationClass.VISIT:
case Message.NotificationClass.TRANSIT:
{
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.ToString();
reqList.RequestId[0].MessageHeader = new MessageHeaderType();
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;
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();
reqList.RequestId[0].REG_TRANSIT.EniNumber = aMessage.MessageCore.ENI;
reqList.RequestId[0].REG_TRANSIT.EtaKielCanal = aMessage.MessageCore.ETA.Value;
reqList.RequestId[0].REG_TRANSIT.ImoNumber = aMessage.MessageCore.IMO;
}
else
{
reqList.RequestId[0].REG_VISIT = new REG_VISIT();
reqList.RequestId[0].REG_VISIT.EniNumber = aMessage.MessageCore.ENI;
reqList.RequestId[0].REG_VISIT.EtaPortOfCall = aMessage.MessageCore.ETA.Value;
reqList.RequestId[0].REG_VISIT.ImoNumber = aMessage.MessageCore.IMO;
reqList.RequestId[0].REG_VISIT.PortOfCall = aMessage.MessageCore.PoC;
}
}
#endregion
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 = "TBD"; // TODO -> Absprache!
vList.Visit[0].MessageHeader.MessageReferenceNumber = aMessage.Id.Value.ToString("N");
vList.Visit[0].MessageType = MessageType.FULL; // bei DRAFT geht es nicht an das NSW
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 = "TBD"; // 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 = false; // TBD
switch (aMessage.MessageNotificationClass)
{
case Message.NotificationClass.NOA_NOD:
bsmd.database.NOA_NOD noa_nod = dbEntity 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;
vList.Visit[0].NOA_NOD.CallPurpose = new CallPurpose[1];
if (noa_nod.CallPurposeCode.HasValue) // TBD: wir haben nur einen CallPurposeCode, hier gibt es mehrere?
{
vList.Visit[0].NOA_NOD.CallPurpose[0].CallPurposeCode = noa_nod.CallPurposeCode.Value;
vList.Visit[0].NOA_NOD.CallPurpose[0].CallPurposeDescription = noa_nod.CallPurposeDescription;
}
break;
case Message.NotificationClass.ATA:
bsmd.database.ATA ata = dbEntity 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 = dbEntity 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 = dbEntity 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++)
{
if (bpol.PortOfItineraries[i].PortOfItineraryETA.HasValue)
vList.Visit[0].BPOL.PortOfItinerary[i].PortOfItineraryETA = bpol.PortOfItineraries[i].PortOfItineraryETA.Value;
vList.Visit[0].BPOL.PortOfItinerary[i].PortOfItineraryName = bpol.PortOfItineraries[i].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: // TBD: dito
{
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 = (CargoHandlingType)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: // TBD: dito
{
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 = (GenderType)gender;
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 = (IdentityDocumentType)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 = dbEntity 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 = dbEntity 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 = dbEntity as bsmd.database.INFO;
vList.Visit[0].INFO = new INFO();
if(info.ShippingArea.HasValue)
vList.Visit[0].INFO.ShippingArea = (ShippingAreaType)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;
break;
case Message.NotificationClass.MDH:
bsmd.database.MDH mdh = dbEntity 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;
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;
vList.Visit[0].MDH.SanitaryMeasuresDetails = new SanitaryMeasuresDetails();
vList.Visit[0].MDH.SanitaryMeasuresDetails.SanitaryMeasuresType = mdh.SanitaryMeasuresType;
vList.Visit[0].MDH.SanitaryMeasuresDetails.SanitaryMeasuresLocation = mdh.SanitaryMeasuresLocation;
if (mdh.SanitaryMeasuresDate.HasValue)
vList.Visit[0].MDH.SanitaryMeasuresDetails.SanitaryMeasuresDate = mdh.SanitaryMeasuresDate.Value;
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;
vList.Visit[0].MDH.InfectedArea = new InfectedArea();
if (mdh.InfectedAreaDate.HasValue)
vList.Visit[0].MDH.InfectedArea.InfectedAreaDate = mdh.InfectedAreaDate.Value;
vList.Visit[0].MDH.InfectedArea.InfectedAreaPort = mdh.InfectedAreaPort;
if (mdh.PortOfCallLast30Days.Count > 0)
{
vList.Visit[0].MDH.PortsOfCallLast30Days = new PortOfCallLast30Days[mdh.PortOfCallLast30Days.Count];
for (int i = 0; i < mdh.PortOfCallLast30Days.Count; i++)
{
vList.Visit[0].MDH.PortsOfCallLast30Days[i] = new PortOfCallLast30Days();
vList.Visit[0].MDH.PortsOfCallLast30Days[i].Locode = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysLocode;
if (mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.HasValue)
vList.Visit[0].MDH.PortsOfCallLast30Days[i].DateOfDeparture = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.Value;
if (mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined.HasValue)
{
vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewMembersJoined = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined.Value;
if(mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count > 0) {
vList.Visit[0].MDH.PortsOfCallLast30Days[i].CrewJoinedShipName = new CrewJoinedShipName[mdh.PortOfCallLast30Days[i].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 = mdh.PortOfCallLast30Days[i].CrewJoinedShip[j].PortOfCallLast30DaysCrewJoinedShipName;
}
}
}
}
}
break;
case Message.NotificationClass.NAME:
bsmd.database.NAME name = dbEntity 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 = (GenderType)pas.PassengerGender.Value;
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 = (IdentityDocumentType)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 = dbEntity 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 = dbEntity 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 = dbEntity 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 = dbEntity 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;
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 = (GeneralCargoType)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();
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].PortName = sec.LastTenPortFacilitesCalled[i].PortFacilityPortName;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].PortCountry = sec.LastTenPortFacilitesCalled[i].PortFacilityPortCountry;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].PortLoCode = sec.LastTenPortFacilitesCalled[i].PortFacilityPortLoCode;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfArrivalSpecified = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.HasValue;
if (sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.HasValue)
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfArrival = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.Value;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfDepartureSpecified = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.HasValue;
if (sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.HasValue)
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].DateOfDeparture = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.Value;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].ShipSecurityLevelSpecified = sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.HasValue;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].ShipSecurityLevel = sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel ?? 0;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].SecurityMattersToReport = sec.LastTenPortFacilitesCalled[i].PortFacilitySecurityMattersToReport;
vList.Visit[0].SEC.LastTenPortFacilitiesCalled[i].GISISCode = sec.LastTenPortFacilitesCalled[i].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++)
{
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationName = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationName;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCode = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationLoCode;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLatitudeSpecified = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude.HasValue;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLatitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude ?? 0;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLongitudeSpecified = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude.HasValue;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].LocationCoordinatesLongitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude ?? 0;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateFromSpecified = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.HasValue;
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.HasValue)
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateFrom = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.Value;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateToSpecified = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.HasValue;
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.HasValue)
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].DateTo = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.Value;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ActivityType = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityType;
vList.Visit[0].SEC.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].SecurityMattersToReport = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].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 = dbEntity as bsmd.database.STAT;
vList.Visit[0].STAT = new STAT();
vList.Visit[0].STAT.ShipName = stat.ShipName;
vList.Visit[0].STAT.CallSign = stat.CallSign;
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;
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;
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;
}
break;
case Message.NotificationClass.WAS:
{
bsmd.database.WAS was = dbEntity 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].ServiceProviderName = was.WasteDisposalServiceProvider[i].WasteDisposalServiceProviderName;
}
}
vList.Visit[0].WAS.WasteDisposalDeliverySpecified = was.WasteDisposalDelivery.HasValue;
byte wdd = was.WasteDisposalDelivery ?? 0;
vList.Visit[0].WAS.WasteDisposalDelivery = (WasteDisposalDeliveryType) 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++)
{
byte wt = was.Waste[i].WasteType ?? 0;
vList.Visit[0].WAS.Waste[i].WasteType = (WasteType)wt;
vList.Visit[0].WAS.Waste[i].Description = was.Waste[i].WasteDescription;
vList.Visit[0].WAS.Waste[i].DisposalAmountMTQSpecified = was.Waste[i].WasteDisposalAmount_MTQ.HasValue;
vList.Visit[0].WAS.Waste[i].DisposalAmountMTQ = was.Waste[i].WasteDisposalAmount_MTQ ?? 0;
vList.Visit[0].WAS.Waste[i].CapacityMTQSpecified = was.Waste[i].WasteCapacity_MTQ.HasValue;
vList.Visit[0].WAS.Waste[i].CapacityMTQ = was.Waste[i].WasteCapacity_MTQ ?? 0;
vList.Visit[0].WAS.Waste[i].AmountRetainedMTQSpecified = was.Waste[i].WasteAmountRetained_MTQ.HasValue;
vList.Visit[0].WAS.Waste[i].AmountRetainedMTQ = was.Waste[i].WasteAmountRetained_MTQ ?? 0;
vList.Visit[0].WAS.Waste[i].DisposalPort = was.Waste[i].WasteDisposalPort;
vList.Visit[0].WAS.Waste[i].AmountGeneratedTillNextPortMTQSpecified = was.Waste[i].WasteAmountGeneratedTillNextPort_MTQ.HasValue;
vList.Visit[0].WAS.Waste[i].AmountGeneratedTillNextPortMTQ = was.Waste[i].WasteAmountGeneratedTillNextPort_MTQ ?? 0;
}
}
}
break;
}
break;
}
// save to temp file
string fileName = string.Format(@"{0}\{1}.xml", Properties.Settings.Default.SFTPOutDir, Guid.NewGuid().ToString());
XmlSerializer serializer = new XmlSerializer(typeof(eDeclarationMessage));
using(TextWriter tw = new StreamWriter(fileName)) {
serializer.Serialize(tw, edm);
}
// call sftp client to send
sftp.Put(fileName);
// remove sent file if not test mode
if (!Properties.Settings.Default.TestMode)
File.Delete(fileName);
}
catch(Exception ex)
{
_log.ErrorFormat("sending failed:{0}", ex.Message);
retval = false;
}
return retval;
}
}
}