2602 lines
133 KiB
C#
2602 lines
133 KiB
C#
//
|
|
// Class: Util
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 6/17/2015 7:12:38 AM
|
|
//
|
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using log4net;
|
|
using bsmd.database;
|
|
using ENI2.Locode;
|
|
|
|
namespace ENI2.Import
|
|
{
|
|
public static class ExcelUtil
|
|
{
|
|
private static readonly ILog _log = LogManager.GetLogger(typeof(ExcelUtil));
|
|
|
|
internal static bool ProcessSheet(ExcelReader reader, out string readMessage, MessageCore messageCore, List<Message.NotificationClass> notificationClasses)
|
|
{
|
|
messageCore = ExcelUtil.LookupMessageCore(reader, out readMessage);
|
|
|
|
if (messageCore == null) return false; // cannot work with this sheet or create one
|
|
|
|
// load messages if already present
|
|
List<Message> messages = DBManager.Instance.GetMessagesForCore(messageCore, DBManager.MessageLoad.ALL);
|
|
|
|
// parse selected classes
|
|
|
|
foreach(Message message in messages)
|
|
{
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.AGNT) && notificationClasses.Contains(Message.NotificationClass.AGNT))
|
|
{ if(ScanAGNT(message, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.ATA) && notificationClasses.Contains(Message.NotificationClass.ATA))
|
|
{ if (ScanATA(message, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.ATD) && notificationClasses.Contains(Message.NotificationClass.ATD))
|
|
{ if (ScanATD(message, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.BKRA) && notificationClasses.Contains(Message.NotificationClass.BKRA))
|
|
{ if (ScanBKRA(message, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.BKRD) && notificationClasses.Contains(Message.NotificationClass.BKRD))
|
|
{ if (ScanBKRD(message, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.BPOL) && notificationClasses.Contains(Message.NotificationClass.BPOL))
|
|
{ if (ScanBPOL(message, messages, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.CREW) && notificationClasses.Contains(Message.NotificationClass.CREW))
|
|
{ if (ScanCREW(message, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.CREWD) && notificationClasses.Contains(Message.NotificationClass.CREWD))
|
|
{ if (ScanCREWD(message, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.HAZA) && notificationClasses.Contains(Message.NotificationClass.HAZA))
|
|
{ if (ScanHAZA(message, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.HAZD) && notificationClasses.Contains(Message.NotificationClass.HAZD))
|
|
{ if (ScanHAZD(message, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.INFO) && notificationClasses.Contains(Message.NotificationClass.INFO))
|
|
{ if (ScanINFO(message, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.LADG) && notificationClasses.Contains(Message.NotificationClass.LADG))
|
|
{ if (ScanLADG(message, messageCore, reader)) SaveMessage(message); break; }
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.MDH) && notificationClasses.Contains(Message.NotificationClass.MDH))
|
|
{ if (ScanMDH(message, messages, messageCore, reader)) SaveMessage(message); break; }
|
|
|
|
}
|
|
|
|
DBManager.Instance.Save(messageCore);
|
|
|
|
return true;
|
|
}
|
|
|
|
internal static void SaveMessage(Message message)
|
|
{
|
|
message.CreatedBy = "EXCEL";
|
|
if ((message.MessageNotificationClass == Message.NotificationClass.CREWD) || (message.MessageNotificationClass == Message.NotificationClass.CREWD) ||
|
|
(message.MessageNotificationClass == Message.NotificationClass.STO))
|
|
message.InternalStatus = Message.BSMDStatus.PREPARE;
|
|
else
|
|
message.InternalStatus = Message.BSMDStatus.EXCEL;
|
|
message.UnsentMessageWarningShown = false;
|
|
DBManager.Instance.Save(message);
|
|
message.SaveElements();
|
|
}
|
|
|
|
#region ATA
|
|
|
|
private static bool ScanATA(Message ataMessage, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
if (ataMessage.Elements.Count == 0)
|
|
{
|
|
ATA newATA = new ATA();
|
|
newATA.MessageHeader = ataMessage;
|
|
ataMessage.Elements.Add(newATA);
|
|
}
|
|
ATA ata = ataMessage.Elements[0] as ATA;
|
|
ExcelUtil.ScanMessage(ata, reader);
|
|
|
|
if(!ata.ATAPortOfCall.HasValue)
|
|
{
|
|
reader.ReadDateTime("ATA.ATADatePortOfCall", "ATA.ATATimePortOfCall");
|
|
}
|
|
|
|
return !(!ata.ATAPortOfCall.HasValue && ataMessage.IsNew);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ATD
|
|
|
|
private static bool ScanATD(Message atdMessage, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
if (atdMessage.Elements.Count == 0)
|
|
{
|
|
ATD newATD = new ATD();
|
|
newATD.MessageHeader = atdMessage;
|
|
atdMessage.Elements.Add(newATD);
|
|
}
|
|
ATD atd = atdMessage.Elements[0] as ATD;
|
|
ExcelUtil.ScanMessage(atd, reader);
|
|
|
|
if (!atd.ATDPortOfCall.HasValue)
|
|
{
|
|
reader.ReadDateTime("ATD.ATDDatePortOfCall", "ATD.ATDTimePortOfCall");
|
|
}
|
|
|
|
return !(!atd.ATDPortOfCall.HasValue && atdMessage.IsNew);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region TIEFA
|
|
|
|
private static void ScanTIEFA(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message tiefaMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.TIEFA);
|
|
if (tiefaMessage.Elements.Count == 0)
|
|
{
|
|
TIEFA newTIEFA = new TIEFA();
|
|
newTIEFA.MessageHeader = tiefaMessage;
|
|
tiefaMessage.Elements.Add(newTIEFA);
|
|
}
|
|
TIEFA tiefa = tiefaMessage.Elements[0] as TIEFA;
|
|
Util.ScanMessage(tiefa, reader);
|
|
if (!tiefa.DraughtUponArrival_DMT.HasValue && tiefaMessage.IsNew)
|
|
messages.Remove(tiefaMessage);
|
|
|
|
reader.Conf.ConfirmNumber("TIEFA.DraughtUponArrival_DMT_DK", tiefa.DraughtUponArrival_DMT, tiefa.DraughtUponArrival_DMT.HasValue ? ExcelReader.ReadState.OK : ExcelReader.ReadState.FAIL);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region TIEFD
|
|
|
|
private static void ScanTIEFD(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message tiefdMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.TIEFD);
|
|
if(tiefdMessage.Elements.Count == 0)
|
|
{
|
|
TIEFD newTIEFD = new TIEFD();
|
|
newTIEFD.MessageHeader = tiefdMessage;
|
|
tiefdMessage.Elements.Add(newTIEFD);
|
|
}
|
|
TIEFD tiefd = tiefdMessage.Elements[0] as TIEFD;
|
|
Util.ScanMessage(tiefd, reader);
|
|
if (!tiefd.DraughtUponDeparture_DMT.HasValue && tiefdMessage.IsNew)
|
|
messages.Remove(tiefdMessage);
|
|
|
|
reader.Conf.ConfirmNumber("TIEFD.DraughtUponDeparture_DMT_DK", tiefd.DraughtUponDeparture_DMT, tiefd.DraughtUponDeparture_DMT.HasValue ? ExcelReader.ReadState.OK : ExcelReader.ReadState.FAIL);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region NAME
|
|
|
|
private static void ScanNAME(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message nameMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.NAME);
|
|
if (nameMessage.Elements.Count == 0)
|
|
{
|
|
NAME newNAME = new NAME();
|
|
newNAME.MessageHeader = nameMessage;
|
|
nameMessage.Elements.Add(newNAME);
|
|
}
|
|
NAME name = nameMessage.Elements[0] as NAME;
|
|
Util.ScanMessage(name, reader);
|
|
if (name.NameOfMaster.IsNullOrEmpty() && name.IsNew)
|
|
messages.Remove(nameMessage);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region BPOL
|
|
|
|
private static bool ScanBPOL(Message bpolMessage, List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
if (bpolMessage.Elements.Count == 0)
|
|
{
|
|
BPOL newBPOL = new BPOL();
|
|
newBPOL.MessageHeader = bpolMessage;
|
|
bpolMessage.Elements.Add(newBPOL);
|
|
}
|
|
|
|
BPOL bpol = bpolMessage.Elements[0] as BPOL;
|
|
ExcelUtil.ScanMessage(bpol, reader);
|
|
|
|
// 19.12.16: Einschleicher-Feld von Klasse POBA übernehmen (anderes ist nicht im Sheet!)
|
|
// (1.12.21: bezweifle ob das so wie gedacht funktioniert..)
|
|
Message pobaMessage = ExcelUtil.GetMessageWithType(messages, messageCore, Message.NotificationClass.POBA);
|
|
if(pobaMessage.Elements.Count > 0)
|
|
{
|
|
POBA poba = pobaMessage.Elements[0] as POBA;
|
|
bpol.StowawaysOnBoard = (poba.TotalStowawaysOnBoardUponArrival ?? 0) > 0;
|
|
}
|
|
|
|
bpol.DeleteElements();
|
|
|
|
// PortOfItinerary
|
|
for (int i = 1; i <= 10; i++)
|
|
{
|
|
string bpolName = string.Format("BPOL.PortOfItineraryName_{0}", i);
|
|
string bpolLocode = string.Format("BPOL.PortOfItineraryLoCode_{0}", i);
|
|
string bpolETADate = string.Format("BPOL.PortOfItineraryETADate_{0}", i);
|
|
string bpolETATime = string.Format("BPOL.PortOfItineraryETATime_{0}", i);
|
|
|
|
string bpolNameValue = reader.ReadText(bpolName)?.Trim();
|
|
string bpolLocodeValue = reader.ReadLoCode(bpolLocode);
|
|
|
|
if (!bpolNameValue.IsNullOrEmpty() || !bpolLocodeValue.IsNullOrEmpty())
|
|
{
|
|
if (!(bpol.GetSublistElementWithIdentifier(i.ToString()) is PortOfItinerary poi))
|
|
{
|
|
poi = new PortOfItinerary();
|
|
poi.BPOL = bpol;
|
|
poi.Identifier = i.ToString();
|
|
bpol.PortOfItineraries.Add(poi);
|
|
}
|
|
|
|
poi.PortOfItineraryName = bpolNameValue;
|
|
poi.PortOfItineraryLocode = bpolLocodeValue;
|
|
// falls nur Locode angegeben wurde, Portname aus Locode ermitteln
|
|
if(poi.PortOfItineraryName.IsNullOrEmpty() && !poi.PortOfItineraryLocode.IsNullOrEmpty() && (poi.PortOfItineraryLocode.Length == 5))
|
|
{
|
|
poi.PortOfItineraryName = LocodeDB.PortNameFromLocode(poi.PortOfItineraryLocode);
|
|
}
|
|
|
|
poi.PortOfItineraryETA = reader.ReadDateTime(bpolETADate, bpolETATime);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region POBA
|
|
|
|
private static void ScanPOBA(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message pobaMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.POBA);
|
|
if(pobaMessage.Elements.Count == 0)
|
|
{
|
|
POBA newPoba = new POBA();
|
|
newPoba.MessageHeader = pobaMessage;
|
|
pobaMessage.Elements.Add(newPoba);
|
|
}
|
|
|
|
POBA poba = pobaMessage.Elements[0] as POBA;
|
|
Util.ScanMessage(poba, reader);
|
|
if (((poba.TotalPersonsOnBoardUponArrival ?? 0) == 0) && poba.IsNew)
|
|
messages.Remove(pobaMessage);
|
|
|
|
reader.Conf.ConfirmNumber("POBA.TotalCrewMembersOnBoardUponArrival_DK", poba.TotalCrewMembersOnBoardUponArrival,
|
|
(poba.TotalCrewMembersOnBoardUponArrival.HasValue && poba.TotalCrewMembersOnBoardUponArrival > 0) ?
|
|
ExcelReader.ReadState.OK : ExcelReader.ReadState.WARN);
|
|
|
|
reader.Conf.ConfirmNumber("POBA.TotalPassengersOnBoardUponArrival_DK", poba.TotalPassengersOnBoardUponArrival,
|
|
ExcelReader.ReadState.OK);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region POBD
|
|
|
|
private static void ScanPOBD(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message pobdMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.POBD);
|
|
if(pobdMessage.Elements.Count == 0)
|
|
{
|
|
POBD newPobd = new POBD();
|
|
newPobd.MessageHeader = pobdMessage;
|
|
pobdMessage.Elements.Add(newPobd);
|
|
}
|
|
|
|
POBD pobd = pobdMessage.Elements[0] as POBD;
|
|
Util.ScanMessage(pobd, reader);
|
|
if (((pobd.TotalPersonsOnBoardUponDeparture ?? 0) == 0) && pobd.IsNew)
|
|
messages.Remove(pobdMessage);
|
|
|
|
reader.Conf.ConfirmNumber("POBD.TotalCrewMembersOnBoardUponDeparture_DK", pobd.TotalCrewMembersOnBoardUponDeparture,
|
|
(pobd.TotalCrewMembersOnBoardUponDeparture.HasValue && pobd.TotalCrewMembersOnBoardUponDeparture > 0) ?
|
|
ExcelReader.ReadState.OK : ExcelReader.ReadState.WARN);
|
|
|
|
reader.Conf.ConfirmNumber("POBD.TotalPassengersOnBoardUponDeparture_DK", pobd.TotalPassengersOnBoardUponDeparture,
|
|
ExcelReader.ReadState.OK);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region HAZA
|
|
|
|
private static bool ScanHAZA(Message hazaMessage, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
|
|
if(hazaMessage.Elements.Count == 0)
|
|
{
|
|
HAZ newHaza = new HAZ();
|
|
newHaza.IsDeparture = false;
|
|
newHaza.MessageHeader = hazaMessage;
|
|
hazaMessage.Elements.Add(newHaza);
|
|
}
|
|
HAZ haza = hazaMessage.Elements[0] as HAZ;
|
|
|
|
haza.NoDPGOnBoardOnArrival = !reader.ReadBoolean("HAZA.DGOnBoard");
|
|
haza.DPGManifestOnBoardOnArrival = reader.ReadBoolean("HAZA.DPGManifestOnBoardOnArrival");
|
|
haza.DPGContactFamilyName = reader.ReadText("HAZA.DPGContactFamilyName");
|
|
haza.DPGContactPhone = reader.ReadText("HAZA.DPGContactPhone");
|
|
haza.MOUBaltic = reader.ReadBoolean("HAZA.MOUBaltic");
|
|
string shipClass = reader.ReadText("HAZA.INFShipClass");
|
|
if(!shipClass.IsNullOrEmpty())
|
|
{
|
|
if (shipClass.Contains('1')) haza.INFShipClass = 0;
|
|
if (shipClass.Contains('2')) haza.INFShipClass = 1;
|
|
if (shipClass.Contains('3')) haza.INFShipClass = 2;
|
|
}
|
|
|
|
#region IMDG
|
|
|
|
for (int i = 1; i <= 10; i++)
|
|
{
|
|
string imdg_unno = string.Format("HAZA.IMDG.UNNumber_{0}", i);
|
|
string imdg_properShippingName = string.Format("HAZA.IMDG.ProperShippingName_{0}", i);
|
|
string imdg_imoClass = string.Format("HAZA.IMDG.IMOClass_{0}", i);
|
|
string imdg_packingGroup = string.Format("HAZA.IMDG.PackingGroup_{0}", i);
|
|
string imdg_marinePollutant = string.Format("HAZA.IMDG.MarinePollutant_{0}", i);
|
|
string imdg_flashpoint = string.Format("HAZA.IMDG.Flashpoint_CEL_{0}", i);
|
|
string imdg_numberOfPackages = string.Format("HAZA.IMDG.NumberOfPackages_{0}", i);
|
|
string imdg_packageType = string.Format("HAZA.IMDG.PackageType_{0}", i);
|
|
string imdg_limitedQuantities = string.Format("HAZA.IMDG.LimitedQuantities_{0}", i);
|
|
string imdg_exceptedQuantities = string.Format("HAZA.IMDG.ExceptedQuantities_{0}", i);
|
|
string imdg_netQuantity = string.Format("HAZA.IMDG.NetQuantity_KGM_{0}", i);
|
|
string imdg_grossQuantity = string.Format("HAZA.IMDG.GrossQuantity_KGM_{0}", i);
|
|
string imdg_number = string.Format("HAZA.IMDG.Number_{0}", i);
|
|
string imdg_stowagePosition = string.Format("HAZA.IMDG.StowagePosition_{0}", i);
|
|
string imdg_portOfLoading = string.Format("HAZA.IMDG.PortOfLoading_{0}", i);
|
|
string imdg_portOfDischarge = string.Format("HAZA.IMDG.PortOfDischarge_{0}", i);
|
|
string imdg_containerNumber = string.Format("HAZA.IMDG.ContainerNumber_{0}", i);
|
|
|
|
|
|
string unNumber = reader.ReadText(imdg_unno);
|
|
if(unNumber.IsNullOrEmpty()) // if unnumber is not set ignore this row
|
|
{
|
|
continue;
|
|
}
|
|
|
|
string posIdent = string.Format("IMDG-{0}", i);
|
|
IMDGPosition imdgPosition = haza.GetIMDGPositionWithIdentifier(posIdent);
|
|
if(imdgPosition == null)
|
|
{
|
|
imdgPosition = new IMDGPosition();
|
|
imdgPosition.HAZ = haza;
|
|
imdgPosition.Identifier = posIdent;
|
|
haza.IMDGPositions.Add(imdgPosition);
|
|
}
|
|
|
|
imdgPosition.UNNumber = unNumber;
|
|
imdgPosition.ProperShippingName = reader.ReadText(imdg_properShippingName);
|
|
imdgPosition.IMOClass = reader.ReadText(imdg_imoClass);
|
|
imdgPosition.PackingGroup = reader.ReadPackingGroup(imdg_packingGroup);
|
|
imdgPosition.MarinePollutant = reader.ReadBoolean(imdg_marinePollutant);
|
|
imdgPosition.Flashpoint_CEL = reader.ReadText(imdg_flashpoint);
|
|
imdgPosition.NumberOfPackages = (int?)reader.ReadNumber(imdg_numberOfPackages);
|
|
imdgPosition.PackageType = reader.ReadText(imdg_packageType);
|
|
imdgPosition.LimitedQuantities = reader.ReadBoolean(imdg_limitedQuantities);
|
|
imdgPosition.ExceptedQuantities = reader.ReadBoolean(imdg_exceptedQuantities);
|
|
imdgPosition.NetQuantity_KGM = reader.ReadNumber(imdg_netQuantity);
|
|
imdgPosition.GrossQuantity_KGM = reader.ReadNumber(imdg_grossQuantity);
|
|
imdgPosition.VehicleLicenseNumber = reader.ReadText(imdg_number);
|
|
imdgPosition.StowagePosition = reader.ReadText(imdg_stowagePosition);
|
|
imdgPosition.PortOfLoading = reader.ReadText(imdg_portOfLoading);
|
|
imdgPosition.PortOfDischarge = reader.ReadText(imdg_portOfDischarge);
|
|
imdgPosition.ContainerNumber = reader.ReadText(imdg_containerNumber);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IBC
|
|
|
|
for (int i = 1; i <= 5; i++)
|
|
{
|
|
string ibc_productName = string.Format("HAZA.IBC.ProductName_{0}", i);
|
|
string ibc_pollutionCategory = string.Format("HAZA.IBC.PollutionCategory_{0}", i);
|
|
string ibc_flash = string.Format("HAZA.IBC.FlashpointInformation_{0}", i);
|
|
string ibc_quantity = string.Format("HAZA.IBC.Quantity_KGM_{0}", i);
|
|
string ibc_stowagePosition = string.Format("HAZA.IBC.StowagePosition_{0}", i);
|
|
string ibc_portOfLoading = string.Format("HAZA.IBC.PortOfLoading_{0}", i);
|
|
string ibc_portOfDischarge = string.Format("HAZA.IBC.PortOfDischarge_{0}", i);
|
|
|
|
string productName = reader.ReadText(ibc_productName);
|
|
if (productName.IsNullOrEmpty()) continue;
|
|
|
|
string posIdent = string.Format("IBC-{0}", i);
|
|
IBCPosition ibcPosition = haza.GetIBCPositionWithIdentifier(posIdent);
|
|
if(ibcPosition == null)
|
|
{
|
|
ibcPosition = new IBCPosition();
|
|
ibcPosition.Identifier = posIdent;
|
|
ibcPosition.HAZ = haza;
|
|
haza.IBCPositions.Add(ibcPosition);
|
|
}
|
|
|
|
ibcPosition.ProductName = productName;
|
|
|
|
string pollutionCategory = reader.ReadText(ibc_pollutionCategory);
|
|
if(!pollutionCategory.IsNullOrEmpty())
|
|
{
|
|
if (pollutionCategory.Equals("X", StringComparison.OrdinalIgnoreCase)) ibcPosition.PollutionCategory = 0;
|
|
if (pollutionCategory.Equals("Y", StringComparison.OrdinalIgnoreCase)) ibcPosition.PollutionCategory = 1;
|
|
if (pollutionCategory.Equals("Z", StringComparison.OrdinalIgnoreCase)) ibcPosition.PollutionCategory = 2;
|
|
if (pollutionCategory.Equals("OS", StringComparison.OrdinalIgnoreCase)) ibcPosition.PollutionCategory = 3;
|
|
}
|
|
|
|
ibcPosition.Flashpoint_CEL = reader.ReadText(ibc_flash);
|
|
if (!ibcPosition.Flashpoint_CEL.IsNullOrEmpty())
|
|
{
|
|
if (ibcPosition.Flashpoint_CEL != "-")
|
|
{
|
|
if (double.TryParse(ibcPosition.Flashpoint_CEL, out double flashval))
|
|
{
|
|
if (flashval > 60) ibcPosition.FlashpointInformation = 1; // GT60CEL
|
|
else ibcPosition.FlashpointInformation = 2; // LE60CEL
|
|
}
|
|
}
|
|
}
|
|
|
|
ibcPosition.Quantity_KGM = (int ?) reader.ReadNumber(ibc_quantity);
|
|
ibcPosition.StowagePosition = reader.ReadText(ibc_stowagePosition);
|
|
ibcPosition.PortOfLoading = reader.ReadText(ibc_portOfLoading);
|
|
ibcPosition.PortOfDischarge = reader.ReadText(ibc_portOfDischarge);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IGC
|
|
|
|
for (int i = 1; i <= 5; i++)
|
|
{
|
|
string igc_productName = string.Format("HAZA.IGC.ProductName_{0}", i);
|
|
string igc_quantity = string.Format("HAZA.IGC.Quantity_KGM_{0}", i);
|
|
string igc_stowagePosition = string.Format("HAZA.IGC.StowagePosition_{0}", i);
|
|
string igc_portOfLoading = string.Format("HAZA.IGC.PortOfLoading_{0}", i);
|
|
string igc_portOfDischarge = string.Format("HAZA.IGC.PortOfDischarge_{0}", i);
|
|
|
|
string productName = reader.ReadText(igc_productName);
|
|
if (productName.IsNullOrEmpty()) continue;
|
|
|
|
string posIdent = string.Format("IGC-{0}", i);
|
|
IGCPosition igcPosition = haza.GetIGCPositionWithIdentifier(posIdent);
|
|
if(igcPosition == null)
|
|
{
|
|
igcPosition = new IGCPosition();
|
|
igcPosition.Identifier = posIdent;
|
|
igcPosition.HAZ = haza;
|
|
haza.IGCPositions.Add(igcPosition);
|
|
}
|
|
|
|
igcPosition.ProductName = productName;
|
|
igcPosition.Quantity_KGM = reader.ReadNumber(igc_quantity);
|
|
igcPosition.StowagePosition = reader.ReadText(igc_stowagePosition);
|
|
igcPosition.PortOfLoading = reader.ReadText(igc_portOfLoading);
|
|
igcPosition.PortOfDischarge = reader.ReadText(igc_portOfDischarge);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IMSBC
|
|
|
|
for (int i = 1; i <= 5; i++)
|
|
{
|
|
string imsbc_bcsn = string.Format("HAZA.IMSBC.BulkCargoShippingName_{0}", i);
|
|
string imsbc_mhb = string.Format("HAZA.IMSBC.MHB_{0}", i);
|
|
string imsbc_quantity = string.Format("HAZA.IMSBC.Quantity_KGM_{0}", i);
|
|
string imsbc_stowagePosition = string.Format("HAZA.IMSBC.StowagePosition_{0}", i);
|
|
string imsbc_portOfLoading = string.Format("HAZA.IMSBC.PortOfLoading_{0}", i);
|
|
string imsbc_portOfDischarge = string.Format("HAZA.IMSBC.PortOfDischarge_{0}", i);
|
|
|
|
string bcsn = reader.ReadText(imsbc_bcsn);
|
|
if (bcsn.IsNullOrEmpty()) continue;
|
|
|
|
string posIdent = string.Format("IMSBC-{0}", i);
|
|
IMSBCPosition imsbcPosition = haza.GetIMSBCPositionWithIdentifier(posIdent);
|
|
if(imsbcPosition == null)
|
|
{
|
|
imsbcPosition = new IMSBCPosition();
|
|
imsbcPosition.Identifier = posIdent;
|
|
imsbcPosition.HAZ = haza;
|
|
haza.IMSBCPositions.Add(imsbcPosition);
|
|
}
|
|
|
|
imsbcPosition.BulkCargoShippingName = bcsn;
|
|
imsbcPosition.MHB = reader.ReadBoolean(imsbc_mhb);
|
|
imsbcPosition.Quantity_KGM = reader.ReadNumber(imsbc_quantity);
|
|
imsbcPosition.StowagePosition = reader.ReadText(imsbc_stowagePosition);
|
|
imsbcPosition.PortOfLoading = reader.ReadText(imsbc_portOfLoading);
|
|
imsbcPosition.PortOfDischarge = reader.ReadText(imsbc_portOfDischarge);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region MARPOL
|
|
|
|
for (int i = 1; i <= 5; i++)
|
|
{
|
|
string marpol_name = string.Format("HAZA.MARPOL.Name_{0}", i);
|
|
string marpol_flash = string.Format("HAZA.MARPOL.Flashpoint_CEL_{0}", i);
|
|
string marpol_quantity = string.Format("HAZA.MARPOL.Quantity_KGM_{0}", i);
|
|
string marpol_stowagePosition = string.Format("HAZA.MARPOL.StowagePosition_{0}", i);
|
|
string marpol_portOfLoading = string.Format("HAZA.MARPOL.PortOfLoading_{0}", i);
|
|
string marpol_portOfDischarge = string.Format("HAZA.MARPOL.PortOfDischarge_{0}", i);
|
|
|
|
string name = reader.ReadText(marpol_name);
|
|
if (name.IsNullOrEmpty()) continue;
|
|
|
|
string posIdent = string.Format("MARPOL-{0}", i);
|
|
MARPOL_Annex_I_Position marpolPosition = haza.GetMARPOLPositionWithIdentifier(posIdent);
|
|
if(marpolPosition == null)
|
|
{
|
|
marpolPosition = new MARPOL_Annex_I_Position();
|
|
marpolPosition.Identifier = posIdent;
|
|
marpolPosition.HAZ = haza;
|
|
haza.MARPOLPositions.Add(marpolPosition);
|
|
}
|
|
|
|
marpolPosition.Name = name;
|
|
marpolPosition.Flashpoint_CEL = reader.ReadText(marpol_flash);
|
|
|
|
// Früher bei NULL: NF // Ableitung Flashpoint-Info: Christin, 22.3.2017
|
|
// jetzt bei leerer Flashpoint_CEL: Flashpointinformation NULL: Basti, 13.7.2020
|
|
if (marpolPosition.Flashpoint_CEL.IsNullOrEmpty()) { marpolPosition.FlashpointInformation = null; }
|
|
else
|
|
{
|
|
if (double.TryParse(marpolPosition.Flashpoint_CEL, out double flashval))
|
|
{
|
|
if (flashval > 60) marpolPosition.FlashpointInformation = 1; // GT60CEL
|
|
else marpolPosition.FlashpointInformation = 2; // LE60CEL
|
|
}
|
|
}
|
|
|
|
marpolPosition.Quantity_KGM = reader.ReadNumber(marpol_quantity);
|
|
marpolPosition.StowagePosition = reader.ReadText(marpol_stowagePosition);
|
|
marpolPosition.PortOfLoading = reader.ReadText(marpol_portOfLoading);
|
|
marpolPosition.PortOfDischarge = reader.ReadText(marpol_portOfDischarge);
|
|
}
|
|
|
|
#endregion
|
|
|
|
if(haza.HasPositions) // Christin 22.3.17: Felder bei Positionen immer fest ausfüllen
|
|
{
|
|
haza.NoDPGOnBoardOnArrival = false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region HAZD
|
|
|
|
private static bool ScanHAZD(Message hazdMessage, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
if (hazdMessage.Elements.Count == 0)
|
|
{
|
|
HAZ newHazd = new HAZ();
|
|
newHazd.IsDeparture = true;
|
|
newHazd.MessageHeader = hazdMessage;
|
|
hazdMessage.Elements.Add(newHazd);
|
|
}
|
|
HAZ hazd = hazdMessage.Elements[0] as HAZ;
|
|
|
|
hazd.NoDPGOnBoardOnArrival = !reader.ReadBoolean("HAZD.DGOnBoard");
|
|
hazd.DPGManifestOnBoardOnArrival = reader.ReadBoolean("HAZD.DPGManifestOnBoardOnDeparture");
|
|
hazd.DPGContactFamilyName = reader.ReadText("HAZD.DPGContactFamilyName");
|
|
hazd.DPGContactPhone = reader.ReadText("HAZD.DPGContactPhone");
|
|
hazd.MOUBaltic = reader.ReadBoolean("HAZD.MOUBaltic");
|
|
string shipClass = reader.ReadText("HAZD.INFShipClass");
|
|
if (!shipClass.IsNullOrEmpty())
|
|
{
|
|
if (shipClass.Contains('1')) hazd.INFShipClass = 0;
|
|
if (shipClass.Contains('2')) hazd.INFShipClass = 1;
|
|
if (shipClass.Contains('3')) hazd.INFShipClass = 2;
|
|
}
|
|
|
|
#region IMDG
|
|
|
|
for (int i = 1; i <= 10; i++)
|
|
{
|
|
string imdg_unno = string.Format("HAZD.IMDG.UNNumber_{0}", i);
|
|
string imdg_properShippingName = string.Format("HAZD.IMDG.ProperShippingName_{0}", i);
|
|
string imdg_imoClass = string.Format("HAZD.IMDG.IMOClass_{0}", i);
|
|
string imdg_packingGroup = string.Format("HAZD.IMDG.PackingGroup_{0}", i);
|
|
string imdg_marinePollutant = string.Format("HAZD.IMDG.MarinePollutant_{0}", i);
|
|
string imdg_flashpoint = string.Format("HAZD.IMDG.Flashpoint_CEL_{0}", i);
|
|
string imdg_numberOfPackages = string.Format("HAZD.IMDG.NumberOfPackages_{0}", i);
|
|
string imdg_packageType = string.Format("HAZD.IMDG.PackageType_{0}", i);
|
|
string imdg_limitedQuantities = string.Format("HAZD.IMDG.LimitedQuantities_{0}", i);
|
|
string imdg_exceptedQuantities = string.Format("HAZD.IMDG.ExceptedQuantities_{0}", i);
|
|
string imdg_netQuantity = string.Format("HAZD.IMDG.NetQuantity_KGM_{0}", i);
|
|
string imdg_grossQuantity = string.Format("HAZD.IMDG.GrossQuantity_KGM_{0}", i);
|
|
string imdg_number = string.Format("HAZD.IMDG.Number_{0}", i);
|
|
string imdg_stowagePosition = string.Format("HAZD.IMDG.StowagePosition_{0}", i);
|
|
string imdg_portOfLoading = string.Format("HAZD.IMDG.PortOfLoading_{0}", i);
|
|
string imdg_portOfDischarge = string.Format("HAZD.IMDG.PortOfDischarge_{0}", i);
|
|
string imdg_containerNumber = string.Format("HAZD.IMDG.ContainerNumber_{0}", i);
|
|
|
|
string unNumber = reader.ReadText(imdg_unno);
|
|
if (unNumber.IsNullOrEmpty()) continue; // if unnumber is not set ignore this row
|
|
|
|
string posIdent = string.Format("IMDG-{0}", i);
|
|
IMDGPosition imdgPosition = hazd.GetIMDGPositionWithIdentifier(posIdent);
|
|
if (imdgPosition == null)
|
|
{
|
|
imdgPosition = new IMDGPosition();
|
|
imdgPosition.HAZ = hazd;
|
|
imdgPosition.Identifier = posIdent;
|
|
hazd.IMDGPositions.Add(imdgPosition);
|
|
}
|
|
|
|
imdgPosition.UNNumber = unNumber;
|
|
imdgPosition.ProperShippingName = reader.ReadText(imdg_properShippingName);
|
|
imdgPosition.IMOClass = reader.ReadText(imdg_imoClass);
|
|
imdgPosition.PackingGroup = reader.ReadPackingGroup(imdg_packingGroup);
|
|
imdgPosition.MarinePollutant = reader.ReadBoolean(imdg_marinePollutant);
|
|
imdgPosition.Flashpoint_CEL = reader.ReadText(imdg_flashpoint);
|
|
imdgPosition.NumberOfPackages = (int?)reader.ReadNumber(imdg_numberOfPackages);
|
|
imdgPosition.PackageType = reader.ReadText(imdg_packageType);
|
|
imdgPosition.LimitedQuantities = reader.ReadBoolean(imdg_limitedQuantities);
|
|
imdgPosition.ExceptedQuantities = reader.ReadBoolean(imdg_exceptedQuantities);
|
|
imdgPosition.NetQuantity_KGM = reader.ReadNumber(imdg_netQuantity);
|
|
imdgPosition.GrossQuantity_KGM = reader.ReadNumber(imdg_grossQuantity);
|
|
imdgPosition.VehicleLicenseNumber = reader.ReadText(imdg_number);
|
|
imdgPosition.StowagePosition = reader.ReadText(imdg_stowagePosition);
|
|
imdgPosition.PortOfLoading = reader.ReadText(imdg_portOfLoading);
|
|
imdgPosition.PortOfDischarge = reader.ReadText(imdg_portOfDischarge);
|
|
imdgPosition.ContainerNumber = reader.ReadText(imdg_containerNumber);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IBC
|
|
|
|
for (int i = 1; i <= 5; i++)
|
|
{
|
|
string ibc_productName = string.Format("HAZD.IBC.ProductName_{0}", i);
|
|
string ibc_pollutionCategory = string.Format("HAZD.IBC.PollutionCategory_{0}", i);
|
|
string ibc_flash = string.Format("HAZD.IBC.Flashpoint_CEL_{0}", i);
|
|
string ibc_quantity = string.Format("HAZD.IBC.Quantity_KGM_{0}", i);
|
|
string ibc_stowagePosition = string.Format("HAZD.IBC.StowagePosition_{0}", i);
|
|
string ibc_portOfLoading = string.Format("HAZD.IBC.PortOfLoading_{0}", i);
|
|
string ibc_portOfDischarge = string.Format("HAZD.IBC.PortOfDischarge_{0}", i);
|
|
|
|
string productName = reader.ReadText(ibc_productName);
|
|
if (productName.IsNullOrEmpty()) continue;
|
|
|
|
string posIdent = string.Format("IBC-{0}", i);
|
|
IBCPosition ibcPosition = hazd.GetIBCPositionWithIdentifier(posIdent);
|
|
if (ibcPosition == null)
|
|
{
|
|
ibcPosition = new IBCPosition();
|
|
ibcPosition.Identifier = posIdent;
|
|
ibcPosition.HAZ = hazd;
|
|
hazd.IBCPositions.Add(ibcPosition);
|
|
}
|
|
|
|
ibcPosition.ProductName = productName;
|
|
string pollutionCategory = reader.ReadText(ibc_pollutionCategory);
|
|
if (!pollutionCategory.IsNullOrEmpty())
|
|
{
|
|
if (pollutionCategory.Equals("X", StringComparison.OrdinalIgnoreCase)) ibcPosition.PollutionCategory = 0;
|
|
if (pollutionCategory.Equals("Y", StringComparison.OrdinalIgnoreCase)) ibcPosition.PollutionCategory = 1;
|
|
if (pollutionCategory.Equals("Z", StringComparison.OrdinalIgnoreCase)) ibcPosition.PollutionCategory = 2;
|
|
if (pollutionCategory.Equals("OS", StringComparison.OrdinalIgnoreCase)) ibcPosition.PollutionCategory = 3;
|
|
}
|
|
|
|
ibcPosition.Flashpoint_CEL = reader.ReadText(ibc_flash);
|
|
|
|
if (!ibcPosition.Flashpoint_CEL.IsNullOrEmpty())
|
|
{
|
|
if (ibcPosition.Flashpoint_CEL != "-")
|
|
{
|
|
if (double.TryParse(ibcPosition.Flashpoint_CEL, out double flashval))
|
|
{
|
|
if (flashval > 60) ibcPosition.FlashpointInformation = 1; // GT60CEL
|
|
else ibcPosition.FlashpointInformation = 2; // LE60CEL
|
|
}
|
|
}
|
|
}
|
|
|
|
ibcPosition.Quantity_KGM = (int?)reader.ReadNumber(ibc_quantity);
|
|
ibcPosition.StowagePosition = reader.ReadText(ibc_stowagePosition);
|
|
ibcPosition.PortOfLoading = reader.ReadText(ibc_portOfLoading);
|
|
ibcPosition.PortOfDischarge = reader.ReadText(ibc_portOfDischarge);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IGC
|
|
|
|
for (int i = 1; i <= 5; i++)
|
|
{
|
|
string igc_productName = string.Format("HAZD.IGC.ProductName_{0}", i);
|
|
string igc_quantity = string.Format("HAZD.IGC.Quantity_KGM_{0}", i);
|
|
string igc_stowagePosition = string.Format("HAZD.IGC.StowagePosition_{0}", i);
|
|
string igc_portOfLoading = string.Format("HAZD.IGC.PortOfLoading_{0}", i);
|
|
string igc_portOfDischarge = string.Format("HAZD.IGC.PortOfDischarge_{0}", i);
|
|
|
|
string productName = reader.ReadText(igc_productName);
|
|
if (productName.IsNullOrEmpty()) continue;
|
|
|
|
string posIdent = string.Format("IGC-{0}", i);
|
|
IGCPosition igcPosition = hazd.GetIGCPositionWithIdentifier(posIdent);
|
|
if (igcPosition == null)
|
|
{
|
|
igcPosition = new IGCPosition();
|
|
igcPosition.Identifier = posIdent;
|
|
igcPosition.HAZ = hazd;
|
|
hazd.IGCPositions.Add(igcPosition);
|
|
}
|
|
|
|
igcPosition.ProductName = productName;
|
|
igcPosition.Quantity_KGM = reader.ReadNumber(igc_quantity);
|
|
igcPosition.StowagePosition = reader.ReadText(igc_stowagePosition);
|
|
igcPosition.PortOfLoading = reader.ReadText(igc_portOfLoading);
|
|
igcPosition.PortOfDischarge = reader.ReadText(igc_portOfDischarge);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IMSBC
|
|
|
|
for (int i = 1; i <= 5; i++)
|
|
{
|
|
string imsbc_bcsn = string.Format("HAZD.IMSBC.BulkCargoShippingName_{0}", i);
|
|
string imsbc_mhb = string.Format("HAZD.IMSBC.MHB_{0}", i);
|
|
string imsbc_quantity = string.Format("HAZD.IMSBC.Quantity_KGM_{0}", i);
|
|
string imsbc_stowagePosition = string.Format("HAZD.IMSBC.StowagePosition_{0}", i);
|
|
string imsbc_portOfLoading = string.Format("HAZD.IMSBC.PortOfLoading_{0}", i);
|
|
string imsbc_portOfDischarge = string.Format("HAZD.IMSBC.PortOfDischarge_{0}", i);
|
|
|
|
string bcsn = reader.ReadText(imsbc_bcsn);
|
|
if (bcsn.IsNullOrEmpty()) continue;
|
|
|
|
string posIdent = string.Format("IMSBC-{0}", i);
|
|
IMSBCPosition imsbcPosition = hazd.GetIMSBCPositionWithIdentifier(posIdent);
|
|
if (imsbcPosition == null)
|
|
{
|
|
imsbcPosition = new IMSBCPosition();
|
|
imsbcPosition.Identifier = posIdent;
|
|
imsbcPosition.HAZ = hazd;
|
|
hazd.IMSBCPositions.Add(imsbcPosition);
|
|
}
|
|
|
|
imsbcPosition.BulkCargoShippingName = bcsn;
|
|
imsbcPosition.MHB = reader.ReadBoolean(imsbc_mhb);
|
|
imsbcPosition.Quantity_KGM = reader.ReadNumber(imsbc_quantity);
|
|
imsbcPosition.StowagePosition = reader.ReadText(imsbc_stowagePosition);
|
|
imsbcPosition.PortOfLoading = reader.ReadText(imsbc_portOfLoading);
|
|
imsbcPosition.PortOfDischarge = reader.ReadText(imsbc_portOfDischarge);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region MARPOL
|
|
|
|
for (int i = 1; i <= 5; i++)
|
|
{
|
|
string marpol_name = string.Format("HAZD.MARPOL.Name_{0}", i);
|
|
string marpol_flash = string.Format("HAZD.MARPOL.Flashpoint_CEL_{0}", i);
|
|
string marpol_quantity = string.Format("HAZD.MARPOL.Quantity_KGM_{0}", i);
|
|
string marpol_stowagePosition = string.Format("HAZD.MARPOL.StowagePosition_{0}", i);
|
|
string marpol_portOfLoading = string.Format("HAZD.MARPOL.PortOfLoading_{0}", i);
|
|
string marpol_portOfDischarge = string.Format("HAZD.MARPOL.PortOfDischarge_{0}", i);
|
|
|
|
string name = reader.ReadText(marpol_name);
|
|
if (name.IsNullOrEmpty()) continue;
|
|
|
|
string posIdent = string.Format("MARPOL-{0}", i);
|
|
MARPOL_Annex_I_Position marpolPosition = hazd.GetMARPOLPositionWithIdentifier(posIdent);
|
|
if (marpolPosition == null)
|
|
{
|
|
marpolPosition = new MARPOL_Annex_I_Position();
|
|
marpolPosition.Identifier = posIdent;
|
|
marpolPosition.HAZ = hazd;
|
|
hazd.MARPOLPositions.Add(marpolPosition);
|
|
}
|
|
|
|
marpolPosition.Name = name;
|
|
marpolPosition.Flashpoint_CEL = reader.ReadText(marpol_flash);
|
|
if (marpolPosition.Flashpoint_CEL.IsNullOrEmpty()) {
|
|
marpolPosition.FlashpointInformation = 0;
|
|
} // NF // Ableitung Flashpoint-Info: Christin, 22.3.2017
|
|
else
|
|
{
|
|
if (double.TryParse(marpolPosition.Flashpoint_CEL, out double flashval))
|
|
{
|
|
if (flashval > 60) marpolPosition.FlashpointInformation = 1; // GT60CEL
|
|
else marpolPosition.FlashpointInformation = 2; // LE60CEL
|
|
}
|
|
}
|
|
|
|
marpolPosition.Quantity_KGM = reader.ReadNumber(marpol_quantity);
|
|
marpolPosition.StowagePosition = reader.ReadText(marpol_stowagePosition);
|
|
marpolPosition.PortOfLoading = reader.ReadText(marpol_portOfLoading);
|
|
marpolPosition.PortOfDischarge = reader.ReadText(marpol_portOfDischarge);
|
|
}
|
|
|
|
#endregion
|
|
|
|
if (hazd.HasPositions) // Christin 22.3.17: Felder bei Positionen immer fest ausfüllen
|
|
{
|
|
hazd.NoDPGOnBoardOnArrival = false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region INFO
|
|
|
|
private static bool ScanINFO(Message infoMessage, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
if(infoMessage.Elements.Count == 0)
|
|
{
|
|
INFO newINFO = new INFO();
|
|
newINFO.MessageHeader = infoMessage;
|
|
infoMessage.Elements.Add(newINFO);
|
|
}
|
|
INFO info = infoMessage.Elements[0] as INFO;
|
|
ExcelUtil.ScanMessage(info, reader);
|
|
|
|
info.ShippingArea = reader.ReadShippingArea("INFO.ShippingArea"); // enum read func
|
|
bool? fumigatedBulkCargo = reader.ReadBoolean("INFO.FumigatedBulkCargo");
|
|
info.FumigatedBulkCargo = (byte) ((fumigatedBulkCargo ?? false) ? 1 : 0);
|
|
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region STAT
|
|
|
|
private static void ScanSTAT(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message statMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.STAT);
|
|
if(statMessage.Elements.Count == 0)
|
|
{
|
|
STAT newSTAT = new STAT();
|
|
newSTAT.MessageHeader = statMessage;
|
|
statMessage.Elements.Add(newSTAT);
|
|
}
|
|
STAT stat = statMessage.Elements[0] as STAT;
|
|
Util.ScanMessage(stat, reader);
|
|
|
|
stat.PortOfRegistry = reader.ReadLoCode("STAT.PortOfRegistry");
|
|
stat.Flag = reader.ReadNationality("STAT.Flag");
|
|
|
|
stat.MMSINumber = reader.ReadTextNoWhitespace("STAT.MMSINumber");
|
|
reader.Conf.ConfirmText("STAT.MMSINumber", stat.MMSINumber, (stat.MMSINumber.IsNullOrEmpty() || (stat.MMSINumber.Length != 9)) ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
|
|
stat.CallSign = reader.ReadTextNoWhitespace("STAT.CallSign");
|
|
reader.Conf.ConfirmText("STAT.CallSign", stat.CallSign, stat.CallSign.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
|
|
stat.ISMCompanyId = reader.ReadTextNoWhitespace("STAT.ISMCompanyId");
|
|
|
|
reader.Conf.ConfirmText("STAT.ISMCompanyId", stat.ISMCompanyId, (stat.ISMCompanyId.IsNullOrEmpty() || (stat.ISMCompanyId.Length != 7)) ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
|
|
if (!stat.ISMCompanyId.IsNullOrEmpty() && stat.ISMCompanyId.Length < 7)
|
|
{
|
|
while (stat.ISMCompanyId.Length < 7)
|
|
stat.ISMCompanyId = "0" + stat.ISMCompanyId;
|
|
}
|
|
|
|
string transportMode = reader.ReadText("STAT.TransportMode");
|
|
if(transportMode != null)
|
|
{
|
|
if (transportMode.Contains("maritime", StringComparison.OrdinalIgnoreCase)) stat.TransportMode = "1";
|
|
if (transportMode.Equals("1")) stat.TransportMode = transportMode;
|
|
|
|
if (transportMode.Contains("inland", StringComparison.OrdinalIgnoreCase)) stat.TransportMode = "8";
|
|
if (transportMode.Equals("8")) stat.TransportMode = transportMode;
|
|
}
|
|
reader.Conf.ConfirmText("STAT.TransportMode", transportMode, stat.TransportMode.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
|
|
|
|
if (!stat.ShipType.IsNullOrEmpty() && stat.ShipType.Length > 3)
|
|
reader.Conf.ConfirmText("STAT.ShipType", stat.ShipType, ExcelReader.ReadState.WARN);
|
|
|
|
// Vessel Email as HerbergEmail sichern
|
|
messageCore.HerbergEmailContactReportingVessel = reader.ReadText("ShipMail");
|
|
reader.Conf.ConfirmText("ShipMail", messageCore.HerbergEmailContactReportingVessel, messageCore.HerbergEmailContactReportingVessel.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
|
|
// wird nicht wieder entfernt (core ist auch da!)
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region NOA_NOD
|
|
|
|
private static void ScanNOA_NOD(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message noa_nodMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.NOA_NOD);
|
|
if (noa_nodMessage.Elements.Count == 0)
|
|
{
|
|
NOA_NOD newNoa_nod = new NOA_NOD();
|
|
newNoa_nod.MessageHeader = noa_nodMessage;
|
|
noa_nodMessage.Elements.Add(newNoa_nod);
|
|
}
|
|
|
|
NOA_NOD noa_nod = noa_nodMessage.Elements[0] as NOA_NOD;
|
|
|
|
DateTime? eta = reader.ReadDateTime("NOA_NOD.ETADateToPortOfCall", "NOA_NOD.ETATimeToPortOfCall");
|
|
|
|
if (messageCore.IsTransit)
|
|
{
|
|
if (eta.HasValue)
|
|
noa_nod.ETAToKielCanal = eta;
|
|
//else
|
|
// noa_nod.ETAToKielCanal = messageCore.ETAKielCanal;
|
|
}
|
|
else
|
|
{
|
|
if (eta.HasValue)
|
|
noa_nod.ETAToPortOfCall = eta;
|
|
//else
|
|
// noa_nod.ETAToPortOfCall = messageCore.ETA;
|
|
|
|
// Zeit muss zurückkonvertiert werden, da toUniversalTime() kodiert
|
|
if(noa_nod.ETAToPortOfCall.HasValue)
|
|
reader.Conf.ConfirmDate("NOA_NOD.ETAToPortOfCall", noa_nod.ETAToPortOfCall.Value.ToLocalTime(), ExcelReader.ReadState.OK);
|
|
|
|
for (int i = 1; i <= noa_nod.NumberOfExcelRows; i++)
|
|
{
|
|
string callPurposeDescriptionKey = string.Format("NOA_NOD.CallPuposeDescription_{0}", i);
|
|
string callPurposeCodeKey = string.Format("NOA_NOD.CallPurposeCode_{0}", i);
|
|
string callPurposeDescription = reader.ReadText(callPurposeDescriptionKey);
|
|
string callPurposeCode = reader.ReadText(callPurposeCodeKey);
|
|
|
|
if (!callPurposeCode.IsNullOrEmpty())
|
|
{
|
|
|
|
if (!(noa_nod.GetSublistElementWithIdentifier(i.ToString()) is CallPurpose callPurpose))
|
|
{
|
|
callPurpose = new CallPurpose();
|
|
callPurpose.NOA_NOD = noa_nod;
|
|
callPurpose.Identifier = i.ToString();
|
|
noa_nod.CallPurposes.Add(callPurpose);
|
|
}
|
|
|
|
callPurpose.CallPurposeCode = ((int?)reader.ReadNumber(callPurposeCodeKey)) ?? 0;
|
|
callPurpose.CallPurposeDescription = callPurposeDescription;
|
|
ExcelReader.ReadState aReadState = ExcelReader.ReadState.OK;
|
|
if (callPurposeDescription.IsNullOrEmpty()) aReadState = ExcelReader.ReadState.WARN;
|
|
else if (callPurposeDescription.Length > 90) aReadState = ExcelReader.ReadState.FAIL;
|
|
reader.Conf.ConfirmText(callPurposeDescriptionKey, callPurposeDescription, aReadState);
|
|
if (i == 1)
|
|
reader.Conf.ConfirmText("NOA_NOD.CallPuposeDescription_1_DK", callPurposeDescription, callPurposeDescription.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
|
|
}
|
|
}
|
|
}
|
|
|
|
string lastPort = reader.ReadText("NOA_NOD.LastPort")?.Trim().ToUpper();
|
|
|
|
if (lastPort != null)
|
|
{
|
|
if (LocodeDB.PortNameFromLocode(lastPort) != null)
|
|
{
|
|
noa_nod.LastPort = lastPort;
|
|
}
|
|
else
|
|
{
|
|
List<string> lastPorts = LocodeDB.AllLocodesForCityName(lastPort);
|
|
if (lastPorts.Count == 1)
|
|
noa_nod.LastPort = lastPorts[0];
|
|
else
|
|
_log.WarnFormat("{0} results in {1} possible LOCODES", lastPort, lastPorts.Count);
|
|
}
|
|
}
|
|
|
|
reader.Conf.ConfirmText("NOA_NOD.LastPort", lastPort, noa_nod.LastPort.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
|
|
|
|
string nextPort = reader.ReadText("NOA_NOD.NextPort")?.Trim().ToUpper();
|
|
bool isValidSSNPort = false;
|
|
if (!nextPort.IsNullOrEmpty())
|
|
{
|
|
if (nextPort.Length > 5)
|
|
nextPort = nextPort.Substring(0, 5); //trunc
|
|
else
|
|
isValidSSNPort = !LocodeDB.SSNPortNameFromLocode(nextPort).IsNullOrEmpty();
|
|
}
|
|
|
|
if(string.IsNullOrEmpty(nextPort))
|
|
reader.Conf.ConfirmText("NOA_NOD.NextPort", nextPort, ExcelReader.ReadState.WARN);
|
|
else
|
|
reader.Conf.ConfirmText("NOA_NOD.NextPort", nextPort, isValidSSNPort ? ExcelReader.ReadState.OK : ExcelReader.ReadState.FAIL);
|
|
|
|
noa_nod.NextPort = nextPort;
|
|
|
|
if(messageCore.IsTransit)
|
|
{
|
|
noa_nod.ETDFromKielCanal = reader.ReadDateTime("NOA_NOD.ETDDateFromPortOfCall", "NOA_NOD.ETDTimeFromPortOfCall");
|
|
if(noa_nod.ETDFromKielCanal.HasValue)
|
|
reader.Conf.ConfirmDate("NOA_NOD.ETDFromPortOfCall", noa_nod.ETDFromKielCanal.Value.ToLocalTime(), ExcelReader.ReadState.OK);
|
|
else
|
|
reader.Conf.ConfirmDate("NOA_NOD.ETDFromPortOfCall", null, ExcelReader.ReadState.FAIL);
|
|
} else
|
|
{
|
|
noa_nod.ETDFromPortOfCall = reader.ReadDateTime("NOA_NOD.ETDDateFromPortOfCall", "NOA_NOD.ETDTimeFromPortOfCall");
|
|
if(noa_nod.ETDFromPortOfCall.HasValue)
|
|
reader.Conf.ConfirmDate("NOA_NOD.ETDFromPortOfCall", noa_nod.ETDFromPortOfCall.Value.ToLocalTime(), ExcelReader.ReadState.OK);
|
|
else
|
|
reader.Conf.ConfirmDate("NOA_NOD.ETDFromPortOfCall", null, ExcelReader.ReadState.FAIL);
|
|
}
|
|
|
|
noa_nod.ETDFromLastPort = reader.ReadDateTime("NOA_NOD.ETDDateFromLastPort", "NOA_NOD.ETDTimeFromLastPort");
|
|
noa_nod.ETAToNextPort = reader.ReadDateTime("NOA_NOD.ETADateToNextPort", "NOA_NOD.ETATimeToNextPort");
|
|
// DK
|
|
noa_nod.IsAnchored = reader.ReadBoolean("NOA_NOD.IsAnchored", reader.Mode == ExcelReader.CountryMode.DE);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region AGNT
|
|
|
|
private static bool ScanAGNT(Message agntMessage, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
if(agntMessage.Elements.Count == 0)
|
|
{
|
|
AGNT newAgnt = new AGNT();
|
|
newAgnt.MessageHeader = agntMessage;
|
|
agntMessage.Elements.Add(newAgnt);
|
|
}
|
|
AGNT agnt = agntMessage.Elements[0] as AGNT;
|
|
ExcelUtil.ScanMessage(agnt, reader);
|
|
|
|
if (agnt.AgentLastName.IsNullOrEmpty()) agnt.AgentLastName = "-";
|
|
|
|
// wird nicht mehr entfernt, egal welche Felder gelesen werden
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region WAS
|
|
|
|
private static void ScanWAS(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message wasMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.WAS);
|
|
if (wasMessage.Elements.Count == 0)
|
|
{
|
|
WAS newWAS = new WAS();
|
|
newWAS.MessageHeader = wasMessage;
|
|
wasMessage.Elements.Add(newWAS);
|
|
}
|
|
WAS was = wasMessage.Elements[0] as WAS;
|
|
was.DeleteElements();
|
|
|
|
Util.ScanMessage(was, reader);
|
|
|
|
was.WasteDisposalDelivery = reader.ReadDelivery("WAS.WasteDisposalDelivery");
|
|
was.LastWasteDisposalPort = reader.ReadLoCode("WAS.LastWasteDisposalPort");
|
|
|
|
string wastedispServProvName = reader.ReadText("WAS.WasteDisposalServiceProviderName");
|
|
if (wastedispServProvName != null)
|
|
{
|
|
if (was.WasteDisposalServiceProvider.Count == 0)
|
|
{
|
|
WasteDisposalServiceProvider wdsp = new WasteDisposalServiceProvider();
|
|
wdsp.Identifier = "1";
|
|
wdsp.WAS = was;
|
|
was.WasteDisposalServiceProvider.Add(wdsp);
|
|
}
|
|
((WasteDisposalServiceProvider) was.WasteDisposalServiceProvider[0]).WasteDisposalServiceProviderName = wastedispServProvName;
|
|
((WasteDisposalServiceProvider) was.WasteDisposalServiceProvider[0]).WasteDisposalDelivery = was.WasteDisposalDelivery;
|
|
}
|
|
|
|
ExcelReader.ReadState readState = ExcelReader.ReadState.WARN;
|
|
if (!wastedispServProvName.IsNullOrEmpty()) {
|
|
if (wastedispServProvName.Length > 90) readState = ExcelReader.ReadState.FAIL;
|
|
else readState = ExcelReader.ReadState.OK;
|
|
}
|
|
|
|
reader.Conf.ConfirmText("WAS.WasteDisposalServiceProviderName", wastedispServProvName, readState);
|
|
|
|
// Waste 1 - 15
|
|
for (int i = 1; i <= was.NumberOfExcelRows; i++)
|
|
{
|
|
string wastetype = string.Format("WAS.WasteType_{0}", i);
|
|
string wasteCode = string.Format("WAS.WasteCode_{0}", i);
|
|
string wasteDescription = string.Format("WAS.WasteDescription_{0}", i);
|
|
string wasteAmount = string.Format("WAS.WasteDisposalAmount_MTQ_{0}", i);
|
|
string wasteCapacity = string.Format("WAS.WasteCapacity_MTQ_{0}", i);
|
|
string wasteRetained = string.Format("WAS.WasteAmountRetained_MTQ_{0}", i);
|
|
string wastePort = string.Format("WAS.WasteDisposalPort_{0}", i);
|
|
string amountGen = string.Format("WAS.WasteAmountGeneratedTillNextPort_MTQ_{0}", i);
|
|
string wasteDis = string.Format("WAS.WasteDisposedAtLastPort_MTQ_{0}", i);
|
|
|
|
if (!(was.GetSublistElementWithIdentifier(i.ToString()) is Waste waste))
|
|
{
|
|
waste = new Waste();
|
|
waste.Identifier = i.ToString();
|
|
waste.WAS = was;
|
|
was.Waste.Add(waste);
|
|
}
|
|
|
|
waste.WasteType = (int?) reader.ReadNumber(wasteCode);
|
|
|
|
if (waste.WasteType.HasValue && (waste.WasteType == 2313))
|
|
waste.WasteType = 2600;
|
|
|
|
if (reader.Mode == ExcelReader.CountryMode.DE)
|
|
{
|
|
reader.Conf.ConfirmText(wastetype, waste.WasteTypeDisplay, ExcelReader.ReadState.OK);
|
|
reader.Conf.ConfirmNumber(wasteCode, waste.WasteType, ExcelReader.ReadState.OK);
|
|
}
|
|
else if (reader.Mode == ExcelReader.CountryMode.DK)
|
|
{
|
|
reader.Conf.ConfirmText(wastetype, WAS.DKWasteTypes[i - 1], ExcelReader.ReadState.OK);
|
|
reader.Conf.ConfirmNumber(wasteCode, WAS.DKWasteCodes[i - 1], ExcelReader.ReadState.OK);
|
|
}
|
|
|
|
// Waste description Spezialfälle für DK
|
|
waste.WasteDescription = reader.ReadText(wasteDescription);
|
|
if (waste.WasteDescription.IsNullOrEmpty())
|
|
{
|
|
if (reader.Mode == ExcelReader.CountryMode.DE)
|
|
{
|
|
waste.WasteDescription = "-";
|
|
}
|
|
else if (reader.Mode == ExcelReader.CountryMode.DK)
|
|
{
|
|
waste.WasteDescription = "-";
|
|
if (i == 6) waste.WasteDescription = "Domestic waste";
|
|
if (i == 9) waste.WasteDescription = "Operational waste";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (reader.Mode == ExcelReader.CountryMode.DK)
|
|
{
|
|
if (i == 6)
|
|
waste.WasteDescription = string.Format("Domestic waste - {0}", waste.WasteDescription);
|
|
if (i == 9)
|
|
waste.WasteDescription = string.Format("Operational waste - {0}", waste.WasteDescription);
|
|
}
|
|
}
|
|
|
|
// RM am 24.1.18, ich hoffe das stimmt so wie sie meint..
|
|
if((reader.Mode == ExcelReader.CountryMode.DK) && (i==9))
|
|
{
|
|
_log.DebugFormat("DK: Changing Waste code {0} to 2300 for line {1}", waste.WasteType, i);
|
|
waste.WasteType = 2300;
|
|
}
|
|
|
|
reader.Conf.ConfirmText(wasteDescription, waste.WasteDescription, waste.WasteDescription.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
|
|
waste.WasteDisposalAmount_MTQ = reader.ReadNumberDefaultZero(wasteAmount);
|
|
waste.WasteCapacity_MTQ = reader.ReadNumberDefaultZero(wasteCapacity);
|
|
waste.WasteAmountRetained_MTQ = reader.ReadNumberDefaultZero(wasteRetained);
|
|
|
|
waste.WasteDisposalPort = reader.ReadLoCode(wastePort);
|
|
bool isLocode;
|
|
ExcelReader.ReadState rs;
|
|
if (waste.WasteDisposalPort.IsNullOrEmpty())
|
|
{
|
|
waste.WasteDisposalPort = "ZZUKN";
|
|
rs = ExcelReader.ReadState.WARN;
|
|
}
|
|
else
|
|
{
|
|
isLocode = (LocodeDB.PortNameFromLocode(waste.WasteDisposalPort) != null);
|
|
rs = isLocode ? ExcelReader.ReadState.OK : ExcelReader.ReadState.FAIL;
|
|
}
|
|
reader.Conf.ConfirmText(wastePort, waste.WasteDisposalPort, rs);
|
|
|
|
waste.WasteAmountGeneratedTillNextPort_MTQ = reader.ReadNumberDefaultZero(amountGen);
|
|
waste.WasteDisposedAtLastPort_MTQ = reader.ReadNumberDefaultZero(wasteDis);
|
|
|
|
/*
|
|
if ((reader.Mode == ExcelReader.CountryMode.DE) &&
|
|
((i == 6) || (i == 8) || (i == 9)))
|
|
{
|
|
waste.WasteDescription = "-";
|
|
waste.WasteDisposalAmount_MTQ = 0;
|
|
waste.WasteCapacity_MTQ = 0;
|
|
waste.WasteAmountRetained_MTQ = 0;
|
|
waste.WasteDisposalPort = "ZZUKN";
|
|
waste.WasteAmountGeneratedTillNextPort_MTQ = 0;
|
|
}
|
|
*/
|
|
|
|
if(i==15) // falls letzte Zeile leer, entfernen: Christin 22.3.17
|
|
{
|
|
if ((waste.WasteDescription.IsNullOrEmpty() || waste.WasteDescription == "-") &&
|
|
((waste.WasteDisposalAmount_MTQ ?? 0) == 0) &&
|
|
(((waste.WasteType ?? 0) == 1300) || !waste.WasteType.HasValue))
|
|
was.Waste.Remove(waste);
|
|
|
|
// 24.3.: - Für Waste-Type 15: Wenn in dieser Zeile andere Werte enthalten, als die nachfolgenden, ist die ganze Zeile rot zu markieren.
|
|
bool highlightRow15 = waste.WasteType != null;
|
|
highlightRow15 &= (waste.WasteDisposalAmount_MTQ > 0);
|
|
highlightRow15 &= (waste.WasteCapacity_MTQ > 0);
|
|
highlightRow15 &= (waste.WasteAmountRetained_MTQ > 0);
|
|
highlightRow15 &= (waste.WasteDisposalPort != "ZZUKN");
|
|
highlightRow15 &= (waste.WasteAmountGeneratedTillNextPort_MTQ > 0);
|
|
highlightRow15 &= (waste.WasteDisposedAtLastPort_MTQ > 0);
|
|
|
|
if(highlightRow15)
|
|
{
|
|
reader.Conf.HighlightCellWithState(wastetype, ExcelReader.ReadState.FAIL);
|
|
reader.Conf.HighlightCellWithState(wasteCode, ExcelReader.ReadState.FAIL);
|
|
reader.Conf.HighlightCellWithState(wasteDescription, ExcelReader.ReadState.FAIL);
|
|
reader.Conf.HighlightCellWithState(wasteAmount, ExcelReader.ReadState.FAIL);
|
|
reader.Conf.HighlightCellWithState(wasteCapacity, ExcelReader.ReadState.FAIL);
|
|
reader.Conf.HighlightCellWithState(wasteRetained, ExcelReader.ReadState.FAIL);
|
|
reader.Conf.HighlightCellWithState(wastePort, ExcelReader.ReadState.FAIL);
|
|
reader.Conf.HighlightCellWithState(amountGen, ExcelReader.ReadState.FAIL);
|
|
reader.Conf.HighlightCellWithState(wasteDis, ExcelReader.ReadState.FAIL);
|
|
}
|
|
}
|
|
|
|
if (!waste.WasteType.HasValue)
|
|
{
|
|
was.Waste.Remove(waste);
|
|
}
|
|
}
|
|
|
|
was.AddMissingWaste();
|
|
|
|
}
|
|
#endregion
|
|
|
|
#region MDH
|
|
|
|
private static bool ScanMDH(Message mdhMessage, List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
if(mdhMessage.Elements.Count == 0)
|
|
{
|
|
MDH newMDH = new MDH();
|
|
newMDH.MessageHeader = mdhMessage;
|
|
mdhMessage.Elements.Add(newMDH);
|
|
}
|
|
MDH mdh = mdhMessage.Elements[0] as MDH;
|
|
mdh.DeleteElements();
|
|
ExcelUtil.ScanMessage(mdh, reader);
|
|
|
|
// lt. Mail von Christin am 28.9.2016
|
|
mdh.MDHSimplification = false;
|
|
mdh.PortOfCallWhereCompleteMDHNotified = "";
|
|
|
|
|
|
string kuerzelErsteZelle = reader.ReadText("MDH.PortOfCallLast30DaysLocode_1");
|
|
|
|
try
|
|
{
|
|
|
|
#region PoC last 30 days
|
|
|
|
// lt. Mail von Christin am 11.10.2016
|
|
// "SEC" Mode, die Werte aus last10PortFacilitesCalled (SEC) werden übernommen
|
|
// das funktioniert, da SEC vor MDH gelesen wird
|
|
if (!kuerzelErsteZelle.IsNullOrEmpty() && kuerzelErsteZelle.Equals("sec", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
Message secMessage = ExcelUtil.GetMessageWithType(messages, messageCore, Message.NotificationClass.SEC);
|
|
if (secMessage.Elements.Count > 0)
|
|
{
|
|
SEC sec = secMessage.Elements[0] as SEC;
|
|
int i = 1;
|
|
foreach (LastTenPortFacilitiesCalled ltpfc in sec.LastTenPortFacilitesCalled)
|
|
{
|
|
if (!(mdh.GetSublistElementWithIdentifier((i + 1).ToString()) is PortOfCallLast30Days poc30d))
|
|
{
|
|
poc30d = new PortOfCallLast30Days();
|
|
poc30d.Identifier = (i + 1).ToString();
|
|
poc30d.MDH = mdh;
|
|
mdh.PortOfCallLast30Days.Add(poc30d);
|
|
}
|
|
|
|
poc30d.PortOfCallLast30DaysCrewMembersJoined = false;
|
|
poc30d.PortOfCallLast30DaysLocode = ltpfc.PortFacilityPortLoCode;
|
|
poc30d.PortOfCallLast30DaysDateOfDeparture = ltpfc.PortFacilityDateOfDeparture;
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
else // "normal mode", aus den Zellen lesen
|
|
{
|
|
|
|
// POC last 30 days
|
|
for (int i = 0; i < mdh.NumberOfExcelRows; 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);
|
|
|
|
if (!(mdh.GetSublistElementWithIdentifier((i + 1).ToString()) is PortOfCallLast30Days poc30d))
|
|
{
|
|
poc30d = new PortOfCallLast30Days();
|
|
poc30d.Identifier = (i + 1).ToString();
|
|
poc30d.MDH = mdh;
|
|
mdh.PortOfCallLast30Days.Add(poc30d);
|
|
}
|
|
|
|
string pName = reader.ReadText(portName);
|
|
string pCountry = reader.ReadText(portCountry);
|
|
|
|
poc30d.PortOfCallLast30DaysDateOfDeparture = reader.ReadDate(depDate);
|
|
poc30d.PortOfCallLast30DaysLocode = reader.ReadLoCode(locode);
|
|
|
|
// Verbesserungsvorschlag Jul/21: CrewMembersJoined Häkchen abhängig von den Namen in der Spalte
|
|
bool? PortOfCallLast30DaysCrewMembersJoinedFlag = reader.ReadBoolean(crewJoined);
|
|
|
|
string crewNameString = reader.ReadText(crewName);
|
|
if (!crewNameString.IsNullOrEmpty())
|
|
poc30d.PortOfCallLast30DaysCrewMembersJoined = true;
|
|
else
|
|
poc30d.PortOfCallLast30DaysCrewMembersJoined = false;
|
|
|
|
if (poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false)
|
|
{
|
|
// try different separators
|
|
string[] crew = crewNameString.Split(';');
|
|
if (crew.Length == 1)
|
|
crew = crewNameString.Split(',');
|
|
ExcelReader.ReadState readState = ExcelReader.ReadState.OK;
|
|
for (int j = 0; j < crew.Length; j++)
|
|
{
|
|
if (!(poc30d.GetSublistElementWithIdentifier((j + 1).ToString()) is PortOfCallLast30DaysCrewJoinedShip poc30dCrew))
|
|
{
|
|
poc30dCrew = new PortOfCallLast30DaysCrewJoinedShip();
|
|
poc30dCrew.Identifier = (j + 1).ToString();
|
|
poc30dCrew.PortOfCallLast30Days = poc30d;
|
|
poc30d.CrewJoinedShip.Add(poc30dCrew);
|
|
}
|
|
|
|
poc30dCrew.PortOfCallLast30DaysCrewJoinedShipName = crew[j];
|
|
if (crew[j].Length > 90)
|
|
readState = ExcelReader.ReadState.FAIL;
|
|
}
|
|
}
|
|
|
|
// Leer/def. Zeilen entfernen
|
|
if (!poc30d.PortOfCallLast30DaysDateOfDeparture.HasValue && (poc30d.PortOfCallLast30DaysLocode == null))
|
|
mdh.PortOfCallLast30Days.Remove(poc30d);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region SanitaryMeasures
|
|
|
|
if (mdh.SanitaryMeasuresApplied ?? false)
|
|
{
|
|
for (int i = 1; i <= 3; i++)
|
|
{
|
|
string smType = string.Format("MDH.SanitaryMeasuresType_{0}", i);
|
|
string smLocation = string.Format("MDH.SanitaryMeasuresLocation_{0}", i);
|
|
string smDate = string.Format("MDH.SanitaryMeasuresDate_{0}", i);
|
|
|
|
SanitaryMeasuresDetail smd = mdh.GetSanitaryMeasuresDetailWithIdentifier(i.ToString());
|
|
if(smd == null)
|
|
{
|
|
smd = new SanitaryMeasuresDetail();
|
|
smd.Identifier = i.ToString();
|
|
mdh.SanitaryMeasuresDetails.Add(smd);
|
|
smd.MDH = mdh;
|
|
}
|
|
|
|
smd.SanitaryMeasuresType = reader.ReadText(smType);
|
|
smd.SanitaryMeasuresLocation = reader.ReadText(smLocation);
|
|
smd.SanitaryMeasuresDate = reader.ReadDate(smDate);
|
|
// dont save completely empty structs
|
|
if (!smd.SanitaryMeasuresDate.HasValue && smd.SanitaryMeasuresLocation.IsNullOrEmpty() && smd.SanitaryMeasuresType.IsNullOrEmpty())
|
|
mdh.SanitaryMeasuresDetails.Remove(smd);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region InfectedArea
|
|
|
|
if (mdh.InfectedAreaVisited ?? false)
|
|
{
|
|
for (int i = 1; i <= 3; i++)
|
|
{
|
|
string iaPort = string.Format("MDH.InfectedAreaPort_{0}", i);
|
|
string iaDate = string.Format("MDH.InfectedAreaDate_{0}", i);
|
|
InfectedArea ia = mdh.GetInfectedAreaWithIdentifier(i.ToString());
|
|
if (ia == null)
|
|
{
|
|
ia = new InfectedArea();
|
|
ia.Identifier = i.ToString();
|
|
mdh.InfectedAreas.Add(ia);
|
|
ia.MDH = mdh;
|
|
}
|
|
|
|
ia.InfectedAreaPort = reader.ReadText(iaPort);
|
|
ia.InfectedAreaDate = reader.ReadDate(iaDate);
|
|
// dont save completely empty structs
|
|
if (!ia.InfectedAreaDate.HasValue && ia.InfectedAreaPort.IsNullOrEmpty())
|
|
mdh.InfectedAreas.Remove(ia);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region StowawaysJoiningLocation
|
|
|
|
if(mdh.StowawaysDetected ?? false)
|
|
{
|
|
for (int i = 1; i <= 3; i++)
|
|
{
|
|
string sjlLookup = string.Format("MDH.StowawaysJoiningLocation_{0}", i);
|
|
StowawaysJoiningLocation sjl = mdh.GetStowawaysJoiningLocationWithIdentifier(i.ToString());
|
|
if (sjl == null)
|
|
{
|
|
sjl = new StowawaysJoiningLocation();
|
|
sjl.Identifier = i.ToString();
|
|
sjl.MDH = mdh;
|
|
mdh.StowawaysJoiningLocations.Add(sjl);
|
|
}
|
|
|
|
sjl.StowawayJoiningLocation = reader.ReadText(sjlLookup);
|
|
if (sjl.StowawayJoiningLocation.IsNullOrEmpty())
|
|
{
|
|
mdh.StowawaysJoiningLocations.Remove(sjl);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
catch(Exception ex)
|
|
{
|
|
_log.ErrorFormat("Crash during reading of MDH message: {0}", ex);
|
|
return false;
|
|
}
|
|
|
|
// wird nicht wieder entfernt falls keine Daten vorliegen
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region SEC
|
|
|
|
private static void ScanSEC(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message secMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.SEC);
|
|
if (secMessage.Elements.Count == 0)
|
|
{
|
|
SEC newSEC = new SEC();
|
|
newSEC.MessageHeader = secMessage;
|
|
secMessage.Elements.Add(newSEC);
|
|
}
|
|
SEC sec = secMessage.Elements[0] as SEC;
|
|
Util.ScanMessage(sec, reader);
|
|
|
|
reader.ReadBoolean("SEC.AreMatterToReport"); // das berücksichtigen wir derzeit nicht in der DB (implizit)
|
|
|
|
string isscType = reader.ReadText("SEC.ISSCType");
|
|
if(isscType != null)
|
|
{
|
|
if (isscType.Equals("full", StringComparison.OrdinalIgnoreCase) || isscType.Equals("1"))
|
|
sec.ISSCType = 0;
|
|
if (isscType.Equals("interim", StringComparison.OrdinalIgnoreCase) || isscType.Equals("2"))
|
|
sec.ISSCType = 1;
|
|
}
|
|
|
|
string shipsecLevel = reader.ReadText("SEC.CurrentShipSecurityLevel");
|
|
if (shipsecLevel.IsNullOrEmpty())
|
|
{
|
|
reader.Conf.ConfirmText("SEC.CurrentShipSecurityLevel", null, ExcelReader.ReadState.FAIL);
|
|
}
|
|
else
|
|
{
|
|
if (shipsecLevel.Contains('1')) sec.CurrentShipSecurityLevel = 1;
|
|
if (shipsecLevel.Contains('2')) sec.CurrentShipSecurityLevel = 2;
|
|
if (shipsecLevel.Contains('3')) sec.CurrentShipSecurityLevel = 3;
|
|
reader.Conf.ConfirmText("SEC.CurrentShipSecurityLevel", shipsecLevel, sec.CurrentShipSecurityLevel.HasValue ? ExcelReader.ReadState.OK : ExcelReader.ReadState.WARN);
|
|
}
|
|
|
|
reader.Conf.ConfirmText("SEC.ISSCType", isscType, sec.ISSCType.HasValue ? ExcelReader.ReadState.OK : ExcelReader.ReadState.FAIL);
|
|
|
|
string isscIssuerType = reader.ReadText("SEC.ISSCIssuerType");
|
|
if(isscIssuerType != null)
|
|
{
|
|
if (isscIssuerType.Equals("rso", StringComparison.OrdinalIgnoreCase) || isscIssuerType.Equals("2"))
|
|
sec.ISSCIssuerType = 1;
|
|
if (isscIssuerType.Contains("admin", StringComparison.OrdinalIgnoreCase) || isscIssuerType.Equals("1"))
|
|
sec.ISSCIssuerType = 0;
|
|
}
|
|
|
|
reader.Conf.ConfirmText("SEC.ISSCIssuerType", isscIssuerType, sec.ISSCIssuerType.HasValue ? ExcelReader.ReadState.OK : ExcelReader.ReadState.FAIL);
|
|
sec.GeneralDescriptionOfCargo = reader.ReadGeneralDescriptionOfCargo("SEC.GeneralDescriptionOfCargo");
|
|
|
|
bool? secKielArrival = reader.ReadBoolean("SEC.KielCanalPassagePlanned_Arrival");
|
|
bool? secKielDeparture = reader.ReadBoolean("SEC.KielCanalPassagePlanned_Departure");
|
|
|
|
// Leichter Umbau ("Verbesserung") der Logik Jul 21: Wenn ETA Werte drin stehen und das Flag nicht gesetzt ist
|
|
// wird es gesetzt sonst nicht gesetzt
|
|
sec.KielCanalPassagePlanned = (secKielArrival ?? false) || (secKielDeparture ?? false);
|
|
// if (sec.KielCanalPassagePlanned ?? false)
|
|
// {
|
|
sec.KielCanalPassagePlannedIncomming = reader.ReadDateTime("SEC.ETADateKielCanalPassagePlannedIncomming", "SEC.ETATimeKielCanalPassagePlannedIncomming", !(secKielArrival ?? false));
|
|
sec.KielCanalPassagePlannedOutgoing = reader.ReadDateTime("SEC.ETADateKielCanalPassagePlannedOutgoing", "SEC.ETATimeKielCanalPassagePlannedOutgoing", !(secKielDeparture ?? false));
|
|
// }
|
|
|
|
if ((!sec.KielCanalPassagePlanned ?? false) && sec.KielCanalPassagePlannedIncomming.HasValue) sec.KielCanalPassagePlanned = true;
|
|
if ((!sec.KielCanalPassagePlanned ?? false) && sec.KielCanalPassagePlannedOutgoing.HasValue) sec.KielCanalPassagePlanned = true;
|
|
|
|
if (!sec.KielCanalPassagePlannedIncomming.HasValue && !sec.KielCanalPassagePlannedOutgoing.HasValue)
|
|
sec.KielCanalPassagePlanned = false;
|
|
|
|
|
|
|
|
|
|
// Last10PortFacilitesCalled
|
|
for (int i = 1; i <= 10; i++)
|
|
{
|
|
string portName = string.Format("SEC.PortFacilityPortName_{0}", i);
|
|
string portCountry = string.Format("SEC.PortFacilityPortCountry_{0}", i);
|
|
string portLocode = string.Format("SEC.PortFacilityPortLoCode_{0}", i);
|
|
string portDateOfArrival = string.Format("SEC.PortFacilityDateOfArrival_{0}", i);
|
|
string portDateOfDeparture = string.Format("SEC.PortFacilityDateOfDeparture_{0}", i);
|
|
string portShipSecLevel = string.Format("SEC.PortFacilityShipSecurityLevel_{0}", i);
|
|
string portGISISCode = string.Format("SEC.PortFacilityGISISCode_{0}", i);
|
|
string portSecMatters = string.Format("SEC.PortFacilitySecurityMattersToReport_{0}", i);
|
|
|
|
if (!(sec.GetPortFacilityWithIdentifier(i.ToString()) is LastTenPortFacilitiesCalled l10fc))
|
|
{
|
|
l10fc = new LastTenPortFacilitiesCalled();
|
|
l10fc.Identifier = i.ToString();
|
|
l10fc.SEC = sec;
|
|
sec.LastTenPortFacilitesCalled.Add(l10fc);
|
|
}
|
|
|
|
l10fc.PortFacilityPortName = reader.ReadText(portName);
|
|
reader.Conf.ConfirmText(portName, l10fc.PortFacilityPortName, ExcelReader.ReadState.OK);
|
|
l10fc.PortFacilityPortCountry = reader.ReadText(portCountry);
|
|
reader.Conf.ConfirmText(portCountry, l10fc.PortFacilityPortCountry, ExcelReader.ReadState.OK);
|
|
l10fc.PortFacilityPortLoCode = reader.ReadLoCode(portLocode);
|
|
l10fc.PortFacilityDateOfArrival = reader.ReadDate(portDateOfArrival);
|
|
l10fc.PortFacilityDateOfDeparture = reader.ReadDate(portDateOfDeparture);
|
|
|
|
string sLevel = reader.ReadText(portShipSecLevel);
|
|
if(sLevel.IsNullOrEmpty())
|
|
{
|
|
reader.Conf.ConfirmText(portShipSecLevel, null, ExcelReader.ReadState.FAIL);
|
|
}
|
|
else
|
|
{
|
|
if (sLevel.Contains('1')) l10fc.PortFacilityShipSecurityLevel = 1;
|
|
if (sLevel.Contains('2')) l10fc.PortFacilityShipSecurityLevel = 2;
|
|
if (sLevel.Contains('3')) l10fc.PortFacilityShipSecurityLevel = 3;
|
|
reader.Conf.ConfirmText(portShipSecLevel, sLevel, l10fc.PortFacilityShipSecurityLevel.HasValue ? ExcelReader.ReadState.OK : ExcelReader.ReadState.WARN);
|
|
}
|
|
|
|
l10fc.PortFacilityGISISCode = reader.ReadTextNoWhitespace(portGISISCode);
|
|
|
|
if (l10fc.PortFacilityGISISCode.IsNullOrEmpty() || l10fc.PortFacilityGISISCode == "0")
|
|
l10fc.PortFacilityGISISCode = "0000";
|
|
if(l10fc.PortFacilityGISISCode?.Length < 4)
|
|
{
|
|
while (l10fc.PortFacilityGISISCode.Length < 4) l10fc.PortFacilityGISISCode = "0" + l10fc.PortFacilityGISISCode;
|
|
}
|
|
if (l10fc.PortFacilityGISISCode.IsNullOrEmpty())
|
|
{
|
|
reader.Conf.ConfirmText(portGISISCode, l10fc.PortFacilityGISISCode, ExcelReader.ReadState.FAIL);
|
|
}
|
|
else
|
|
{
|
|
reader.Conf.ConfirmText(portGISISCode, l10fc.PortFacilityGISISCode, l10fc.PortFacilityGISISCode.IsDigitsOnly() ? ExcelReader.ReadState.OK : ExcelReader.ReadState.WARN);
|
|
}
|
|
|
|
l10fc.PortFacilitySecurityMattersToReport = reader.ReadText(portSecMatters);
|
|
reader.Conf.ConfirmText(portSecMatters, l10fc.PortFacilitySecurityMattersToReport, l10fc.PortFacilitySecurityMattersToReport.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL :ExcelReader.ReadState.OK);
|
|
|
|
// keinen "leeren" Hafen anlegen, wenn der Eintrag leer war (trifft anscheinend bei Neubauten zu, siehe E-Mail Christin vom 20./22.6.17
|
|
if (l10fc.PortFacilityPortName.IsNullOrEmpty() && l10fc.PortFacilityPortLoCode.IsNullOrEmpty() && l10fc.PortFacilityPortCountry.IsNullOrEmpty())
|
|
sec.LastTenPortFacilitesCalled.Remove(l10fc);
|
|
|
|
}
|
|
|
|
// Ship2ShipActivities
|
|
for (int i = 1; i <= 10; i++)
|
|
{
|
|
string s2sName = string.Format("SEC.ShipToShipActivityLocationName_{0}", i);
|
|
string s2sLocode = string.Format("SEC.ShipToShipActivityLocationLoCode_{0}", i);
|
|
string s2sLatitude = string.Format("SEC.ShipToShipActivityLocationCoordinatesLatitude_{0}", i);
|
|
string s2sLongitude = string.Format("SEC.ShipToShipActivityLocationCoordinatesLongitude_{0}", i);
|
|
string s2sFromDate = string.Format("SEC.ShipToShipActivityDateFrom_{0}", i);
|
|
string s2sToDate = string.Format("SEC.ShipToShipActivityDateTo_{0}", i);
|
|
string s2sSec = string.Format("SEC.ShipToShipActivitySecurityMattersToReport_{0}", i);
|
|
string s2sActivityString = string.Format("SEC.ShipToShipActivityType_{0}", i);
|
|
|
|
|
|
if (!(sec.GetShipToShipWithIdentifier(i.ToString()) is ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2sActivity))
|
|
{
|
|
s2sActivity = new ShipToShipActivitiesDuringLastTenPortFacilitiesCalled();
|
|
s2sActivity.Identifier = i.ToString();
|
|
s2sActivity.SEC = sec;
|
|
sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Add(s2sActivity);
|
|
}
|
|
|
|
s2sActivity.ShipToShipActivityLocationName = reader.ReadText(s2sName);
|
|
if (s2sActivity.ShipToShipActivityLocationName.IsNullOrEmpty())
|
|
{
|
|
sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Remove(s2sActivity);
|
|
continue;
|
|
}
|
|
reader.Conf.ConfirmText(s2sName, s2sActivity.ShipToShipActivityLocationName, ExcelReader.ReadState.OK);
|
|
|
|
s2sActivity.ShipToShipActivityLocationLoCode = reader.ReadLoCode(s2sLocode);
|
|
s2sActivity.ShipToShipActivityLocationCoordinatesLatitude = (int?)reader.ReadNumber(s2sLatitude);
|
|
// keine "0" (d.h. fehlerhafte Koordinaten) ins ANSW übergeben falls im Sheet nichts ist aber der Reader das aus irgendeinem Grund liest
|
|
if (s2sActivity.ShipToShipActivityLocationCoordinatesLatitude.HasValue && s2sActivity.ShipToShipActivityLocationCoordinatesLatitude.Value == 0)
|
|
s2sActivity.ShipToShipActivityLocationCoordinatesLatitude = null;
|
|
s2sActivity.ShipToShipActivityLocationCoordinatesLongitude = (int?)reader.ReadNumber(s2sLongitude);
|
|
if (s2sActivity.ShipToShipActivityLocationCoordinatesLongitude.HasValue && s2sActivity.ShipToShipActivityLocationCoordinatesLongitude.Value == 0)
|
|
s2sActivity.ShipToShipActivityLocationCoordinatesLongitude = null;
|
|
s2sActivity.ShipToShipActivityDateFrom = reader.ReadDate(s2sFromDate);
|
|
s2sActivity.ShipToShipActivityDateTo = reader.ReadDate(s2sToDate);
|
|
s2sActivity.ShipToShipActivityTypeCode = (int?) reader.ReadNumber(s2sActivityString);
|
|
reader.ReadShip2ShipActivityType(s2sActivityString); // 24.8.21 nicht Code dem Klartext zuordnen, nur das Feld kolorieren
|
|
s2sActivity.ShipToShipActivitySecurityMattersToReport = reader.ReadText(s2sSec);
|
|
reader.Conf.ConfirmText(s2sSec, s2sActivity.ShipToShipActivitySecurityMattersToReport, s2sActivity.ShipToShipActivitySecurityMattersToReport.IsNullOrEmpty() ? ExcelReader.ReadState.NONE : ExcelReader.ReadState.OK);
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region BKRA
|
|
|
|
private static bool ScanBKRA(Message bkraMessage, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
bkraMessage.DeleteElements();
|
|
for (int i = 1; i <= bkraMessage.NumberOfExcelRows; i++)
|
|
{
|
|
string lnQuantity = string.Format("BKRA.BunkerFuelQuantity_TNE_{0}", i);
|
|
string lnType = string.Format("BKRA.BunkerFuelType_{0}", i);
|
|
|
|
if (!(bkraMessage.GetSublistElementWithIdentifier((i).ToString()) is BRKA bkra))
|
|
{
|
|
bkra = new BRKA();
|
|
bkra.Identifier = (i).ToString();
|
|
bkra.MessageHeader = bkraMessage;
|
|
bkraMessage.Elements.Add(bkra);
|
|
}
|
|
|
|
bkra.BunkerFuelQuantity_TNE = reader.ReadNumber(lnQuantity);
|
|
bkra.BunkerFuelType = reader.ReadText(lnType);
|
|
|
|
// dont save empty element
|
|
if (bkra.IsNew && !bkra.BunkerFuelQuantity_TNE.HasValue && bkra.BunkerFuelType.IsNullOrEmpty())
|
|
bkraMessage.Elements.Remove(bkra);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region BKRD
|
|
|
|
private static bool ScanBKRD(Message bkrdMessage, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
bkrdMessage.DeleteElements();
|
|
for (int i = 1; i <= bkrdMessage.NumberOfExcelRows; i++)
|
|
{
|
|
string lnQuantity = string.Format("BKRD.BunkerFuelQuantity_TNE_{0}", i);
|
|
string lnType = string.Format("BKRD.BunkerFuelType_{0}", i);
|
|
if (!(bkrdMessage.GetSublistElementWithIdentifier((i).ToString()) is BRKD bkrd))
|
|
{
|
|
bkrd = new BRKD();
|
|
bkrd.Identifier = (i).ToString();
|
|
bkrd.MessageHeader = bkrdMessage;
|
|
bkrdMessage.Elements.Add(bkrd);
|
|
}
|
|
|
|
bkrd.BunkerFuelQuantity_TNE = reader.ReadNumber(lnQuantity);
|
|
bkrd.BunkerFuelType = reader.ReadText(lnType);
|
|
|
|
// dont save empty element
|
|
if (bkrd.IsNew && !bkrd.BunkerFuelQuantity_TNE.HasValue && bkrd.BunkerFuelType.IsNullOrEmpty())
|
|
bkrdMessage.Elements.Remove(bkrd);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region TOWA
|
|
|
|
private static void ScanTOWA(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message towaMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.TOWA);
|
|
|
|
// 24.4.21: TOWA beim Excel import
|
|
bool hasTOWAMarker = false;
|
|
for (int i = 1; i <= towaMessage.NumberOfExcelRows; i++)
|
|
{
|
|
string tName = string.Format("TOWA.TowageOnArrivalName_{0}", i);
|
|
string towageName = reader.ReadText(tName);
|
|
if (!towageName.IsNullOrEmpty())
|
|
{
|
|
hasTOWAMarker = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!hasTOWAMarker) return; // no TOWA info on sheet
|
|
|
|
towaMessage.DeleteElements();
|
|
for (int i = 1; i <= towaMessage.NumberOfExcelRows; i++)
|
|
{
|
|
string tName = string.Format("TOWA.TowageOnArrivalName_{0}", i);
|
|
string tFlag = string.Format("TOWA.TowageOnArrivalFlag_{0}", i);
|
|
string tPoC = string.Format("TOWA.TowageOnArrivalPurposeOfCall_{0}", i);
|
|
string tDraft = string.Format("TOWA.TowageOnArrivalDraught_DMT_{0}", i);
|
|
string tGT = string.Format("TOWA.TowageOnArrivalGrossTonnage_{0}", i);
|
|
string tLen = string.Format("TOWA.TowageOnArrivalLengthOverall_MTR_{0}", i);
|
|
string tBeam = string.Format("TOWA.TowageOnArrivalBeam_MTR_{0}", i);
|
|
string tOp = string.Format("TOWA.TowageOnArrivalOperatorCompanyName_{0}", i);
|
|
|
|
string towageName = reader.ReadText(tName);
|
|
if (towageName.IsNullOrEmpty()) continue;
|
|
|
|
if (!(towaMessage.GetSublistElementWithIdentifier((i).ToString()) is TOWA towa))
|
|
{
|
|
towa = new TOWA();
|
|
towa.Identifier = (i).ToString();
|
|
towa.MessageHeader = towaMessage;
|
|
towaMessage.Elements.Add(towa);
|
|
}
|
|
|
|
towa.TowageOnArrivalName = towageName;
|
|
reader.Conf.ConfirmText(tName, towageName, ExcelReader.ReadState.OK);
|
|
towa.TowageOnArrivalFlag = reader.ReadText(tFlag);
|
|
reader.Conf.ConfirmText(tFlag, towa.TowageOnArrivalFlag, towa.TowageOnArrivalFlag.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
|
|
towa.TowageOnArrivalPurposeOfCall = reader.ReadText(tPoC);
|
|
reader.Conf.ConfirmText(tPoC, towa.TowageOnArrivalPurposeOfCall, towa.TowageOnArrivalPurposeOfCall.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
|
|
towa.TowageOnArrivalDraught_DMT = reader.ReadNumber(tDraft);
|
|
towa.TowageOnArrivalGrossTonnage = (int?) reader.ReadNumber(tGT);
|
|
towa.TowageOnArrivalLengthOverall_MTR = reader.ReadNumber(tLen);
|
|
towa.TowageOnArrivalBeam_MTR = reader.ReadNumber(tBeam);
|
|
towa.TowageOnArrivalOperatorCompanyName = reader.ReadText(tOp);
|
|
reader.Conf.ConfirmText(tOp, towa.TowageOnArrivalOperatorCompanyName, towa.TowageOnArrivalOperatorCompanyName.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region TOWD
|
|
|
|
private static void ScanTOWD(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message towdMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.TOWD);
|
|
|
|
// 24.4.21: TOWD beim Excel import
|
|
bool hasTOWDMarker = false;
|
|
for (int i = 1; i <= towdMessage.NumberOfExcelRows; i++)
|
|
{
|
|
string tName = string.Format("TOWD.TowageOnDepartureName_{0}", i);
|
|
string towageName = reader.ReadText(tName);
|
|
if (!towageName.IsNullOrEmpty())
|
|
{
|
|
hasTOWDMarker = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!hasTOWDMarker) return; // no TOWD info on sheet
|
|
|
|
towdMessage.DeleteElements();
|
|
|
|
for (int i = 1; i <= towdMessage.NumberOfExcelRows; i++)
|
|
{
|
|
string tName = string.Format("TOWD.TowageOnDepartureName_{0}", i);
|
|
string tFlag = string.Format("TOWD.TowageOnDepartureFlag_{0}", i);
|
|
string tDraft = string.Format("TOWD.TowageOnDepartureDraught_DMT_{0}", i);
|
|
string tLen = string.Format("TOWD.TowageOnDepartureLengthOverall_MTR_{0}", i);
|
|
string tBeam = string.Format("TOWD.TowageOnDepartureBeam_MTR_{0}", i);
|
|
string tOp = string.Format("TOWD.TowageOnDepartureOperatorCompanyName_{0}", i);
|
|
|
|
string towageName = reader.ReadText(tName);
|
|
if (towageName.IsNullOrEmpty()) continue;
|
|
|
|
if (!(towdMessage.GetSublistElementWithIdentifier((i).ToString()) is TOWD towd))
|
|
{
|
|
towd = new TOWD();
|
|
towd.Identifier = (i).ToString();
|
|
towd.MessageHeader = towdMessage;
|
|
towdMessage.Elements.Add(towd);
|
|
}
|
|
|
|
towd.TowageOnDepartureName = towageName;
|
|
reader.Conf.ConfirmText(tName, towageName, ExcelReader.ReadState.OK);
|
|
towd.TowageOnDepartureFlag = reader.ReadText(tFlag);
|
|
reader.Conf.ConfirmText(tFlag, towd.TowageOnDepartureFlag, towd.TowageOnDepartureFlag.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
|
|
towd.TowageOnDepartureDraught_DMT = reader.ReadNumber(tDraft);
|
|
towd.TowageOnDepartureLengthOverall_MTR = reader.ReadNumber(tLen);
|
|
towd.TowageOnDepartureBeam_MTR = reader.ReadNumber(tBeam);
|
|
towd.TowageOnDepartureOperatorCompanyName = reader.ReadText(tOp);
|
|
reader.Conf.ConfirmText(tOp, towd.TowageOnDepartureOperatorCompanyName, towd.TowageOnDepartureOperatorCompanyName.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region PRE72H
|
|
|
|
private static void ScanPRE72H(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message pre72hMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.PRE72H);
|
|
if (pre72hMessage.Elements.Count == 0)
|
|
{
|
|
PRE72H newPRE72H = new PRE72H();
|
|
newPRE72H.MessageHeader = pre72hMessage;
|
|
pre72hMessage.Elements.Add(newPRE72H);
|
|
}
|
|
PRE72H pre72h = pre72hMessage.Elements[0] as PRE72H;
|
|
Util.ScanMessage(pre72h, reader);
|
|
// diese Nachricht bleibt auch wenn sie leer ist
|
|
pre72h.ConditionCargoBallastTanks = reader.ReadConditionTanks("PRE72H.ConditionCargoBallastTanks");
|
|
pre72h.TankerHullConfiguration = reader.ReadHullConfiguration("PRE72H.TankerHullConfiguration");
|
|
pre72h.PlannedWorks = reader.ReadText("PRE72H.PlannedWorks");
|
|
reader.Conf.ConfirmText("PRE72H.PlannedWorks", pre72h.PlannedWorks, pre72h.PlannedWorks.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region SERV
|
|
|
|
private static void ScanSERV(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message servMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.SERV);
|
|
if(servMessage.Elements.Count == 0)
|
|
{
|
|
SERV newSERV = new SERV();
|
|
newSERV.MessageHeader = servMessage;
|
|
newSERV.Identifier = "1";
|
|
servMessage.Elements.Add(newSERV);
|
|
}
|
|
SERV serv = servMessage.Elements[0] as SERV;
|
|
Util.ScanMessage(serv, reader);
|
|
if (serv.ServiceBeneficiary.IsNullOrEmpty() && serv.ServiceInvoiceRecipient.IsNullOrEmpty())
|
|
servMessage.Elements.Remove(serv);
|
|
if (serv.ServiceBeneficiary.IsNullOrEmpty()) reader.Conf.ConfirmText("SERV.ServiceBeneficiary", null, ExcelReader.ReadState.FAIL);
|
|
if (serv.ServiceInvoiceRecipient.IsNullOrEmpty()) reader.Conf.ConfirmText("SERV.ServiceInvoiceRecipient", null, ExcelReader.ReadState.FAIL);
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region STO
|
|
|
|
private static void ScanSTO(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message stoMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.STO);
|
|
stoMessage.DeleteElements();
|
|
|
|
for(int i=0;i<stoMessage.NumberOfExcelRows;i++) // 10
|
|
{
|
|
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);
|
|
|
|
if (!(stoMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is STO sto))
|
|
{
|
|
sto = new STO();
|
|
sto.Identifier = (i + 1).ToString();
|
|
sto.MessageHeader = stoMessage;
|
|
stoMessage.Elements.Add(sto);
|
|
}
|
|
|
|
sto.Name = reader.ReadTextNoWhitespace(stoName);
|
|
reader.Conf.ConfirmText(stoName, sto.Name, ExcelReader.ReadState.OK);
|
|
sto.Quantity = (int?)reader.ReadNumber(stoQuantity);
|
|
sto.QuantityUnit = reader.ReadTextNoWhitespace(stoQuantityUnit);
|
|
reader.Conf.ConfirmText(stoQuantityUnit, sto.QuantityUnit, ExcelReader.ReadState.OK);
|
|
sto.LocationOnBoard = reader.ReadTextNoWhitespace(stoLocationOnBoard);
|
|
reader.Conf.ConfirmText(stoLocationOnBoard, sto.LocationOnBoard, ExcelReader.ReadState.OK);
|
|
sto.OfficialUse = reader.ReadTextNoWhitespace(stoOfficialUse);
|
|
reader.Conf.ConfirmText(stoOfficialUse, sto.OfficialUse, ExcelReader.ReadState.OK);
|
|
|
|
// dont save empty element
|
|
if (sto.IsNew && sto.Name.IsNullOrEmpty())
|
|
stoMessage.Elements.Remove(sto);
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region LADG
|
|
|
|
private static bool ScanLADG(Message ladgMessage, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
ladgMessage.DeleteElements();
|
|
|
|
for (int i = 0; i < ladgMessage.NumberOfExcelRows; 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);
|
|
|
|
if (!(ladgMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is LADG ladg))
|
|
{
|
|
ladg = new LADG();
|
|
ladg.Identifier = (i + 1).ToString();
|
|
ladg.MessageHeader = ladgMessage;
|
|
ladgMessage.Elements.Add(ladg);
|
|
}
|
|
|
|
ladg.CargoHandlingType = reader.ReadCargoHandlingType(lnCHT);
|
|
|
|
// Transit-Ladung für DE nicht übernehmen!
|
|
if ((reader.Mode == ExcelReader.CountryMode.DE) && ((ladg.CargoHandlingType ?? 0) == 2))
|
|
{
|
|
ladgMessage.Elements.Remove(ladg);
|
|
continue;
|
|
}
|
|
|
|
ladg.CargoCodeNST = reader.ReadText(lnType);
|
|
// Cargo Type Freitext in DK
|
|
|
|
if (reader.Mode == ExcelReader.CountryMode.DE)
|
|
{
|
|
if (ladg.CargoCodeNST?.Length == 1)
|
|
ladg.CargoCodeNST = "0" + ladg.CargoCodeNST;
|
|
|
|
if ((ladg.CargoCodeNST != null) && (ladg.CargoCodeNST.Length != 2))
|
|
{
|
|
ladg.CargoCodeNST = null; // stupid validation
|
|
}
|
|
else
|
|
{
|
|
if(Int32.TryParse(ladg.CargoCodeNST, out int ccnst))
|
|
{
|
|
if ((ccnst <= 0) && (ccnst > 20))
|
|
{
|
|
ladg.CargoCodeNST = null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
ladg.CargoCodeNST = null;
|
|
}
|
|
}
|
|
}
|
|
|
|
ladg.CargoLACode = reader.ReadCargoLACode(lnLACode);
|
|
|
|
ladg.CargoCodeNST_3 = reader.ReadText(lnZusatz);
|
|
if (!ladg.CargoCodeNST_3.IsNullOrEmpty())
|
|
{
|
|
if (ladg.CargoCodeNST_3.Length > 8)
|
|
{
|
|
ladg.CargoCodeNST_3 = ladg.CargoCodeNST_3.Substring(0, 8);
|
|
}
|
|
}
|
|
|
|
ladg.CargoNumberOfItems = (int?) reader.ReadNumber(lnCNOI);
|
|
ladg.CargoGrossQuantity_TNE = reader.ReadNumber(lnCGQ);
|
|
ladg.PortOfLoading = reader.ReadLoCode(lnLoad);
|
|
ladg.PortOfDischarge = reader.ReadLoCode(lnDis);
|
|
|
|
// dont save empty element
|
|
if (ladg.IsNew && !ladg.CargoHandlingType.HasValue)
|
|
ladgMessage.Elements.Remove(ladg);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region CREW
|
|
|
|
private static bool ScanCREW(Message crewMessage, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
crewMessage.DeleteElements();
|
|
|
|
for (int i = 0; i < crewMessage.NumberOfExcelRows; i++)
|
|
{
|
|
string crewLastName = string.Format("CREW.CrewMemberLastName_{0}", i + 1);
|
|
string crewFirstName = string.Format("CREW.CrewMemberFirstName_{0}", i + 1);
|
|
string crewGender = string.Format("CREW.CrewMemberGender_{0}", i + 1);
|
|
string crewNationality = string.Format("CREW.CrewMemberNationality_{0}", i + 1);
|
|
string crewDuty = string.Format("CREW.CrewMemberDuty_{0}", i + 1);
|
|
string crewPlaceOfBirth = string.Format("CREW.CrewMemberPlaceOfBirth_{0}", i + 1);
|
|
string crewDateOfBirth = string.Format("CREW.CrewMemberDateOfBirth_{0}", i + 1);
|
|
string crewIdentDocType = string.Format("CREW.CrewMemberIdentityDocumentType_{0}", i + 1);
|
|
string crewIdentDocId = string.Format("CREW.CrewMemberIdentityDocumentId_{0}", i + 1);
|
|
string crewVisaNo = string.Format("CREW.CrewMemberVisaNumber_{0}", i + 1);
|
|
|
|
string lastName = reader.ReadText(crewLastName);
|
|
string firstName = reader.ReadText(crewFirstName);
|
|
|
|
if (!lastName.IsNullOrEmpty() || !firstName.IsNullOrEmpty())
|
|
{
|
|
if (!(crewMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is CREW crew))
|
|
{
|
|
crew = new CREW();
|
|
crew.Identifier = (i + 1).ToString();
|
|
crew.MessageHeader = crewMessage;
|
|
crewMessage.Elements.Add(crew);
|
|
}
|
|
|
|
crew.CrewMemberLastName = lastName;
|
|
crew.CrewMemberFirstName = firstName;
|
|
crew.CrewMemberGender = reader.ReadGender(crewGender);
|
|
crew.CrewMemberDuty = reader.ReadText(crewDuty);
|
|
crew.CrewMemberNationality = reader.ReadNationality(crewNationality);
|
|
crew.CrewMemberPlaceOfBirth = reader.ReadText(crewPlaceOfBirth);
|
|
crew.CrewMemberDateOfBirth = reader.ReadBirthDate(crewDateOfBirth);
|
|
crew.CrewMemberIdentityDocumentType = reader.ReadIdentityDocumentType(crewIdentDocType);
|
|
crew.CrewMemberIdentityDocumentId = reader.ReadText(crewIdentDocId);
|
|
crew.CrewMemberVisaNumber = reader.ReadText(crewVisaNo);
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private static bool ScanCREWD(Message crewdMessage, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
crewdMessage.DeleteElements();
|
|
// CREW DEPARTURE
|
|
|
|
for (int i = 0; i < crewdMessage.NumberOfExcelRows; i++)
|
|
{
|
|
string crewLastName = string.Format("CREWD.CrewMemberLastName_{0}", i + 1);
|
|
string crewFirstName = string.Format("CREWD.CrewMemberFirstName_{0}", i + 1);
|
|
string crewGender = string.Format("CREWD.CrewMemberGender_{0}", i + 1);
|
|
string crewNationality = string.Format("CREWD.CrewMemberNationality_{0}", i + 1);
|
|
string crewDuty = string.Format("CREWD.CrewMemberDuty_{0}", i + 1);
|
|
string crewPlaceOfBirth = string.Format("CREWD.CrewMemberPlaceOfBirth_{0}", i + 1);
|
|
string crewDateOfBirth = string.Format("CREWD.CrewMemberDateOfBirth_{0}", i + 1);
|
|
string crewIdentDocType = string.Format("CREWD.CrewMemberIdentityDocumentType_{0}", i + 1);
|
|
string crewIdentDocId = string.Format("CREWD.CrewMemberIdentityDocumentId_{0}", i + 1);
|
|
string crewVisaNo = string.Format("CREWD.CrewMemberVisaNumber_{0}", i + 1);
|
|
|
|
string lastName = reader.ReadText(crewLastName);
|
|
if (!lastName.IsNullOrEmpty())
|
|
{
|
|
if (!(crewdMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is CREWD crew))
|
|
{
|
|
crew = new CREWD();
|
|
crew.Identifier = (i + 1).ToString();
|
|
crew.MessageHeader = crewdMessage;
|
|
crewdMessage.Elements.Add(crew);
|
|
}
|
|
|
|
crew.IsDeparture = true;
|
|
crew.CrewMemberLastName = lastName;
|
|
crew.CrewMemberFirstName = reader.ReadText(crewFirstName);
|
|
crew.CrewMemberGender = reader.ReadGender(crewGender);
|
|
crew.CrewMemberDuty = reader.ReadText(crewDuty);
|
|
crew.CrewMemberNationality = reader.ReadNationality(crewNationality);
|
|
crew.CrewMemberPlaceOfBirth = reader.ReadText(crewPlaceOfBirth);
|
|
crew.CrewMemberDateOfBirth = reader.ReadBirthDate(crewDateOfBirth);
|
|
crew.CrewMemberIdentityDocumentType = reader.ReadIdentityDocumentType(crewIdentDocType);
|
|
crew.CrewMemberIdentityDocumentId = reader.ReadText(crewIdentDocId);
|
|
crew.CrewMemberVisaNumber = reader.ReadText(crewVisaNo);
|
|
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region PAS
|
|
|
|
private static void ScanPAS(List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
|
{
|
|
Message pasMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.PAS);
|
|
pasMessage.DeleteElements();
|
|
|
|
for (int i = 0; i < pasMessage.NumberOfExcelRows; i++)
|
|
{
|
|
string pasLastName = string.Format("PAS.PassengerLastName_{0}", i + 1);
|
|
string pasFirstName = string.Format("PAS.PassengerFirstName_{0}", i + 1);
|
|
string pasGender = string.Format("PAS.PassengerGender_{0}", i + 1);
|
|
string pasNationality = string.Format("PAS.PassengerNationality_{0}", i + 1);
|
|
string pasEmbarkation = string.Format("PAS.PassengerPortOfEmbarkation_{0}", i + 1);
|
|
string pasDebarkation = string.Format("PAS.PassengerPortOfDisembarkation_{0}", i + 1);
|
|
string pasTransit = string.Format("PAS.PassengerInTransit_{0}", i + 1);
|
|
string pasPlaceOfBirth = string.Format("PAS.PassengerPlaceOfBirth_{0}", i + 1);
|
|
string pasDateOfBirth = string.Format("PAS.PassengerDateOfBirth_{0}", i + 1);
|
|
string pasIdentDocType = string.Format("PAS.PassengerIdentityDocumentType_{0}", i + 1);
|
|
string pasIdentDocId = string.Format("PAS.PassengerIdentityDocumentId_{0}", i + 1);
|
|
string pasVisaNo = string.Format("PAS.PassengerVisaNumber_{0}", i + 1);
|
|
|
|
string lastName = reader.ReadText(pasLastName);
|
|
string firstName = reader.ReadText(pasFirstName);
|
|
|
|
if (!lastName.IsNullOrEmpty() || !firstName.IsNullOrEmpty())
|
|
{
|
|
if (!(pasMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is PAS pas))
|
|
{
|
|
pas = new PAS();
|
|
pas.Identifier = (i + 1).ToString();
|
|
pas.MessageHeader = pasMessage;
|
|
pasMessage.Elements.Add(pas);
|
|
}
|
|
|
|
pas.PassengerLastName = lastName;
|
|
reader.Conf.ConfirmText(pasLastName, lastName, lastName.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
pas.PassengerFirstName = firstName;
|
|
reader.Conf.ConfirmText(pasFirstName, pas.PassengerFirstName, pas.PassengerFirstName.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
pas.PassengerGender = reader.ReadGender(pasGender);
|
|
pas.PassengerNationality = reader.ReadNationality(pasNationality);
|
|
// TODO: Nicht klar ob hier LOCODEs kommen oder nicht
|
|
pas.PassengerPortOfEmbarkation = reader.ReadLoCode(pasEmbarkation);
|
|
reader.Conf.ConfirmText(pasEmbarkation, pas.PassengerPortOfEmbarkation, pas.PassengerPortOfEmbarkation.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
pas.PassengerPortOfDisembarkation = reader.ReadLoCode(pasDebarkation);
|
|
reader.Conf.ConfirmText(pasDebarkation, pas.PassengerPortOfDisembarkation, pas.PassengerPortOfDisembarkation.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
pas.PassengerInTransit = reader.ReadBoolean(pasTransit);
|
|
pas.PassengerPlaceOfBirth = reader.ReadText(pasPlaceOfBirth);
|
|
reader.Conf.ConfirmText(pasPlaceOfBirth, pas.PassengerPlaceOfBirth, pas.PassengerPlaceOfBirth.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL: ExcelReader.ReadState.OK);
|
|
pas.PassengerDateOfBirth = reader.ReadBirthDate(pasDateOfBirth);
|
|
pas.PassengerIdentityDocumentType = reader.ReadIdentityDocumentType(pasIdentDocType);
|
|
pas.PassengerIdentityDocumentId = reader.ReadText(pasIdentDocId);
|
|
reader.Conf.ConfirmText(pasIdentDocId, pas.PassengerIdentityDocumentId, pas.PassengerIdentityDocumentId.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
pas.PassengerVisaNumber = reader.ReadText(pasVisaNo);
|
|
reader.Conf.ConfirmText(pasVisaNo, pas.PassengerVisaNumber, pas.PassengerVisaNumber.IsNullOrEmpty() ? ExcelReader.ReadState.WARN :ExcelReader.ReadState.OK);
|
|
}
|
|
}
|
|
|
|
// PASSENGER DEPARTURE
|
|
pasMessage = Util.GetMessageWithType(messages, messageCore, Message.NotificationClass.PASD);
|
|
for (int i = 0; i < pasMessage.NumberOfExcelRows; i++)
|
|
{
|
|
string pasLastName = string.Format("PASD.PassengerLastName_{0}", i + 1);
|
|
string pasFirstName = string.Format("PASD.PassengerFirstName_{0}", i + 1);
|
|
string pasGender = string.Format("PASD.PassengerGender_{0}", i + 1);
|
|
string pasNationality = string.Format("PASD.PassengerNationality_{0}", i + 1);
|
|
string pasEmbarkation = string.Format("PASD.PassengerPortOfEmbarkation_{0}", i + 1);
|
|
string pasDebarkation = string.Format("PASD.PassengerPortOfDisembarkation_{0}", i + 1);
|
|
string pasTransit = string.Format("PASD.PassengerInTransit_{0}", i + 1);
|
|
string pasPlaceOfBirth = string.Format("PASD.PassengerPlaceOfBirth_{0}", i + 1);
|
|
string pasDateOfBirth = string.Format("PASD.PassengerDateOfBirth_{0}", i + 1);
|
|
string pasIdentDocType = string.Format("PASD.PassengerIdentityDocumentType_{0}", i + 1);
|
|
string pasIdentDocId = string.Format("PASD.PassengerIdentityDocumentId_{0}", i + 1);
|
|
string pasVisaNo = string.Format("PASD.PassengerVisaNumber_{0}", i + 1);
|
|
|
|
string lastName = reader.ReadText(pasLastName);
|
|
if (!lastName.IsNullOrEmpty())
|
|
{
|
|
if (!(pasMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is PASD pas))
|
|
{
|
|
pas = new PASD();
|
|
pas.Identifier = (i + 1).ToString();
|
|
pas.MessageHeader = pasMessage;
|
|
pasMessage.Elements.Add(pas);
|
|
}
|
|
|
|
pas.IsDeparture = true;
|
|
|
|
pas.PassengerLastName = lastName;
|
|
reader.Conf.ConfirmText(pasLastName, lastName, ExcelReader.ReadState.OK);
|
|
pas.PassengerFirstName = reader.ReadText(pasFirstName);
|
|
reader.Conf.ConfirmText(pasFirstName, pas.PassengerFirstName, pas.PassengerFirstName.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
pas.PassengerGender = reader.ReadGender(pasGender);
|
|
pas.PassengerNationality = reader.ReadNationality(pasNationality);
|
|
// TODO: Nicht klar ob hier LOCODEs kommen oder nicht
|
|
pas.PassengerPortOfEmbarkation = reader.ReadTextNoWhitespace(pasEmbarkation);
|
|
reader.Conf.ConfirmText(pasEmbarkation, pas.PassengerPortOfEmbarkation, pas.PassengerPortOfEmbarkation.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
pas.PassengerPortOfDisembarkation = reader.ReadTextNoWhitespace(pasDebarkation);
|
|
reader.Conf.ConfirmText(pasDebarkation, pas.PassengerPortOfDisembarkation, pas.PassengerPortOfDisembarkation.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
pas.PassengerInTransit = reader.ReadBoolean(pasTransit);
|
|
pas.PassengerPlaceOfBirth = reader.ReadText(pasPlaceOfBirth);
|
|
reader.Conf.ConfirmText(pasPlaceOfBirth, pas.PassengerPlaceOfBirth, pas.PassengerPlaceOfBirth.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
pas.PassengerDateOfBirth = reader.ReadBirthDate(pasDateOfBirth);
|
|
pas.PassengerIdentityDocumentType = reader.ReadIdentityDocumentType(pasIdentDocType);
|
|
pas.PassengerIdentityDocumentId = reader.ReadText(pasIdentDocId);
|
|
reader.Conf.ConfirmText(pasIdentDocId, pas.PassengerIdentityDocumentId, pas.PassengerIdentityDocumentId.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
pas.PassengerVisaNumber = reader.ReadText(pasVisaNo);
|
|
reader.Conf.ConfirmText(pasVisaNo, pas.PassengerVisaNumber, pas.PassengerVisaNumber.IsNullOrEmpty() ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK);
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ScanMessage (generic)
|
|
|
|
private static void ScanMessage(DatabaseEntity dbEntity, ExcelReader reader)
|
|
{
|
|
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;
|
|
|
|
if (property.PropertyType == typeof(DateTime?))
|
|
{
|
|
DateTime? sheetValue = reader.ReadDate(lookupNameAttribute.LookupName);
|
|
if (sheetValue != null)
|
|
{
|
|
property.SetValue(dbEntity, sheetValue);
|
|
reader.Conf.ConfirmDate(lookupNameAttribute.LookupName, sheetValue, ExcelReader.ReadState.OK);
|
|
}
|
|
else
|
|
{
|
|
reader.Conf.ConfirmDate(lookupNameAttribute.LookupName, sheetValue, ExcelReader.ReadState.WARN);
|
|
}
|
|
|
|
}
|
|
else if (property.PropertyType == typeof(double?))
|
|
{
|
|
double? sheetValue = reader.ReadNumber(lookupNameAttribute.LookupName);
|
|
if (sheetValue != null)
|
|
{
|
|
property.SetValue(dbEntity, sheetValue);
|
|
reader.Conf.ConfirmNumber(lookupNameAttribute.LookupName, sheetValue, ExcelReader.ReadState.OK);
|
|
}
|
|
else
|
|
{
|
|
reader.Conf.ConfirmNumber(lookupNameAttribute.LookupName, sheetValue, ExcelReader.ReadState.WARN);
|
|
}
|
|
}
|
|
else if (property.PropertyType == typeof(string))
|
|
{
|
|
string sheetValue = reader.ReadText(lookupNameAttribute.LookupName);
|
|
if (sheetValue != null)
|
|
{
|
|
|
|
property.SetValue(dbEntity, sheetValue);
|
|
ExcelReader.ReadState readState = ExcelReader.ReadState.OK;
|
|
// Wenn der Zellentext länger ist als 90 Zeichen und maximal 99/100 Zeichen lang ist soll die Zelle rot gefärbt werden
|
|
if (Attribute.IsDefined(property, typeof(MaxLengthAttribute)))
|
|
{
|
|
MaxLengthAttribute mla = Attribute.GetCustomAttribute(property, typeof(MaxLengthAttribute)) as MaxLengthAttribute;
|
|
if ((sheetValue.Length >= 90) && ((mla.MaxLength == 99) || (mla.MaxLength == 100)))
|
|
{
|
|
readState = ExcelReader.ReadState.FAIL;
|
|
}
|
|
}
|
|
|
|
reader.Conf.ConfirmText(lookupNameAttribute.LookupName, sheetValue, readState);
|
|
}
|
|
else
|
|
{
|
|
reader.Conf.ConfirmText(lookupNameAttribute.LookupName, sheetValue, ExcelReader.ReadState.WARN);
|
|
}
|
|
}
|
|
else if (property.PropertyType == typeof(int?))
|
|
{
|
|
double? sheetValue = reader.ReadNumber(lookupNameAttribute.LookupName);
|
|
if (sheetValue.HasValue)
|
|
{
|
|
property.SetValue(dbEntity, (int)sheetValue.Value);
|
|
reader.Conf.ConfirmNumber(lookupNameAttribute.LookupName, sheetValue, ExcelReader.ReadState.OK);
|
|
}
|
|
else
|
|
{
|
|
reader.Conf.ConfirmNumber(lookupNameAttribute.LookupName, sheetValue, ExcelReader.ReadState.WARN);
|
|
}
|
|
}
|
|
else if (property.PropertyType == typeof(byte?))
|
|
{
|
|
double? sheetValue = reader.ReadNumber(lookupNameAttribute.LookupName);
|
|
if (sheetValue.HasValue)
|
|
{
|
|
property.SetValue(dbEntity, (byte)sheetValue.Value);
|
|
reader.Conf.ConfirmNumber(lookupNameAttribute.LookupName, sheetValue, ExcelReader.ReadState.OK);
|
|
}
|
|
else
|
|
{
|
|
reader.Conf.ConfirmNumber(lookupNameAttribute.LookupName, sheetValue, ExcelReader.ReadState.WARN);
|
|
}
|
|
|
|
}
|
|
else if (property.PropertyType == typeof(Boolean?))
|
|
{
|
|
bool? sheetValue = reader.ReadBoolean(lookupNameAttribute.LookupName);
|
|
string boolStringValue = reader.ReadText(lookupNameAttribute.LookupName);
|
|
if (sheetValue.HasValue) {
|
|
property.SetValue(dbEntity, sheetValue);
|
|
reader.Conf.ConfirmText(lookupNameAttribute.LookupName, sheetValue.Value ? "Y" : "N",
|
|
ExcelReader.ReadState.OK);
|
|
}
|
|
else
|
|
{
|
|
reader.Conf.ConfirmText(lookupNameAttribute.LookupName, boolStringValue, ExcelReader.ReadState.WARN);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
_log.DebugFormat("unhandled property type: {0}", property.PropertyType);
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region LookupMessageCore
|
|
|
|
/// <summary>
|
|
/// Check with cell values if this message core is already in our DB
|
|
/// </summary>
|
|
private static MessageCore LookupMessageCore(ExcelReader reader, out string message)
|
|
{
|
|
// lookup using field values
|
|
MessageCore result = null;
|
|
DateTime? eta = null;
|
|
string poc;
|
|
string imo = null;
|
|
message = string.Empty;
|
|
bool isTransit = false;
|
|
|
|
// first check with visit/transit ID
|
|
string visitTransitId = reader.ReadTextNoWhitespace("ID");
|
|
|
|
if (visitTransitId != null)
|
|
{
|
|
if (bsmd.database.Util.IsVisitId(visitTransitId))
|
|
{
|
|
result = DBManager.Instance.GetMessageCoreByVisitId(visitTransitId);
|
|
}
|
|
else if (bsmd.database.Util.IsTransitId(visitTransitId))
|
|
{
|
|
result = DBManager.Instance.GetMessageCoreByTransitId(visitTransitId);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
message = "Visit / Transit Id missing!";
|
|
return null;
|
|
}
|
|
|
|
if (result != null)
|
|
{
|
|
// setup returning confirmation sheets according to PoC
|
|
if (result.PoC.Substring(0, 2) == "DK")
|
|
reader.SetConfirmation(Properties.Settings.Default.ConfirmationDK);
|
|
else
|
|
reader.SetConfirmation(Properties.Settings.Default.ConfirmationDE);
|
|
|
|
// copy poc/imo/eta to return sheet
|
|
poc = reader.ReadText("Visit.PortOfCall");
|
|
reader.Conf.ConfirmText("Visit.PortOfCall", poc, ExcelReader.ReadState.OK);
|
|
reader.Conf.ConfirmText("Visit.PortOfCall_DK", poc, ExcelReader.ReadState.OK);
|
|
imo = reader.ReadText("Visit.IMONumber");
|
|
reader.Conf.ConfirmText("Visit.IMONumber", imo, ExcelReader.ReadState.OK);
|
|
eta = reader.ReadDateTime("NOA_NOD.ETADateToPortOfCall", "NOA_NOD.ETATimeToPortOfCall");
|
|
result.HerbergReportType = reader.ReadText("ReferenceNumber");
|
|
reader.Conf.ConfirmText("ReferenceNumber", result.HerbergReportType, result.HerbergReportType.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
}
|
|
else
|
|
{
|
|
// lookup poc, imo, eta
|
|
poc = reader.ReadText("Visit.PortOfCall");
|
|
|
|
if (poc != null)
|
|
{
|
|
|
|
// Prüfen auf Transit
|
|
if (poc.IndexOf("CANAL", StringComparison.OrdinalIgnoreCase) >= 0 || poc.Equals("ZZNOK", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
reader.SetConfirmation(Properties.Settings.Default.ConfirmationDE);
|
|
poc = "ZZNOK";
|
|
isTransit = true;
|
|
}
|
|
else
|
|
{
|
|
// Im Sheet könnte der Name statt des LOCODES stehen!
|
|
if (!RuleEngine.IsGermanLocode(poc))
|
|
{
|
|
string aGermanPortName = poc;
|
|
|
|
if(poc.Contains(',')) // irgendwas wie "Hamburg, Germany"
|
|
{
|
|
aGermanPortName = poc.Split(',')[0];
|
|
}
|
|
|
|
if (RuleEngine.IsGermanLocode(aGermanPortName))
|
|
{
|
|
poc = aGermanPortName;
|
|
}
|
|
else
|
|
{
|
|
// somehow lookup LOCODE from the port's name!
|
|
poc = LocodeDB.LocodeGERFromCity(aGermanPortName);
|
|
}
|
|
|
|
// okay, könnte DK Locode etc sein..
|
|
if(poc == null)
|
|
{
|
|
if(aGermanPortName?.Length == 5) // possible locode?
|
|
{
|
|
if (LocodeDB.PortNameFromLocode(aGermanPortName) != null)
|
|
poc = aGermanPortName;
|
|
}
|
|
}
|
|
|
|
if(poc == null)
|
|
{
|
|
List<string> locodes = LocodeDB.AllLocodesForCityName(aGermanPortName);
|
|
if (locodes.Count > 0)
|
|
poc = locodes[0];
|
|
}
|
|
|
|
}
|
|
|
|
if (poc != null)
|
|
{
|
|
poc = poc.ToUpper();
|
|
|
|
// setup returning confirmation sheets according to PoC
|
|
if (poc.Substring(0, 2) == "DK")
|
|
reader.SetConfirmation(Properties.Settings.Default.ConfirmationDK);
|
|
else
|
|
reader.SetConfirmation(Properties.Settings.Default.ConfirmationDE);
|
|
}
|
|
else
|
|
{
|
|
message = "invalid PoC";
|
|
return null;
|
|
}
|
|
}
|
|
|
|
imo = reader.ReadText("Visit.IMONumber");
|
|
reader.Conf.ConfirmText("Visit.IMONumber", imo, imo.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
if ((imo.Length > 0) && !bsmd.database.Util.IsIMOValid(imo))
|
|
reader.Conf.ConfirmText("Visit.IMONumber", imo, ExcelReader.ReadState.WARN);
|
|
|
|
// ETA
|
|
if (poc != null)
|
|
eta = reader.ReadDateTime("NOA_NOD.ETADateToPortOfCall", "NOA_NOD.ETATimeToPortOfCall");
|
|
|
|
if ((imo != null) && (eta.HasValue) && (poc != null))
|
|
{
|
|
result = DBManager.Instance.GetMessageCoreByShipInfos(imo, eta.Value, poc);
|
|
if(result != null)
|
|
{
|
|
_log.InfoFormat("Core [{3}] found for IMO {0}, ETA {1}, Poc {2}", imo, eta, poc, result.Id);
|
|
result.HerbergReportType = reader.ReadText("ReferenceNumber");
|
|
reader.Conf.ConfirmText("ReferenceNumber", result.HerbergReportType, result.HerbergReportType.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
|
|
// Spezialfall: Wenn ein Core gefunden wird, dieser jedoch eine andere Visit/Transit Id hat als die Anmeldung ist das eine Neuanlage!
|
|
// Eingebaut 17.11.17
|
|
if(!visitTransitId.IsNullOrEmpty() && !result.DisplayId.IsNullOrEmpty() &&
|
|
(visitTransitId != result.DisplayId))
|
|
{
|
|
_log.WarnFormat("Different visit ID ({0} (Sheet) {1} (Core) for the same decl. treating as NEW!", visitTransitId, result.DisplayId);
|
|
result = null;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
reader.Conf.ConfirmText("Visit.PortOfCall", poc, ExcelReader.ReadState.OK);
|
|
reader.Conf.ConfirmText("Visit.PortOfCall_DK", poc, ExcelReader.ReadState.OK);
|
|
}
|
|
|
|
else
|
|
{
|
|
message = string.Format("Port of call missing or not found for IMO {0}", imo);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
bool isValidId = bsmd.database.Util.IsVisitId(visitTransitId) ||bsmd.database.Util.IsTransitId(visitTransitId);
|
|
reader.Conf.ConfirmText("ID", visitTransitId, isValidId ? ExcelReader.ReadState.OK : ExcelReader.ReadState.FAIL);
|
|
|
|
if (result == null)
|
|
{
|
|
if (imo == null)
|
|
{
|
|
message = "IMO number missing or not found";
|
|
return null;
|
|
}
|
|
|
|
if(poc == null)
|
|
{
|
|
message = string.Format("Port of call missing or not found for IMO {0}", imo);
|
|
return null;
|
|
}
|
|
|
|
if(eta == null)
|
|
{
|
|
message = string.Format("ETA missing or not found for IMO {0}", imo);
|
|
return null;
|
|
}
|
|
|
|
// neuen MessageCore erzeugen
|
|
result = new MessageCore();
|
|
|
|
result.Incoming = true;
|
|
result.HerbergFormGuid = Guid.Empty;
|
|
result.IMO = imo;
|
|
result.IsTransit = isTransit;
|
|
result.ReportStatus = MessageCore.ReportStatusEnum.NONE; // Bestätigungs-Sheet reicht als Report, keine separate Generierung
|
|
result.BSMDStatusInternal = MessageCore.BSMDStatus.PREPARE;
|
|
result.PoC = poc;
|
|
result.Portname = LocodeDB.PortNameFromLocode(poc);
|
|
|
|
result.HerbergEmailContactReportingVessel = reader.ReadText("ShipMail");
|
|
result.HerbergReportType = reader.ReadText("ReferenceNumber");
|
|
reader.Conf.ConfirmText("ReferenceNumber", result.HerbergReportType, result.HerbergReportType.IsNullOrEmpty() ? ExcelReader.ReadState.FAIL : ExcelReader.ReadState.OK);
|
|
|
|
if (result.IsTransit)
|
|
result.ETAKielCanal = eta;
|
|
else
|
|
result.ETA = eta;
|
|
|
|
if (result.IMO.Length > 7)
|
|
{
|
|
_log.WarnFormat("IMO {0} is longer than 7 chars, truncating!", result.IMO);
|
|
result.IMO = result.IMO.Substring(0, 7);
|
|
}
|
|
|
|
if((result.IMO.Length == 7) && !bsmd.database.Util.IsIMOValid(result.IMO))
|
|
{
|
|
_log.WarnFormat("IMO {0} possibly invalid (checksum number violation)", result.IMO);
|
|
}
|
|
|
|
if(visitTransitId != null)
|
|
{
|
|
if (bsmd.database.Util.IsTransitId(visitTransitId))
|
|
result.TransitId = visitTransitId;
|
|
else
|
|
result.VisitId = visitTransitId;
|
|
}
|
|
|
|
DBManager.Instance.Save(result);
|
|
// Meldeklassen erzeugen um doppelte Generierung über ENI-2 zu vermeiden
|
|
bsmd.database.Util.CreateMessagesForCore(result, new List<Message>(), null);
|
|
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region GetMessageWithType
|
|
|
|
private static Message GetMessageWithType(List<Message> messages, MessageCore core, Message.NotificationClass type)
|
|
{
|
|
foreach(Message message in messages)
|
|
if (message.MessageNotificationClass == type) return message;
|
|
|
|
Message newMessage = DBManager.Instance.GetMessage(core, type);
|
|
if (newMessage == null)
|
|
{
|
|
newMessage = new Message();
|
|
newMessage.MessageNotificationClass = type;
|
|
messages.Add(newMessage);
|
|
newMessage.MessageCore = core;
|
|
newMessage.MessageCoreId = core.Id;
|
|
}
|
|
return newMessage;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|