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

1846 lines
107 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));
private static Dictionary<Guid, ReportingParty> _reportingPartyDict = null;
private static Dictionary<MessageCore, Dictionary<Message, string>> coreFilenameDict = new Dictionary<MessageCore, Dictionary<Message,string>>();
private static Dictionary<MessageCore, bool> coreUseTestDict = new Dictionary<MessageCore, bool>();
//private static Dictionary<Message.NotificationClass, Message> noteMessageDict = new Dictionary<Message.NotificationClass, Message>();
internal static Dictionary<Guid, ReportingParty> ReportingPartyDict
{
get
{
if (_reportingPartyDict == null)
{
_reportingPartyDict = DBManager.Instance.GetReportingPartyDict();
}
return _reportingPartyDict;
}
}
public static void ReadResponseFiles()
{
foreach (MessageCore core in coreFilenameDict.Keys)
{
List<Message> responseList = new List<Message>();
foreach (Message message in coreFilenameDict[core].Keys)
{
transmitter.result theResult = transmitter.GetResult(coreFilenameDict[core][message], coreUseTestDict[core]);
if (theResult != null)
{
_log.InfoFormat("Result: Code {0} Detail {1} Message {2}", theResult.code, theResult.detail, theResult.message);
if (theResult.code > 0)
{
MessageCore reloadCore = DBManager.Instance.GetMessageCoreById(core.Id.Value);
reloadCore.BSMDStatusInternal = MessageCore.BSMDStatus.FAILURE;
DBManager.Instance.Save(reloadCore);
message.InternalStatus = Message.BSMDStatus.SEND_FAILED;
DBManager.Instance.Save(message);
SystemError se = new SystemError();
se.ErrorCode = theResult.code;
se.ErrorMessage = theResult.message.Truncate(255);
se.ErrorDescription = theResult.detail.Truncate(255);
se.ErrorAt = DateTime.Now;
se.MessageCoreId = core.Id.Value;
se.MessageHeaderId = message.Id;
DBManager.Instance.Save(se);
}
responseList.Add(message);
}
}
foreach (Message removeMessage in responseList)
coreFilenameDict[core].Remove(removeMessage);
}
}
public static bool? CreateSendFile(MessageCore core, Message message, bool useTest)
{
bool? retval = null;
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();
ReportingParty rp = null;
if(core.DefaultReportingPartyId.HasValue && Request.ReportingPartyDict.ContainsKey(core.DefaultReportingPartyId.Value))
rp = Request.ReportingPartyDict[core.DefaultReportingPartyId.Value];
if(rp == null)
{
_log.ErrorFormat("Cannot find reporting party for core {0}", core.Id);
return false;
}
_nsw.conveyance.owner_sender.name_short = @"BSMD";
_nsw.conveyance.owner_sender.name_long = @"BSMD";// rp.Name; // core.Customer.Name;
_nsw.conveyance.owner_sender.address = new addresstype();
_nsw.conveyance.owner_sender.address.StreetNumber = rp.StreetAndNumber;
_nsw.conveyance.owner_sender.address.PostCode = rp.PostalCode;
_nsw.conveyance.owner_sender.address.Place = rp.City;
// das hier ist der e-mail(!) Empfänger für Error/Violation Meldungen
_nsw.conveyance.owner_sender.contact = new contacts();
_nsw.conveyance.owner_sender.contact.name = @"BSMD"; // rp.LastName;
_nsw.conveyance.owner_sender.contact.email = rp.EMail;
_nsw.conveyance.owner_sender.contact.firstname = string.Format("{0} {1}", rp.FirstName, rp.LastName);
_nsw.conveyance.owner_sender.contact.phone = rp.Phone;
_nsw.conveyance.owner_sender.contact.fax = rp.Fax;
_nsw.document_reference = core.Id.Value.ToString();
_nsw.conveyance.code = core.Id.ToString();
if (!core.VisitId.IsNullOrEmpty())
{
_nsw.conveyance.Items = new string[1];
_nsw.conveyance.ItemsElementName = new ItemsChoiceType[1];
_nsw.conveyance.Items[0] = core.VisitId;
_nsw.conveyance.ItemsElementName[0] = ItemsChoiceType.VisitId;
}
else if (!core.TransitId.IsNullOrEmpty())
{
_nsw.conveyance.Items = new string[1];
_nsw.conveyance.ItemsElementName = new ItemsChoiceType[1];
_nsw.conveyance.Items[0] = core.TransitId;
_nsw.conveyance.ItemsElementName[0] = ItemsChoiceType.TransitId;
}
else // liegt noch nichts vor, Id muss beantragt werden
{
retval = true;
_nsw.conveyance.Items = new object[4];
_nsw.conveyance.ItemsElementName = new ItemsChoiceType[4];
_nsw.conveyance.Items[0] = core.Shipname;
_nsw.conveyance.ItemsElementName[0] = ItemsChoiceType.name;
_nsw.conveyance.Items[1] = core.IMO.IsNullOrEmpty() ? core.ENI : core.IMO;
_nsw.conveyance.ItemsElementName[1] = core.IMO.IsNullOrEmpty() ? ItemsChoiceType.ENINumber : ItemsChoiceType.IMONumber;
_nsw.conveyance.Items[2] = core.PoC;
_nsw.conveyance.ItemsElementName[2] = ItemsChoiceType.PortOfCall;
_nsw.conveyance.Items[3] = core.IsTransit ? core.ETAKielCanal : core.ETA; // TODO Datum konvertieren?
_nsw.conveyance.ItemsElementName[3] = ItemsChoiceType.ETAPortOfCall;
}
#endregion
#region NSW message area
// wir wissen noch nicht wieviele es werden, von daher erstmal eine Liste!
List<Items1ChoiceType> items1ChoiceType = new List<Items1ChoiceType>();
List<object> items1 = new List<object>();
if (core.Cancelled ?? false)
{
// nur das "STORNO" Element hinzufügen
items1ChoiceType.Add(Items1ChoiceType.STORNO);
items1.Add(ytype.Y);
}
else
{
#region STAT
if (message.MessageNotificationClass == Message.NotificationClass.STAT)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_STAT);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
STAT stat = message.Elements[0] as STAT;
vesseltype hn_stat = new vesseltype();
if (stat.Beam_MTR.HasValue)
hn_stat.Beam_MTR = (float)stat.Beam_MTR.Value;
hn_stat.CallSign = stat.CallSign;
hn_stat.Flag = stat.Flag;
if (stat.GrossTonnage.HasValue)
hn_stat.GrossTonnage = stat.GrossTonnage.Value.ToString();
if (!stat.InmarsatCallNumber.IsNullOrEmpty())
{
hn_stat.InmarsatCallNumbers = new vesseltypeInmarsatCallNumbers();
List<string> callNumbers = new List<string>();
foreach(string aNumber in stat.InmarsatCallNumber.Split('\n'))
{
if ((aNumber.Length > 0) && (aNumber.Length <= 50))
callNumbers.Add(aNumber.Trim());
}
// es können durch die Validierung nicht mehr als 5 sein, sonst müsste man hier abschneiden
hn_stat.InmarsatCallNumbers.InmarsatCallNumber = callNumbers.ToArray();
}
if (!stat.ISMCompanyName.IsNullOrEmpty() || ((stat.GrossTonnage ?? 0) > 500)) // Vio. 821
{
hn_stat.ISMCompany = new ismcompany();
if (!stat.ISMCompanyCity.IsNullOrEmpty())
hn_stat.ISMCompany.ISMCompanyCity = stat.ISMCompanyCity;
if (!stat.ISMCompanyCountry.IsNullOrEmpty())
hn_stat.ISMCompany.ISMCompanyCountry = stat.ISMCompanyCountry;
hn_stat.ISMCompany.ISMCompanyId = stat.ISMCompanyId;
hn_stat.ISMCompany.ISMCompanyName = stat.ISMCompanyName;
if (!stat.ISMCompanyPostalCode.IsNullOrEmpty())
hn_stat.ISMCompany.ISMCompanyPostalCode = stat.ISMCompanyPostalCode;
if (!stat.ISMCompanyStreetAndNumber.IsNullOrEmpty())
hn_stat.ISMCompany.ISMCompanyStreetAndNumber = stat.ISMCompanyStreetAndNumber;
}
if (stat.LengthOverall_MTR.HasValue)
hn_stat.LengthOverall_MTR = (float)stat.LengthOverall_MTR.Value;
hn_stat.MMSINumber = stat.MMSINumber;
hn_stat.PortOfRegistry = stat.PortOfRegistry;
hn_stat.ShipName = stat.ShipName;
hn_stat.TransportMode = stat.TransportMode;
hn_stat.ShipType = stat.ShipType;
items1ChoiceType.Add(Items1ChoiceType.STAT);
items1.Add(hn_stat);
}
}
}
#endregion
#region NOA_NOD
if (message.MessageNotificationClass == Message.NotificationClass.NOA_NOD)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_NOANOD);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
NOA_NOD noa_nod = message.Elements[0] as NOA_NOD;
noanod hn_noanod = new noanod();
if (message.MessageCore.IsTransit)
{
if (noa_nod.ETAToKielCanal.HasValue)
hn_noanod.ETAToPortOfCall = noa_nod.ETAToKielCanal.Value;
if (noa_nod.ETDFromKielCanal.HasValue)
hn_noanod.ETDFromPortOfCall = noa_nod.ETDFromKielCanal.Value;
}
else
{
if (noa_nod.ETAToPortOfCall.HasValue)
hn_noanod.ETAToPortOfCall = noa_nod.ETAToPortOfCall.Value;
if (noa_nod.ETDFromPortOfCall.HasValue)
hn_noanod.ETDFromPortOfCall = noa_nod.ETDFromPortOfCall.Value;
hn_noanod.CallPurposes = new callpurpose[noa_nod.CallPurposes.Count];
for (int i = 0; i < noa_nod.CallPurposes.Count; i++)
{
hn_noanod.CallPurposes[i] = new callpurpose();
CallPurpose callPurpose = noa_nod.CallPurposes[i] as CallPurpose;
hn_noanod.CallPurposes[i].CallPurposeCode = callPurpose.CallPurposeCode.ToString();
hn_noanod.CallPurposes[i].CallPurposeDescription = callPurpose.CallPurposeDescription;
}
}
hn_noanod.LastPort = noa_nod.LastPort;
hn_noanod.ETDFromLastPortSpecified = noa_nod.ETDFromLastPort.HasValue;
if (hn_noanod.ETDFromLastPortSpecified)
hn_noanod.ETDFromLastPort = noa_nod.ETDFromLastPort.Value;
hn_noanod.NextPort = noa_nod.NextPort;
hn_noanod.ETAToNextPortSpecified = noa_nod.ETAToNextPort.HasValue;
if (hn_noanod.ETAToNextPortSpecified)
hn_noanod.ETAToNextPort = noa_nod.ETAToNextPort.Value;
items1ChoiceType.Add(Items1ChoiceType.NOANOD);
items1.Add(hn_noanod);
}
}
}
#endregion
#region ATA / ATD
if (message.MessageNotificationClass == Message.NotificationClass.ATA)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_ATA);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
ATA ata = message.Elements[0] as ATA;
items1ChoiceType.Add(Items1ChoiceType.ATA);
items1.Add(ata.ATAPortOfCall);
}
} }
if (message.MessageNotificationClass == Message.NotificationClass.ATD)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_ATD);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
ATD atd = message.Elements[0] as ATD;
items1ChoiceType.Add(Items1ChoiceType.ATD);
items1.Add(atd.ATDPortOfCall);
}
}
}
#endregion
#region POBA
if (message.MessageNotificationClass == Message.NotificationClass.POBA)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_POBA);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
POBA poba = message.Elements[0] as POBA;
global::poba hn_poba = new global::poba();
hn_poba.TotalCrewMembersOnBoardUponArrival = (poba.TotalCrewMembersOnBoardUponArrival ?? 0).ToString();
hn_poba.TotalPassengersOnBoardUponArrival = (poba.TotalPassengersOnBoardUponArrival ?? 0).ToString();
hn_poba.TotalPersonsOnBoardUponArrival = (poba.TotalPersonsOnBoardUponArrival ?? 0).ToString();
hn_poba.TotalStowawaysOnBoardUponArrival = (poba.TotalStowawaysOnBoardUponArrival ?? 0).ToString();
items1ChoiceType.Add(Items1ChoiceType.POBA);
items1.Add(hn_poba);
}
}
}
#endregion
#region POBD
if (message.MessageNotificationClass == Message.NotificationClass.POBD)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_POBD);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
POBD pobd = message.Elements[0] as POBD;
global::pobd hn_pobd = new global::pobd();
hn_pobd.TotalCrewMembersOnBoardUponDeparture = (pobd.TotalCrewMembersOnBoardUponDeparture ?? 0).ToString();
hn_pobd.TotalPassengersOnBoardUponDeparture = (pobd.TotalPassengersOnBoardUponDeparture ?? 0).ToString();
hn_pobd.TotalPersonsOnBoardUponDeparture = (pobd.TotalPersonsOnBoardUponDeparture ?? 0).ToString();
hn_pobd.TotalStowawaysOnBoardUponDeparture = (pobd.TotalStowawaysOnBoardUponDeparture ?? 0).ToString();
items1ChoiceType.Add(Items1ChoiceType.POBD);
items1.Add(hn_pobd);
}
}
}
#endregion
#region NAME
if (message.MessageNotificationClass == Message.NotificationClass.NAME)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_NameOfMaster);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
NAME name = message.Elements[0] as NAME;
items1ChoiceType.Add(Items1ChoiceType.NameOfMaster);
items1.Add(name.NameOfMaster);
}
}
}
#endregion
#region TIEFA / TIEFD
if (message.MessageNotificationClass == Message.NotificationClass.TIEFA)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_TIEFA);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
TIEFA tiefa = message.Elements[0] as TIEFA;
if (tiefa.DraughtUponArrival_DMT.HasValue)
{
items1ChoiceType.Add(Items1ChoiceType.TIEFA);
items1.Add((float)tiefa.DraughtUponArrival_DMT.Value);
}
}
}
}
if (message.MessageNotificationClass == Message.NotificationClass.TIEFD)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_TIEFD);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
TIEFD tiefd = message.Elements[0] as TIEFD;
if (tiefd.DraughtUponDeparture_DMT.HasValue)
{
items1ChoiceType.Add(Items1ChoiceType.TIEFD);
items1.Add((float)tiefd.DraughtUponDeparture_DMT.Value);
}
}
}
}
#endregion
#region INFO
if (message.MessageNotificationClass == Message.NotificationClass.INFO)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_INFO);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
INFO info = message.Elements[0] as INFO;
global::info hn_info = new global::info();
if (info.ShippingArea.HasValue)
hn_info.ShippingArea = (shippingareatype)info.ShippingArea.Value;
hn_info.PortArea = info.PortArea;
hn_info.RequestedPositionInPortOfCall = info.RequestedPositionInPortOfCall;
hn_info.SpecialRequirementsOfShipAtBerth = info.SpecialRequirementsOfShipAtBerth;
hn_info.ConstructionCharacteristicsOfShip = info.ConstructionCharacteristicsOfShip;
hn_info.BowThrusterPower = info.BowThrusterPower;
hn_info.SternThrusterPower = info.SternThrusterPower;
if (info.FumigatedBulkCargo.HasValue)
hn_info.FumigatedBulkCargo = (info.FumigatedBulkCargo.Value == 1) ? yorntype.Y : yorntype.N;
else
hn_info.FumigatedBulkCargo = yorntype.N;
hn_info.DeadWeightSummer_TNESpecified = info.DeplacementSummerDraught_TNE.HasValue;
if (hn_info.DeadWeightSummer_TNESpecified)
hn_info.DeadWeightSummer_TNE = (float)info.DeplacementSummerDraught_TNE.Value;
items1ChoiceType.Add(Items1ChoiceType.INFO);
items1.Add(hn_info);
}
}
}
#endregion
#region BKRA / BKRD
if (message.MessageNotificationClass == Message.NotificationClass.BKRA)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_BKRA);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
global::bkra hn_bkra = new bkra();
hn_bkra.BunkerFuelArrival = new bunkerfuel[message.Elements.Count];
for (int i = 0; i < message.Elements.Count; i++)
{
BRKA brka = message.Elements[i] as BRKA;
hn_bkra.BunkerFuelArrival[i] = new bunkerfuel();
hn_bkra.BunkerFuelArrival[i].BunkerFuelType = brka.BunkerFuelType;
hn_bkra.BunkerFuelArrival[i].BunkerFuelQuantity_TNE = (float)brka.BunkerFuelQuantity_TNE;
}
items1ChoiceType.Add(Items1ChoiceType.BKRA);
items1.Add(hn_bkra);
}
}
}
if (message.MessageNotificationClass == Message.NotificationClass.BKRD)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_BKRD);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
global::bkrd hn_bkrd = new bkrd();
hn_bkrd.BunkerFuelDeparture = new bunkerfuel[message.Elements.Count];
for (int i = 0; i < message.Elements.Count; i++)
{
BRKD brkd = message.Elements[i] as BRKD;
hn_bkrd.BunkerFuelDeparture[i] = new bunkerfuel();
hn_bkrd.BunkerFuelDeparture[i].BunkerFuelType = brkd.BunkerFuelType;
hn_bkrd.BunkerFuelDeparture[i].BunkerFuelQuantity_TNE = (float)brkd.BunkerFuelQuantity_TNE;
}
items1ChoiceType.Add(Items1ChoiceType.BKRD);
items1.Add(hn_bkrd);
}
}
}
#endregion
#region HAZA / HAZD
if (message.MessageNotificationClass == Message.NotificationClass.HAZA)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_HAZA);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
HAZ haz = message.Elements[0] as HAZ;
global::haza hn_haza = new haza();
if (haz.NoDPGOnBoardOnArrival ?? false)
{
hn_haza.Items = new object[1];
hn_haza.ItemsElementName = new ItemsChoiceType1[1];
hn_haza.Items[0] = ytype.Y;
hn_haza.ItemsElementName[0] = ItemsChoiceType1.NoDPGOnBoardOnArrival;
}
else
{
List<object> hn_haza_items = new List<object>();
List<ItemsChoiceType1> hn_haza_itemsChoiceType1 = new List<ItemsChoiceType1>();
if (haz.DPGManifestOnBoardOnArrival.HasValue)
{
hn_haza_items.Add(haz.DPGManifestOnBoardOnArrival.Value ? yorntype.Y : yorntype.N);
hn_haza_itemsChoiceType1.Add(ItemsChoiceType1.DPGManifestOnBoardOnArrival);
}
if (haz.INFShipClass.HasValue)
{
infclasstype infclass = (infclasstype)haz.INFShipClass.Value; // ich hoffe diese casts passen immer :\
hn_haza_items.Add(infclass);
hn_haza_itemsChoiceType1.Add(ItemsChoiceType1.INFShipClass);
}
if (haz.MOUBaltic ?? false)
{
hn_haza_items.Add(ytype.Y);
hn_haza_itemsChoiceType1.Add(ItemsChoiceType1.MOUBaltic);
}
dglist hn_dgList = new dglist();
SetHAZPositions(hn_dgList, haz);
hn_haza_items.Add(hn_dgList);
hn_haza_itemsChoiceType1.Add(ItemsChoiceType1.DPGOnArrival);
hn_haza.Items = hn_haza_items.ToArray();
hn_haza.ItemsElementName = hn_haza_itemsChoiceType1.ToArray();
}
items1ChoiceType.Add(Items1ChoiceType.HAZA);
items1.Add(hn_haza);
}
}
}
if (message.MessageNotificationClass == Message.NotificationClass.HAZD)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_HAZD);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
HAZ haz = message.Elements[0] as HAZ;
global::hazd hn_hazd = new hazd();
if (haz.NoDPGOnBoardOnArrival ?? false)
{
hn_hazd.Items = new object[1];
hn_hazd.ItemsElementName = new ItemsChoiceType2[1];
hn_hazd.Items[0] = ytype.Y;
hn_hazd.ItemsElementName[0] = ItemsChoiceType2.NoDPGOnBoardOnDeparture;
}
else
{
List<object> hn_hazd_items = new List<object>();
List<ItemsChoiceType2> hn_hazd_itemsChoiceType2 = new List<ItemsChoiceType2>();
if (haz.DPGManifestOnBoardOnArrival.HasValue)
{
hn_hazd_items.Add(haz.DPGManifestOnBoardOnArrival.Value ? yorntype.Y : yorntype.N);
hn_hazd_itemsChoiceType2.Add(ItemsChoiceType2.DPGManifestOnBoardOnDeparture);
}
if (haz.INFShipClass.HasValue)
{
infclasstype infclass = (infclasstype)haz.INFShipClass.Value; // ich hoffe diese casts passen immer :\
hn_hazd_items.Add(infclass);
hn_hazd_itemsChoiceType2.Add(ItemsChoiceType2.INFShipClass);
}
if (haz.MOUBaltic ?? false)
{
hn_hazd_items.Add(ytype.Y);
hn_hazd_itemsChoiceType2.Add(ItemsChoiceType2.MOUBaltic);
}
dglist hn_dgList = new dglist();
SetHAZPositions(hn_dgList, haz);
hn_hazd_items.Add(hn_dgList);
hn_hazd_itemsChoiceType2.Add(ItemsChoiceType2.DPGOnDeparture);
hn_hazd.Items = hn_hazd_items.ToArray();
hn_hazd.ItemsElementName = hn_hazd_itemsChoiceType2.ToArray();
}
items1ChoiceType.Add(Items1ChoiceType.HAZD);
items1.Add(hn_hazd);
}
}
}
#endregion
#region LADG
if (message.MessageNotificationClass == Message.NotificationClass.LADG)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_LADG);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
global::generalcargo hn_generalcargo = new generalcargo();
hn_generalcargo.Cargo = 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();
if (ladg.CargoHandlingType.HasValue)
lu.CargoHandlingType = (handlingcodetype)ladg.CargoHandlingType.Value;
lu.CargoCodeNST = ladg.CargoCodeNST;
lu.CargoCodeNST_3 = ladg.CargoCodeNST_3;
if ((ladg.CargoNumberOfItems ?? 0) > 0)
lu.CargoNumberOfItems = ladg.CargoNumberOfItems.Value.ToString();
if (ladg.CargoGrossQuantity_TNE.HasValue)
lu.CargoGrossQuantity_TNE = (float)ladg.CargoGrossQuantity_TNE.Value;
lu.CargoPortOfLoading = ladg.PortOfLoading;
lu.CargoPortOfDischarge = ladg.PortOfDischarge;
hn_generalcargo.Cargo[i] = lu;
}
items1ChoiceType.Add(Items1ChoiceType.LADG);
items1.Add(hn_generalcargo);
}
}
}
#endregion
#region SERV
if (message.MessageNotificationClass == Message.NotificationClass.SERV)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_SERV);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
global::serv hn_serv = new serv();
hn_serv.Service = new service[message.Elements.Count];
for (int i = 0; i < message.Elements.Count; i++)
{
SERV serv = message.Elements[i] as SERV;
hn_serv.Service[i] = new service();
hn_serv.Service[i].ServiceBeneficiary = serv.ServiceBeneficiary;
if(!serv.ServiceName.IsNullOrEmpty())
hn_serv.Service[i].ServiceName = serv.ServiceName;
hn_serv.Service[i].ServiceInvoiceRecipient = serv.ServiceInvoiceRecipient;
}
items1ChoiceType.Add(Items1ChoiceType.SERV);
items1.Add(hn_serv);
}
}
}
#endregion
#region PRE72H
if (message.MessageNotificationClass == Message.NotificationClass.PRE72H)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_PRE72H);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
PRE72H pre72h = message.Elements[0] as PRE72H;
global::pre72 hn_pre72 = new pre72();
if (pre72h.DateOfLastExpandedInspection.HasValue)
hn_pre72.DateOfLastExpandedInspection = pre72h.DateOfLastExpandedInspection.Value;
hn_pre72.PlannedOperations = pre72h.PlannedOperations;
if (pre72h.PlannedPeriodOfStay_HUR.HasValue)
hn_pre72.PlannedPeriodOfStay_HUR = (float)pre72h.PlannedPeriodOfStay_HUR.Value;
hn_pre72.PlannedWorks = pre72h.PlannedWorks;
hn_pre72.Tanker = (pre72h.Tanker ?? false) ? yorntype.Y : yorntype.N;
if (pre72h.Tanker ?? false)
{
hn_pre72.TankerDetails = new tankerdetails();
if (pre72h.ConditionCargoBallastTanks.HasValue)
hn_pre72.TankerDetails.ConditionCargoBallastTanks = (cargoconditiontype)pre72h.ConditionCargoBallastTanks.Value;
hn_pre72.TankerDetails.TypeOfCargo = pre72h.NatureOfCargo;
if (pre72h.TankerHullConfiguration.HasValue)
hn_pre72.TankerDetails.TankerHullConfiguration = (hullconfigtype)pre72h.TankerHullConfiguration.Value;
if (pre72h.VolumeOfCargo.HasValue)
hn_pre72.TankerDetails.VolumeOfCargo_TNE = (float)pre72h.VolumeOfCargo.Value;
hn_pre72.TankerDetails.VolumeOfCargo_TNESpecified = pre72h.VolumeOfCargo.HasValue;
}
else
{
hn_pre72.TankerDetails = null;
}
items1ChoiceType.Add(Items1ChoiceType.PRE72H);
items1.Add(hn_pre72);
}
}
}
#endregion
#region SEC
if (message.MessageNotificationClass == Message.NotificationClass.SEC)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_SEC);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
SEC sec = message.Elements[0] as SEC;
global::sec _sec = new global::sec();
if (sec.KielCanalPassagePlanned ?? false)
{
_sec.KielCanalPassage = new KielCanalPassage();
_sec.KielCanalPassage.KielCanalPassagePlanned = ytype.Y;
_sec.KielCanalPassage.KielCanalPassagePlannedIncomingSpecified = sec.KielCanalPassagePlannedIncomming.HasValue;
if (_sec.KielCanalPassage.KielCanalPassagePlannedIncomingSpecified)
_sec.KielCanalPassage.KielCanalPassagePlannedIncoming = sec.KielCanalPassagePlannedIncomming.Value;
_sec.KielCanalPassage.KielCanalPassagePlannedOutgoingSpecified = sec.KielCanalPassagePlannedOutgoing.HasValue;
if (_sec.KielCanalPassage.KielCanalPassagePlannedOutgoingSpecified)
_sec.KielCanalPassage.KielCanalPassagePlannedOutgoing = sec.KielCanalPassagePlannedOutgoing.Value;
}
if (sec.CurrentShipSecurityLevel.HasValue)
_sec.CurrentShipSecurityLevel = (posint13type) (sec.CurrentShipSecurityLevel.Value - 1);
List<object> secItems = new List<object>();
List<ItemsChoiceType4> secItemNames = new List<ItemsChoiceType4>();
if (sec.SECSimplification ?? false)
{
secItemNames.Add(ItemsChoiceType4.SECSimplification);
secItems.Add(ytype.Y);
secItemNames.Add(ItemsChoiceType4.PortOfCallWhereCompleteSECNotified);
secItems.Add(sec.PortOfCallWhereCompleteSECNotified);
}
else
{
secItemNames.Add(ItemsChoiceType4.CSOLastName);
secItems.Add(sec.CSOLastName);
if (!sec.CSOFirstName.IsNullOrEmpty())
{
secItemNames.Add(ItemsChoiceType4.CSOFirstName);
secItems.Add(sec.CSOFirstName);
}
secItemNames.Add(ItemsChoiceType4.CSOPhone);
secItems.Add(sec.CSOPhone);
if (!sec.CSOFax.IsNullOrEmpty())
{
secItemNames.Add(ItemsChoiceType4.CSOFax);
secItems.Add(sec.CSOFax);
}
if (!sec.CSOEMail.IsNullOrEmpty())
{
secItemNames.Add(ItemsChoiceType4.CSOEMail);
secItems.Add(sec.CSOEMail);
}
secItemNames.Add(ItemsChoiceType4.ValidISSCOnBoard);
secItems.Add((sec.ValidISSCOnBoard ?? false) ? yorntype.Y : yorntype.N);
if ((!sec.ValidISSCOnBoard ?? false) && (!sec.ReasonsForNoValidISSC.IsNullOrEmpty())) {
secItemNames.Add(ItemsChoiceType4.ReasonsForNoValidISSC);
secItems.Add(sec.ReasonsForNoValidISSC);
}
if (sec.ISSCType.HasValue)
{
secItemNames.Add(ItemsChoiceType4.ISSCType);
secItems.Add((issctype)sec.ISSCType.Value);
}
if (sec.ISSCIssuerType.HasValue)
{
secItemNames.Add(ItemsChoiceType4.ISSCIssuerType);
secItems.Add((isscissuertype)sec.ISSCIssuerType.Value);
}
secItemNames.Add(ItemsChoiceType4.ISSCIssuerName);
secItems.Add(sec.ISSCIssuerName);
if (sec.ISSCDateOfExpiration.HasValue)
{
secItemNames.Add(ItemsChoiceType4.ISSCDateOfExpiration);
secItems.Add(sec.ISSCDateOfExpiration.Value);
}
if (sec.ApprovedSecurityPlanOnBoard.HasValue)
{
secItemNames.Add(ItemsChoiceType4.ApprovedSecurityPlanOnBoard);
secItems.Add(sec.ApprovedSecurityPlanOnBoard.Value ? yorntype.Y : yorntype.N);
}
if (!sec.PortFacilityOfArrival.IsNullOrEmpty())
{
secItemNames.Add(ItemsChoiceType4.PortFacilityOfArrival);
secItems.Add(sec.PortFacilityOfArrival);
}
if (sec.GeneralDescriptionOfCargo.HasValue)
{
secItemNames.Add(ItemsChoiceType4.GeneralDescriptionOfCargo);
secItems.Add((cargodescriptiontype)sec.GeneralDescriptionOfCargo.Value);
}
foreach (LastTenPortFacilitiesCalled l10Called in sec.LastTenPortFacilitesCalled)
{
last10port hn_last10port = new last10port();
if(!l10Called.PortFacilityPortName.IsNullOrEmpty())
hn_last10port.PortFacilityPortName = l10Called.PortFacilityPortName;
if(!l10Called.PortFacilityPortCountry.IsNullOrEmpty())
hn_last10port.PortFacilityPortCountry = l10Called.PortFacilityPortCountry;
if(!l10Called.PortFacilityPortLoCode.IsNullOrEmpty())
hn_last10port.PortFacilityPortLoCode = l10Called.PortFacilityPortLoCode;
if (l10Called.PortFacilityDateOfArrival.HasValue)
hn_last10port.PortFacilityDateOfArrival = l10Called.PortFacilityDateOfArrival.Value;
if (l10Called.PortFacilityDateOfDeparture.HasValue)
hn_last10port.PortFacilityDateOfDeparture = l10Called.PortFacilityDateOfDeparture.Value;
if (l10Called.PortFacilityShipSecurityLevel.HasValue)
hn_last10port.PortFacilityShipSecurityLevel = (posint13type) (l10Called.PortFacilityShipSecurityLevel.Value - 1);
if(!l10Called.PortFacilitySecurityMattersToReport.IsNullOrEmpty())
hn_last10port.PortFacilitySecurityMattersToReport = l10Called.PortFacilitySecurityMattersToReport;
hn_last10port.PortFacilityGISISCode = l10Called.PortFacilityGISISCode;
secItemNames.Add(ItemsChoiceType4.LastTenPortFacilitiesCalled);
secItems.Add(hn_last10port);
}
foreach (ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2s in sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled)
{
lastactivity hn_lastactivity = new lastactivity();
hn_lastactivity.ShipToShipActivityLocation = new location();
List<object> locationItems = new List<object>();
List<ItemsChoiceType3> locationItemNames = new List<ItemsChoiceType3>();
if (!s2s.ShipToShipActivityLocationName.IsNullOrEmpty())
{
locationItems.Add(s2s.ShipToShipActivityLocationName);
locationItemNames.Add(ItemsChoiceType3.ShipToShipActivityLocationName);
}
if (!s2s.ShipToShipActivityLocationLoCode.IsNullOrEmpty())
{
locationItems.Add(s2s.ShipToShipActivityLocationLoCode);
locationItemNames.Add(ItemsChoiceType3.ShipToShipActivityLocationLoCode);
}
if (s2s.ShipToShipActivityLocationCoordinatesLatitude.HasValue && s2s.ShipToShipActivityLocationCoordinatesLongitude.HasValue)
{
coordinates coords = new coordinates();
coords.ShipToShipActivityLocationCoordinatesLatitude = s2s.ShipToShipActivityLocationCoordinatesLatitude.Value.ToString();
coords.ShipToShipActivityLocationCoordinatesLongitude = s2s.ShipToShipActivityLocationCoordinatesLongitude.Value.ToString();
locationItems.Add(coords);
locationItemNames.Add(ItemsChoiceType3.ShipToShipActivityLocationCoordinates);
}
hn_lastactivity.ShipToShipActivityLocation.Items = locationItems.ToArray();
hn_lastactivity.ShipToShipActivityLocation.ItemsElementName = locationItemNames.ToArray();
if (s2s.ShipToShipActivityDateFrom.HasValue)
hn_lastactivity.ShipToShipActivityDateFrom = s2s.ShipToShipActivityDateFrom.Value;
if (s2s.ShipToShipActivityDateTo.HasValue)
hn_lastactivity.ShipToShipActivityDateTo = s2s.ShipToShipActivityDateTo.Value;
/*
int edifact8025;
if (Int32.TryParse(s2s.ShipToShipActivityType, out edifact8025) && (edifact8025 > 0) && (edifact8025 < 24))
hn_lastactivity.ShipToShipActivityType = edifact8025.ToString();
*/
if (s2s.ShipToShipActivityTypeCode.HasValue)
{
if (s2s.ShipToShipActivityTypeCode.Value == 98)
hn_lastactivity.ShipToShipActivityType = lastactivityShipToShipActivityType.Item98;
else
hn_lastactivity.ShipToShipActivityType = (lastactivityShipToShipActivityType)(s2s.ShipToShipActivityTypeCode.Value - 1);
}
if(!s2s.ShipToShipActivitySecurityMattersToReport.IsNullOrEmpty())
hn_lastactivity.ShipToShipActivitySecurityMattersToReportOf = s2s.ShipToShipActivitySecurityMattersToReport;
secItemNames.Add(ItemsChoiceType4.ShipToShipActivities);
secItems.Add(hn_lastactivity);
}
}
_sec.Items = secItems.ToArray();
_sec.ItemsElementName = secItemNames.ToArray();
items1ChoiceType.Add(Items1ChoiceType.SEC);
items1.Add(_sec);
}
}
}
#endregion
#region MDH
if (message.MessageNotificationClass == Message.NotificationClass.MDH)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_MDH);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
MDH mdh = message.Elements[0] as MDH;
global::mdh hn_mdh = new global::mdh();
List<object> mdh_items = new List<object>();
List<ItemsChoiceType5> mdh_types = new List<ItemsChoiceType5>();
if (mdh.MDHSimplification.HasValue && mdh.MDHSimplification.Value)
{
mdh_items.Add(ytype.Y);
mdh_types.Add(ItemsChoiceType5.MDHSimplification);
mdh_items.Add(mdh.PortOfCallWhereCompleteMDHNotified);
mdh_types.Add(ItemsChoiceType5.PortOfCallWhereCompleteMDHNotified);
}
else
{
mdh_items.Add((mdh.NonAccidentalDeathsDuringVoyage ?? false) ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.NonAccidentialDeathsDuringVoyage);
if (mdh.NonAccidentalDeathsDuringVoyage ?? false)
{
mdh_items.Add((mdh.NonAccidentalDeathsDuringVoyageCount ?? 0).ToString());
mdh_types.Add(ItemsChoiceType5.NonAccidentialDeathsDuringVoyageCount);
}
mdh_items.Add((mdh.SuspisionInfectiousNature ?? false) ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.SuspisionInfectiousNature);
mdh_items.Add((mdh.NumberOfIllPersonsHigherThanExpected ?? false) ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.NumberOfIllPersonsHigherThanExpected);
if (mdh.NumberOfIllPersonsHigherThanExpected ?? false)
{
mdh_items.Add((mdh.NumberOfIllPersons ?? 0).ToString());
mdh_types.Add(ItemsChoiceType5.NumberOfIllPersons);
}
mdh_items.Add((mdh.SickPersonsOnBoard ?? false) ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.SickPersonsOnBoard);
mdh_items.Add((mdh.MedicalConsulted ?? false) ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.MedicalConsulted);
mdh_items.Add((mdh.AwareOfFurtherInfections ?? false) ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.AwareOfConditionsForFurtherInfections);
bool sanitaryMeasuresApplied = mdh.SanitaryMeasuresApplied ?? false;
mdh_items.Add(sanitaryMeasuresApplied ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.SanitaryMeasuresApplied);
if (sanitaryMeasuresApplied)
{
//sanitarydetail[] sanitaryDetails = new sanitarydetail[mdh.SanitaryMeasuresDetails.Count];
for (int j = 0; j < mdh.SanitaryMeasuresDetails.Count; j++)
{
SanitaryMeasuresDetail detail = mdh.SanitaryMeasuresDetails[j] as SanitaryMeasuresDetail;
sanitarydetail aSanitaryDetail = new sanitarydetail();
//sanitaryDetails[j] = new sanitarydetail();
if (detail.SanitaryMeasuresDate.HasValue)
aSanitaryDetail.SanitaryMeasuresDate = detail.SanitaryMeasuresDate.Value;
aSanitaryDetail.SanitaryMeasuresLocation = detail.SanitaryMeasuresLocation;
aSanitaryDetail.SanitaryMeasuresType = detail.SanitaryMeasuresType;
mdh_items.Add(aSanitaryDetail);
mdh_types.Add(ItemsChoiceType5.SanitaryMeasuresDetails);
}
}
mdh_items.Add((mdh.StowawaysDetected ?? false) ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.StowawaysDetected);
foreach (StowawaysJoiningLocation joininglocation in mdh.StowawaysJoiningLocations)
{
mdh_items.Add(joininglocation.StowawayJoiningLocation);
mdh_types.Add(ItemsChoiceType5.StowawaysJoiningLocation);
}
mdh_items.Add((mdh.SickAnimalOrPetOnBoard ?? false) ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.SickAnimalOrPetOnBoard);
mdh_items.Add((mdh.ValidSanitaryControlExemptionOrCertificateOnBoard ?? false) ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.ValidSanitaryControlExemptionOrCertificateOnBoard);
if (mdh.ValidSanitaryControlExemptionOrCertificateOnBoard ?? false)
{
sanitarycertificate certificate = new sanitarycertificate();
if (mdh.DateOfIssue.HasValue)
certificate.DateOfIssue = mdh.DateOfIssue.Value;
certificate.PlaceOfIssue = mdh.PlaceOfIssue;
mdh_items.Add(certificate);
mdh_types.Add(ItemsChoiceType5.ValidSanitaryControlExemptionOrCertificate);
}
mdh_items.Add((mdh.SanitaryControlReinspectionRequired ?? false) ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.SanitaryControlReinspectionRequired);
bool infectedAreaVisited = mdh.InfectedAreaVisited ?? false;
mdh_items.Add(infectedAreaVisited ? yorntype.Y : yorntype.N);
mdh_types.Add(ItemsChoiceType5.InfectedAreaVisited);
if (infectedAreaVisited)
{
foreach (InfectedArea infectedArea in mdh.InfectedAreas)
{
infectedarea ia = new infectedarea();
if (infectedArea.InfectedAreaDate.HasValue)
ia.InfectedAreaDate = infectedArea.InfectedAreaDate.Value;
ia.InfectedAreaPort = infectedArea.InfectedAreaPort;
mdh_items.Add(ia);
mdh_types.Add(ItemsChoiceType5.InfectedArea);
}
}
portofcalls pocs = new portofcalls();
pocs.PortOfCallLast30Days = new portofcallmdh[mdh.PortOfCallLast30Days.Count];
for (int j = 0; j < mdh.PortOfCallLast30Days.Count; j++)
{
pocs.PortOfCallLast30Days[j] = new portofcallmdh();
PortOfCallLast30Days portOfCallLast30Days = mdh.PortOfCallLast30Days[j] as PortOfCallLast30Days;
pocs.PortOfCallLast30Days[j].PortOfCallLast30DaysLocode = portOfCallLast30Days.PortOfCallLast30DaysLocode;
if (portOfCallLast30Days.PortOfCallLast30DaysDateOfDeparture.HasValue)
pocs.PortOfCallLast30Days[j].PortOfCallLast30DaysDateOfDeparture = portOfCallLast30Days.PortOfCallLast30DaysDateOfDeparture.Value;
pocs.PortOfCallLast30Days[j].PortOfCallLast30DaysCrewMembersJoined = (portOfCallLast30Days.PortOfCallLast30DaysCrewMembersJoined ?? false) ? yorntype.Y : yorntype.N;
if (portOfCallLast30Days.CrewJoinedShip.Count > 0)
{
List<string> crewJoinedShipList = new List<string>();
for (int k = 0; k < portOfCallLast30Days.CrewJoinedShip.Count; k++)
{
if (!((PortOfCallLast30DaysCrewJoinedShip)portOfCallLast30Days.CrewJoinedShip[k]).PortOfCallLast30DaysCrewJoinedShipName.IsNullOrEmpty())
crewJoinedShipList.Add(((PortOfCallLast30DaysCrewJoinedShip)portOfCallLast30Days.CrewJoinedShip[k]).PortOfCallLast30DaysCrewJoinedShipName);
}
pocs.PortOfCallLast30Days[j].PortOfCallLast30DaysCrewJoinedShip = crewJoinedShipList.ToArray();
}
}
mdh_items.Add(pocs);
mdh_types.Add(ItemsChoiceType5.PortsOfCallLast30Days);
}
hn_mdh.Items = mdh_items.ToArray();
hn_mdh.ItemsElementName = mdh_types.ToArray();
items1.Add(hn_mdh);
items1ChoiceType.Add(Items1ChoiceType.MDH);
}
}
}
#endregion
#region WAS
if (message.MessageNotificationClass == Message.NotificationClass.WAS)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_WAS);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
WAS was = message.Elements[0] as WAS;
global::was hn_was = new global::was();
List<object> was_items = new List<object>();
List<ItemsChoiceType6> was_item_names = new List<ItemsChoiceType6>();
if (was.WasteDisposalValidExemption ?? false)
{
was_item_names.Add(ItemsChoiceType6.WasteDisposalValidExemption);
was_items.Add(ytype.Y);
}
else
{
was_items.Add(was.LastWasteDisposalPort);
was_item_names.Add(ItemsChoiceType6.LastWasteDisposalPort);
if (was.LastWasteDisposalDate.HasValue)
{
was_items.Add(was.LastWasteDisposalDate.Value);
was_item_names.Add(ItemsChoiceType6.LastWasteDisposalDate);
}
for (int i = 0; i < was.WasteDisposalServiceProvider.Count; i++)
{
if (!((WasteDisposalServiceProvider) was.WasteDisposalServiceProvider[i]).WasteDisposalServiceProviderName.IsNullOrEmpty())
{
was_items.Add(((WasteDisposalServiceProvider) was.WasteDisposalServiceProvider[i]).WasteDisposalServiceProviderName);
was_item_names.Add(ItemsChoiceType6.WasteDisposalServiceProviderName);
}
}
if (was.WasteDisposalDelivery.HasValue)
{
was_items.Add((wastedeliverytype)was.WasteDisposalDelivery);
was_item_names.Add(ItemsChoiceType6.WasteDisposalDelivery);
}
if (was.Waste.Count > 0)
{
for (int i = 0; i < was.Waste.Count; i++)
{
waste hn_waste = new waste();
Waste waste = was.Waste[i] as Waste;
if (waste.WasteDisposalAmount_MTQ.HasValue)
hn_waste.WasteDisposalAmount_MTQ = (float)waste.WasteDisposalAmount_MTQ.Value;
if (waste.WasteDisposedAtLastPort_MTQ.HasValue)
hn_waste.WasteDisposedAtLastPort_MTQ = (float)waste.WasteDisposedAtLastPort_MTQ.Value;
hn_waste.WasteType = new wastetyp();
if (waste.WasteType.HasValue)
hn_waste.WasteType.WasteCode = waste.WasteType.Value.ToString();
if(!waste.WasteDescription.IsNullOrEmpty())
hn_waste.WasteType.WasteDescription = waste.WasteDescription;
hn_waste.WasteDetails = new wastedetails();
hn_waste.WasteDetails.WasteAmountGeneratedTillNextPort_MTQSpecified = waste.WasteAmountGeneratedTillNextPort_MTQ.HasValue;
if (hn_waste.WasteDetails.WasteAmountGeneratedTillNextPort_MTQSpecified)
hn_waste.WasteDetails.WasteAmountGeneratedTillNextPort_MTQ = (float)waste.WasteAmountGeneratedTillNextPort_MTQ.Value;
hn_waste.WasteDetails.WasteAmountRetained_MTQSpecified = waste.WasteAmountRetained_MTQ.HasValue;
if (hn_waste.WasteDetails.WasteAmountRetained_MTQSpecified)
hn_waste.WasteDetails.WasteAmountRetained_MTQ = (float)waste.WasteAmountRetained_MTQ.Value;
hn_waste.WasteDetails.WasteCapacity_MTQSpecified = waste.WasteCapacity_MTQ.HasValue;
if (hn_waste.WasteDetails.WasteCapacity_MTQSpecified)
hn_waste.WasteDetails.WasteCapacity_MTQ = (float)waste.WasteCapacity_MTQ.Value;
hn_waste.WasteDetails.WasteDisposalPort = waste.WasteDisposalPort;
was_items.Add(hn_waste);
was_item_names.Add(ItemsChoiceType6.Waste);
}
}
if (was.ConfirmationOfCorrectness ?? false)
{
was_items.Add(ytype.Y);
was_item_names.Add(ItemsChoiceType6.ConfirmationOfCorrectnessAndSufficiency);
}
}
hn_was.Items = was_items.ToArray();
hn_was.ItemsElementName = was_item_names.ToArray();
items1.Add(hn_was);
items1ChoiceType.Add(Items1ChoiceType.WAS);
}
}
}
#endregion
#region BPOL
if (message.MessageNotificationClass == Message.NotificationClass.BPOL)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_BPOL);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
BPOL bpol = message.Elements[0] as BPOL;
global::bpol hn_bpol = new global::bpol();
hn_bpol.StowawayOnBoard = (bpol.StowawaysOnBoard ?? false) ? yorntype.Y : yorntype.N;
if (!bpol.PortOfItineraries.IsNullOrEmpty())
{
hn_bpol.PortOfItinerary = new portofitinery[bpol.PortOfItineraries.Count];
for (int i = 0; i < bpol.PortOfItineraries.Count; i++)
{
hn_bpol.PortOfItinerary[i] = new portofitinery();
PortOfItinerary portOfItinerary = bpol.PortOfItineraries[i] as PortOfItinerary;
hn_bpol.PortOfItinerary[i].PortOfItineryName = portOfItinerary.PortOfItineraryName;
if (portOfItinerary.PortOfItineraryETA.HasValue)
hn_bpol.PortOfItinerary[i].PortOfItineryETA = portOfItinerary.PortOfItineraryETA.Value;
}
}
items1ChoiceType.Add(Items1ChoiceType.BPOL);
items1.Add(hn_bpol);
}
}
}
#endregion
#region PAS
if (message.MessageNotificationClass == Message.NotificationClass.PAS)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_PAS);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
global::pas hn_pas = new pas();
hn_pas.Passenger = new passenger[message.Elements.Count];
for (int i = 0; i < message.Elements.Count; i++)
{
PAS pas = message.Elements[i] as PAS;
hn_pas.Passenger[i] = new passenger();
if (pas.PassengerDateOfBirth.HasValue)
hn_pas.Passenger[i].PassengerDateOfBirth = pas.PassengerDateOfBirth.Value;
hn_pas.Passenger[i].PassengerFirstName = pas.PassengerFirstName;
if (pas.PassengerGender.HasValue)
hn_pas.Passenger[i].PassengerGender = (gendertype)pas.PassengerGender.Value;
hn_pas.Passenger[i].PassengerGenderSpecified = pas.PassengerGender.HasValue;
hn_pas.Passenger[i].PassengerIdentityDocumentId = pas.PassengerIdentityDocumentId;
if (pas.PassengerIdentityDocumentType.HasValue)
hn_pas.Passenger[i].PassengerIdentityDocumentType = (documenttype)pas.PassengerIdentityDocumentType.Value;
if (pas.PassengerInTransit.HasValue)
hn_pas.Passenger[i].PassengerInTransit = pas.PassengerInTransit.Value ? yorntype.Y : yorntype.N;
hn_pas.Passenger[i].PassengerLastName = pas.PassengerLastName;
hn_pas.Passenger[i].PassengerNationality = pas.PassengerNationality;
hn_pas.Passenger[i].PassengerPlaceOfBirth = pas.PassengerPlaceOfBirth;
hn_pas.Passenger[i].PassengerPortOfDisembarkation = pas.PassengerPortOfDisembarkation;
hn_pas.Passenger[i].PassengerPortOfEmbarkation = pas.PassengerPortOfEmbarkation;
if(!pas.PassengerVisaNumber.IsNullOrEmpty())
hn_pas.Passenger[i].PassengerVisaNumber = pas.PassengerVisaNumber;
}
items1ChoiceType.Add(Items1ChoiceType.PAS);
items1.Add(hn_pas);
}
}
}
#endregion
#region CREW
if (message.MessageNotificationClass == Message.NotificationClass.CREW)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_CREW);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
global::crew hn_crew = new crew();
hn_crew.CrewMember = new crewmember[message.Elements.Count];
for (int i = 0; i < message.Elements.Count; i++)
{
CREW crew = message.Elements[i] as CREW;
hn_crew.CrewMember[i] = new crewmember();
if (crew.CrewMemberDateOfBirth.HasValue)
hn_crew.CrewMember[i].CrewMemberDateOfBirth = crew.CrewMemberDateOfBirth.Value;
hn_crew.CrewMember[i].CrewMemberDuty = crew.CrewMemberDuty;
hn_crew.CrewMember[i].CrewMemberFirstName = crew.CrewMemberFirstName;
if (crew.CrewMemberGender.HasValue)
hn_crew.CrewMember[i].CrewMemberGender = (gendertype)crew.CrewMemberGender.Value;
hn_crew.CrewMember[i].CrewMemberGenderSpecified = crew.CrewMemberGender.HasValue;
hn_crew.CrewMember[i].CrewMemberIdentityDocumentId = crew.CrewMemberIdentityDocumentId;
if (crew.CrewMemberIdentityDocumentType.HasValue)
hn_crew.CrewMember[i].CrewMemberIdentityDocumentType = (documenttype)crew.CrewMemberIdentityDocumentType.Value;
hn_crew.CrewMember[i].CrewMemberLastName = crew.CrewMemberLastName;
hn_crew.CrewMember[i].CrewMemberNationality = crew.CrewMemberNationality;
hn_crew.CrewMember[i].CrewMemberPlaceOfBirth = crew.CrewMemberPlaceOfBirth;
hn_crew.CrewMember[i].CrewMemberVisaNumber = crew.CrewMemberVisaNumber.IsNullOrEmpty() ? "-" : crew.CrewMemberVisaNumber;
}
items1ChoiceType.Add(Items1ChoiceType.CREW);
items1.Add(hn_crew);
}
}
}
#endregion
#region TOWA / TOWD
if (message.MessageNotificationClass == Message.NotificationClass.TOWA)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_TOWA);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
global::towa hn_towa = new towa();
hn_towa.TowageOnArrival = new arrival[message.Elements.Count];
for (int i = 0; i < message.Elements.Count; i++)
{
TOWA towa = message.Elements[0] as TOWA;
arrival hn_arrival = new arrival();
hn_towa.TowageOnArrival[i] = hn_arrival;
if (towa.TowageOnArrivalBeam_MTR.HasValue)
hn_arrival.TowageOnArrivalBeam_MTR = (float)towa.TowageOnArrivalBeam_MTR.Value;
if (towa.TowageOnArrivalDraught_DMT.HasValue)
hn_arrival.TowageOnArrivalDraught_DMT = (float)towa.TowageOnArrivalDraught_DMT.Value;
if(!towa.TowageOnArrivalFlag.IsNullOrEmpty())
hn_arrival.TowageOnArrivalFlag = towa.TowageOnArrivalFlag;
if (towa.TowageOnArrivalGrossTonnage.HasValue)
hn_arrival.TowageOnArrivalGrossTonnage = towa.TowageOnArrivalGrossTonnage.Value.ToString();
if (towa.TowageOnArrivalLengthOverall_MTR.HasValue)
hn_arrival.TowageOnArrivalLengthOverall_MTR = (float)towa.TowageOnArrivalLengthOverall_MTR.Value;
if(!towa.TowageOnArrivalName.IsNullOrEmpty())
hn_arrival.TowageOnArrivalName = towa.TowageOnArrivalName;
hn_arrival.TowageOnArrivalOperator = new arrivaloperator();
if(!towa.TowageOnArrivalOperatorCity.IsNullOrEmpty())
hn_arrival.TowageOnArrivalOperator.TowageOnArrivalOperatorCity = towa.TowageOnArrivalOperatorCity;
if(!towa.TowageOnArrivalOperatorCountry.IsNullOrEmpty())
hn_arrival.TowageOnArrivalOperator.TowageOnArrivalOperatorCountry = towa.TowageOnArrivalOperatorCountry;
if(!towa.TowageOnArrivalOperatorPostalCode.IsNullOrEmpty())
hn_arrival.TowageOnArrivalOperator.TowageOnArrivalOperatorPostalCode = towa.TowageOnArrivalOperatorPostalCode;
if(!towa.TowageOnArrivalOperatorStreetNameAndNumber.IsNullOrEmpty())
hn_arrival.TowageOnArrivalOperator.TowageOnArrivalOperatorStreetAndNumber = towa.TowageOnArrivalOperatorStreetNameAndNumber;
if(!towa.TowageOnArrivalOperatorFax.IsNullOrEmpty())
hn_arrival.TowageOnArrivalOperator.TowageOnArrivalOperatorFax = towa.TowageOnArrivalOperatorFax;
if(!towa.TowageOnArrivalOperatorPhone.IsNullOrEmpty())
hn_arrival.TowageOnArrivalOperator.TowageOnArrivalOperatorPhone = towa.TowageOnArrivalOperatorPhone;
if(!towa.TowageOnArrivalOperatorEmail.IsNullOrEmpty())
hn_arrival.TowageOnArrivalOperator.TowageOnArrivalOperatorEMail = towa.TowageOnArrivalOperatorEmail;
if(!towa.TowageOnArrivalOperatorCompanyName.IsNullOrEmpty())
hn_arrival.TowageOnArrivalOperator.TowageOnArrivalOperatorCompanyName = towa.TowageOnArrivalOperatorCompanyName;
if(!towa.TowageOnArrivalPurposeOfCall.IsNullOrEmpty())
hn_arrival.TowageOnArrivalPurposeOfCall = towa.TowageOnArrivalPurposeOfCall;
if(!towa.TowageOnArrivalRemarks.IsNullOrEmpty())
hn_arrival.TowageOnArrivalRemarks = towa.TowageOnArrivalRemarks;
}
items1ChoiceType.Add(Items1ChoiceType.TOWA);
items1.Add(hn_towa);
}
}
}
if (message.MessageNotificationClass == Message.NotificationClass.TOWD)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_TOWD);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
global::towd hn_towd = new towd();
hn_towd.TowageOnDeparture = new departure[message.Elements.Count];
for (int i = 0; i < message.Elements.Count; i++)
{
departure hn_departure = new departure();
hn_towd.TowageOnDeparture[i] = hn_departure;
TOWD towd = message.Elements[0] as TOWD;
hn_departure.TowageOnDepartureBeam_MTRSpecified = towd.TowageOnDepartureBeam_MTR.HasValue;
if (hn_departure.TowageOnDepartureBeam_MTRSpecified)
hn_departure.TowageOnDepartureBeam_MTR = (float)towd.TowageOnDepartureBeam_MTR.Value;
if (towd.TowageOnDepartureDraught_DMT.HasValue)
hn_departure.TowageOnDepartureDraught_DMT = (float)towd.TowageOnDepartureDraught_DMT.Value;
if(!towd.TowageOnDepartureFlag.IsNullOrEmpty())
hn_departure.TowageOnDepartureFlag = towd.TowageOnDepartureFlag;
if(!towd.TowageOnDepartureName.IsNullOrEmpty())
hn_departure.TowageOnDepartureName = towd.TowageOnDepartureName;
hn_departure.TowageOnDepartureOperator = new departureoperator();
if(!towd.TowageOnDepartureOperatorCity.IsNullOrEmpty())
hn_departure.TowageOnDepartureOperator.TowageOnDepartureOperatorCity = towd.TowageOnDepartureOperatorCity;
if(!towd.TowageOnDepartureOperatorCountry.IsNullOrEmpty())
hn_departure.TowageOnDepartureOperator.TowageOnDepartureOperatorCountry = towd.TowageOnDepartureOperatorCountry;
if(!towd.TowageOnDepartureOperatorPostalCode.IsNullOrEmpty())
hn_departure.TowageOnDepartureOperator.TowageOnDepartureOperatorPostalCode = towd.TowageOnDepartureOperatorPostalCode;
if(!towd.TowageOnDepartureOperatorStreetNameAndNumber.IsNullOrEmpty())
hn_departure.TowageOnDepartureOperator.TowageOnDepartureOperatorStreetAndNumber = towd.TowageOnDepartureOperatorStreetNameAndNumber;
if(!towd.TowageOnDepartureOperatorFax.IsNullOrEmpty())
hn_departure.TowageOnDepartureOperator.TowageOnDepartureOperatorFax = towd.TowageOnDepartureOperatorFax;
if(!towd.TowageOnDepartureOperatorPhone.IsNullOrEmpty())
hn_departure.TowageOnDepartureOperator.TowageOnDepartureOperatorPhone = towd.TowageOnDepartureOperatorPhone;
if(!towd.TowageOnDepartureOperatorEmail.IsNullOrEmpty())
hn_departure.TowageOnDepartureOperator.TowageOnDepartureOperatorEMail = towd.TowageOnDepartureOperatorEmail;
if(!towd.TowageOnDepartureOperatorCompanyName.IsNullOrEmpty())
hn_departure.TowageOnDepartureOperator.TowageOnDepartureOperatorCompanyName = towd.TowageOnDepartureOperatorCompanyName;
hn_departure.TowageOnDepartureLengthOverall_MTRSpecified = towd.TowageOnDepartureLengthOverall_MTR.HasValue;
if (hn_departure.TowageOnDepartureLengthOverall_MTRSpecified)
hn_departure.TowageOnDepartureLengthOverall_MTR = (float)towd.TowageOnDepartureLengthOverall_MTR.Value;
if(!towd.TowageOnDepartureRemarks.IsNullOrEmpty())
hn_departure.TowageOnDepartureRemarks = towd.TowageOnDepartureRemarks;
}
items1ChoiceType.Add(Items1ChoiceType.TOWD);
items1.Add(hn_towd);
}
}
}
#endregion
#region AGNT
if (message.MessageNotificationClass == Message.NotificationClass.AGNT)
{
if (message.Reset)
{
items1ChoiceType.Add(Items1ChoiceType.RESET_AGNT);
items1.Add(ytype.Y);
}
else
{
if (message.Elements.Count > 0)
{
AGNT agnt = message.Elements[0] as AGNT;
global::agnt hn_agnt = new global::agnt();
if(!agnt.AgentCity.IsNullOrEmpty())
hn_agnt.AgentCity = agnt.AgentCity;
hn_agnt.AgentCompanyName = agnt.AgentCompanyName;
if(!agnt.AgentCountry.IsNullOrEmpty())
hn_agnt.AgentCountry = agnt.AgentCountry;
if(!agnt.AgentEMail.IsNullOrEmpty())
hn_agnt.AgentEMail = agnt.AgentEMail;
if(!agnt.AgentFax.IsNullOrEmpty())
hn_agnt.AgentFax = agnt.AgentFax;
if(!agnt.AgentFirstName.IsNullOrEmpty())
hn_agnt.AgentFirstName = agnt.AgentFirstName;
hn_agnt.AgentLastName = agnt.AgentLastName;
hn_agnt.AgentPhone = agnt.AgentPhone;
if(!agnt.AgentPostalCode.IsNullOrEmpty())
hn_agnt.AgentPostalCode = agnt.AgentPostalCode;
if(!agnt.AgentStreetAndNumber.IsNullOrEmpty())
hn_agnt.AgentStreetAndNumber = agnt.AgentStreetAndNumber;
items1ChoiceType.Add(Items1ChoiceType.AGNT);
items1.Add(hn_agnt);
}
}
}
#endregion
}
_nsw.conveyance.Items1 = items1.ToArray();
_nsw.conveyance.Items1ElementName = items1ChoiceType.ToArray();
#endregion
#region serialize and save message
string outputDir = Path.Combine(useTest ? Properties.Settings.Default.TestTransmitterRoot : Properties.Settings.Default.LiveTransmitterRoot,
Properties.Settings.Default.OutputDir);
string filename = string.Format("BSMD_{1}-{2}-{0}.xml", (message == null) ? "CANCEL" : message.MessageNotificationClassDisplay, DateTime.Now.ToString("yyyyMMddHHmmss"), core.Id.Value);
_log.InfoFormat("saving {0} to output directory", filename);
string filePath = Path.Combine(outputDir, filename);
XmlSerializer serializer = new XmlSerializer(typeof(nsw));
using (TextWriter tw = new StreamWriter(filePath))
{
serializer.Serialize(tw, _nsw);
}
if (!coreFilenameDict.ContainsKey(core))
coreFilenameDict[core] = new Dictionary<Message, string>();
if(message != null)
coreFilenameDict[core][message] = filename;
coreUseTestDict[core] = useTest;
retval = true;
#endregion
}
catch (Exception ex)
{
_log.ErrorFormat("Error sending message via hisnord: {0}", ex);
retval = false;
}
return retval;
}
#region helper class to fill HAZ positions
private static void SetHAZPositions(dglist hn_dgList, HAZ haz)
{
List<object> dgList = new List<object>();
#region IMDGPositions
if (haz.IMDGPositions.Count > 0)
{
for (int i = 0; i < haz.IMDGPositions.Count; i++)
{
IMDGPosition imdgPosition = haz.IMDGPositions[i] as IMDGPosition;
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;
if(!imdgPosition.TechnicalName.IsNullOrEmpty())
pi.TechnicalName = imdgPosition.TechnicalName;
pi.NetExplosiveMass_KGMSpecified = imdgPosition.NetExplosiveMass_KGM.HasValue;
if (pi.NetExplosiveMass_KGMSpecified)
pi.NetExplosiveMass_KGM = (float)imdgPosition.NetExplosiveMass_KGM.Value;
if(!imdgPosition.Flashpoint_CEL.IsNullOrEmpty())
pi.Flashpoint_CEL = imdgPosition.Flashpoint_CEL;
if(!imdgPosition.Class7NuclideName.IsNullOrEmpty())
pi.Class7NuclideName = imdgPosition.Class7NuclideName;
pi.Class7MaxActivity_BQLSpecified = imdgPosition.Class7MaxActivity_BQL.HasValue;
if (pi.Class7MaxActivity_BQLSpecified)
pi.Class7MaxActivity_BQL = (float)imdgPosition.Class7MaxActivity_BQL.Value;
pi.Class7CategorySpecified = imdgPosition.Class7Category.HasValue;
if (pi.Class7CategorySpecified)
pi.Class7Category = (class7cattype)imdgPosition.Class7Category.Value;
pi.Class7TransportIndexSpecified = imdgPosition.Class7TransportIndex.HasValue;
if (pi.Class7TransportIndexSpecified)
pi.Class7TransportIndex = (float)imdgPosition.Class7TransportIndex.Value;
pi.Class7CSISpecified = imdgPosition.Class7CSI.HasValue;
if (pi.Class7CSISpecified)
pi.Class7CSI = (float)imdgPosition.Class7CSI.Value;
pi.ControlTemperature_CELSpecified = imdgPosition.ControlTemperature_CEL.HasValue;
if (pi.ControlTemperature_CELSpecified)
pi.ControlTemperature_CEL = (float)imdgPosition.ControlTemperature_CEL.Value;
pi.EmergencyTemperature_CELSpecified = imdgPosition.EmergencyTemperature_CEL.HasValue;
if (pi.EmergencyTemperature_CELSpecified)
pi.EmergencyTemperature_CEL = (float)imdgPosition.EmergencyTemperature_CEL.Value;
if(imdgPosition.SubsidiaryRiskList.Count > 0)
{
pi.SubsidiaryRisks = new string[Math.Min(imdgPosition.SubsidiaryRiskList.Count, 5)];
for (int j = 0; j < Math.Min(imdgPosition.SubsidiaryRiskList.Count, 5); j++)
pi.SubsidiaryRisks[j] = imdgPosition.SubsidiaryRiskList[j].SubsidiaryRisk;
}
pi.MarinePollutant = (imdgPosition.MarinePollutant ?? false) ? yorntype.Y : yorntype.N;
pi.NumberOfPackages = imdgPosition.NumberOfPackages?.ToString();
pi.PackageType = imdgPosition.PackageType;
pi.LimitedQuantities = (imdgPosition.LimitedQuantities ?? false) ? yorntype.Y : yorntype.N;
pi.ExceptedQuantities = (imdgPosition.ExceptedQuantities ?? false) ? yorntype.Y : yorntype.N;
pi.NetQuantity_KGMSpecified = imdgPosition.NetQuantity_KGM.HasValue;
if (pi.NetQuantity_KGMSpecified)
pi.NetQuantity_KGM = (float)imdgPosition.NetQuantity_KGM.Value;
pi.GrossQuantity_KGMSpecified = imdgPosition.GrossQuantity_KGM.HasValue;
if (pi.GrossQuantity_KGMSpecified)
pi.GrossQuantity_KGM = (float)imdgPosition.GrossQuantity_KGM.Value;
pi.Volume_MTQSpecified = imdgPosition.Volume_MTQ.HasValue;
if (pi.Volume_MTQSpecified)
pi.Volume_MTQ = (float)imdgPosition.Volume_MTQ.Value;
pi.GeneralCargoIBCSpecified = imdgPosition.GeneralCargoIBC.HasValue;
if (pi.GeneralCargoIBCSpecified)
pi.GeneralCargoIBC = imdgPosition.GeneralCargoIBC.Value ? yorntype.Y : yorntype.N;
if(!imdgPosition.ContainerNumber.IsNullOrEmpty())
pi.ContainerNumber = imdgPosition.ContainerNumber;
if(!imdgPosition.VehicleLicenseNumber.IsNullOrEmpty())
pi.VehicleLicenseNumber = imdgPosition.VehicleLicenseNumber;
if(!imdgPosition.StowagePosition.IsNullOrEmpty())
{
pi.Item = imdgPosition.StowagePosition;
}
else
{
global::stowagepositionbayrowtier spbrt = new global::stowagepositionbayrowtier();
spbrt.Bay = imdgPosition.Bay;
spbrt.Row = imdgPosition.Row;
spbrt.Tier = imdgPosition.Tier;
pi.Item = spbrt;
}
pi.PortOfLoading = imdgPosition.PortOfLoading;
pi.PortOfDischarge = imdgPosition.PortOfDischarge;
if(!imdgPosition.Remarks.IsNullOrEmpty())
pi.Remarks = imdgPosition.Remarks;
dgList.Add(pi);
}
}
#endregion
#region IBCPositions
if (haz.IBCPositions.Count > 0)
{
for (int i = 0; i < haz.IBCPositions.Count; i++)
{
positionibc pi = new positionibc();
IBCPosition ibcPosition = haz.IBCPositions[i] as IBCPosition;
pi.ProductName = ibcPosition.ProductName;
if (ibcPosition.PollutionCategory.HasValue)
pi.PollutionCategory = (polcattype)ibcPosition.PollutionCategory.Value;
pi.HazardsSpecified = ibcPosition.Hazards.HasValue;
if (pi.HazardsSpecified)
pi.Hazards = (hazardtype)ibcPosition.Hazards.Value;
if (ibcPosition.FlashpointInformation.HasValue)
pi.FlashpointInformation = (flashpointinfotype)ibcPosition.FlashpointInformation.Value;
if(!ibcPosition.Flashpoint_CEL.IsNullOrEmpty())
pi.Flashpoint_CEL = ibcPosition.Flashpoint_CEL;
if (ibcPosition.Quantity_KGM.HasValue)
pi.Quantity_KGM = (float)ibcPosition.Quantity_KGM.Value;
pi.StowagePosition = ibcPosition.StowagePosition;
pi.PortOfLoading = ibcPosition.PortOfLoading;
pi.PortOfDischarge = ibcPosition.PortOfDischarge;
pi.SpecRef15_19Specified = ibcPosition.SpecRef15_19.HasValue;
if (pi.SpecRef15_19Specified)
pi.SpecRef15_19 = ibcPosition.SpecRef15_19.Value ? yorntype.Y : yorntype.N;
if(!ibcPosition.Remarks.IsNullOrEmpty())
pi.Remarks = ibcPosition.Remarks;
dgList.Add(pi);
}
}
#endregion
#region IGCPositions
if (haz.IGCPositions.Count > 0)
{
for (int i = 0; i < haz.IGCPositions.Count; i++)
{
positionigc pi = new positionigc();
IGCPosition igcPosition = haz.IGCPositions[i] as IGCPosition;
if(!igcPosition.UNNumber.IsNullOrEmpty())
pi.UNNumber = igcPosition.UNNumber;
if(!igcPosition.IMOClass.IsNullOrEmpty())
pi.IMOClass = igcPosition.IMOClass;
pi.ProductName = igcPosition.ProductName;
if (igcPosition.Quantity_KGM.HasValue)
pi.Quantity_KGM = (float)igcPosition.Quantity_KGM.Value;
pi.StowagePosition = igcPosition.StowagePosition;
pi.PortOfLoading = igcPosition.PortOfLoading;
pi.PortOfDischarge = igcPosition.PortOfDischarge;
if(!igcPosition.Remarks.IsNullOrEmpty())
pi.Remarks = igcPosition.Remarks;
dgList.Add(pi);
}
}
#endregion
#region IMSBCPositions
if (haz.IMSBCPositions.Count > 0)
{
for (int i = 0; i < haz.IMSBCPositions.Count; i++)
{
positionimsbc pi = new positionimsbc();
IMSBCPosition imsbcPosition = haz.IMSBCPositions[i] as IMSBCPosition;
pi.BulkCargoShippingName = imsbcPosition.BulkCargoShippingName;
pi.MHB = (imsbcPosition.MHB ?? false) ? yorntype.Y : yorntype.N;
if(!imsbcPosition.UNNumber.IsNullOrEmpty())
pi.UNNumber = imsbcPosition.UNNumber;
if(!imsbcPosition.IMOClass.IsNullOrEmpty())
pi.IMOClass = imsbcPosition.IMOClass;
if (imsbcPosition.Quantity_KGM.HasValue)
pi.Quantity_KGM = (float)imsbcPosition.Quantity_KGM.Value;
pi.StowagePosition = imsbcPosition.StowagePosition;
pi.PortOfLoading = imsbcPosition.PortOfLoading;
pi.PortOfDischarge = imsbcPosition.PortOfDischarge;
if(!imsbcPosition.Remarks.IsNullOrEmpty())
pi.Remarks = imsbcPosition.Remarks;
dgList.Add(pi);
}
}
#endregion
#region MARPOLPositions
if (haz.MARPOLPositions.Count > 0)
{
for (int i = 0; i < haz.MARPOLPositions.Count; i++)
{
positionmarpol pi = new positionmarpol();
MARPOL_Annex_I_Position marpolPosition = haz.MARPOLPositions[i] as MARPOL_Annex_I_Position;
pi.Name = marpolPosition.Name;
if (marpolPosition.FlashpointInformation.HasValue)
pi.FlashpointInformation = (flashpointinfotype)marpolPosition.FlashpointInformation.Value;
if(!marpolPosition.Flashpoint_CEL.IsNullOrEmpty())
pi.Flashpoint_CEL = marpolPosition.Flashpoint_CEL;
if (marpolPosition.Quantity_KGM.HasValue)
pi.Quantity_KGM = (float)marpolPosition.Quantity_KGM.Value;
pi.StowagePosition = marpolPosition.StowagePosition;
pi.PortOfLoading = marpolPosition.PortOfLoading;
pi.PortOfDischarge = marpolPosition.PortOfDischarge;
if(!marpolPosition.Remarks.IsNullOrEmpty())
pi.Remarks = marpolPosition.Remarks;
dgList.Add(pi);
}
}
#endregion
hn_dgList.Items = dgList.ToArray();
}
#endregion
}
}