1412 lines
69 KiB
C#
1412 lines
69 KiB
C#
// Copyright (c) 2017- schick Informatik
|
|
// Description:
|
|
//
|
|
|
|
using Microsoft.Office.Interop.Excel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
|
|
using bsmd.database;
|
|
using ENI2.Report;
|
|
using ENI2.Util;
|
|
|
|
namespace ENI2.Excel
|
|
{
|
|
internal class ExcelWriter : ExcelBase
|
|
{
|
|
|
|
#region Fields
|
|
|
|
private readonly string _saveFilePath;
|
|
|
|
#endregion
|
|
|
|
#region Construction
|
|
|
|
public ExcelWriter(string filePath, bool isRefSheet) : base(filePath)
|
|
{
|
|
string filename = @"Excel\EU-NoAD-Data-Collecting-Tool-5_0.xlsx";
|
|
if (isRefSheet) filename = @"Excel\Reference_Sheet_DE.xlsx";
|
|
|
|
string refFilePath = System.IO.Path.Combine(Environment.CurrentDirectory, filename);
|
|
this._workBook = _excelWorkbooks.Open(refFilePath, 0, true, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false);
|
|
|
|
this.InitNameFields();
|
|
_saveFilePath = filePath;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region public methods
|
|
|
|
public void WriteData(List<Message> messages, MessageCore core, out string resultMessage, bool isRefSheet)
|
|
{
|
|
resultMessage = "";
|
|
|
|
foreach (Message message in messages)
|
|
{
|
|
try
|
|
{
|
|
switch(message.MessageNotificationClass)
|
|
{
|
|
case Message.NotificationClass.AGNT:
|
|
if (message.Elements[0] is AGNT agnt) this.WriteMessage(agnt);
|
|
break;
|
|
case Message.NotificationClass.ATA:
|
|
if (message.Elements[0] is ATA ata)
|
|
{
|
|
WriteDate("ATA.ATADatePortOfCall", ata.ATAPortOfCall);
|
|
WriteTime("ATA.ATATimePortOfCall", ata.ATAPortOfCall);
|
|
}
|
|
break;
|
|
case Message.NotificationClass.ATD:
|
|
if (message.Elements[0] is ATD atd)
|
|
{
|
|
WriteDate("ATD.ATDDatePortOfCall", atd.ATDPortOfCall);
|
|
WriteTime("ATD.ATDTimePortOfCall", atd.ATDPortOfCall);
|
|
}
|
|
break;
|
|
case Message.NotificationClass.BKRA:
|
|
this.WriteBKRA(message);
|
|
break;
|
|
case Message.NotificationClass.BKRD:
|
|
this.WriteBKRD(message);
|
|
break;
|
|
case Message.NotificationClass.BPOL:
|
|
if (message.Elements[0] is BPOL bpol)
|
|
{
|
|
this.WriteMessage(bpol);
|
|
this.WriteItineraries(bpol);
|
|
}
|
|
break;
|
|
case Message.NotificationClass.CREW:
|
|
this.WriteCREW(message, true, isRefSheet);
|
|
break;
|
|
//case Message.NotificationClass.CREWD: // XXX-TODO
|
|
// this.WriteCREW(message, false, isRefSheet);
|
|
// break;
|
|
case Message.NotificationClass.HAZA:
|
|
this.WriteHAZ(message, true);
|
|
break;
|
|
case Message.NotificationClass.HAZD:
|
|
this.WriteHAZ(message, false);
|
|
break;
|
|
case Message.NotificationClass.INFO:
|
|
if (message.Elements[0] is INFO info)
|
|
{
|
|
this.WriteMessage(info);
|
|
this.WriteINFO(info, isRefSheet);
|
|
}
|
|
break;
|
|
case Message.NotificationClass.LADG:
|
|
this.WriteLADG(message, isRefSheet);
|
|
break;
|
|
case Message.NotificationClass.MDH:
|
|
if (message.Elements[0] is MDH mdh)
|
|
{
|
|
this.WriteMessage(mdh);
|
|
this.WriteMDH(mdh);
|
|
}
|
|
break;
|
|
case Message.NotificationClass.NAME:
|
|
if (message.Elements[0] is NAME name) this.WriteMessage(name);
|
|
break;
|
|
case Message.NotificationClass.NOA_NOD:
|
|
if (message.Elements[0] is NOA_NOD noa_nod) this.WriteNOA_NOD(noa_nod, core.IsTransit, isRefSheet);
|
|
break;
|
|
case Message.NotificationClass.PAS:
|
|
this.WritePAS(message, true, isRefSheet);
|
|
break;
|
|
//case Message.NotificationClass.PASD: // XXX - TODO
|
|
// this.WritePAS(message, false, isRefSheet);
|
|
// break;
|
|
case Message.NotificationClass.POBA:
|
|
if (message.Elements[0] is POBA poba) this.WriteMessage(poba);
|
|
break;
|
|
case Message.NotificationClass.POBD:
|
|
if (message.Elements[0] is POBD pobd) this.WriteMessage(pobd);
|
|
break;
|
|
case Message.NotificationClass.PRE72H:
|
|
if (message.Elements[0] is PRE72H pre72h)
|
|
{
|
|
this.WriteMessage(pre72h);
|
|
this.WritePRE72H(pre72h);
|
|
}
|
|
break;
|
|
case Message.NotificationClass.SEC:
|
|
if (message.Elements[0] is SEC sec) this.WriteMessage(sec);
|
|
this.WriteSEC(message, isRefSheet);
|
|
break;
|
|
case Message.NotificationClass.SERV:
|
|
this.WriteSERV(message);
|
|
break;
|
|
case Message.NotificationClass.STAT:
|
|
if (message.Elements[0] is STAT stat)
|
|
{
|
|
this.WriteMessage(stat);
|
|
this.WriteSTAT(stat, isRefSheet);
|
|
}
|
|
break;
|
|
case Message.NotificationClass.STO:
|
|
this.WriteSTO(message);
|
|
break;
|
|
case Message.NotificationClass.TIEFA:
|
|
if (message.Elements[0] is TIEFA tiefa)
|
|
{
|
|
// Ref-Sheet: dm, neues Formblatt: m
|
|
if (tiefa.DraughtUponArrival_DMT.HasValue)
|
|
WriteNumber("TIEFA.DraughtUponArrival_DMT", tiefa.DraughtUponArrival_DMT.Value / (isRefSheet ? 1 : 10.0));
|
|
}
|
|
break;
|
|
case Message.NotificationClass.TIEFD:
|
|
if (message.Elements[0] is TIEFD tiefd)
|
|
{
|
|
// Ref-Sheet: dm, neues Formblatt: m
|
|
if (tiefd.DraughtUponDeparture_DMT.HasValue)
|
|
WriteNumber("TIEFD.DraughtUponDeparture_DMT", tiefd.DraughtUponDeparture_DMT.Value / (isRefSheet ? 1 : 10.0));
|
|
}
|
|
break;
|
|
case Message.NotificationClass.TOWA:
|
|
WriteTOWA(message, isRefSheet);
|
|
break;
|
|
case Message.NotificationClass.TOWD:
|
|
WriteTOWD(message, isRefSheet);
|
|
break;
|
|
case Message.NotificationClass.WAS:
|
|
if (message.Elements[0] is WAS was) this.WriteMessage(was);
|
|
WriteWAS(message, isRefSheet);
|
|
break;
|
|
case Message.NotificationClass.WAS_RCPT:
|
|
WriteWAS_RCPT(message);
|
|
break;
|
|
default:
|
|
_log.InfoFormat("skip writing message class {0}", message.MessageNotificationClassDisplay);
|
|
break;
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
resultMessage += string.Format("{2}:{0}{1}", ex.Message, Environment.NewLine, message.MessageNotificationClassDisplay);
|
|
}
|
|
}
|
|
|
|
WriteCore(core, isRefSheet);
|
|
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
this._workBook.SaveAs(_saveFilePath, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange,
|
|
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
|
|
this._workBook.Saved = true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region private excel field writing
|
|
|
|
// generische Methode zum Schreiben der Felder nach Excel für Meldeklassen, die kein
|
|
// Listentyp sind
|
|
private void WriteMessage(DatabaseEntity dbEntity)
|
|
{
|
|
Type objType = dbEntity.GetType();
|
|
List<PropertyInfo> props = new List<PropertyInfo>();
|
|
|
|
// add lookup properties to scan list
|
|
props.AddRange(objType.GetProperties().Where(prop => Attribute.IsDefined(prop, typeof(LookupNameAttribute))));
|
|
|
|
|
|
foreach (PropertyInfo property in props)
|
|
{
|
|
object propValue = property.GetValue(dbEntity, null);
|
|
string value = (propValue == null) ? string.Empty : propValue.ToString();
|
|
LookupNameAttribute lookupNameAttribute = Attribute.GetCustomAttribute(property, typeof(LookupNameAttribute)) as LookupNameAttribute;
|
|
bool success = true;
|
|
|
|
if (property.PropertyType == typeof(DateTime?))
|
|
{
|
|
success = this.WriteDate(lookupNameAttribute.LookupName, property.GetValue(dbEntity));
|
|
}
|
|
else if (property.PropertyType == typeof(double?))
|
|
{
|
|
success = this.WriteNumber(lookupNameAttribute.LookupName, property.GetValue(dbEntity));
|
|
}
|
|
else if (property.PropertyType == typeof(string))
|
|
{
|
|
success = this.WriteText(lookupNameAttribute.LookupName, property.GetValue(dbEntity));
|
|
}
|
|
else if (property.PropertyType == typeof(int?))
|
|
{
|
|
success = this.WriteNumber(lookupNameAttribute.LookupName, property.GetValue(dbEntity));
|
|
}
|
|
else if (property.PropertyType == typeof(byte?))
|
|
{
|
|
success = this.WriteNumber(lookupNameAttribute.LookupName, property.GetValue(dbEntity));
|
|
}
|
|
else if (property.PropertyType == typeof(Boolean?))
|
|
{
|
|
object boolVal = property.GetValue(dbEntity);
|
|
if(boolVal != null)
|
|
success = this.WriteBoolean(lookupNameAttribute.LookupName, boolVal);
|
|
}
|
|
else
|
|
{
|
|
string message = string.Format("unhandled property type: {0} for lookup {1}", property.PropertyType, lookupNameAttribute.LookupName);
|
|
_log.Warn(message);
|
|
}
|
|
|
|
if (!success)
|
|
{
|
|
string message = string.Format("Sheet does not contain lookup field {0}", lookupNameAttribute.LookupName);
|
|
_log.Error(message);
|
|
System.Diagnostics.Trace.WriteLine(message);
|
|
// throw new FormatException(message);
|
|
}
|
|
}
|
|
}
|
|
|
|
private void WriteCore(MessageCore core, bool isRefSheet)
|
|
{
|
|
WriteText("ID", core.IsTransit ? core.TransitId : core.VisitId);
|
|
WriteText("Visit.PortOfCall", isRefSheet ? core.PoC : Locode.LocodeDB.LocationNameFromLocode(core.PoC));
|
|
WriteText("Visit.IMONumber", core.IMO);
|
|
WriteText("ReferenceNumber", core.HerbergReportType);
|
|
WriteText("ShipMail", core.HerbergEmailContactReportingVessel);
|
|
}
|
|
|
|
#region list / special message classes
|
|
|
|
#region LADG
|
|
|
|
private void WriteLADG(Message ladgMessage, bool isRefSheet)
|
|
{
|
|
for (int i = 0; i < Math.Min(ladgMessage.NumberOfExcelRows, ladgMessage.Elements.Count); i++)
|
|
{
|
|
string lnCHT = string.Format("LADG.CargoHandlingType_{0}", i + 1);
|
|
string lnType = string.Format("LADG.CargoType_{0}", i + 1);
|
|
string lnCNOI = string.Format("LADG.CargoNumberOfItems_{0}", i + 1);
|
|
string lnCGQ = string.Format("LADG.CargoGrossQuantity_TNE_{0}", i + 1);
|
|
string lnLoad = string.Format("LADG.CargoPortOfLoading_{0}", i + 1);
|
|
string lnDis = string.Format("LADG.CargoPortOfDischarge_{0}", i + 1);
|
|
string lnLACode = string.Format("LADG.CargoLACode_{0}", i + 1);
|
|
string lnZusatz = string.Format("LADG.CargoTypeZusatz_{0}", i + 1);
|
|
|
|
LADG ladg = ladgMessage.Elements[i] as LADG;
|
|
if (ladg.CargoHandlingType.HasValue)
|
|
{
|
|
switch (ladg.CargoHandlingType)
|
|
{
|
|
case 0: WriteText(lnCHT, "load"); break;
|
|
case 1: WriteText(lnCHT, "discharge"); break;
|
|
case 2: WriteText(lnCHT, "transit"); break;
|
|
default: break;
|
|
}
|
|
}
|
|
|
|
if (isRefSheet)
|
|
{
|
|
WriteText(lnType, ladg.CargoCodeNST);
|
|
}
|
|
else
|
|
{
|
|
if (ReportDocument.cargoCodesNST.TryGetValue(ladg.CargoCodeNST, out string cargoCode))
|
|
WriteText(lnType, cargoCode.Substring(3)); // description w/o code
|
|
}
|
|
WriteText(lnZusatz, ladg.CargoCodeNST_3);
|
|
WriteNumber(lnCNOI, ladg.CargoNumberOfItems);
|
|
WriteNumber(lnCGQ, ladg.CargoGrossQuantity_TNE);
|
|
WriteText(lnLoad, isRefSheet ? ladg.PortOfLoading : Locode.LocodeDB.LocationNameFromLocode(ladg.PortOfLoading));
|
|
WriteText(lnDis, isRefSheet ? ladg.PortOfDischarge : Locode.LocodeDB.LocationNameFromLocode(ladg.PortOfDischarge));
|
|
WriteNumber(lnLACode, ladg.CargoLACode);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region BKRA
|
|
|
|
private void WriteBKRA(Message bkraMessage)
|
|
{
|
|
for (int i = 0; i < Math.Min(bkraMessage.NumberOfExcelRows, bkraMessage.Elements.Count); i++)
|
|
{
|
|
string lnQuantity = string.Format("BKRA.BunkerFuelQuantity_TNE_{0}", i + 1);
|
|
string lnType = string.Format("BKRA.BunkerFuelType_{0}", i + 1);
|
|
BRKA brka = bkraMessage.Elements[i] as BRKA;
|
|
WriteNumber(lnQuantity, brka.BunkerFuelQuantity_TNE);
|
|
WriteText(lnType, brka.BunkerFuelType);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region BKRD
|
|
|
|
private void WriteBKRD(Message bkrdMessage)
|
|
{
|
|
for (int i = 0; i < Math.Min(bkrdMessage.NumberOfExcelRows, bkrdMessage.Elements.Count); i++)
|
|
{
|
|
string lnQuantity = string.Format("BKRD.BunkerFuelQuantity_TNE_{0}", i + 1);
|
|
string lnType = string.Format("BKRD.BunkerFuelType_{0}", i + 1);
|
|
BRKD brkd = bkrdMessage.Elements[i] as BRKD;
|
|
WriteNumber(lnQuantity, brkd.BunkerFuelQuantity_TNE);
|
|
WriteText(lnType, brkd.BunkerFuelType);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region BPOL
|
|
|
|
private void WriteItineraries(BPOL bpol)
|
|
{
|
|
for (int i = 0; i < Math.Min(10, bpol.PortOfItineraries.Count); i++)
|
|
{
|
|
string bpolName = string.Format("BPOL.PortOfItineraryName_{0}", i + 1);
|
|
string bpolLocode = string.Format("BPOL.PortOfItineraryLoCode_{0}", i + 1);
|
|
string bpolETADate = string.Format("BPOL.PortOfItineraryETADate_{0}", i + 1);
|
|
string bpolETATime = string.Format("BPOL.PortOfItineraryETATime_{0}", i + 1);
|
|
PortOfItinerary poi = bpol.PortOfItineraries[i];
|
|
WriteText(bpolName, poi.PortOfItineraryName);
|
|
WriteText(bpolLocode, poi.PortOfItineraryLocode);
|
|
if (poi.PortOfItineraryETA.HasValue)
|
|
{
|
|
WriteDate(bpolETADate, poi.PortOfItineraryETA.Value);
|
|
WriteTime(bpolETATime, poi.PortOfItineraryETA.Value);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CREW
|
|
|
|
private void WriteCREW(Message crewMessage, bool isArrival, bool isRefSheet)
|
|
{
|
|
|
|
/* XXX - TODO
|
|
if (crewMessage.Elements.Count > 0)
|
|
{
|
|
WriteBoolean(string.Format("CREW{0}.NotificationSchengen", isArrival ? "" : "D"), ((CREW)crewMessage.Elements[0]).NotificationSchengen);
|
|
WriteBoolean(string.Format("CREW{0}.NotificationPAX", isArrival ? "" : "D"), ((CREW)crewMessage.Elements[0]).NotificationPAX);
|
|
}
|
|
*/
|
|
|
|
for(int i = 0; i<Math.Min(crewMessage.NumberOfExcelRows, crewMessage.Elements.Count); i++)
|
|
{
|
|
string crewLastName = string.Format("CREW{1}.CrewMemberLastName_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewFirstName = string.Format("CREW{1}.CrewMemberFirstName_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewGender = string.Format("CREW{1}.CrewMemberGender_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewNationality = string.Format("CREW{1}.CrewMemberNationality_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewDuty = string.Format("CREW{1}.CrewMemberDuty_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewPlaceOfBirth = string.Format("CREW{1}.CrewMemberPlaceOfBirth_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewDateOfBirth = string.Format("CREW{1}.CrewMemberDateOfBirth_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewIdentDocType = string.Format("CREW{1}.CrewMemberIdentityDocumentType_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewIdentDocId = string.Format("CREW{1}.CrewMemberIdentityDocumentId_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewVisaNo = string.Format("CREW{1}.CrewMemberVisaNumber_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewIssuingState = string.Format("CREW{1}.CrewMemberIdentityDocumentIssuingState_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewExpiry = string.Format("CREW{1}.CrewmemberIdentityDocumentExpiryDate_{0}", i + 1, isArrival ? "" : "D");
|
|
string crewCountry = string.Format("CREW{1}.CountryOfBirth_{0}", i + 1, isArrival ? "" : "D");
|
|
string effects = string.Format("CREW.Effects_{0}", i + 1);
|
|
|
|
CREW crew = crewMessage.Elements[i] as CREW; // das funktioniert weil CREWD von CREW ableitet..
|
|
|
|
WriteText(crewLastName, crew.CrewMemberLastName);
|
|
WriteText(crewFirstName, crew.CrewMemberFirstName);
|
|
if (isRefSheet)
|
|
WriteGenderCode(crewGender, crew.CrewMemberGender);
|
|
else
|
|
WriteGenderFull(crewGender, crew.CrewMemberGender);
|
|
WriteText(crewNationality, crew.CrewMemberNationality);
|
|
WriteText(crewDuty, crew.CrewMemberDuty);
|
|
WriteText(crewPlaceOfBirth, crew.CrewMemberPlaceOfBirth);
|
|
if(crew.CrewMemberDateOfBirth.HasValue)
|
|
WriteDate(crewDateOfBirth, crew.CrewMemberDateOfBirth.Value);
|
|
WriteText(crewIdentDocType, crew.CrewMemberIdentityDocumentTypeDisplay);
|
|
WriteText(crewIdentDocId, crew.CrewMemberIdentityDocumentId);
|
|
WriteText(crewVisaNo, crew.CrewMemberVisaNumber);
|
|
if (isRefSheet)
|
|
{
|
|
WriteText(crewIssuingState, crew.CrewMemberIdentityDocumentIssuingState);
|
|
}
|
|
else
|
|
{
|
|
if(!crew.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty() && !crew.CrewMemberIdentityDocumentIssuingState.Equals("XX"))
|
|
WriteText(crewIssuingState, crew.CrewMemberIdentityDocumentIssuingState);
|
|
}
|
|
if(isRefSheet)
|
|
{
|
|
WriteDate(crewExpiry, crew.CrewMemberIdentityDocumentExpiryDate);
|
|
}
|
|
else
|
|
{
|
|
if(crew.CrewMemberIdentityDocumentExpiryDate != new DateTime(2100, 12, 31))
|
|
WriteDate(crewExpiry, crew.CrewMemberIdentityDocumentExpiryDate);
|
|
}
|
|
|
|
WriteText(crewCountry, crew.CrewMemberCountryOfBirth);
|
|
if (isArrival)
|
|
WriteText(effects, crew.Effects);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region HAZ
|
|
|
|
private void WriteHAZ(Message hazMessage, bool isArrival)
|
|
{
|
|
string noDPGOnBoard = isArrival ? "HAZA.DGOnBoard" : "HAZD.DGOnBoard";
|
|
string dpgManifestOnBoard = isArrival ? "HAZA.DPGManifestOnBoardOnArrival" : "HAZD.DPGManifestOnBoardOnDeparture";
|
|
string dpgContactFamilyName = isArrival ? "HAZA.DPGContactFamilyName" : "HAZD.DPGContactFamilyName";
|
|
string dpgContactPhone = isArrival ? "HAZA.DPGContactPhone" : "HAZD.DPGContactPhone";
|
|
string mouBaltic = isArrival ? "HAZA.MOUBaltic" : "HAZD.MOUBaltic";
|
|
string shipClass = isArrival ? "HAZA.INFShipClass" : "HAZD.INFShipClass";
|
|
HAZ haz = hazMessage.Elements[0] as HAZ;
|
|
WriteBoolean(noDPGOnBoard, !haz.NoDPGOnBoardOnArrival); // inverted "logic" in exported sheet
|
|
WriteBoolean(dpgManifestOnBoard, haz.DPGManifestOnBoardOnArrival);
|
|
WriteText(dpgContactFamilyName, haz.DPGContactFamilyName);
|
|
WriteText(dpgContactPhone, haz.DPGContactPhone);
|
|
WriteBoolean(mouBaltic, haz.MOUBaltic);
|
|
switch(haz.INFShipClass)
|
|
{
|
|
case 0: WriteText(shipClass, "INF1"); break;
|
|
case 1: WriteText(shipClass, "INF2"); break;
|
|
case 2: WriteText(shipClass, "INF3"); break;
|
|
}
|
|
|
|
string className = isArrival ? "HAZA" : "HAZD";
|
|
|
|
#region IMDG
|
|
|
|
for (int i = 0; i < Math.Min(haz.IMDGPositions.Count, 10); i++)
|
|
{
|
|
string imdg_unno = string.Format("{1}.IMDG.UNNumber_{0}", i + 1, className);
|
|
string imdg_properShippingName = string.Format("{1}.IMDG.ProperShippingName_{0}", i + 1, className);
|
|
string imdg_imoClass = string.Format("{1}.IMDG.IMOClass_{0}", i + 1, className);
|
|
string imdg_packingGroup = string.Format("{1}.IMDG.PackingGroup_{0}", i + 1, className);
|
|
string imdg_marinePollutant = string.Format("{1}.IMDG.MarinePollutant_{0}", i + 1, className);
|
|
string imdg_flashpoint = string.Format("{1}.IMDG.Flashpoint_CEL_{0}", i + 1, className);
|
|
string imdg_numberOfPackages = string.Format("{1}.IMDG.NumberOfPackages_{0}", i + 1, className);
|
|
string imdg_packageType = string.Format("{1}.IMDG.PackageType_{0}", i + 1, className);
|
|
string imdg_limitedQuantities = string.Format("{1}.IMDG.LimitedQuantities_{0}", i + 1, className);
|
|
string imdg_exceptedQuantities = string.Format("{1}.IMDG.ExceptedQuantities_{0}", i + 1, className);
|
|
string imdg_netQuantity = string.Format("{1}.IMDG.NetQuantity_KGM_{0}", i + 1, className);
|
|
string imdg_grossQuantity = string.Format("{1}.IMDG.GrossQuantity_KGM_{0}", i + 1, className);
|
|
string imdg_number = string.Format("{1}.IMDG.Number_{0}", i + 1, className);
|
|
string imdg_stowagePosition = string.Format("{1}.IMDG.StowagePosition_{0}", i + 1, className);
|
|
string imdg_portOfLoading = string.Format("{1}.IMDG.PortOfLoading_{0}", i + 1, className);
|
|
string imdg_portOfDischarge = string.Format("{1}.IMDG.PortOfDischarge_{0}", i + 1, className);
|
|
string imdg_containerNumber = string.Format("{1}.IMDG.ContainerNumber_{0}", i + 1, className);
|
|
string imdg_remarks = string.Format("{1}.IMDG.Remarks_{0}", i + 1, className);
|
|
IMDGPosition imdgPosition = haz.IMDGPositions[i];
|
|
WriteText(imdg_unno, imdgPosition.UNNumber);
|
|
WriteText(imdg_properShippingName, imdgPosition.ProperShippingName);
|
|
WriteText(imdg_imoClass, imdgPosition.IMOClass);
|
|
if (imdgPosition.PackingGroup.HasValue)
|
|
{
|
|
switch (imdgPosition.PackingGroup.Value)
|
|
{
|
|
case 0: WriteText(imdg_packingGroup, "I"); break;
|
|
case 1: WriteText(imdg_packingGroup, "II"); break;
|
|
case 2: WriteText(imdg_packingGroup, "III"); break;
|
|
}
|
|
}
|
|
WriteBoolean(imdg_marinePollutant, imdgPosition.MarinePollutant);
|
|
WriteText(imdg_flashpoint, imdgPosition.Flashpoint_CEL);
|
|
if (imdgPosition.NumberOfPackages.HasValue)
|
|
WriteNumber(imdg_numberOfPackages, imdgPosition.NumberOfPackages.Value);
|
|
WriteText(imdg_packageType, imdgPosition.PackageType);
|
|
WriteBoolean(imdg_limitedQuantities, imdgPosition.LimitedQuantities);
|
|
WriteBoolean(imdg_exceptedQuantities, imdgPosition.ExceptedQuantities);
|
|
if (imdgPosition.NetQuantity_KGM.HasValue)
|
|
WriteNumber(imdg_netQuantity, imdgPosition.NetQuantity_KGM.Value);
|
|
if (imdgPosition.GrossQuantity_KGM.HasValue)
|
|
WriteNumber(imdg_grossQuantity, imdgPosition.GrossQuantity_KGM.Value);
|
|
WriteText(imdg_number, imdgPosition.VehicleLicenseNumber);
|
|
WriteText(imdg_stowagePosition, imdgPosition.StowagePosition);
|
|
WriteText(imdg_portOfLoading, imdgPosition.PortOfLoading);
|
|
WriteText(imdg_portOfDischarge, imdgPosition.PortOfDischarge);
|
|
WriteText(imdg_containerNumber, imdgPosition.ContainerNumber);
|
|
WriteText(imdg_remarks, imdgPosition.Remarks);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IBC
|
|
|
|
for (int i = 0; i < Math.Min(haz.IBCPositions.Count, 5); i++)
|
|
{
|
|
string ibc_productName = string.Format("{1}.IBC.ProductName_{0}", i + 1, className);
|
|
string ibc_pollutionCategory = string.Format("{1}.IBC.PollutionCategory_{0}", i + 1, className);
|
|
string ibc_flash = string.Format("{1}.IBC.Flashpoint_CEL_{0}", i + 1, className);
|
|
string ibc_quantity = string.Format("{1}.IBC.Quantity_KGM_{0}", i + 1, className);
|
|
string ibc_stowagePosition = string.Format("{1}.IBC.StowagePosition_{0}", i + 1, className);
|
|
string ibc_portOfLoading = string.Format("{1}.IBC.PortOfLoading_{0}", i + 1, className);
|
|
string ibc_portOfDischarge = string.Format("{1}.IBC.PortOfDischarge_{0}", i + 1, className);
|
|
string ibc_hazards = string.Format("{1}.IBC.Hazards_{0}", i + 1, className);
|
|
string ibc_specref = string.Format("{1}.IBC.SpecRef15_19_{0}", i + 1, className);
|
|
string ibc_remarks = string.Format("{1}.IBC.Remarks_{0}", i + 1, className);
|
|
IBCPosition ibcPosition = haz.IBCPositions[i];
|
|
WriteText(ibc_productName, ibcPosition.ProductName);
|
|
if(ibcPosition.PollutionCategory.HasValue)
|
|
{
|
|
switch(ibcPosition.PollutionCategory.Value)
|
|
{
|
|
case 0: WriteText(ibc_pollutionCategory, "X"); break;
|
|
case 1: WriteText(ibc_pollutionCategory, "Y"); break;
|
|
case 2: WriteText(ibc_pollutionCategory, "Z"); break;
|
|
case 3: WriteText(ibc_pollutionCategory, "OS"); break;
|
|
}
|
|
}
|
|
|
|
if (ibcPosition.FlashpointInformation == 0) // == "NF"
|
|
WriteText(ibc_flash, "-");
|
|
else
|
|
WriteText(ibc_flash, ibcPosition.Flashpoint_CEL);
|
|
|
|
if (ibcPosition.Quantity_KGM.HasValue)
|
|
WriteNumber(ibc_quantity, ibcPosition.Quantity_KGM.Value);
|
|
WriteText(ibc_stowagePosition, ibcPosition.StowagePosition);
|
|
WriteText(ibc_portOfLoading, ibcPosition.PortOfLoading);
|
|
WriteText(ibc_portOfDischarge, ibcPosition.PortOfDischarge);
|
|
WriteText(ibc_hazards, ibcPosition.HazardsDisplay);
|
|
WriteBoolean(ibc_specref, ibcPosition.SpecRef15_19 ?? false);
|
|
WriteText(ibc_remarks, ibcPosition.Remarks);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IGC
|
|
|
|
for (int i = 0; i < Math.Min(haz.IGCPositions.Count, 5); i++)
|
|
{
|
|
string igc_productName = string.Format("{1}.IGC.ProductName_{0}", i + 1, className);
|
|
string igc_quantity = string.Format("{1}.IGC.Quantity_KGM_{0}", i + 1, className);
|
|
string igc_stowagePosition = string.Format("{1}.IGC.StowagePosition_{0}", i + 1, className);
|
|
string igc_portOfLoading = string.Format("{1}.IGC.PortOfLoading_{0}", i + 1, className);
|
|
string igc_portOfDischarge = string.Format("{1}.IGC.PortOfDischarge_{0}", i + 1, className);
|
|
string igc_unnumber = string.Format("{1}.IGC.UNNumber_{0}", i + 1, className);
|
|
string igc_IMOClass = string.Format("{1}.IGC.IMOClass_{0}", i + 1, className);
|
|
string igc_Remarks = string.Format("{1}.IGC.Remarks_{0}", i + 1, className);
|
|
IGCPosition igcPosition = haz.IGCPositions[i];
|
|
WriteText(igc_productName, igcPosition.ProductName);
|
|
if (igcPosition.Quantity_KGM.HasValue)
|
|
WriteNumber(igc_quantity, igcPosition.Quantity_KGM.Value);
|
|
WriteText(igc_stowagePosition, igcPosition.StowagePosition);
|
|
WriteText(igc_portOfLoading, igcPosition.PortOfLoading);
|
|
WriteText(igc_portOfDischarge, igcPosition.PortOfDischarge);
|
|
WriteText(igc_unnumber, igcPosition.UNNumber);
|
|
WriteText(igc_IMOClass, igcPosition.IMOClass);
|
|
WriteText(igc_Remarks, igcPosition.Remarks);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IMSBC
|
|
|
|
for (int i = 0; i < Math.Min(haz.IMSBCPositions.Count, 5); i++)
|
|
{
|
|
string imsbc_bcsn = string.Format("{1}.IMSBC.BulkCargoShippingName_{0}", i + 1, className);
|
|
string imsbc_mhb = string.Format("{1}.IMSBC.MHB_{0}", i + 1, className);
|
|
string imsbc_quantity = string.Format("{1}.IMSBC.Quantity_KGM_{0}", i + 1, className);
|
|
string imsbc_stowagePosition = string.Format("{1}.IMSBC.StowagePosition_{0}", i + 1, className);
|
|
string imsbc_portOfLoading = string.Format("{1}.IMSBC.PortOfLoading_{0}", i + 1, className);
|
|
string imsbc_portOfDischarge = string.Format("{1}.IMSBC.PortOfDischarge_{0}", i + 1, className);
|
|
string imsbc_imohazard = string.Format("{1}.IMSBC.IMOHazardClass_{0}", i + 1, className);
|
|
string imsbc_unnumber = string.Format("{1}.IMSBC.UNNumber_{0}", i + 1, className);
|
|
string imsbc_imoclass = string.Format("{1}.IMSBC.IMOClass_{0}", i + 1, className);
|
|
string imsbc_remarks = string.Format("{1}.IMSBC.Remarks_{0}", i + 1, className);
|
|
IMSBCPosition imsbcPosition = haz.IMSBCPositions[i];
|
|
WriteText(imsbc_bcsn, imsbcPosition.BulkCargoShippingName);
|
|
WriteBoolean(imsbc_mhb, imsbcPosition.MHB);
|
|
if (imsbcPosition.Quantity_KGM.HasValue)
|
|
WriteNumber(imsbc_quantity, imsbcPosition.Quantity_KGM.Value);
|
|
WriteText(imsbc_stowagePosition, imsbcPosition.StowagePosition);
|
|
WriteText(imsbc_portOfLoading, imsbcPosition.PortOfLoading);
|
|
WriteText(imsbc_portOfDischarge, imsbcPosition.PortOfDischarge);
|
|
WriteText(imsbc_imohazard, imsbcPosition.IMOHazardClassDisplay);
|
|
WriteText(imsbc_unnumber, imsbcPosition.UNNumber);
|
|
WriteText(imsbc_imoclass, imsbcPosition.IMOClass);
|
|
WriteText(imsbc_remarks, imsbcPosition.Remarks);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region MARPOL
|
|
|
|
for (int i = 0; i < Math.Min(haz.MARPOLPositions.Count, 5); i++)
|
|
{
|
|
string marpol_name = string.Format("{1}.MARPOL.Name_{0}", i + 1, className);
|
|
string marpol_flash = string.Format("{1}.MARPOL.Flashpoint_CEL_{0}", i + 1, className);
|
|
string marpol_quantity = string.Format("{1}.MARPOL.Quantity_KGM_{0}", i + 1, className);
|
|
string marpol_stowagePosition = string.Format("{1}.MARPOL.StowagePosition_{0}", i + 1, className);
|
|
string marpol_portOfLoading = string.Format("{1}.MARPOL.PortOfLoading_{0}", i + 1, className);
|
|
string marpol_portOfDischarge = string.Format("{1}.MARPOL.PortOfDischarge_{0}", i + 1, className);
|
|
string marpol_remarks = string.Format("{1}.MARPOL.Remarks_{0}", i + 1, className);
|
|
MARPOL_Annex_I_Position marpolPosition = haz.MARPOLPositions[i];
|
|
WriteText(marpol_name, marpolPosition.Name);
|
|
WriteText(marpol_flash, marpolPosition.Flashpoint_CEL);
|
|
if (marpolPosition.Quantity_KGM.HasValue)
|
|
WriteNumber(marpol_quantity, marpolPosition.Quantity_KGM.Value);
|
|
WriteText(marpol_stowagePosition, marpolPosition.StowagePosition);
|
|
WriteText(marpol_portOfLoading, marpolPosition.PortOfLoading);
|
|
WriteText(marpol_portOfDischarge, marpolPosition.PortOfDischarge);
|
|
WriteText(marpol_remarks, marpolPosition.Remarks);
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region MDH
|
|
|
|
private void WriteMDH(MDH mdh)
|
|
{
|
|
#region POC
|
|
|
|
for(int i = 0; i < Math.Min(mdh.NumberOfExcelRows, mdh.PortOfCallLast30Days.Count); i++)
|
|
{
|
|
string portName = string.Format("MDH.PortOfCallLast30DaysPort_{0}", i + 1);
|
|
string portCountry = string.Format("MDH.PortOfCallLast30DaysCountry_{0}", i + 1);
|
|
string locode = string.Format("MDH.PortOfCallLast30DaysLocode_{0}", i + 1);
|
|
string crewJoined = string.Format("MDH.PortOfCallLast30DaysCrewMembersJoined_{0}", i + 1);
|
|
string crewName = string.Format("MDH.PortOfCallLast30DaysCrewJoinedShipName_{0}", i + 1);
|
|
string depDate = string.Format("MDH.PortOfCallLast30DaysDateOfDeparture_{0}", i + 1);
|
|
PortOfCallLast30Days poc30d = mdh.PortOfCallLast30Days[i];
|
|
WriteText(portName, Locode.LocodeDB.LocationNameFromLocode(poc30d.PortOfCallLast30DaysLocode));
|
|
if (poc30d.PortOfCallLast30DaysLocode.Length == 5)
|
|
WriteText(portCountry, poc30d.PortOfCallLast30DaysLocode.Substring(0, 2));
|
|
WriteText(locode, poc30d.PortOfCallLast30DaysLocode);
|
|
WriteBoolean(crewJoined, poc30d.PortOfCallLast30DaysCrewMembersJoined);
|
|
WriteText(crewName, poc30d.CrewMembersJoinedText);
|
|
if (poc30d.PortOfCallLast30DaysDateOfDeparture.HasValue)
|
|
WriteDate(depDate, poc30d.PortOfCallLast30DaysDateOfDeparture.Value);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region SanitaryMeasures
|
|
|
|
for(int i = 0; i < Math.Min(mdh.SanitaryMeasuresDetails.Count, 3); i++)
|
|
{
|
|
string smType = string.Format("MDH.SanitaryMeasuresType_{0}", i + 1);
|
|
string smLocation = string.Format("MDH.SanitaryMeasuresLocation_{0}", i + 1);
|
|
string smDate = string.Format("MDH.SanitaryMeasuresDate_{0}", i + 1);
|
|
SanitaryMeasuresDetail smd = mdh.SanitaryMeasuresDetails[i];
|
|
WriteText(smType, smd.SanitaryMeasuresType);
|
|
WriteText(smLocation, smd.SanitaryMeasuresLocation);
|
|
if (smd.SanitaryMeasuresDate.HasValue)
|
|
WriteDate(smDate, smd.SanitaryMeasuresDate.Value);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region InfectedAreas
|
|
|
|
for(int i = 0; i < Math.Min(mdh.InfectedAreas.Count, 3); i++)
|
|
{
|
|
string iaPort = string.Format("MDH.InfectedAreaPort_{0}", i + 1);
|
|
string iaDate = string.Format("MDH.InfectedAreaDate_{0}", i + 1);
|
|
InfectedArea ia = mdh.InfectedAreas[i];
|
|
WriteText(iaPort, ia.InfectedAreaPort);
|
|
if (ia.InfectedAreaDate.HasValue)
|
|
WriteDate(iaDate, ia.InfectedAreaDate.Value);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region StowawayJoiningLocation
|
|
|
|
for(int i = 0; i < Math.Min(mdh.StowawaysJoiningLocations.Count, 3); i++)
|
|
{
|
|
string sjlLookup = string.Format("MDH.StowawaysJoiningLocation_{0}", i + 1);
|
|
StowawaysJoiningLocation sjl = mdh.StowawaysJoiningLocations[i];
|
|
WriteText(sjlLookup, sjl.StowawayJoiningLocation);
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region NOA_NOD
|
|
|
|
private void WriteNOA_NOD(NOA_NOD noa_nod, bool isTransit, bool isRefSheet)
|
|
{
|
|
if(isTransit && noa_nod.ETAToKielCanal.HasValue)
|
|
{
|
|
WriteDate("NOA_NOD.ETADateToPortOfCall", noa_nod.ETAToKielCanal.Value);
|
|
WriteTime("NOA_NOD.ETATimeToPortOfCall", noa_nod.ETAToKielCanal.Value);
|
|
}
|
|
|
|
if(!isTransit && noa_nod.ETAToPortOfCall.HasValue)
|
|
{
|
|
WriteDate("NOA_NOD.ETADateToPortOfCall", noa_nod.ETAToPortOfCall.Value);
|
|
WriteTime("NOA_NOD.ETATimeToPortOfCall", noa_nod.ETAToPortOfCall.Value);
|
|
}
|
|
|
|
if(isTransit)
|
|
{
|
|
if(noa_nod.ETDFromKielCanal.HasValue)
|
|
{
|
|
WriteDate("NOA_NOD.ETDDateFromPortOfCall", noa_nod.ETDFromKielCanal.Value);
|
|
WriteTime("NOA_NOD.ETDTimeFromPortOfCall", noa_nod.ETDFromKielCanal.Value);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for(int i = 0; i < Math.Min(noa_nod.NumberOfExcelRows, noa_nod.CallPurposes.Count); i++)
|
|
{
|
|
string callPurposeDescriptionKey = string.Format("NOA_NOD.CallPuposeDescription_{0}", i + 1);
|
|
string callPurposeCodeKey = string.Format("NOA_NOD.CallPurposeCode_{0}", i + 1);
|
|
CallPurpose cp = noa_nod.CallPurposes[i];
|
|
WriteText(callPurposeDescriptionKey, cp.CallPurposeDescription);
|
|
WriteText(callPurposeCodeKey, cp.CallPurposeCode);
|
|
}
|
|
|
|
if (noa_nod.ETDFromPortOfCall.HasValue)
|
|
{
|
|
WriteDate("NOA_NOD.ETDDateFromPortOfCall", noa_nod.ETDFromPortOfCall.Value);
|
|
WriteTime("NOA_NOD.ETDTimeFromPortOfCall", noa_nod.ETDFromPortOfCall.Value);
|
|
}
|
|
}
|
|
|
|
WriteText("NOA_NOD.LastPort", isRefSheet ? noa_nod.LastPort : Locode.LocodeDB.LocationNameFromLocode(noa_nod.LastPort));
|
|
WriteText("NOA_NOD.NextPort", isRefSheet ? noa_nod.NextPort : Locode.LocodeDB.LocationNameFromLocode(noa_nod.NextPort));
|
|
|
|
if(noa_nod.ETDFromLastPort.HasValue)
|
|
{
|
|
WriteDate("NOA_NOD.ETDDateFromLastPort", noa_nod.ETDFromLastPort.Value);
|
|
WriteTime("NOA_NOD.ETDTimeFromLastPort", noa_nod.ETDFromLastPort.Value);
|
|
}
|
|
|
|
if(noa_nod.ETAToNextPort.HasValue)
|
|
{
|
|
WriteDate("NOA_NOD.ETADateToNextPort", noa_nod.ETAToNextPort.Value);
|
|
WriteTime("NOA_NOD.ETATimeToNextPort", noa_nod.ETAToNextPort.Value);
|
|
}
|
|
|
|
WriteBoolean("NOA_NOD.IsAnchored", noa_nod.IsAnchored);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region PAS
|
|
|
|
private void WritePAS(Message pasMessage, bool isArrival, bool isRefSheet)
|
|
{
|
|
/* XXX - TODO
|
|
if(pasMessage.Elements.Count > 0)
|
|
{
|
|
WriteBoolean(string.Format("PAS{0}.NotificationSchengen", isArrival ? "" : "D"), ((PAS)pasMessage.Elements[0]).NotificationSchengen);
|
|
WriteBoolean(string.Format("PAS{0}.NotificationPAX", isArrival ? "" : "D"), ((PAS)pasMessage.Elements[0]).NotificationPAX);
|
|
}
|
|
*/
|
|
|
|
for(int i = 0; i < Math.Min(pasMessage.NumberOfExcelRows, pasMessage.Elements.Count); i++)
|
|
{
|
|
string pasLastName = string.Format("PAS{1}.PassengerLastName_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasFirstName = string.Format("PAS{1}.PassengerFirstName_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasGender = string.Format("PAS{1}.PassengerGender_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasNationality = string.Format("PAS{1}.PassengerNationality_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasEmbarkation = string.Format("PAS{1}.PassengerPortOfEmbarkation_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasDebarkation = string.Format("PAS{1}.PassengerPortOfDisembarkation_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasTransit = string.Format("PAS{1}.PassengerInTransit_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasPlaceOfBirth = string.Format("PAS{1}.PassengerPlaceOfBirth_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasDateOfBirth = string.Format("PAS{1}.PassengerDateOfBirth_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasIdentDocType = string.Format("PAS{1}.PassengerIdentityDocumentType_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasIdentDocId = string.Format("PAS{1}.PassengerIdentityDocumentId_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasVisaNo = string.Format("PAS{1}.PassengerVisaNumber_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasIssuing = string.Format("PAS{1}.PassengerIdentityDocumentIssuingState_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasExpiry = string.Format("PAS{1}.PassengerIdentityDocumentExpiryDate_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasCountry = string.Format("PAS{1}.CountryOfBirth_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasEmergencyCare = string.Format("PAS{1}.EmergencyCare_{0}", i + 1, isArrival ? "" : "D");
|
|
string pasEmergencyContact = string.Format("PAS{1}.EmergencyContactNumber_{0}", i + 1, isArrival ? "" : "D");
|
|
|
|
PAS pas = pasMessage.Elements[i] as PAS; // PASD is derived from PAS daher ok!
|
|
|
|
WriteText(pasLastName, pas.PassengerLastName);
|
|
WriteText(pasFirstName, pas.PassengerFirstName);
|
|
if (isRefSheet)
|
|
WriteGenderCode(pasGender, pas.PassengerGender);
|
|
else
|
|
WriteGenderFull(pasGender, pas.PassengerGender);
|
|
WriteText(pasNationality, pas.PassengerNationality);
|
|
WriteText(pasEmbarkation, pas.PassengerPortOfEmbarkation);
|
|
WriteText(pasDebarkation, pas.PassengerPortOfDisembarkation);
|
|
WriteBoolean(pasTransit, pas.PassengerInTransit);
|
|
WriteText(pasPlaceOfBirth, pas.PassengerPlaceOfBirth);
|
|
if(pas.PassengerDateOfBirth.HasValue)
|
|
WriteDate(pasDateOfBirth, pas.PassengerDateOfBirth);
|
|
WriteText(pasIdentDocType, pas.PassengerIdentityDocumentTypeDisplay);
|
|
WriteText(pasIdentDocId, pas.PassengerIdentityDocumentId);
|
|
WriteText(pasVisaNo, pas.PassengerVisaNumber);
|
|
if (isRefSheet)
|
|
{
|
|
WriteText(pasIssuing, pas.PassengerIdentityDocumentIssuingState);
|
|
}
|
|
else
|
|
{
|
|
if(!pas.PassengerIdentityDocumentIssuingState.IsNullOrEmpty() && !pas.PassengerIdentityDocumentIssuingState.Equals("XX"))
|
|
WriteText(pasIssuing, pas.PassengerIdentityDocumentIssuingState);
|
|
}
|
|
if (isRefSheet)
|
|
{
|
|
WriteDate(pasExpiry, pas.PassengerIdentityDocumentExpiryDate);
|
|
}
|
|
else
|
|
{
|
|
if (pas.PassengerIdentityDocumentExpiryDate != new DateTime(2100, 12, 31))
|
|
WriteDate(pasExpiry, pas.PassengerIdentityDocumentExpiryDate);
|
|
}
|
|
WriteText(pasCountry, pas.PassengerCountryOfBirth);
|
|
WriteText(pasEmergencyCare, pas.EmergencyCare);
|
|
WriteText(pasEmergencyContact, pas.EmergencyContactNumber);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region SEC
|
|
|
|
private void WriteSEC(Message secMessage, bool isRefSheet)
|
|
{
|
|
if (secMessage.Elements.Count == 0) return;
|
|
SEC sec = secMessage.Elements[0] as SEC;
|
|
if(sec.ISSCType.HasValue)
|
|
{
|
|
switch(sec.ISSCType.Value)
|
|
{
|
|
case 0: WriteText("SEC.ISSCType", "full"); break;
|
|
case 1: WriteText("SEC.ISSCType", "interim"); break;
|
|
}
|
|
}
|
|
|
|
if (sec.CurrentShipSecurityLevel.HasValue)
|
|
WriteText("SEC.CurrentShipSecurityLevel", sec.CurrentShipSecurityLevel.Value.ToString());
|
|
|
|
WriteText("SEC.ISSCIssuerType", sec.ISSCIssuerTypeDisplay);
|
|
|
|
if(sec.GeneralDescriptionOfCargo.HasValue)
|
|
{
|
|
switch(sec.GeneralDescriptionOfCargo.Value)
|
|
{
|
|
case 0: WriteText("SEC.GeneralDescriptionOfCargo", "container"); break;
|
|
case 1: WriteText("SEC.GeneralDescriptionOfCargo", "vehicles"); break;
|
|
case 2: WriteText("SEC.GeneralDescriptionOfCargo", "convent"); break;
|
|
case 3: WriteText("SEC.GeneralDescriptionOfCargo", "dry"); break;
|
|
case 4: WriteText("SEC.GeneralDescriptionOfCargo", "liquid"); break;
|
|
case 5: WriteText("SEC.GeneralDescriptionOfCargo", "empty"); break;
|
|
}
|
|
}
|
|
|
|
WriteBoolean("SEC.KielCanalPassagePlanned_Arrival", sec.KielCanalPassagePlannedIncomming.HasValue);
|
|
WriteBoolean("SEC.KielCanalPassagePlanned_Departure", sec.KielCanalPassagePlannedOutgoing.HasValue);
|
|
if(sec.KielCanalPassagePlannedIncomming.HasValue)
|
|
{
|
|
WriteDate("SEC.ETADateKielCanalPassagePlannedIncomming", sec.KielCanalPassagePlannedIncomming.Value);
|
|
WriteTime("SEC.ETATimeKielCanalPassagePlannedIncomming", sec.KielCanalPassagePlannedIncomming.Value);
|
|
}
|
|
if(sec.KielCanalPassagePlannedOutgoing.HasValue)
|
|
{
|
|
WriteDate("SEC.ETADateKielCanalPassagePlannedOutgoing", sec.KielCanalPassagePlannedOutgoing.Value);
|
|
WriteTime("SEC.ETATimeKielCanalPassagePlannedOutgoing", sec.KielCanalPassagePlannedOutgoing.Value);
|
|
}
|
|
|
|
for(int i = 0; i < Math.Min(sec.LastTenPortFacilitesCalled.Count, 10); i++)
|
|
{
|
|
string portName = string.Format("SEC.PortFacilityPortName_{0}", i + 1);
|
|
string portCountry = string.Format("SEC.PortFacilityPortCountry_{0}", i + 1);
|
|
string portLocode = string.Format("SEC.PortFacilityPortLoCode_{0}", i + 1);
|
|
string portDateOfArrival = string.Format("SEC.PortFacilityDateOfArrival_{0}", i + 1);
|
|
string portDateOfDeparture = string.Format("SEC.PortFacilityDateOfDeparture_{0}", i + 1);
|
|
string portShipSecLevel = string.Format("SEC.PortFacilityShipSecurityLevel_{0}", i + 1);
|
|
string portGISISCode = string.Format("SEC.PortFacilityGISISCode_{0}", i + 1);
|
|
string portSecMatters = string.Format("SEC.PortFacilitySecurityMattersToReport_{0}", i + 1);
|
|
LastTenPortFacilitiesCalled l10 = sec.LastTenPortFacilitesCalled[i];
|
|
WriteText(portName, l10.PortFacilityPortName);
|
|
WriteText(portCountry, l10.PortFacilityPortCountry);
|
|
WriteText(portLocode, l10.PortFacilityPortLoCode);
|
|
if (l10.PortFacilityDateOfArrival.HasValue)
|
|
WriteDate(portDateOfArrival, l10.PortFacilityDateOfArrival.Value);
|
|
if (l10.PortFacilityDateOfDeparture.HasValue)
|
|
WriteDate(portDateOfDeparture, l10.PortFacilityDateOfDeparture.Value);
|
|
if (l10.PortFacilityShipSecurityLevel.HasValue)
|
|
WriteText(portShipSecLevel, l10.PortFacilityShipSecurityLevel.Value.ToString());
|
|
WriteText(portGISISCode, l10.PortFacilityGISISCode);
|
|
WriteText(portSecMatters, l10.PortFacilitySecurityMattersToReport);
|
|
}
|
|
|
|
for(int i = 0; i < Math.Min(sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count, 10); i++)
|
|
{
|
|
string s2sName = string.Format("SEC.ShipToShipActivityLocationName_{0}", i + 1);
|
|
string s2sLocode = string.Format("SEC.ShipToShipActivityLocationLoCode_{0}", i + 1);
|
|
string s2sLatitude = string.Format("SEC.ShipToShipActivityLocationCoordinatesLatitude_{0}", i + 1);
|
|
string s2sLongitude = string.Format("SEC.ShipToShipActivityLocationCoordinatesLongitude_{0}", i + 1);
|
|
string s2sFromDate = string.Format("SEC.ShipToShipActivityDateFrom_{0}", i + 1);
|
|
string s2sToDate = string.Format("SEC.ShipToShipActivityDateTo_{0}", i + 1);
|
|
string s2sSec = string.Format("SEC.ShipToShipActivitySecurityMattersToReport_{0}", i + 1);
|
|
string s2sActivityString = string.Format("SEC.ShipToShipActivityType_{0}", i + 1);
|
|
ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2s = sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i];
|
|
WriteText(s2sName, s2s.ShipToShipActivityLocationName);
|
|
WriteText(s2sLocode, s2s.ShipToShipActivityLocationLoCode);
|
|
if(s2s.ShipToShipActivityLocationCoordinatesLatitude.HasValue)
|
|
WriteNumber(s2sLatitude, s2s.ShipToShipActivityLocationCoordinatesLatitude.Value);
|
|
if (s2s.ShipToShipActivityLocationCoordinatesLongitude.HasValue)
|
|
WriteNumber(s2sLongitude, s2s.ShipToShipActivityLocationCoordinatesLongitude.Value);
|
|
if (s2s.ShipToShipActivityDateFrom.HasValue)
|
|
WriteDate(s2sFromDate, s2s.ShipToShipActivityDateFrom.Value);
|
|
if (s2s.ShipToShipActivityDateTo.HasValue)
|
|
WriteDate(s2sToDate, s2s.ShipToShipActivityDateTo.Value);
|
|
WriteText(s2sSec, s2s.ShipToShipActivitySecurityMattersToReport);
|
|
if (s2s.ShipToShipActivityTypeCode.HasValue)
|
|
{
|
|
if (isRefSheet)
|
|
{
|
|
WriteText(s2sActivityString, s2s.ShipToShipActivityTypeCode.Value.ToString());
|
|
}
|
|
else
|
|
{
|
|
if (GlobalStructures.Edifact8025.TryGetValue(s2s.ShipToShipActivityTypeCode.Value, out string code))
|
|
WriteText(s2sActivityString, code);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region SERV
|
|
|
|
private void WriteSERV(Message servMessage)
|
|
{
|
|
if(servMessage.Elements.Count > 0)
|
|
{
|
|
SERV serv = servMessage.Elements[0] as SERV;
|
|
WriteMessage(serv);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region STO
|
|
|
|
private void WriteSTO(Message stoMessage)
|
|
{
|
|
for(int i = 0; i < Math.Min(stoMessage.Elements.Count, stoMessage.NumberOfExcelRows); i++)
|
|
{
|
|
string stoName = string.Format("STO.Name_{0}", i + 1);
|
|
string stoQuantity = string.Format("STO.Quantity_{0}", i + 1);
|
|
string stoQuantityUnit = string.Format("STO.QuantityUnit_{0}", i + 1);
|
|
string stoLocationOnBoard = string.Format("STO.LocationOnBoard_{0}", i + 1);
|
|
string stoOfficialUse = string.Format("STO.OfficialUse_{0}", i + 1);
|
|
|
|
STO sto = stoMessage.Elements[i] as STO;
|
|
|
|
WriteText(stoName, sto.Name);
|
|
if (sto.Quantity.HasValue)
|
|
WriteNumber(stoQuantity, sto.Quantity.Value);
|
|
WriteText(stoQuantityUnit, sto.QuantityUnit);
|
|
WriteText(stoLocationOnBoard, sto.LocationOnBoard);
|
|
WriteText(stoOfficialUse, sto.OfficialUse);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region TOWA
|
|
|
|
private void WriteTOWA(Message towaMessage, bool isRefSheet)
|
|
{
|
|
for(int i = 0; i < Math.Min(towaMessage.Elements.Count, towaMessage.NumberOfExcelRows); i++)
|
|
{
|
|
string tName = string.Format("TOWA.TowageOnArrivalName_{0}", i + 1);
|
|
string tFlag = string.Format("TOWA.TowageOnArrivalFlag_{0}", i + 1);
|
|
string tPoC = string.Format("TOWA.TowageOnArrivalPurposeOfCall_{0}", i + 1);
|
|
string tDraft = string.Format("TOWA.TowageOnArrivalDraught_DMT_{0}", i + 1);
|
|
string tGT = string.Format("TOWA.TowageOnArrivalGrossTonnage_{0}", i + 1);
|
|
string tLen = string.Format("TOWA.TowageOnArrivalLengthOverall_MTR_{0}", i + 1);
|
|
string tBeam = string.Format("TOWA.TowageOnArrivalBeam_MTR_{0}", i + 1);
|
|
string tOp = string.Format("TOWA.TowageOnArrivalOperatorCompanyName_{0}", i + 1);
|
|
|
|
TOWA towa = towaMessage.Elements[i] as TOWA;
|
|
|
|
WriteText(tName, towa.TowageOnArrivalName);
|
|
if(isRefSheet)
|
|
{
|
|
WriteText(tFlag, towa.TowageOnArrivalFlag);
|
|
}
|
|
else
|
|
{
|
|
if(CREW.NationalityDict.TryGetValue(towa.TowageOnArrivalFlag, out string country))
|
|
WriteText(tFlag, country.Substring(3));
|
|
}
|
|
|
|
WriteText(tPoC, towa.TowageOnArrivalPurposeOfCall);
|
|
if (towa.TowageOnArrivalDraught_DMT.HasValue)
|
|
WriteNumber(tDraft, towa.TowageOnArrivalDraught_DMT.Value);
|
|
if (towa.TowageOnArrivalGrossTonnage.HasValue)
|
|
WriteNumber(tGT, towa.TowageOnArrivalGrossTonnage.Value);
|
|
if (towa.TowageOnArrivalLengthOverall_MTR.HasValue)
|
|
WriteNumber(tLen, towa.TowageOnArrivalLengthOverall_MTR.Value);
|
|
if (towa.TowageOnArrivalBeam_MTR.HasValue)
|
|
WriteNumber(tBeam, towa.TowageOnArrivalBeam_MTR.Value);
|
|
WriteText(tOp, towa.TowageOnArrivalOperatorCompanyName);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region TOWD
|
|
|
|
private void WriteTOWD(Message towdMessage, bool isRefSheet)
|
|
{
|
|
for (int i = 0; i < Math.Min(towdMessage.Elements.Count, towdMessage.NumberOfExcelRows); i++)
|
|
{
|
|
string tName = string.Format("TOWD.TowageOnDepartureName_{0}", i + 1);
|
|
string tFlag = string.Format("TOWD.TowageOnDepartureFlag_{0}", i + 1);
|
|
string tDraft = string.Format("TOWD.TowageOnDepartureDraught_DMT_{0}", i + 1);
|
|
string tLen = string.Format("TOWD.TowageOnDepartureLengthOverall_MTR_{0}", i + 1);
|
|
string tBeam = string.Format("TOWD.TowageOnDepartureBeam_MTR_{0}", i + 1);
|
|
string tOp = string.Format("TOWD.TowageOnDepartureOperatorCompanyName_{0}", i + 1);
|
|
string tPoc = string.Format("TOWD.TowageOnDeparturePurposeOfCall_{0}", i + 1);
|
|
|
|
TOWD towd = towdMessage.Elements[i] as TOWD;
|
|
|
|
WriteText(tName, towd.TowageOnDepartureName);
|
|
if (isRefSheet)
|
|
{
|
|
WriteText(tFlag, towd.TowageOnDepartureFlag);
|
|
}
|
|
else
|
|
{
|
|
if (CREW.NationalityDict.TryGetValue(towd.TowageOnDepartureFlag, out string country))
|
|
WriteText(tFlag, country.Substring(3));
|
|
}
|
|
if (towd.TowageOnDepartureDraught_DMT.HasValue)
|
|
WriteNumber(tDraft, towd.TowageOnDepartureDraught_DMT.Value);
|
|
if (towd.TowageOnDepartureLengthOverall_MTR.HasValue)
|
|
WriteNumber(tLen, towd.TowageOnDepartureLengthOverall_MTR.Value);
|
|
if (towd.TowageOnDepartureBeam_MTR.HasValue)
|
|
WriteNumber(tBeam, towd.TowageOnDepartureBeam_MTR.Value);
|
|
WriteText(tOp, towd.TowageOnDepartureOperatorCompanyName);
|
|
// WriteText(tPoc, towd.Tow)
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region WAS
|
|
|
|
private void WriteWAS(Message wasMessage, bool isRefSheet)
|
|
{
|
|
if (wasMessage.Elements.Count == 0) return;
|
|
WAS was = wasMessage.Elements[0] as WAS;
|
|
|
|
if (was.WasteDisposalDelivery.HasValue) // TODO: CH schreibt für DK erforderlich -> nachfragen
|
|
{
|
|
switch (was.WasteDisposalDelivery)
|
|
{
|
|
case 0: WriteText("WAS.WasteDisposalDelivery", "ALL"); break;
|
|
case 1: WriteText("WAS.WasteDisposalDelivery", "SOME"); break;
|
|
case 2: WriteText("WAS.WasteDisposalDelivery", "NONE"); break;
|
|
default: break;
|
|
}
|
|
}
|
|
|
|
WriteText("WAS.LastWasteDisposalPort", isRefSheet ? was.LastWasteDisposalPort : Locode.LocodeDB.LocationNameFromLocode(was.LastWasteDisposalPort));
|
|
WriteText("WAS.WasteDisposalServiceProviderName", was.WasteDisposalServiceProviderText);
|
|
WriteText("WAS.NextWasteDisposalPort", isRefSheet? was.NextWasteDisposalPort : Locode.LocodeDB.LocationNameFromLocode(was.NextWasteDisposalPort));
|
|
WriteBoolean("WAS.ConfirmationOfCorrectness", true);
|
|
WriteBoolean("WAS.ConfirmationOfSufficiency", true);
|
|
|
|
for(int i = 0; i < was.NumberOfExcelRows; i++)
|
|
{
|
|
int? wasteType = (int?)ReadNumber(string.Format("WAS.WasteCode_{0}", i + 1));
|
|
if (!wasteType.HasValue) continue;
|
|
|
|
string wasteDescription = string.Format("WAS.WasteDescription_{0}", i + 1);
|
|
string wasteAmount = string.Format("WAS.WasteDisposalAmount_MTQ_{0}", i + 1);
|
|
string wasteCapacity = string.Format("WAS.WasteCapacity_MTQ_{0}", i + 1);
|
|
string wasteRetained = string.Format("WAS.WasteAmountRetained_MTQ_{0}", i + 1);
|
|
string wastePort = string.Format("WAS.WasteDisposalPort_{0}", i + 1);
|
|
string amountGen = string.Format("WAS.WasteAmountGeneratedTillNextPort_MTQ_{0}", i + 1);
|
|
|
|
Waste waste = was.GetWasteForType(wasteType.Value);
|
|
|
|
WriteText(wasteDescription, waste.WasteDescription);
|
|
if (waste.WasteDisposalAmount_MTQ.HasValue)
|
|
WriteNumber(wasteAmount, waste.WasteDisposalAmount_MTQ.Value);
|
|
if (waste.WasteCapacity_MTQ.HasValue)
|
|
WriteNumber(wasteCapacity, waste.WasteCapacity_MTQ.Value);
|
|
if (waste.WasteAmountRetained_MTQ.HasValue)
|
|
WriteNumber(wasteRetained, waste.WasteAmountRetained_MTQ.Value);
|
|
WriteText(wastePort, isRefSheet ? waste.WasteDisposalPort : Locode.LocodeDB.LocationNameFromLocode(waste.WasteDisposalPort));
|
|
if (waste.WasteAmountGeneratedTillNextPort_MTQ.HasValue)
|
|
WriteNumber(amountGen, waste.WasteAmountGeneratedTillNextPort_MTQ.Value);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region WAS_RCPT
|
|
|
|
private void WriteWAS_RCPT(Message wasRcptmessage)
|
|
{
|
|
for (int i = 1; i <= Math.Min(wasRcptmessage.NumberOfExcelRows, wasRcptmessage.Elements.Count); i++)
|
|
{
|
|
string ident = string.Format("WAS_RCPT.WasteDeliveryReceipt_{0}.IdentificationNumber", i);
|
|
string prfn = string.Format("WAS_RCPT.WasteDeliveryReceipt_{0}.PortReceptionFacilityName", i);
|
|
string prfpn = string.Format("WAS_RCPT.WasteDeliveryReceipt_{0}.PortReceptionFacilityProviderName", i);
|
|
string tfpn = string.Format("WAS_RCPT.WasteDeliveryReceipt_{0}.TreatmentFacilityProviderName", i);
|
|
string wddfd = string.Format("WAS_RCPT.WasteDeliveryReceipt_{0}.WasteDeliveryDateFromDate", i);
|
|
string wddft = string.Format("WAS_RCPT.WasteDeliveryReceipt_{0}.WasteDeliveryDateFromTime", i);
|
|
string wddtd = string.Format("WAS_RCPT.WasteDeliveryReceipt_{0}.WasteDeliveryDateToDate", i);
|
|
string wddtt = string.Format("WAS_RCPT.WasteDeliveryReceipt_{0}.WasteDeliveryDateToTime", i);
|
|
|
|
WAS_RCPT wrcpt = wasRcptmessage.Elements[i-1] as WAS_RCPT;
|
|
|
|
WriteText(ident, wrcpt.IdentificationNumber);
|
|
WriteText(prfn, wrcpt.PortReceptionFacilityName);
|
|
WriteText(prfpn, wrcpt.PortReceptionFacilityProviderName);
|
|
WriteText(tfpn, wrcpt.TreatmentFacilityProviderText);
|
|
WriteDate(wddfd, wrcpt.WasteDeliveryDateFrom);
|
|
WriteTime(wddft, wrcpt.WasteDeliveryDateFrom);
|
|
WriteDate(wddtd, wrcpt.WasteDeliveryDateTo);
|
|
WriteTime(wddtt, wrcpt.WasteDeliveryDateTo);
|
|
|
|
for(int j = 1; j <= wrcpt.NumberOfExcelRows; j++)
|
|
{
|
|
int? wasteType = (int?)ReadNumber(string.Format("WAS_RCPT.WasteDeliveryReceipt.WasteCode_{0}", i + 1));
|
|
if (!wasteType.HasValue) continue;
|
|
|
|
string wdesc = string.Format("WAS_RCPT.WasteDeliveryReceipt_{0}.WasteDescription_{1}", i, j);
|
|
string wamount = string.Format("WAS_RCPT.WasteDeliveryReceipt_{0}.AmountWasteReceived_MTQ_{1}", i, j);
|
|
|
|
WasteReceived wReceived = wrcpt.GetWasteReceivedForType(wasteType.Value);
|
|
|
|
WriteText(wdesc, wReceived.WasteDescription);
|
|
WriteNumber(wamount, wReceived.AmountWasteReceived_MTQ);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region INFO
|
|
|
|
private void WriteINFO(INFO info, bool isRefSheet)
|
|
{
|
|
if (info != null)
|
|
{
|
|
this.WriteBoolean("INFO.FumigatedBulkCargo", info.FumigatedBulkCargoBool);
|
|
|
|
if (info.ShippingArea.HasValue)
|
|
{
|
|
switch (info.ShippingArea.Value)
|
|
{
|
|
case 0: this.WriteText("INFO.ShippingArea", "NORTH_BALTIC_SEA"); break;
|
|
case 1: this.WriteText("INFO.ShippingArea", "EUROPE"); break;
|
|
case 2: this.WriteText("INFO.ShippingArea", "OVERSEAS"); break;
|
|
}
|
|
}
|
|
|
|
if(isRefSheet)
|
|
{
|
|
WriteText("INFO.PortArea", info.PortArea);
|
|
}
|
|
else
|
|
{
|
|
WriteText("INFO.PortArea", LocalizedLookup.GetPortAreaFromCode(info.PortArea));
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region STAT
|
|
|
|
private void WriteSTAT(STAT stat, bool isRefSheet)
|
|
{
|
|
if (stat != null)
|
|
{
|
|
WriteText("STAT.PortOfRegistry", isRefSheet ? stat.PortOfRegistry : Locode.LocodeDB.LocationNameFromLocode(stat.PortOfRegistry));
|
|
WriteText("STAT.TransportMode", stat.TransportModeDisplay);
|
|
if(isRefSheet)
|
|
{
|
|
WriteText("STAT.Flag", stat.Flag);
|
|
}
|
|
else
|
|
{
|
|
if (CREW.NationalityDict.TryGetValue(stat.Flag, out string country))
|
|
WriteText("STAT.Flag", country.Substring(3));
|
|
}
|
|
if(isRefSheet)
|
|
{
|
|
WriteText("STAT.ShipType", stat.ShipType);
|
|
}
|
|
else
|
|
{
|
|
if (LocalizedLookup.getVesselTypes().TryGetValue(stat.ShipType, out string shipType))
|
|
WriteText("STAT.ShipType", shipType.Substring(3));
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region PRE72H
|
|
|
|
private void WritePRE72H(PRE72H pre72h)
|
|
{
|
|
if(pre72h != null)
|
|
{
|
|
if(pre72h.TankerHullConfiguration.HasValue)
|
|
{
|
|
switch(pre72h.TankerHullConfiguration.Value)
|
|
{
|
|
case 0: WriteText("PRE72H.TankerHullConfiguration", "SINGLE HULL"); break;
|
|
case 1: WriteText("PRE72H.TankerHullConfiguration", "SINGLE HULL WITH SBT"); break;
|
|
case 2: WriteText("PRE72H.TankerHullConfiguration", "DOUBLE HULL"); break;
|
|
}
|
|
}
|
|
if(pre72h.ConditionCargoBallastTanks.HasValue)
|
|
{
|
|
switch(pre72h.ConditionCargoBallastTanks.Value)
|
|
{
|
|
case 0: WriteText("PRE72H.ConditionCargoBallastTanks", "FULL"); break;
|
|
case 1: WriteText("PRE72H.ConditionCargoBallastTanks", "EMPTY"); break;
|
|
case 2: WriteText("PRE72H.ConditionCargoBallastTanks", "INERTED"); break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
#region write simple things
|
|
|
|
private void WriteGenderCode(string label, byte? gender)
|
|
{
|
|
if(gender.HasValue)
|
|
{
|
|
if (gender == 0) WriteText(label, "not known");
|
|
if (gender == 1) WriteText(label, "m");
|
|
if (gender == 2) WriteText(label, "f");
|
|
if (gender == 9) WriteText(label, "d");
|
|
}
|
|
}
|
|
|
|
private void WriteGenderFull(string label, byte? gender)
|
|
{
|
|
if (gender.HasValue)
|
|
{
|
|
if (gender == 0) WriteText(label, "not known");
|
|
if (gender == 1) WriteText(label, "male");
|
|
if (gender == 2) WriteText(label, "female");
|
|
if (gender == 9) WriteText(label, "not applicable");
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region write value types
|
|
|
|
private bool WriteBoolean(string lookupName, object v)
|
|
{
|
|
bool result = _nameDict.ContainsKey(lookupName);
|
|
bool? b = (bool?) v;
|
|
try
|
|
{
|
|
if (result && b.HasValue)
|
|
{
|
|
_nameDict[lookupName].RefersToRange.Value = b.Value ? "Y" : "N";
|
|
}
|
|
}
|
|
catch(Exception)
|
|
{
|
|
System.Diagnostics.Trace.WriteLine(string.Format("Error writing {0} to excel, field missing", lookupName));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
private bool WriteText(string lookupName, object v)
|
|
{
|
|
bool result = _nameDict.ContainsKey(lookupName);
|
|
try
|
|
{
|
|
if (result)
|
|
{
|
|
_nameDict[lookupName].RefersToRange.Value = v;
|
|
}
|
|
}
|
|
catch(Exception)
|
|
{
|
|
System.Diagnostics.Trace.WriteLine(string.Format("Error writing {0} to excel, field missing", lookupName));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
private bool WriteNumber(string lookupName, object v)
|
|
{
|
|
bool result = _nameDict.ContainsKey(lookupName);
|
|
|
|
if (result)
|
|
{
|
|
_nameDict[lookupName].RefersToRange.Value = v;
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
private bool WriteDate(string lookupName, object v)
|
|
{
|
|
bool result = _nameDict.ContainsKey(lookupName);
|
|
|
|
if (result)
|
|
{
|
|
if(v != null)
|
|
{
|
|
_nameDict[lookupName].RefersToRange.Value = ((DateTime) v).ToLocalTime().ToOADate();
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
private bool WriteTime(string lookupName, object v)
|
|
{
|
|
bool result = _nameDict.ContainsKey(lookupName);
|
|
|
|
if (result)
|
|
{
|
|
if (v != null)
|
|
{
|
|
_nameDict[lookupName].RefersToRange.Value = ((DateTime)v).ToLocalTime().ToShortTimeString();
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|