1389 lines
95 KiB
C#
1389 lines
95 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;
|
||
|
||
messages.Sort();
|
||
|
||
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 = @"BSMD"; // messages[0].MessageCore.Customer.Name;
|
||
_nsw.conveyance.owner_sender.name_long = @"BSMD"; // 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
|
||
|
||
Message visitTransitHeader = null;
|
||
|
||
foreach (Message message in messages)
|
||
{
|
||
|
||
if (!XtraSendLogic.ShouldSendMessage(message)) continue;
|
||
|
||
switch (message.MessageNotificationClass)
|
||
{
|
||
case Message.NotificationClass.VISIT:
|
||
if (!messages[0].MessageCore.IsTransit) visitTransitHeader = message;
|
||
break;
|
||
case Message.NotificationClass.TRANSIT:
|
||
if (messages[0].MessageCore.IsTransit) visitTransitHeader = message;
|
||
break;
|
||
|
||
#region AGNT
|
||
|
||
case Message.NotificationClass.AGNT:
|
||
if (message.Elements.Count > 0)
|
||
{
|
||
AGNT agnt = message.Elements[0] as AGNT;
|
||
_nsw.conveyance.AGNT = new global::agnt();
|
||
_nsw.conveyance.AGNT.AgentCity = agnt.AgentCity;
|
||
_nsw.conveyance.AGNT.AgentCompanyName = agnt.AgentCompanyName;
|
||
_nsw.conveyance.AGNT.AgentCountry = agnt.AgentCountry;
|
||
_nsw.conveyance.AGNT.AgentEMail = agnt.AgentEMail;
|
||
_nsw.conveyance.AGNT.AgentFax = agnt.AgentFax;
|
||
_nsw.conveyance.AGNT.AgentFirstName = agnt.AgentFirstName;
|
||
_nsw.conveyance.AGNT.AgentLastName = agnt.AgentLastName;
|
||
_nsw.conveyance.AGNT.AgentPhone = agnt.AgentPhone;
|
||
_nsw.conveyance.AGNT.AgentPostalCode = agnt.AgentPostalCode;
|
||
_nsw.conveyance.AGNT.AgentStreetAndNumber = agnt.AgentStreetAndNumber;
|
||
}
|
||
break;
|
||
|
||
#endregion
|
||
|
||
#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.IsNullOrEmpty() ? "-" : crew.CrewMemberVisaNumber;
|
||
}
|
||
}
|
||
break;
|
||
#endregion
|
||
|
||
#region HAZ
|
||
|
||
case Message.NotificationClass.HAZA:
|
||
case Message.NotificationClass.HAZD:
|
||
// abh. von LADG!
|
||
{
|
||
if (message.Elements.Count > 0)
|
||
{
|
||
HAZ haz = message.Elements[0] as HAZ;
|
||
|
||
#region HAZ header area
|
||
|
||
List<object> flagItems = new List<object>();
|
||
if (haz.NoDPGOnBoardOnArrival ?? false)
|
||
{
|
||
flagItems.Add(ytype.Y);
|
||
}
|
||
else
|
||
{
|
||
if (haz.DPGManifestOnBoardOnArrival ?? false)
|
||
flagItems.Add(yorntype.Y);
|
||
else
|
||
flagItems.Add(yorntype.N);
|
||
if (haz.INFShipClass.HasValue)
|
||
{
|
||
flagItems.Add((infclasstype)haz.INFShipClass.Value);
|
||
}
|
||
|
||
dgcodes _dgCodes = new dgcodes();
|
||
List<dgcodetype> _dgCodeTypes = new List<dgcodetype>();
|
||
if (haz.DPGClassificationIBC ?? false)
|
||
_dgCodeTypes.Add(dgcodetype.IBC);
|
||
if (haz.DPGClassificationIGC ?? false)
|
||
_dgCodeTypes.Add(dgcodetype.IGC);
|
||
if (haz.DPGClassificationIMDG ?? false)
|
||
_dgCodeTypes.Add(dgcodetype.IMDG);
|
||
// was ist das? dgcodetype.IMDG_MoU
|
||
if (haz.DPGClassificationIMSBC ?? false)
|
||
_dgCodeTypes.Add(dgcodetype.IMSBC);
|
||
if (haz.DPGClassificationMARPOL_ANNEX_I ?? false)
|
||
_dgCodeTypes.Add(dgcodetype.MARPOL_ANNEX_I);
|
||
_dgCodes.DGCode = _dgCodeTypes.ToArray();
|
||
|
||
flagItems.Add(_dgCodes);
|
||
|
||
}
|
||
|
||
_nsw.conveyance.Items1 = flagItems.ToArray();
|
||
|
||
#endregion
|
||
|
||
// Durch Sortierung nach NotificationClass kommt LADG vor HAZ, daher sollte das Feld
|
||
// GeneralCargo nicht leer sein
|
||
if (_nsw.conveyance.GeneralCargo == null)
|
||
{
|
||
_log.Warn("LADG (conveyance.GeneralCargo) is empty. Cannot add HAZ information!");
|
||
}
|
||
else
|
||
{
|
||
List<object> dgList = new List<object>();
|
||
|
||
#region IMDGPositions
|
||
|
||
if (haz.IMDGPositions.Count > 0)
|
||
{
|
||
positionimdg[] imdgPositions = new positionimdg[haz.IMDGPositions.Count];
|
||
for (int i = 0; i < haz.IMDGPositions.Count; i++)
|
||
{
|
||
IMDGPosition imdgPosition = haz.IMDGPositions[i];
|
||
positionimdg pi = new positionimdg();
|
||
|
||
pi.UNNumber = imdgPosition.UNNumber;
|
||
if (imdgPosition.PackingGroup.HasValue)
|
||
pi.PackingGroup = (packinggrouptype)imdgPosition.PackingGroup;
|
||
pi.ProperShippingName = imdgPosition.ProperShippingName;
|
||
pi.IMOClass = imdgPosition.IMOClass;
|
||
pi.CompatibilityGroup = imdgPosition.CompatibilityGroup;
|
||
pi.TechnicalName = imdgPosition.TechnicalName;
|
||
pi.NetMassKGMSpecified = imdgPosition.NetExplosiveMass_KGM.HasValue;
|
||
if (imdgPosition.NetExplosiveMass_KGM.HasValue)
|
||
pi.NetMassKGM = (float)imdgPosition.NetExplosiveMass_KGM.Value;
|
||
pi.FlashpointCEL = imdgPosition.Flashpoint_CEL;
|
||
pi.Class7NuclideName = imdgPosition.Class7NuclideName;
|
||
pi.Class7MaxActivityBQLSpecified = imdgPosition.Class7MaxActivity_BQL.HasValue;
|
||
if (imdgPosition.Class7MaxActivity_BQL.HasValue)
|
||
pi.Class7MaxActivityBQL = (float)imdgPosition.Class7MaxActivity_BQL.Value;
|
||
pi.Class7CategorySpecified = imdgPosition.Class7Category.HasValue;
|
||
if (imdgPosition.Class7Category.HasValue)
|
||
pi.Class7Category = (class7cattype)imdgPosition.Class7Category.Value;
|
||
pi.Class7TISpecified = imdgPosition.Class7TransportIndex.HasValue;
|
||
if (imdgPosition.Class7TransportIndex.HasValue)
|
||
pi.Class7TI = (float)imdgPosition.Class7TransportIndex.Value;
|
||
pi.Class7CSI = imdgPosition.Class7CSI.HasValue ? imdgPosition.Class7CSI.Value.ToString() : "";
|
||
pi.ControlTempCELSpecified = imdgPosition.ControlTemperature_CEL.HasValue;
|
||
if (imdgPosition.ControlTemperature_CEL.HasValue)
|
||
pi.ControlTempCEL = (float)imdgPosition.ControlTemperature_CEL.Value;
|
||
pi.EmergencyTempCELSpecified = imdgPosition.EmergencyTemperature_CEL.HasValue;
|
||
if (imdgPosition.EmergencyTemperature_CEL.HasValue)
|
||
pi.EmergencyTempCEL = (float)imdgPosition.EmergencyTemperature_CEL.Value;
|
||
if (imdgPosition.SubsidiaryRiskList.Count > 0)
|
||
{
|
||
pi.SubsidiaryRisks = new string[imdgPosition.SubsidiaryRiskList.Count];
|
||
for (int j = 0; j < imdgPosition.SubsidiaryRiskList.Count; j++)
|
||
{
|
||
pi.SubsidiaryRisks[j] = imdgPosition.SubsidiaryRiskList[j].SubsidiaryRisk;
|
||
}
|
||
}
|
||
pi.MarinePollutant = (imdgPosition.MarinePollutant ?? false) ? yorntype.Y : yorntype.N;
|
||
pi.NumberOfPackages = imdgPosition.NumberOfPackages.HasValue ? imdgPosition.NumberOfPackages.Value.ToString() : "";
|
||
// pi.PackageType = ?? feld nicht vorhanden
|
||
pi.LimitedQuantities = (imdgPosition.LimitedQuantities ?? false) ? yorntype.Y : yorntype.N;
|
||
pi.ExceptedQuantities = (imdgPosition.ExceptedQuantities ?? false) ? yorntype.Y : yorntype.N;
|
||
// pi.NetQuantity ?? feld nicht vorhanden odér ist das NetMassKGM ?
|
||
pi.GrossMassKGMSpecified = imdgPosition.GrossQuantity_KGM.HasValue;
|
||
if (imdgPosition.GrossQuantity_KGM.HasValue)
|
||
pi.GrossMassKGM = (float)imdgPosition.GrossQuantity_KGM.Value;
|
||
// pi.Volume_MTQ ?? feld nicht vorhanden
|
||
pi.GeneralCargoIBCSpecified = imdgPosition.GeneralCargoIBC.HasValue;
|
||
if (imdgPosition.GeneralCargoIBC.HasValue)
|
||
pi.GeneralCargoIBC = (imdgPosition.GeneralCargoIBC.Value) ? yorntype.Y : yorntype.N;
|
||
pi.ContainerNumber = imdgPosition.ContainerNumber;
|
||
pi.VehicleLicenseNumber = imdgPosition.VehicleLicenseNumber;
|
||
pi.Remarks = imdgPosition.Remarks;
|
||
|
||
// hier fehlt auch StowagePosition, PortOfLoading, PortOfDischarge
|
||
// das ist eine Ebene höher und damit ist die Zuordnung falsch, weil es nicht 1:n ist sondern nachfolgende
|
||
// abweichende Einträge hier eine Überschreibung verursachen
|
||
|
||
if (!imdgPosition.StowagePosition.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].Item = imdgPosition.StowagePosition;
|
||
else
|
||
{
|
||
if(!imdgPosition.Bay.IsNullOrEmpty() || !imdgPosition.Row.IsNullOrEmpty() || !imdgPosition.Tier.IsNullOrEmpty())
|
||
{
|
||
stowagepositionbayrowtier spbr = new stowagepositionbayrowtier();
|
||
spbr.Bay = imdgPosition.Bay;
|
||
spbr.Row = imdgPosition.Row;
|
||
spbr.Tier = imdgPosition.Tier;
|
||
_nsw.conveyance.GeneralCargo[0].Item = spbr;
|
||
}
|
||
}
|
||
|
||
if (!imdgPosition.PortOfLoading.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].PortOfLoadingLocode = imdgPosition.PortOfLoading;
|
||
if (!imdgPosition.PortOfDischarge.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].PortOfDischargeLocode = imdgPosition.PortOfDischarge;
|
||
|
||
pi.Index = imdgPosition.Identifier;
|
||
|
||
imdgPositions[i] = pi;
|
||
}
|
||
dgList.Add(imdgPositions);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region IBCPositions
|
||
|
||
if (haz.IBCPositions.Count > 0)
|
||
{
|
||
positionibc[] ibcPositions = new positionibc[haz.IBCPositions.Count];
|
||
|
||
for (int i = 0; i < haz.IBCPositions.Count; i++)
|
||
{
|
||
positionibc pi = new positionibc();
|
||
IBCPosition ibcPosition = haz.IBCPositions[i];
|
||
pi.Name = ibcPosition.ProductName;
|
||
if (ibcPosition.PollutionCategory.HasValue)
|
||
pi.PollutionCategory = (polcattype)ibcPosition.PollutionCategory.Value;
|
||
pi.HazardsSpecified = ibcPosition.Hazards.HasValue;
|
||
if (ibcPosition.Hazards.HasValue)
|
||
pi.Hazards = (hazardtype)ibcPosition.Hazards.Value;
|
||
if (ibcPosition.FlashpointInformation.HasValue)
|
||
pi.FlashpointInfo = (flashpointinfotype)ibcPosition.FlashpointInformation.Value;
|
||
pi.FlashpointCEL = ibcPosition.Flashpoint_CEL;
|
||
if (ibcPosition.Quantity_KGM.HasValue)
|
||
pi.NetMassKGM = (float)ibcPosition.Quantity_KGM.Value;
|
||
pi.SpecRef15_19Specified = ibcPosition.SpecRef15_19.HasValue;
|
||
if (ibcPosition.SpecRef15_19.HasValue)
|
||
pi.SpecRef15_19 = ibcPosition.SpecRef15_19.Value ? yorntype.Y : yorntype.N;
|
||
pi.Remarks = ibcPosition.Remarks;
|
||
|
||
if (!ibcPosition.StowagePosition.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].Item = ibcPosition.StowagePosition;
|
||
|
||
if (!ibcPosition.PortOfLoading.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].PortOfLoadingLocode = ibcPosition.PortOfLoading;
|
||
if (!ibcPosition.PortOfDischarge.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].PortOfDischargeLocode = ibcPosition.PortOfDischarge;
|
||
|
||
pi.Index = ibcPosition.Identifier;
|
||
|
||
ibcPositions[i] = pi;
|
||
}
|
||
|
||
dgList.Add(ibcPositions);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region IGCPositions
|
||
|
||
if (haz.IGCPositions.Count > 0)
|
||
{
|
||
positionigc[] igcPositions = new positionigc[haz.IGCPositions.Count];
|
||
|
||
for (int i = 0; i < haz.IGCPositions.Count; i++)
|
||
{
|
||
positionigc pi = new positionigc();
|
||
IGCPosition igcPosition = haz.IGCPositions[i];
|
||
|
||
pi.UNNumber = igcPosition.UNNumber;
|
||
pi.IMOClass = igcPosition.IMOClass;
|
||
pi.Name = igcPosition.ProductName;
|
||
if (igcPosition.Quantity_KGM.HasValue)
|
||
pi.NetMassKGM = (float)igcPosition.Quantity_KGM.Value;
|
||
pi.Remarks = igcPosition.Remarks;
|
||
|
||
if (!igcPosition.StowagePosition.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].Item = igcPosition.StowagePosition;
|
||
|
||
if (!igcPosition.PortOfLoading.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].PortOfLoadingLocode = igcPosition.PortOfLoading;
|
||
if (!igcPosition.PortOfDischarge.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].PortOfDischargeLocode = igcPosition.PortOfDischarge;
|
||
|
||
pi.Index = igcPosition.Identifier;
|
||
|
||
igcPositions[i] = pi;
|
||
}
|
||
|
||
dgList.Add(igcPositions);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region IMSBCPositions
|
||
|
||
if (haz.IMSBCPositions.Count > 0)
|
||
{
|
||
positionimsbc[] imsbcPositions = new positionimsbc[haz.IMSBCPositions.Count];
|
||
|
||
for (int i = 0; i < haz.IMSBCPositions.Count; i++)
|
||
{
|
||
positionimsbc pi = new positionimsbc();
|
||
IMSBCPosition imsbcPosition = haz.IMSBCPositions[i];
|
||
|
||
pi.Name = imsbcPosition.BulkCargoShippingName;
|
||
pi.MHB = (imsbcPosition.MHB ?? false) ? yorntype.Y : yorntype.N;
|
||
pi.UNNumber = imsbcPosition.UNNumber;
|
||
pi.IMOClass = imsbcPosition.IMOClass;
|
||
if (imsbcPosition.Quantity_KGM.HasValue)
|
||
pi.NetMassKGM = (float)imsbcPosition.Quantity_KGM.Value;
|
||
pi.Remarks = imsbcPosition.Remarks;
|
||
|
||
if (!imsbcPosition.StowagePosition.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].Item = imsbcPosition.StowagePosition;
|
||
|
||
if (!imsbcPosition.PortOfLoading.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].PortOfLoadingLocode = imsbcPosition.PortOfLoading;
|
||
if (!imsbcPosition.PortOfDischarge.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].PortOfDischargeLocode = imsbcPosition.PortOfDischarge;
|
||
|
||
pi.Index = imsbcPosition.Identifier;
|
||
|
||
imsbcPositions[i] = pi;
|
||
}
|
||
|
||
dgList.Add(imsbcPositions);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region IMDGPositions
|
||
|
||
if (haz.MARPOLPositions.Count > 0)
|
||
{
|
||
positionmarpol[] marpolPositions = new positionmarpol[haz.MARPOLPositions.Count];
|
||
|
||
for (int i = 0; i < haz.MARPOLPositions.Count; i++)
|
||
{
|
||
positionmarpol pi = new positionmarpol();
|
||
MARPOL_Annex_I_Position marpolPosition = haz.MARPOLPositions[i];
|
||
|
||
pi.Name = marpolPosition.Name;
|
||
if (marpolPosition.FlashpointInformation.HasValue)
|
||
pi.FlashpointInformation = (flashpointinfotype)marpolPosition.FlashpointInformation.Value;
|
||
pi.Flashpoint_CEL = marpolPosition.Flashpoint_CEL;
|
||
if (marpolPosition.Quantity_KGM.HasValue)
|
||
pi.NetMassKGM = (float)marpolPosition.Quantity_KGM.Value;
|
||
pi.Remarks = marpolPosition.Remarks;
|
||
|
||
if (!marpolPosition.StowagePosition.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].Item = marpolPosition.StowagePosition;
|
||
|
||
if (!marpolPosition.PortOfLoading.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].PortOfLoadingLocode = marpolPosition.PortOfLoading;
|
||
if (!marpolPosition.PortOfDischarge.IsNullOrEmpty())
|
||
_nsw.conveyance.GeneralCargo[0].PortOfDischargeLocode = marpolPosition.PortOfDischarge;
|
||
|
||
pi.Index = marpolPosition.Identifier;
|
||
|
||
marpolPositions[i] = pi;
|
||
}
|
||
|
||
dgList.Add(marpolPositions);
|
||
}
|
||
|
||
#endregion
|
||
|
||
// HACK! Die erste "vorhandene" Liste. Dieses Format hier setzt voraus dass man immer nur einen Listentyp
|
||
// haben kann, das steht aber nirgends im NSW
|
||
// alles andere wird bis zur Klärung hier erst einmal ignoriert
|
||
if(dgList.Count > 0)
|
||
_nsw.conveyance.GeneralCargo[0].DGList = (object[])dgList[0]; //.ToArray();
|
||
}
|
||
}
|
||
}
|
||
break;
|
||
|
||
#endregion
|
||
|
||
#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;
|
||
else
|
||
_nsw.conveyance.Info.FumigatedBulkCargo = yorntype.N;
|
||
_nsw.conveyance.Info.PortArea = info.PortArea;
|
||
_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 ?? 0) > 0)
|
||
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;
|
||
|
||
// if (mdh.InfectedAreas.Count > 0)
|
||
// {
|
||
_mdh.InfectedAreas = new infectedarea[mdh.InfectedAreas.Count];
|
||
for (int i = 0; i < mdh.InfectedAreas.Count; i++)
|
||
{
|
||
_mdh.InfectedAreas[i] = new infectedarea();
|
||
if (mdh.InfectedAreas[i].InfectedAreaDate.HasValue)
|
||
_mdh.InfectedAreas[i].InfectedAreaDate = mdh.InfectedAreas[i].InfectedAreaDate.Value;
|
||
_mdh.InfectedAreas[i].InfectedAreaPort = mdh.InfectedAreas[i].InfectedAreaPort;
|
||
}
|
||
// }
|
||
|
||
if (mdh.InfectedAreaVisited.HasValue)
|
||
_mdh.InfectedAreaVisited = mdh.InfectedAreaVisited ?? false ? 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+1).ToString(); // POSINT = 1-basiert
|
||
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;
|
||
|
||
// if (mdh.SanitaryMeasuresDetails.Count > 0)
|
||
// {
|
||
_mdh.SanitaryMeasuresDetails = new sanitarydetail[mdh.SanitaryMeasuresDetails.Count];
|
||
for (int i = 0; i < mdh.SanitaryMeasuresDetails.Count; i++)
|
||
{
|
||
_mdh.SanitaryMeasuresDetails[i] = new sanitarydetail();
|
||
if (mdh.SanitaryMeasuresDetails[i].SanitaryMeasuresDate.HasValue)
|
||
_mdh.SanitaryMeasuresDetails[i].SanitaryMeasuresDate = mdh.SanitaryMeasuresDetails[i].SanitaryMeasuresDate.Value;
|
||
_mdh.SanitaryMeasuresDetails[i].SanitaryMeasuresLocation = mdh.SanitaryMeasuresDetails[i].SanitaryMeasuresLocation;
|
||
_mdh.SanitaryMeasuresDetails[i].SanitaryMeasuresType = mdh.SanitaryMeasuresDetails[i].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.StowawaysDetected = (mdh.StowawaysDetected ?? false) ? yorntype.Y : yorntype.N;
|
||
// if ((_mdh.StowawaysDetected == yorntype.Y) && (mdh.StowawaysJoiningLocations.Count > 0))
|
||
// {
|
||
_mdh.StowawayJoiningLocations = new string[mdh.StowawaysJoiningLocations.Count];
|
||
for (int i = 0; i < mdh.StowawaysJoiningLocations.Count; i++)
|
||
{
|
||
_mdh.StowawayJoiningLocations[i] = mdh.StowawaysJoiningLocations[i].StowawayJoiningLocation;
|
||
}
|
||
// }
|
||
if (mdh.SuspisionInfectiousNature.HasValue)
|
||
_mdh.SuspisionInfectiousNature = mdh.SuspisionInfectiousNature.Value ? yorntype.Y : yorntype.N;
|
||
|
||
_mdh.ValidSanitaryControlExemptionOrCertificateOnBoard = (mdh.ValidSanitaryControlExemptionOrCertificateOnBoard ?? false) ? yorntype.Y : yorntype.N;
|
||
if (_mdh.ValidSanitaryControlExemptionOrCertificateOnBoard == yorntype.Y)
|
||
{
|
||
_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;
|
||
if (_transit == null)
|
||
{
|
||
_transit = new transit();
|
||
_nsw.conveyance.Item = _transit;
|
||
}
|
||
|
||
_transit.LastPort = new lastport();
|
||
|
||
if((noa_nod.LastPort != null) && (noa_nod.LastPort.Trim() != ""))
|
||
_transit.LastPort.Locode = noa_nod.LastPort;
|
||
if(!noa_nod.LastPort.IsNullOrEmpty() && !noa_nod.LastPort.Equals("ZZUKN"))
|
||
{
|
||
if (noa_nod.ETDFromLastPort.HasValue)
|
||
_transit.LastPort.ETD = noa_nod.ETDFromLastPort.Value;
|
||
_transit.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue;
|
||
}
|
||
|
||
|
||
_transit.NextPort = new nextporthazmat();
|
||
if (noa_nod.ETAToNextPort.HasValue)
|
||
_transit.NextPort.ETA = noa_nod.ETAToNextPort.Value;
|
||
_transit.NextPort.ETASpecified = noa_nod.ETAToNextPort.HasValue;
|
||
if ((noa_nod.NextPort != null) && (noa_nod.NextPort.Trim() != ""))
|
||
_transit.NextPort.Locode = noa_nod.NextPort;
|
||
}
|
||
else if (message.MessageCore.Incoming) // einlaufend
|
||
{
|
||
import _import = _nsw.conveyance.Item as import;
|
||
if (_import == null)
|
||
{
|
||
_import = new import();
|
||
_nsw.conveyance.Item = _import;
|
||
}
|
||
|
||
_import.LastPort = new lastport();
|
||
|
||
if ((noa_nod.LastPort != null) && (noa_nod.LastPort.Trim() != ""))
|
||
_import.LastPort.Locode = noa_nod.LastPort;
|
||
if (!noa_nod.LastPort.IsNullOrEmpty() && !noa_nod.LastPort.Equals("ZZUKN"))
|
||
{
|
||
if (noa_nod.ETDFromLastPort.HasValue)
|
||
_import.LastPort.ETD = noa_nod.ETDFromLastPort.Value;
|
||
_import.LastPort.ETDSpecified = noa_nod.ETDFromLastPort.HasValue;
|
||
}
|
||
|
||
_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;
|
||
if ((message.MessageCore.PoC != null) && (message.MessageCore.PoC.Trim() != ""))
|
||
_import.PortOfCall.Locode = message.MessageCore.PoC;
|
||
if (noa_nod.CallPurposes.Count > 0)
|
||
{
|
||
_import.PortOfCall.CallPurposes = new callpurpose[noa_nod.CallPurposes.Count];
|
||
for(int i=0;i<noa_nod.CallPurposes.Count;i++)
|
||
{
|
||
_import.PortOfCall.CallPurposes[i] = new callpurpose();
|
||
_import.PortOfCall.CallPurposes[i].CallPurposeCode = noa_nod.CallPurposes[i].CallPurposeCode.ToString();
|
||
_import.PortOfCall.CallPurposes[i].CallPurposeDescription = noa_nod.CallPurposes[i].CallPurposeDescription;
|
||
}
|
||
}
|
||
}
|
||
else // auslaufend
|
||
{
|
||
export _export = _nsw.conveyance.Item as export;
|
||
if (_export == null)
|
||
{
|
||
_export = new export();
|
||
_nsw.conveyance.Item = _export;
|
||
}
|
||
|
||
_export.NextPort = new nextporthazmat();
|
||
if (noa_nod.ETAToNextPort.HasValue)
|
||
_export.NextPort.ETA = noa_nod.ETAToNextPort.Value;
|
||
_export.NextPort.ETASpecified = noa_nod.ETAToNextPort.HasValue;
|
||
if ((noa_nod.NextPort != null) && (noa_nod.NextPort.Trim() != ""))
|
||
_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;
|
||
if ((message.MessageCore.PoC != null) && (message.MessageCore.PoC.Trim() != ""))
|
||
_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;
|
||
|
||
_nsw.conveyance.Pre72H.Tanker = (pre72h.Tanker ?? false) ? yorntype.Y : yorntype.N;
|
||
|
||
if (pre72h.Tanker ?? false)
|
||
{
|
||
_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;
|
||
}
|
||
else
|
||
{
|
||
_nsw.conveyance.Pre72H.TankerDetails = null;
|
||
}
|
||
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 - 1); // HRO Enumeration is 1-based
|
||
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+1).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].PortFacilityPortName;
|
||
_sec.Last10Ports[i].PortFacilitySecurityMattersToReport = sec.LastTenPortFacilitesCalled[i].PortFacilitySecurityMattersToReport;
|
||
if (sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.HasValue)
|
||
_sec.Last10Ports[i].PortFacilityShipSecurityLevel = (posint13type) (sec.LastTenPortFacilitesCalled[i].PortFacilityShipSecurityLevel.Value - 1);
|
||
}
|
||
}
|
||
|
||
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.TransportMode = stat.TransportMode;
|
||
_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();
|
||
string tempWasteType = was.Waste[i].WasteTypeDisplay ?? "";
|
||
// im Gegensatz zu Spec gibt überfl. Description einen Parse-Fehler :(
|
||
if (tempWasteType.Equals("WASTE_OILS-OTHERS") || tempWasteType.Equals("GARBAGE-OTHER") || tempWasteType.Equals("CARGO-RESIDUES") || tempWasteType.Equals("CARGO-ASSOCIATED_WASTE"))
|
||
_aWaste.WasteDescription = was.Waste[i].WasteDescription;
|
||
else
|
||
_aWaste.WasteDescription = null;
|
||
_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 - 1); // im XSD scheint das 0-basiert zu sein (falsch?)
|
||
_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.UseHisNordTransmitter(filePath);
|
||
if (theResult != null)
|
||
{
|
||
_log.InfoFormat("Result: Code {0} Detail {1} Message {2}", theResult.code, theResult.detail, theResult.message);
|
||
|
||
if (visitTransitHeader != null)
|
||
{
|
||
if (theResult.code > 0)
|
||
{
|
||
MessageError error = new MessageError();
|
||
error.MessageHeaderId = visitTransitHeader.Id.Value;
|
||
error.ErrorCode = theResult.code;
|
||
|
||
if ((theResult.detail != null) && (theResult.detail.Length > 255))
|
||
error.ErrorText = theResult.detail.Substring(0, 255);
|
||
else
|
||
error.ErrorText = theResult.detail;
|
||
|
||
DBManager.Instance.Save(error);
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
_log.ErrorFormat("Error sending message via hisnord: {0}", ex.Message);
|
||
retval = false;
|
||
}
|
||
|
||
return retval;
|
||
}
|
||
|
||
#region ReadAnswers()
|
||
|
||
public static void ReadAnswers()
|
||
{
|
||
foreach (string answerFile in Directory.GetFiles(Properties.Settings.Default.AnswerDir))
|
||
{
|
||
VisitId aVisitId = VisitId.ReadVisitId(answerFile);
|
||
if (aVisitId != null)
|
||
{
|
||
_log.InfoFormat("HIS-NORD: Visit-ID {0} delivered for Core {1}", aVisitId.Value, aVisitId.MessageCoreId);
|
||
// update MessageCore
|
||
if (aVisitId.MessageCoreId.HasValue)
|
||
{
|
||
MessageCore answerCore = DBManager.Instance.GetMessageCoreById(aVisitId.MessageCoreId.Value);
|
||
if (answerCore == null)
|
||
{
|
||
_log.WarnFormat("HIS-NORD: Core not found for conveyance code {0}", aVisitId.ConveyanceCode);
|
||
}
|
||
else {
|
||
if (!answerCore.IsTransit)
|
||
answerCore.VisitId = aVisitId.Value;
|
||
else
|
||
answerCore.TransitId = aVisitId.Value;
|
||
answerCore.BSMDStatusInternal = MessageCore.BSMDStatus.RESPONDED;
|
||
DBManager.Instance.Save(answerCore);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
_log.WarnFormat("{0} ANSWER parsed, but MessageCoreId is no Guid: {1}",
|
||
Path.GetFileName(answerFile),
|
||
aVisitId.ConveyanceCode);
|
||
}
|
||
// archive file
|
||
File.Move(answerFile, Path.Combine(Properties.Settings.Default.AnswerArchiveDir, Path.GetFileName(answerFile)));
|
||
}
|
||
else
|
||
{
|
||
TransitId aTransitId = TransitId.ReadTransitId(answerFile);
|
||
if (aTransitId != null)
|
||
{
|
||
_log.InfoFormat("HIS-NORD: Transit-ID {0} delivered for Core {1}", aTransitId.Value, aTransitId.MessageCoreId);
|
||
// update MessageCore
|
||
if (aTransitId.MessageCoreId.HasValue)
|
||
{
|
||
MessageCore answerCore = DBManager.Instance.GetMessageCoreById(aTransitId.MessageCoreId.Value);
|
||
if (answerCore == null)
|
||
{
|
||
_log.WarnFormat("HIS-NORD: Core not found for conveyance code {0}", aTransitId.ConveyanceCode);
|
||
}
|
||
else {
|
||
if (!answerCore.IsTransit)
|
||
answerCore.VisitId = aTransitId.Value;
|
||
else
|
||
answerCore.TransitId = aTransitId.Value;
|
||
answerCore.BSMDStatusInternal = MessageCore.BSMDStatus.RESPONDED;
|
||
DBManager.Instance.Save(answerCore);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
_log.WarnFormat("{0} ANSWER parsed, but MessageCoreId is no Guid: {1}",
|
||
Path.GetFileName(answerFile),
|
||
aTransitId.ConveyanceCode);
|
||
}
|
||
// archive file
|
||
File.Move(answerFile, Path.Combine(Properties.Settings.Default.AnswerArchiveDir, Path.GetFileName(answerFile)));
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
}
|
||
}
|