863 lines
60 KiB
C#
863 lines
60 KiB
C#
//
|
||
// Class: Request
|
||
// Current CLR: 4.0.30319.34209
|
||
// System: Microsoft Visual Studio 10.0
|
||
// Author: dani
|
||
// Created: 7/6/2015 7:04:01 PM
|
||
//
|
||
// 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.hisnord
|
||
{
|
||
public class Request
|
||
{
|
||
private static ILog _log = LogManager.GetLogger(typeof(Request));
|
||
|
||
public static bool Send(List<Message> messages)
|
||
{
|
||
bool retval = true;
|
||
|
||
try
|
||
{
|
||
nsw _nsw = new nsw();
|
||
_nsw.conveyance = new conveyance();
|
||
|
||
#region general info area
|
||
|
||
_nsw.date_registration = DateTime.Now; // dient zur Sequenzierung der Nachrichten
|
||
_nsw.message_sender = "BSMD";
|
||
_nsw.message_recipient = "HIS-NORD";
|
||
_nsw.conveyance.owner_sender = new broker_owner();
|
||
_nsw.conveyance.owner_sender.contact = new contacts();
|
||
|
||
// das hier ist der e-mail(!) Empfänger für Error/Violation Meldungen
|
||
_nsw.conveyance.owner_sender.contact.name = "BSMD";
|
||
_nsw.conveyance.owner_sender.contact.email = "nsw@textbausteine.de";
|
||
_nsw.conveyance.owner_sender.contact.firstname = "Daniel Schick";
|
||
_nsw.conveyance.owner_sender.contact.phone = "0171 641 6421";
|
||
_nsw.conveyance.owner_sender.contact.fax = "+49 (0)421 – 38 08 887";
|
||
|
||
if (messages[0].MessageCore.Customer != null)
|
||
{
|
||
_nsw.conveyance.owner_sender.name_short = messages[0].MessageCore.Customer.Name;
|
||
_nsw.conveyance.owner_sender.name_long = messages[0].MessageCore.Customer.Name;
|
||
|
||
_nsw.conveyance.owner_sender.address = new addresstype();
|
||
_nsw.conveyance.owner_sender.address.StreetNumber = messages[0].MessageCore.Customer.StreetAndNumber;
|
||
_nsw.conveyance.owner_sender.address.PostCode = messages[0].MessageCore.Customer.PostalCode;
|
||
_nsw.conveyance.owner_sender.address.Place = messages[0].MessageCore.Customer.City;
|
||
}
|
||
|
||
_nsw.conveyance.vessel = new vesseltype();
|
||
_nsw.conveyance.vessel.ENINumber = messages[0].MessageCore.ENI;
|
||
_nsw.conveyance.vessel.IMONumber = messages[0].MessageCore.IMO;
|
||
|
||
_nsw.document_reference = messages[0].MessageCore.Id.Value.ToString();
|
||
|
||
_nsw.conveyance.Items = new string[1];
|
||
_nsw.conveyance.ItemsElementName = new ItemsChoiceType[1];
|
||
if (!messages[0].MessageCore.VisitId.IsNullOrEmpty())
|
||
{
|
||
_nsw.conveyance.Items[0] = messages[0].MessageCore.VisitId;
|
||
_nsw.conveyance.ItemsElementName[0] = ItemsChoiceType.VisitId;
|
||
}
|
||
else if (!messages[0].MessageCore.TransitId.IsNullOrEmpty())
|
||
{
|
||
_nsw.conveyance.Items[0] = messages[0].MessageCore.TransitId;
|
||
_nsw.conveyance.ItemsElementName[0] = ItemsChoiceType.TransitId;
|
||
}
|
||
else // liegt noch nix vor
|
||
{
|
||
_nsw.conveyance.Items[0] = messages[0].MessageCore.Id.ToString();
|
||
_nsw.conveyance.ItemsElementName[0] = ItemsChoiceType.code;
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region NSW message area
|
||
|
||
foreach (Message message in messages)
|
||
{
|
||
|
||
switch (message.MessageNotificationClass)
|
||
{
|
||
case Message.NotificationClass.VISIT:
|
||
|
||
break;
|
||
case Message.NotificationClass.TRANSIT:
|
||
|
||
break;
|
||
|
||
#region ATA/ATD
|
||
case Message.NotificationClass.ATA:
|
||
if (message.MessageCore.Incoming)
|
||
{
|
||
import _import = null;
|
||
portofcallhazmat _poc = null;
|
||
if (_nsw.conveyance.Item != null)
|
||
{
|
||
_import = _nsw.conveyance.Item as import;
|
||
if (_import.PortOfCall != null)
|
||
{
|
||
_poc = _import.PortOfCall;
|
||
}
|
||
else
|
||
{
|
||
_poc = new portofcallhazmat();
|
||
_import.PortOfCall = _poc;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
_import = new import();
|
||
_nsw.conveyance.Item = _import;
|
||
_poc = new portofcallhazmat();
|
||
_import.PortOfCall = _poc;
|
||
}
|
||
ATA ata = message.Elements[0] as ATA;
|
||
if (ata != null)
|
||
{
|
||
if (ata.ATAPortOfCall.HasValue)
|
||
_import.PortOfCall.ATA = ata.ATAPortOfCall.Value;
|
||
_import.PortOfCall.ATASpecified = ata.ATAPortOfCall.HasValue;
|
||
}
|
||
}
|
||
break;
|
||
case Message.NotificationClass.ATD:
|
||
if (!message.MessageCore.Incoming)
|
||
{
|
||
export _export = null;
|
||
portofcallhazmat _poc = null;
|
||
if (_nsw.conveyance.Item != null)
|
||
{
|
||
_export = _nsw.conveyance.Item as export;
|
||
if (_export.PortOfCall != null)
|
||
{
|
||
_poc = _export.PortOfCall;
|
||
}
|
||
else
|
||
{
|
||
_poc = new portofcallhazmat();
|
||
_export.PortOfCall = _poc;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
_export = new export();
|
||
_nsw.conveyance.Item = _export;
|
||
_poc = new portofcallhazmat();
|
||
_export.PortOfCall = _poc;
|
||
}
|
||
ATD atd = message.Elements[0] as ATD;
|
||
if (atd != null)
|
||
{
|
||
if (atd.ATDPortOfCall.HasValue)
|
||
_export.PortOfCall.ATD = atd.ATDPortOfCall.Value;
|
||
_export.PortOfCall.ATDSpecified = atd.ATDPortOfCall.HasValue;
|
||
}
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region BKRA/BKRD
|
||
case Message.NotificationClass.BKRA:
|
||
if (message.MessageCore.Incoming)
|
||
{
|
||
if (message.Elements.Count > 0)
|
||
{
|
||
_nsw.conveyance.BunkerFuelList = new bunkerfuel[message.Elements.Count];
|
||
for (int i = 0; i < message.Elements.Count; i++)
|
||
{
|
||
BRKA brka = message.Elements[i] as BRKA;
|
||
_nsw.conveyance.BunkerFuelList[i] = new bunkerfuel();
|
||
_nsw.conveyance.BunkerFuelList[i].Name = brka.BunkerFuelType;
|
||
if (brka.BunkerFuelQuantity_TNE.HasValue)
|
||
_nsw.conveyance.BunkerFuelList[i].NetMassTNE = (float)brka.BunkerFuelQuantity_TNE.Value;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case Message.NotificationClass.BKRD:
|
||
if (!message.MessageCore.Incoming)
|
||
{
|
||
if (message.Elements.Count > 0)
|
||
{
|
||
_nsw.conveyance.BunkerFuelList = new bunkerfuel[message.Elements.Count];
|
||
for (int i = 0; i < message.Elements.Count; i++)
|
||
{
|
||
BRKD brkd = message.Elements[i] as BRKD;
|
||
_nsw.conveyance.BunkerFuelList[i] = new bunkerfuel();
|
||
_nsw.conveyance.BunkerFuelList[i].Name = brkd.BunkerFuelType;
|
||
if (brkd.BunkerFuelQuantity_TNE.HasValue)
|
||
_nsw.conveyance.BunkerFuelList[i].NetMassTNE = (float)brkd.BunkerFuelQuantity_TNE.Value;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region BPOL
|
||
case Message.NotificationClass.BPOL:
|
||
if (message.Elements.Count > 0)
|
||
{
|
||
BPOL bpol = message.Elements[0] as BPOL;
|
||
_nsw.conveyance.BPOL = new bpol();
|
||
_nsw.conveyance.BPOL.StowawayOnBoard = (bpol.StowawaysOnBoard ?? false) ? yorntype.Y : yorntype.N;
|
||
if (!bpol.PortOfItineraries.IsNullOrEmpty())
|
||
{
|
||
_nsw.conveyance.BPOL.PortsOfItinery = new portofitinery[bpol.PortOfItineraries.Count];
|
||
for (int i = 0; i < bpol.PortOfItineraries.Count; i++)
|
||
{
|
||
_nsw.conveyance.BPOL.PortsOfItinery[i] = new portofitinery();
|
||
_nsw.conveyance.BPOL.PortsOfItinery[i].PortOfItineryName = bpol.PortOfItineraries[i].PortOfItineraryName;
|
||
if (bpol.PortOfItineraries[i].PortOfItineraryETA.HasValue)
|
||
_nsw.conveyance.BPOL.PortsOfItinery[i].PortOfItineryETA = bpol.PortOfItineraries[i].PortOfItineraryETA.Value;
|
||
_nsw.conveyance.BPOL.PortsOfItinery[i].Index = (i+1).ToString();
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region CREW
|
||
case Message.NotificationClass.CREW:
|
||
if (message.Elements.Count > 0)
|
||
{
|
||
_nsw.conveyance.CREW = new crew();
|
||
_nsw.conveyance.CREW.CrewMembers = new crewmember[message.Elements.Count];
|
||
for (int i = 0; i < message.Elements.Count; i++)
|
||
{
|
||
CREW crew = message.Elements[i] as CREW;
|
||
_nsw.conveyance.CREW.CrewMembers[i] = new crewmember();
|
||
if (crew.CrewMemberDateOfBirth.HasValue)
|
||
_nsw.conveyance.CREW.CrewMembers[i].CrewMemberDateOfBirth = crew.CrewMemberDateOfBirth.Value;
|
||
_nsw.conveyance.CREW.CrewMembers[i].CrewMemberDuty = crew.CrewMemberDuty;
|
||
_nsw.conveyance.CREW.CrewMembers[i].CrewMemberFirstName = crew.CrewMemberFirstName;
|
||
if (crew.CrewMemberGender.HasValue)
|
||
_nsw.conveyance.CREW.CrewMembers[i].CrewMemberGender = (gendertype)crew.CrewMemberGender.Value;
|
||
_nsw.conveyance.CREW.CrewMembers[i].CrewMemberGenderSpecified = crew.CrewMemberGender.HasValue;
|
||
_nsw.conveyance.CREW.CrewMembers[i].CrewMemberIdentityDocumentId = crew.CrewMemberIdentityDocumentId;
|
||
if (crew.CrewMemberIdentityDocumentType.HasValue)
|
||
_nsw.conveyance.CREW.CrewMembers[i].CrewMemberIdentityDocumentType = (documenttype)crew.CrewMemberIdentityDocumentType.Value;
|
||
_nsw.conveyance.CREW.CrewMembers[i].CrewMemberLastName = crew.CrewMemberLastName;
|
||
_nsw.conveyance.CREW.CrewMembers[i].CrewMemberNationality = crew.CrewMemberNationality;
|
||
_nsw.conveyance.CREW.CrewMembers[i].CrewMemberPlaceOfBirth = crew.CrewMemberPlaceOfBirth;
|
||
_nsw.conveyance.CREW.CrewMembers[i].CrewMemberVisaNumber = crew.CrewMemberVisaNumber;
|
||
}
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
case Message.NotificationClass.HAZA:
|
||
// abh. von LADG!
|
||
break;
|
||
case Message.NotificationClass.HAZD:
|
||
// abh. von LADG!
|
||
break;
|
||
|
||
#region INFO
|
||
case Message.NotificationClass.INFO:
|
||
INFO info = message.Elements[0] as INFO;
|
||
_nsw.conveyance.Info = new info();
|
||
_nsw.conveyance.Info.ConstructionCharacteristicsOfShip = info.ConstructionCharacteristicsOfShip;
|
||
if (info.DeplacementSummerDraught_TNE.HasValue)
|
||
_nsw.conveyance.Info.DeadWeightSummer_TNE = (float)info.DeplacementSummerDraught_TNE.Value;
|
||
_nsw.conveyance.Info.DeadWeightSummer_TNESpecified = info.DeplacementSummerDraught_TNE.HasValue;
|
||
if (info.FumigatedBulkCargo.HasValue)
|
||
_nsw.conveyance.Info.FumigatedBulkCargo = (info.FumigatedBulkCargo.Value == 1) ? yorntype.Y : yorntype.N;
|
||
_nsw.conveyance.Info.RequestedPositionInPortOfCall = info.RequestedPositionInPortOfCall;
|
||
if (info.ShippingArea.HasValue)
|
||
_nsw.conveyance.Info.ShippingArea = (shippingareatype)info.ShippingArea.Value;
|
||
_nsw.conveyance.Info.SpecialRequirementsOfShipAtBerth = info.SpecialRequirementsOfShipAtBerth;
|
||
break;
|
||
#endregion
|
||
|
||
#region LADG
|
||
case Message.NotificationClass.LADG:
|
||
if (message.Elements.Count > 0)
|
||
{
|
||
_nsw.conveyance.GeneralCargo = new loadunit[message.Elements.Count];
|
||
for (int i = 0; i < message.Elements.Count; i++)
|
||
{
|
||
LADG ladg = message.Elements[i] as LADG;
|
||
loadunit lu = new loadunit();
|
||
lu.CargoCodeNST = ladg.CargoCodeNST;
|
||
if (ladg.CargoGrossQuantity_TNE.HasValue)
|
||
lu.CargoGrossQuantity_TNE = (float)ladg.CargoGrossQuantity_TNE.Value;
|
||
if (ladg.CargoNumberOfItems.HasValue)
|
||
lu.CargoNumberOfItems = ladg.CargoNumberOfItems.Value.ToString();
|
||
if (ladg.CargoHandlingType.HasValue)
|
||
lu.HandlingCode = (handlingcodetype)ladg.CargoHandlingType.Value;
|
||
_nsw.conveyance.GeneralCargo[i] = lu;
|
||
}
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region MDH
|
||
case Message.NotificationClass.MDH:
|
||
MDH mdh = message.Elements[0] as MDH;
|
||
if (mdh.MDHSimplification.HasValue && mdh.MDHSimplification.Value)
|
||
{
|
||
_nsw.conveyance.Items3 = new object[2];
|
||
_nsw.conveyance.Items3[0] = ytype.Y;
|
||
_nsw.conveyance.Items3[1] = mdh.PortOfCallWhereCompleteMDHNotified;
|
||
}
|
||
else
|
||
{
|
||
_nsw.conveyance.Items3 = new object[1];
|
||
mdh _mdh = new mdh();
|
||
if (mdh.AwareOfFurtherInfections.HasValue)
|
||
_mdh.AwareOfConditionsForFurtherInfections = mdh.AwareOfFurtherInfections.Value ? yorntype.Y : yorntype.N;
|
||
_mdh.InfectedArea = new infectedarea();
|
||
if (mdh.InfectedAreaDate.HasValue)
|
||
_mdh.InfectedArea.InfectedAreaDate = mdh.InfectedAreaDate.Value;
|
||
_mdh.InfectedArea.InfectedAreaPort = mdh.InfectedAreaPort;
|
||
if (mdh.InfectedAreaVisited.HasValue)
|
||
_mdh.InfectedAreaVisited = mdh.InfectedAreaVisited.Value ? yorntype.Y : yorntype.N;
|
||
if (mdh.MedicalConsulted.HasValue)
|
||
_mdh.MedicalConsulted = mdh.MedicalConsulted.Value ? yorntype.Y : yorntype.N;
|
||
if (mdh.NonAccidentalDeathsDuringVoyage.HasValue)
|
||
_mdh.NonAccidentialDeathsDuringVoyage = mdh.NonAccidentalDeathsDuringVoyage.Value ? yorntype.Y : yorntype.N;
|
||
if (mdh.NonAccidentalDeathsDuringVoyageCount.HasValue)
|
||
_mdh.NonAccidentialDeathsDuringVoyageCount = mdh.NonAccidentalDeathsDuringVoyageCount.Value.ToString();
|
||
if (mdh.NumberOfIllPersons.HasValue)
|
||
_mdh.NumberOfIllPersons = mdh.NumberOfIllPersons.Value.ToString();
|
||
if (mdh.NumberOfIllPersonsHigherThanExpected.HasValue)
|
||
_mdh.NumberOfIllPersonsHigherThanExpected = mdh.NumberOfIllPersonsHigherThanExpected.Value ? yorntype.Y : yorntype.N;
|
||
if (mdh.PortOfCallLast30Days.Count > 0)
|
||
{
|
||
_mdh.PortsOfCallLast30Days = new portofcallmdh[mdh.PortOfCallLast30Days.Count];
|
||
for (int i = 0; i < mdh.PortOfCallLast30Days.Count; i++)
|
||
{
|
||
_mdh.PortsOfCallLast30Days[i] = new portofcallmdh();
|
||
_mdh.PortsOfCallLast30Days[i].Index = i.ToString();
|
||
if (mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count > 0)
|
||
{
|
||
_mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip = new string[mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count];
|
||
for (int j = 0; j < mdh.PortOfCallLast30Days[i].CrewJoinedShip.Count; j++)
|
||
{
|
||
_mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysCrewJoinedShip[j] = mdh.PortOfCallLast30Days[i].CrewJoinedShip[j].PortOfCallLast30DaysCrewJoinedShipName;
|
||
}
|
||
}
|
||
if (mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined.HasValue)
|
||
_mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysCrewMembersJoined.Value ? yorntype.Y : yorntype.N;
|
||
if (mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.HasValue)
|
||
_mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysDateOfDeparture.Value;
|
||
_mdh.PortsOfCallLast30Days[i].PortOfCallLast30DaysLocode = mdh.PortOfCallLast30Days[i].PortOfCallLast30DaysLocode;
|
||
}
|
||
}
|
||
if (mdh.SanitaryControlReinspectionRequired.HasValue)
|
||
_mdh.SanitaryControlReinspectionRequired = mdh.SanitaryControlReinspectionRequired.Value ? yorntype.Y : yorntype.N;
|
||
if (mdh.SanitaryMeasuresApplied.HasValue)
|
||
_mdh.SanitaryMeasuresApplied = mdh.SanitaryMeasuresApplied.Value ? yorntype.Y : yorntype.N;
|
||
_mdh.SanitaryMeasuresDetails = new sanitarydetails();
|
||
if (mdh.SanitaryMeasuresDate.HasValue)
|
||
_mdh.SanitaryMeasuresDetails.SanitaryMeasuresDate = mdh.SanitaryMeasuresDate.Value;
|
||
_mdh.SanitaryMeasuresDetails.SanitaryMeasuresLocation = mdh.SanitaryMeasuresLocation;
|
||
_mdh.SanitaryMeasuresDetails.SanitaryMeasuresType = mdh.SanitaryMeasuresType;
|
||
if (mdh.SickAnimalOrPetOnBoard.HasValue)
|
||
_mdh.SickAnimalOrPetOnBoard = mdh.SickAnimalOrPetOnBoard.Value ? yorntype.Y : yorntype.N;
|
||
if (mdh.SickPersonsOnBoard.HasValue)
|
||
_mdh.SickPersonOnBoard = mdh.SickPersonsOnBoard.Value ? yorntype.Y : yorntype.N;
|
||
_mdh.StowawayJoiningLocation = mdh.StowawaysJoiningLocation;
|
||
if (mdh.StowawaysDetected.HasValue)
|
||
_mdh.StowawaysDetected = mdh.StowawaysDetected.Value ? yorntype.Y : yorntype.N;
|
||
if (mdh.SuspisionInfectiousNature.HasValue)
|
||
_mdh.SuspisionInfectiousNature = mdh.SuspisionInfectiousNature.Value ? yorntype.Y : yorntype.N;
|
||
if (mdh.ValidSanitaryControlExemptionOrCertificateOnBoard.HasValue)
|
||
_mdh.ValidSanitaryControlExemptionOrCertificateOnBoard = mdh.ValidSanitaryControlExemptionOrCertificateOnBoard.Value ? yorntype.Y : yorntype.N;
|
||
_mdh.ValidSanitaryControlExemptionOrCertificate = new sanitarycertificate();
|
||
if (mdh.DateOfIssue.HasValue)
|
||
_mdh.ValidSanitaryControlExemptionOrCertificate.DateOfIssue = mdh.DateOfIssue.Value;
|
||
_mdh.ValidSanitaryControlExemptionOrCertificate.PlaceOfIssue = mdh.PlaceOfIssue;
|
||
|
||
_nsw.conveyance.Items3[0] = _mdh;
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region NAME
|
||
case Message.NotificationClass.NAME:
|
||
NAME name = message.Elements[0] as NAME;
|
||
_nsw.conveyance.NameOfMaster = name.NameOfMaster;
|
||
break;
|
||
#endregion
|
||
|
||
#region NOA_NOD
|
||
case Message.NotificationClass.NOA_NOD:
|
||
NOA_NOD noa_nod = message.Elements[0] as NOA_NOD;
|
||
|
||
if (message.MessageCore.IsTransit)
|
||
{
|
||
transit _transit = _nsw.conveyance.Item as transit;
|
||
|
||
_transit.LastPort = new lastport();
|
||
if (noa_nod.ETDFromLastPort.HasValue)
|
||
_transit.LastPort.ETD = noa_nod.ETDFromLastPort.Value;
|
||
_transit.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue;
|
||
_transit.LastPort.Locode = noa_nod.LastPort;
|
||
|
||
_transit.NextPort = new nextporthazmat();
|
||
if (noa_nod.ETAToNextPort.HasValue)
|
||
_transit.NextPort.ETA = noa_nod.ETAToNextPort.Value;
|
||
_transit.NextPort.ETASpecified = noa_nod.ETAToNextPort.HasValue;
|
||
_transit.NextPort.Locode = noa_nod.NextPort;
|
||
}
|
||
else if (message.MessageCore.Incoming) // einlaufend
|
||
{
|
||
import _import = _nsw.conveyance.Item as import;
|
||
_import.LastPort = new lastport();
|
||
if (noa_nod.ETDFromLastPort.HasValue)
|
||
_import.LastPort.ETD = noa_nod.ETDFromLastPort.Value;
|
||
_import.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue;
|
||
_import.LastPort.Locode = noa_nod.LastPort;
|
||
_import.PortOfCall = new portofcallhazmat();
|
||
if (noa_nod.ETAToPortOfCall.HasValue)
|
||
_import.PortOfCall.ETA = noa_nod.ETAToPortOfCall.Value;
|
||
if (noa_nod.ETDFromPortOfCall.HasValue)
|
||
_import.PortOfCall.ETD = noa_nod.ETDFromPortOfCall.Value;
|
||
_import.PortOfCall.Locode = message.MessageCore.PoC;
|
||
|
||
}
|
||
else // auslaufend
|
||
{
|
||
export _export = _nsw.conveyance.Item as export;
|
||
_export.NextPort = new nextporthazmat();
|
||
if (noa_nod.ETAToNextPort.HasValue)
|
||
_export.NextPort.ETA = noa_nod.ETAToNextPort.Value;
|
||
_export.NextPort.ETASpecified = noa_nod.ETAToNextPort.HasValue;
|
||
_export.NextPort.Locode = noa_nod.NextPort;
|
||
_export.PortOfCall = new portofcallhazmat();
|
||
if (noa_nod.ETAToPortOfCall.HasValue)
|
||
_export.PortOfCall.ETA = noa_nod.ETAToPortOfCall.Value;
|
||
if (noa_nod.ETDFromPortOfCall.HasValue)
|
||
_export.PortOfCall.ETD = noa_nod.ETDFromPortOfCall.Value;
|
||
_export.PortOfCall.Locode = message.MessageCore.PoC;
|
||
}
|
||
|
||
break;
|
||
#endregion
|
||
|
||
#region PAS
|
||
case Message.NotificationClass.PAS:
|
||
if (message.Elements.Count > 0)
|
||
{
|
||
_nsw.conveyance.PAS = new pas();
|
||
_nsw.conveyance.PAS.Passengers = new passenger[message.Elements.Count];
|
||
for (int i = 0; i < message.Elements.Count; i++)
|
||
{
|
||
PAS pas = message.Elements[i] as PAS;
|
||
_nsw.conveyance.PAS.Passengers[i] = new passenger();
|
||
if (pas.PassengerDateOfBirth.HasValue)
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerDateOfBirth = pas.PassengerDateOfBirth.Value;
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerFirstName = pas.PassengerFirstName;
|
||
if (pas.PassengerGender.HasValue)
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerGender = (gendertype)pas.PassengerGender.Value;
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerGenderSpecified = pas.PassengerGender.HasValue;
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerIdentityDocumentId = pas.PassengerIdentityDocumentId;
|
||
if (pas.PassengerIdentityDocumentType.HasValue)
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerIdentityDocumentType = (documenttype)pas.PassengerIdentityDocumentType.Value;
|
||
if (pas.PassengerInTransit.HasValue)
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerInTransit = pas.PassengerInTransit.Value ? yorntype.Y : yorntype.N;
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerLastName = pas.PassengerLastName;
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerNationality = pas.PassengerNationality;
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerPlaceOfBirth = pas.PassengerPlaceOfBirth;
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerPortOfDisembarkation = pas.PassengerPortOfDisembarkation;
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerPortOfEmbarkation = pas.PassengerPortOfEmbarkation;
|
||
_nsw.conveyance.PAS.Passengers[i].PassengerVisaNumber = pas.PassengerVisaNumber;
|
||
}
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region POBA
|
||
case Message.NotificationClass.POBA:
|
||
if (message.MessageCore.Incoming)
|
||
{
|
||
POBA poba = message.Elements[0] as POBA;
|
||
_nsw.conveyance.PersonsOnBoard = new pob();
|
||
if (poba.TotalCrewMembersOnBoardUponArrival.HasValue)
|
||
_nsw.conveyance.PersonsOnBoard.TotalCrewMembersOnBoard = poba.TotalCrewMembersOnBoardUponArrival.Value.ToString();
|
||
if (poba.TotalPassengersOnBoardUponArrival.HasValue)
|
||
_nsw.conveyance.PersonsOnBoard.TotalPassengersOnBoard = poba.TotalPassengersOnBoardUponArrival.Value.ToString();
|
||
if (poba.TotalPersonsOnBoardUponArrival.HasValue)
|
||
_nsw.conveyance.PersonsOnBoard.TotalPersonsOnBoard = poba.TotalPersonsOnBoardUponArrival.Value.ToString();
|
||
if (poba.TotalStowawaysOnBoardUponArrival.HasValue)
|
||
_nsw.conveyance.PersonsOnBoard.TotalStowawaysOnBoard = poba.TotalStowawaysOnBoardUponArrival.Value.ToString();
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region POBD
|
||
case Message.NotificationClass.POBD:
|
||
if (!message.MessageCore.Incoming)
|
||
{
|
||
POBD pobd = message.Elements[0] as POBD;
|
||
_nsw.conveyance.PersonsOnBoard = new pob();
|
||
if (pobd.TotalCrewMembersOnBoardUponDeparture.HasValue)
|
||
_nsw.conveyance.PersonsOnBoard.TotalCrewMembersOnBoard = pobd.TotalCrewMembersOnBoardUponDeparture.Value.ToString();
|
||
if (pobd.TotalPassengersOnBoardUponDeparture.HasValue)
|
||
_nsw.conveyance.PersonsOnBoard.TotalPassengersOnBoard = pobd.TotalPassengersOnBoardUponDeparture.Value.ToString();
|
||
if (pobd.TotalPersonsOnBoardUponDeparture.HasValue)
|
||
_nsw.conveyance.PersonsOnBoard.TotalPersonsOnBoard = pobd.TotalPersonsOnBoardUponDeparture.Value.ToString();
|
||
if (pobd.TotalStowawaysOnBoardUponDeparture.HasValue)
|
||
_nsw.conveyance.PersonsOnBoard.TotalStowawaysOnBoard = pobd.TotalStowawaysOnBoardUponDeparture.Value.ToString();
|
||
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region PRE72H
|
||
case Message.NotificationClass.PRE72H:
|
||
PRE72H pre72h = message.Elements[0] as PRE72H;
|
||
_nsw.conveyance.Pre72H = new pre72();
|
||
if (pre72h.DateOfLastExpandedInspection.HasValue)
|
||
_nsw.conveyance.Pre72H.DateOfLastExpandedInspection = pre72h.DateOfLastExpandedInspection.Value;
|
||
_nsw.conveyance.Pre72H.PlannedOperations = pre72h.PlannedOperations;
|
||
if (pre72h.PlannedPeriodOfStay_HUR.HasValue)
|
||
_nsw.conveyance.Pre72H.PlannedPeriodOfStay_HUR = (float)pre72h.PlannedPeriodOfStay_HUR.Value;
|
||
_nsw.conveyance.Pre72H.PlannedWorks = pre72h.PlannedWorks;
|
||
if (pre72h.Tanker.HasValue)
|
||
_nsw.conveyance.Pre72H.Tanker = pre72h.Tanker.Value ? yorntype.Y : yorntype.N;
|
||
_nsw.conveyance.Pre72H.TankerDetails = new tankerdetails();
|
||
if (pre72h.ConditionCargoBallastTanks.HasValue)
|
||
_nsw.conveyance.Pre72H.TankerDetails.ConditionCargoBallastTanks = (cargoconditiontype)pre72h.ConditionCargoBallastTanks.Value;
|
||
_nsw.conveyance.Pre72H.TankerDetails.NatureOfCargo = pre72h.NatureOfCargo;
|
||
if (pre72h.TankerHullConfiguration.HasValue)
|
||
_nsw.conveyance.Pre72H.TankerDetails.TankerHullConfiguration = (hullconfigtype)pre72h.TankerHullConfiguration.Value;
|
||
if (pre72h.VolumeOfCargo.HasValue)
|
||
_nsw.conveyance.Pre72H.TankerDetails.VolumeOfCargo_TNE = (float)pre72h.VolumeOfCargo.Value;
|
||
_nsw.conveyance.Pre72H.TankerDetails.VolumeOfCargo_TNESpecified = pre72h.VolumeOfCargo.HasValue;
|
||
break;
|
||
#endregion
|
||
|
||
#region SEC
|
||
case Message.NotificationClass.SEC:
|
||
SEC sec = message.Elements[0] as SEC;
|
||
if (sec.SECSimplification.HasValue)
|
||
{
|
||
if (sec.SECSimplification.Value)
|
||
{
|
||
_nsw.conveyance.Items2 = new object[2];
|
||
_nsw.conveyance.Items2[0] = ytype.Y;
|
||
_nsw.conveyance.Items2[1] = sec.PortOfCallWhereCompleteSECNotified;
|
||
}
|
||
else
|
||
{
|
||
_nsw.conveyance.Items2 = new object[1];
|
||
sec _sec = new sec();
|
||
if (sec.ApprovedSecurityPlanOnBoard.HasValue)
|
||
_sec.ApprovedSecurityPlanOnBoard = sec.ApprovedSecurityPlanOnBoard.Value ? yorntype.Y : yorntype.N;
|
||
_sec.CSOEMail = sec.CSOEMail;
|
||
_sec.CSOFax = sec.CSOFax;
|
||
_sec.CSOFirstName = sec.CSOFirstName;
|
||
_sec.CSOLastName = sec.CSOLastName;
|
||
_sec.CSOPhone = sec.CSOPhone;
|
||
if (sec.CurrentShipSecurityLevel.HasValue)
|
||
_sec.CurrentShipSecurityLevel = (posint13type)sec.CurrentShipSecurityLevel.Value;
|
||
if (sec.GeneralDescriptionOfCargo.HasValue)
|
||
_sec.GeneralDescriptionOfCargo = (cargodescriptiontype)sec.GeneralDescriptionOfCargo.Value;
|
||
if (sec.ISSCDateOfExpiration.HasValue)
|
||
_sec.ISSCDateOfExpiration = sec.ISSCDateOfExpiration.Value;
|
||
_sec.ISSCIssuerName = sec.ISSCIssuerName;
|
||
if (sec.ISSCIssuerType.HasValue)
|
||
_sec.ISSCIssuerType = (isscissuertype)sec.ISSCIssuerType;
|
||
if (sec.ISSCType.HasValue)
|
||
_sec.ISSCType = (issctype)sec.ISSCType;
|
||
_sec.PortFacilityOfArrival = sec.PortFacilityOfArrival;
|
||
_sec.ReasonsForNoValidISSC = sec.ReasonsForNoValidISSC;
|
||
if (sec.ValidISSCOnBoard.HasValue)
|
||
_sec.ValidISSCOnBoard = sec.ValidISSCOnBoard.Value ? yorntype.Y : yorntype.N;
|
||
if (!sec.LastTenPortFacilitesCalled.IsNullOrEmpty())
|
||
{
|
||
_sec.Last10Ports = new last10port[sec.LastTenPortFacilitesCalled.Count];
|
||
for (int i = 0; i < sec.LastTenPortFacilitesCalled.Count; i++)
|
||
{
|
||
_sec.Last10Ports[i] = new last10port();
|
||
_sec.Last10Ports[i].Index = i.ToString();
|
||
if (sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.HasValue)
|
||
_sec.Last10Ports[i].PortFacilityDateOfArrival = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfArrival.Value;
|
||
if (sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.HasValue)
|
||
_sec.Last10Ports[i].PortFacilityDateOfDeparture = sec.LastTenPortFacilitesCalled[i].PortFacilityDateOfDeparture.Value;
|
||
_sec.Last10Ports[i].PortFacilityGISISCode = sec.LastTenPortFacilitesCalled[i].PortFacilityGISISCode;
|
||
_sec.Last10Ports[i].PortFacilityPortCountry = sec.LastTenPortFacilitesCalled[i].PortFacilityPortCountry;
|
||
_sec.Last10Ports[i].PortFacilityPortLoCode = sec.LastTenPortFacilitesCalled[i].PortFacilityPortLoCode;
|
||
_sec.Last10Ports[i].PortFacilityPortName = sec.LastTenPortFacilitesCalled[i].PortFacilitySecurityMattersToReport;
|
||
_sec.Last10Ports[i].PortFacilitySecurityMattersToReport = sec.LastTenPortFacilitesCalled[i].PortFacilitySecurityMattersToReport;
|
||
if (sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.HasValue)
|
||
_sec.Last10Ports[i].PortFacilityShipSecurityLevel = (posint13type)sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.Value;
|
||
}
|
||
}
|
||
|
||
if (!sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.IsNullOrEmpty())
|
||
{
|
||
_sec.LastActivities = new lastactivity[sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count];
|
||
for (int i = 0; i < sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count; i++)
|
||
{
|
||
_sec.LastActivities[i] = new lastactivity();
|
||
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.HasValue)
|
||
_sec.LastActivities[i].ShipToShipActivityDateFrom = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateFrom.Value;
|
||
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.HasValue)
|
||
_sec.LastActivities[i].ShipToShipActivityDateTo = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityDateTo.Value;
|
||
_sec.LastActivities[i].ShipToShipActivityLocation = new location();
|
||
_sec.LastActivities[i].ShipToShipActivityLocation.Items = new object[3];
|
||
|
||
coordinates coords = new coordinates();
|
||
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude.HasValue)
|
||
coords.ShipToShipActivityLocationCoordinatesLatitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLatitude.Value.ToString();
|
||
if (sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude.HasValue)
|
||
coords.ShipToShipActivityLocationCoordinatesLongitude = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationCoordinatesLongitude.Value.ToString();
|
||
_sec.LastActivities[i].ShipToShipActivityLocation.Items[0] = coords;
|
||
_sec.LastActivities[i].ShipToShipActivityLocation.Items[1] = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationLoCode;
|
||
_sec.LastActivities[i].ShipToShipActivityLocation.Items[2] = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityLocationName;
|
||
_sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName = new ItemsChoiceType2[3];
|
||
_sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName[0] = ItemsChoiceType2.ShipToShipActivityLocationCoordinates;
|
||
_sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName[1] = ItemsChoiceType2.ShipToShipActivityLocationLoCode;
|
||
_sec.LastActivities[i].ShipToShipActivityLocation.ItemsElementName[2] = ItemsChoiceType2.ShipToShipActivityLocationName;
|
||
_sec.LastActivities[i].ShipToShipActivitySecurityMattersToReportOf = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivitySecurityMattersToReport;
|
||
_sec.LastActivities[i].ShipToShipActivityType = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i].ShipToShipActivityType;
|
||
}
|
||
}
|
||
_nsw.conveyance.Items2[0] = _sec;
|
||
}
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region SERV
|
||
case Message.NotificationClass.SERV:
|
||
if (!message.Elements.IsNullOrEmpty())
|
||
{
|
||
_nsw.conveyance.Serv = new serv();
|
||
_nsw.conveyance.Serv.Services = new service[message.Elements.Count];
|
||
for (int i = 0; i < message.Elements.Count; i++)
|
||
{
|
||
SERV serv = message.Elements[i] as SERV;
|
||
_nsw.conveyance.Serv.Services[i] = new service();
|
||
_nsw.conveyance.Serv.Services[i].ServiceBeneficiary = serv.ServiceBeneficiary;
|
||
_nsw.conveyance.Serv.Services[i].ServiceInvoiced = serv.ServiceName;
|
||
_nsw.conveyance.Serv.Services[i].ServiceInvoiceRecipient = serv.ServiceInvoiceRecipient;
|
||
}
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region STAT
|
||
case Message.NotificationClass.STAT:
|
||
STAT stat = message.Elements[0] as STAT;
|
||
if (stat.Beam_MTR.HasValue)
|
||
_nsw.conveyance.vessel.Beam_MTR = (float)stat.Beam_MTR.Value;
|
||
_nsw.conveyance.vessel.CallSign = stat.CallSign;
|
||
_nsw.conveyance.vessel.Flag = stat.Flag;
|
||
if (stat.GrossTonnage.HasValue)
|
||
_nsw.conveyance.vessel.GrossTonnage = stat.GrossTonnage.Value.ToString();
|
||
_nsw.conveyance.vessel.InmarsatCallNumber = stat.InmarsatCallNumber;
|
||
_nsw.conveyance.vessel.ISMCompany = new ismcompany();
|
||
_nsw.conveyance.vessel.ISMCompany.ISMCompanyCity = stat.ISMCompanyCity;
|
||
_nsw.conveyance.vessel.ISMCompany.ISMCompanyCountry = stat.ISMCompanyCountry;
|
||
_nsw.conveyance.vessel.ISMCompany.ISMCompanyId = stat.ISMCompanyId;
|
||
_nsw.conveyance.vessel.ISMCompany.ISMCompanyName = stat.ISMCompanyName;
|
||
_nsw.conveyance.vessel.ISMCompany.ISMCompanyPostalCode = stat.ISMCompanyPostalCode;
|
||
_nsw.conveyance.vessel.ISMCompany.ISMCompanyStreetAndNumber = stat.ISMCompanyStreetAndNumber;
|
||
if (stat.LengthOverall_MTR.HasValue)
|
||
_nsw.conveyance.vessel.LengthOverall_MTR = (float)stat.LengthOverall_MTR.Value;
|
||
_nsw.conveyance.vessel.MMSINumber = stat.MMSINumber;
|
||
_nsw.conveyance.vessel.PortOfRegistry = stat.PortOfRegistry;
|
||
_nsw.conveyance.vessel.ShipName = stat.ShipName;
|
||
_nsw.conveyance.vessel.ShipType = stat.ShipType;
|
||
break;
|
||
#endregion
|
||
|
||
#region TIEFA
|
||
case Message.NotificationClass.TIEFA:
|
||
TIEFA tiefa = message.Elements[0] as TIEFA;
|
||
if (tiefa != null)
|
||
{
|
||
if (tiefa.DraughtUponArrival_DMT.HasValue)
|
||
_nsw.conveyance.Draught_DMT = (float)tiefa.DraughtUponArrival_DMT.Value;
|
||
_nsw.conveyance.Draught_DMTSpecified = tiefa.DraughtUponArrival_DMT.HasValue;
|
||
}
|
||
break;
|
||
case Message.NotificationClass.TIEFD:
|
||
TIEFD tiefd = message.Elements[0] as TIEFD;
|
||
if (tiefd != null)
|
||
{
|
||
if (tiefd.DraughtUponDeparture_DMT.HasValue)
|
||
_nsw.conveyance.Draught_DMT = (float)tiefd.DraughtUponDeparture_DMT.Value;
|
||
_nsw.conveyance.Draught_DMTSpecified = tiefd.DraughtUponDeparture_DMT.HasValue;
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region TOWA/TOWD
|
||
case Message.NotificationClass.TOWA:
|
||
if (message.MessageCore.Incoming)
|
||
{
|
||
if (message.Elements.Count > 0)
|
||
{
|
||
_nsw.conveyance.TOWS = new tow[message.Elements.Count];
|
||
for (int i = 0; i < message.Elements.Count; i++)
|
||
{
|
||
tow _tow = new tow();
|
||
_nsw.conveyance.TOWS[i] = _tow;
|
||
TOWA towa = message.Elements[0] as TOWA;
|
||
if (towa.TowageOnArrivalBeam_MTR.HasValue)
|
||
_tow.TowageBeam_MTR = (float)towa.TowageOnArrivalBeam_MTR.Value;
|
||
if (towa.TowageOnArrivalDraught_DMT.HasValue)
|
||
_tow.TowageDraught_DMT = (float)towa.TowageOnArrivalDraught_DMT.Value;
|
||
_tow.TowageFlag = towa.TowageOnArrivalFlag;
|
||
if (towa.TowageOnArrivalGrossTonnage.HasValue)
|
||
_tow.TowageGrossTonnage = towa.TowageOnArrivalGrossTonnage.Value.ToString();
|
||
if (towa.TowageOnArrivalLengthOverall_MTR.HasValue)
|
||
_tow.TowageLengthOverall_MTR = (float)towa.TowageOnArrivalLengthOverall_MTR.Value;
|
||
_tow.TowageName = towa.TowageOnArrivalName;
|
||
_tow.TowageOperator = new towageoperator();
|
||
_tow.TowageOperator.Address = new address();
|
||
_tow.TowageOperator.Address.TowageOperatorCity = towa.TowageOnArrivalOperatorCity;
|
||
_tow.TowageOperator.Address.TowageOperatorCountry = towa.TowageOnArrivalOperatorCountry;
|
||
_tow.TowageOperator.Address.TowageOperatorPostalCode = towa.TowageOnArrivalOperatorPostalCode;
|
||
_tow.TowageOperator.Address.TowageOperatorStreetAndNumber = towa.TowageOnArrivalOperatorStreetNameAndNumber;
|
||
_tow.TowageOperator.Contact = new contact();
|
||
_tow.TowageOperator.Contact.TowageOperatorFax = towa.TowageOnArrivalOperatorFax;
|
||
_tow.TowageOperator.Contact.TowageOperatorPhone = towa.TowageOnArrivalOperatorPhone;
|
||
_tow.TowageOperator.Contact.TowareOperatorEMail = towa.TowageOnArrivalOperatorEmail;
|
||
_tow.TowageOperator.TowageOperatorCompanyName = towa.TowageOnArrivalOperatorCompanyName;
|
||
_tow.TowagePurposeOfCall = towa.TowageOnArrivalPurposeOfCall;
|
||
_tow.TowageRemarks = towa.TowageOnArrivalRemarks;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
case Message.NotificationClass.TOWD:
|
||
if (!message.MessageCore.Incoming)
|
||
{
|
||
if (message.Elements.Count > 0)
|
||
{
|
||
_nsw.conveyance.TOWS = new tow[message.Elements.Count];
|
||
for (int i = 0; i < message.Elements.Count; i++)
|
||
{
|
||
tow _tow = new tow();
|
||
_nsw.conveyance.TOWS[i] = _tow;
|
||
TOWD towd = message.Elements[0] as TOWD;
|
||
if (towd.TowageOnDepartureBeam_MTR.HasValue)
|
||
_tow.TowageBeam_MTR = (float)towd.TowageOnDepartureBeam_MTR.Value;
|
||
if (towd.TowageOnDepartureDraught_DMT.HasValue)
|
||
_tow.TowageDraught_DMT = (float)towd.TowageOnDepartureDraught_DMT.Value;
|
||
_tow.TowageFlag = towd.TowageOnDepartureFlag;
|
||
_tow.TowageName = towd.TowageOnDepartureName;
|
||
_tow.TowageOperator = new towageoperator();
|
||
_tow.TowageOperator.Address = new address();
|
||
_tow.TowageOperator.Address.TowageOperatorCity = towd.TowageOnDepartureOperatorCity;
|
||
_tow.TowageOperator.Address.TowageOperatorCountry = towd.TowageOnDepartureOperatorCountry;
|
||
_tow.TowageOperator.Address.TowageOperatorPostalCode = towd.TowageOnDepartureOperatorPostalCode;
|
||
_tow.TowageOperator.Address.TowageOperatorStreetAndNumber = towd.TowageOnDepartureOperatorStreetNameAndNumber;
|
||
_tow.TowageOperator.Contact = new contact();
|
||
_tow.TowageOperator.Contact.TowageOperatorFax = towd.TowageOnDepartureOperatorFax;
|
||
_tow.TowageOperator.Contact.TowageOperatorPhone = towd.TowageOnDepartureOperatorPhone;
|
||
_tow.TowageOperator.Contact.TowareOperatorEMail = towd.TowageOnDepartureOperatorEmail;
|
||
_tow.TowageOperator.TowageOperatorCompanyName = towd.TowageOnDepartureOperatorCompanyName;
|
||
_tow.TowageRemarks = towd.TowageOnDepartureRemarks;
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region WAS
|
||
case Message.NotificationClass.WAS:
|
||
WAS was = message.Elements[0] as WAS;
|
||
if (was.WasteDisposalValidExemption ?? false)
|
||
{
|
||
_nsw.conveyance.Item1 = new object();
|
||
_nsw.conveyance.Item1 = ytype.Y;
|
||
}
|
||
else
|
||
{
|
||
was _waste = new was();
|
||
_waste.ConfirmationOfCorrectness = (was.ConfirmationOfCorrectness ?? false) ? yorntype.Y : yorntype.N;
|
||
if (was.LastWasteDisposalDate.HasValue)
|
||
_waste.LastWasteDisposalDate = was.LastWasteDisposalDate.Value;
|
||
_waste.LastWasteDisposalPort = was.LastWasteDisposalPort;
|
||
if (was.WasteDisposalDelivery.HasValue)
|
||
_waste.WasteDisposalDelivery = (wastedeliverytype)was.WasteDisposalDelivery.Value;
|
||
if (was.WasteDisposalServiceProvider.Count > 0)
|
||
_waste.WasteDisposalServiceProviderName = new string[was.WasteDisposalServiceProvider.Count];
|
||
for (int i = 0; i < was.WasteDisposalServiceProvider.Count; i++)
|
||
{
|
||
_waste.WasteDisposalServiceProviderName[i] = was.WasteDisposalServiceProvider[i].WasteDisposalServiceProviderName;
|
||
}
|
||
if (was.Waste.Count > 0)
|
||
{
|
||
_waste.Wastes = new waste[was.Waste.Count];
|
||
for (int i = 0; i < was.Waste.Count; i++)
|
||
{
|
||
waste _aWaste = new waste();
|
||
_aWaste.WasteDescription = was.Waste[i].WasteDescription;
|
||
_aWaste.WasteDetails = new wastedetails();
|
||
_aWaste.WasteDetails.WasteAmountGeneratedTillNextPort_MTQSpecified = was.Waste[i].WasteAmountGeneratedTillNextPort_MTQ.HasValue;
|
||
if (was.Waste[i].WasteAmountGeneratedTillNextPort_MTQ.HasValue)
|
||
_aWaste.WasteDetails.WasteAmountGeneratedTillNextPort_MTQ = (float)was.Waste[i].WasteAmountGeneratedTillNextPort_MTQ.Value;
|
||
_aWaste.WasteDetails.WasteAmountRetained_MTQSpecified = was.Waste[i].WasteAmountRetained_MTQ.HasValue;
|
||
if (was.Waste[i].WasteAmountRetained_MTQ.HasValue)
|
||
_aWaste.WasteDetails.WasteAmountRetained_MTQ = (float)was.Waste[i].WasteAmountRetained_MTQ.Value;
|
||
_aWaste.WasteDetails.WasteCapacity_MTQSpecified = was.Waste[i].WasteCapacity_MTQ.HasValue;
|
||
if (was.Waste[i].WasteCapacity_MTQ.HasValue)
|
||
_aWaste.WasteDetails.WasteCapacity_MTQ = (float)was.Waste[i].WasteCapacity_MTQ.Value;
|
||
_aWaste.WasteDetails.WasteDisposalPort = was.Waste[i].WasteDisposalPort;
|
||
if (was.Waste[i].WasteDisposalAmount_MTQ.HasValue)
|
||
_aWaste.WasteDisposalAmount_MTQ = (float)was.Waste[i].WasteDisposalAmount_MTQ.Value;
|
||
if (was.Waste[i].WasteType.HasValue)
|
||
_aWaste.WasteType = (wastetype)was.Waste[i].WasteType.Value;
|
||
_waste.Wastes[i] = _aWaste;
|
||
}
|
||
}
|
||
_nsw.conveyance.Item1 = _waste;
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region serialize and save message
|
||
|
||
string filename = string.Format("{0}-{1}.xml", DateTime.Now.ToString("yyyyMMddHHmmss"), messages[0].MessageCore.Id.Value);
|
||
_log.InfoFormat("saving {0} to output directory", filename);
|
||
|
||
string filePath = Path.Combine(Properties.Settings.Default.OutputDir, filename);
|
||
XmlSerializer serializer = new XmlSerializer(typeof(nsw));
|
||
using(TextWriter tw = new StreamWriter(filePath)) {
|
||
serializer.Serialize(tw, _nsw);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region send message and store result
|
||
|
||
transmitter.result theResult = transmitter.transmit(filePath);
|
||
|
||
#endregion
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
_log.ErrorFormat("Error sending message via hisnord: {0}", ex.Message);
|
||
retval = false;
|
||
}
|
||
|
||
return retval;
|
||
}
|
||
}
|
||
}
|