Dakosy import SEC

This commit is contained in:
Daniel Schick 2022-05-04 10:48:52 +02:00
parent 9b06decc43
commit 942b8f6dcb

View File

@ -147,14 +147,30 @@ namespace ENI2.Excel
throw new NotImplementedException();
}
private static bool ScanTIEFD(Message message, ExcelReader reader)
private static bool ScanTIEFD(Message tiefdMessage, ExcelReader reader)
{
throw new NotImplementedException();
if (tiefdMessage.Elements.Count == 0)
{
TIEFD newTIEFD = new TIEFD();
newTIEFD.MessageHeader = tiefdMessage;
tiefdMessage.Elements.Add(newTIEFD);
}
TIEFD tiefd = tiefdMessage.Elements[0] as TIEFD;
tiefd.DraughtUponDeparture_DMT = reader.ReadCellAsDecimal("traffic message on departure", "C14");
return tiefd.DraughtUponDeparture_DMT.HasValue;
}
private static bool ScanTIEFA(Message message, ExcelReader reader)
private static bool ScanTIEFA(Message tiefaMessage, ExcelReader reader)
{
throw new NotImplementedException();
if (tiefaMessage.Elements.Count == 0)
{
TIEFA newTIEFA = new TIEFA();
newTIEFA.MessageHeader = tiefaMessage;
tiefaMessage.Elements.Add(newTIEFA);
}
TIEFA tiefa = tiefaMessage.Elements[0] as TIEFA;
tiefa.DraughtUponArrival_DMT = reader.ReadCellAsDecimal("traffic message on arrival", "C14");
return tiefa.DraughtUponArrival_DMT.HasValue;
}
private static bool ScanSTO(Message message, ExcelReader reader)
@ -232,9 +248,117 @@ namespace ENI2.Excel
return result;
}
private static bool ScanSEC(Message message, ExcelReader reader)
private static bool ScanSEC(Message secMessage, ExcelReader reader)
{
throw new NotImplementedException();
if (secMessage.Elements.Count == 0)
{
SEC newSEC = new SEC();
newSEC.MessageHeader = secMessage;
secMessage.Elements.Add(newSEC);
}
SEC sec = secMessage.Elements[0] as SEC;
sec.CurrentShipSecurityLevel = (byte?)reader.ReadCellAsDecimal("security", "D7");
sec.SECSimplification = reader.ReadCellAsBool("security", "D9");
sec.KielCanalPassagePlanned = reader.ReadCellAsBool("security", "I7");
if(sec.KielCanalPassagePlanned ?? false)
{
sec.KielCanalPassagePlannedIncomming = reader.ReadCellAsDateTime("security", "I9");
sec.KielCanalPassagePlannedOutgoing = reader.ReadCellAsDateTime("security", "I12");
}
if(sec.SECSimplification ?? false)
{
sec.PortOfCallWhereCompleteSECNotified = reader.ReadCellAsText("security", "D10")?.Substring(0, 5);
}
else
{
sec.CSOLastName = reader.ReadCellAsText("security", "D12");
sec.CSOFirstName = reader.ReadCellAsText("security", "D13");
sec.CSOPhone = reader.ReadCellAsText("security", "D14");
sec.CSOFax = reader.ReadCellAsText("security", "D15");
sec.CSOEMail = reader.ReadCellAsText("security", "D16");
sec.ValidISSCOnBoard = reader.ReadCellAsBool("security", "D17");
sec.ReasonsForNoValidISSC = reader.ReadCellAsText("security", "D18");
string isscType = reader.ReadCellAsText("security", "D19");
if(!isscType.IsNullOrEmpty())
{
if (isscType.Equals("full", StringComparison.OrdinalIgnoreCase)) sec.ISSCType = 0;
if (isscType.Equals("interim", StringComparison.OrdinalIgnoreCase)) sec.ISSCType = 1;
}
string issuerType = reader.ReadCellAsText("security", "D20");
if(!issuerType.IsNullOrEmpty())
{
if (isscType.Equals("ADMINISTRATION", StringComparison.OrdinalIgnoreCase)) sec.ISSCIssuerType = 0;
if (isscType.Equals("RSO", StringComparison.OrdinalIgnoreCase)) sec.ISSCIssuerType = 1;
}
sec.ISSCIssuerName = reader.ReadCellAsText("security", "D21");
sec.ISSCDateOfExpiration = reader.ReadCellAsDateTime("security", "D22");
sec.ApprovedSecurityPlanOnBoard = reader.ReadCellAsBool("security", "D23");
sec.PortFacilityOfArrival = reader.ReadCellAsText("security", "D24");
string generalDoC = reader.ReadCellAsText("security", "D25");
if(!generalDoC.IsNullOrEmpty())
{
if(generalDoC.Equals("container", StringComparison.OrdinalIgnoreCase)) sec.GeneralDescriptionOfCargo = 0;
if (generalDoC.Equals("vehicles", StringComparison.OrdinalIgnoreCase)) sec.GeneralDescriptionOfCargo = 1;
if (generalDoC.Equals("conventional_general_cargo", StringComparison.OrdinalIgnoreCase)) sec.GeneralDescriptionOfCargo = 2;
if (generalDoC.Equals("dry_cargo_in_bulk", StringComparison.OrdinalIgnoreCase)) sec.GeneralDescriptionOfCargo = 3;
if (generalDoC.Equals("liquid_cargo_in_bulk", StringComparison.OrdinalIgnoreCase)) sec.GeneralDescriptionOfCargo = 4;
if (generalDoC.Equals("empty", StringComparison.OrdinalIgnoreCase)) sec.GeneralDescriptionOfCargo = 5;
}
for (int i = 1; i <= 10; 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.ReadCellAsText("security", String.Format("B{0}", i + 30));
l10fc.PortFacilityPortCountry = reader.ReadCellAsText("security", String.Format("C{0}", i + 30));
l10fc.PortFacilityPortLoCode = reader.ReadCellAsText("security", String.Format("D{0}", i + 30));
l10fc.PortFacilityDateOfArrival = reader.ReadCellAsDateTime("security", String.Format("E{0}", i + 30));
l10fc.PortFacilityDateOfDeparture = reader.ReadCellAsDateTime("security", String.Format("F{0}", i + 30));
l10fc.PortFacilityShipSecurityLevel = (byte?) reader.ReadCellAsDecimal("security", String.Format("G{0}", i + 30));
l10fc.PortFacilitySecurityMattersToReport = reader.ReadCellAsText("security", String.Format("H{0}", i + 30));
l10fc.PortFacilityGISISCode = reader.ReadCellAsText("security", String.Format("I{0}", i + 30));
l10fc.PortFacilityGISISCodeLocode = reader.ReadCellAsText("security", String.Format("J{0}", i + 30));
// 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);
}
for (int i = 1; i <= 10; 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.ReadCellAsText("security", string.Format("B{0}", i + 45));
s2sActivity.ShipToShipActivityLocationLoCode = reader.ReadCellAsText("security", string.Format("C{0}", i + 45));
s2sActivity.ShipToShipActivityLocationCoordinatesLatitude = (int?) reader.ReadCellAsDecimal("security", string.Format("D{0}", i + 45));
s2sActivity.ShipToShipActivityLocationCoordinatesLongitude = (int?) reader.ReadCellAsDecimal("security", string.Format("E{0}", i + 45));
s2sActivity.ShipToShipActivityDateFrom = reader.ReadCellAsDateTime("security", string.Format("F{0}", i + 45));
s2sActivity.ShipToShipActivityDateTo = reader.ReadCellAsDateTime("security", string.Format("G{0}", i + 45));
s2sActivity.ShipToShipActivityTypeCode = (int?) reader.ReadCellAsDecimal("security", string.Format("H{0}", i + 45));
s2sActivity.ShipToShipActivitySecurityMattersToReport = reader.ReadCellAsText("security", string.Format("I{0}", i + 45));
if (s2sActivity.ShipToShipActivityLocationName.IsNullOrEmpty() && s2sActivity.ShipToShipActivityLocationLoCode.IsNullOrEmpty() &&
!(s2sActivity.ShipToShipActivityLocationCoordinatesLatitude.HasValue && s2sActivity.ShipToShipActivityLocationCoordinatesLongitude.HasValue))
sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Remove(s2sActivity);
}
}
return true;
}
private static bool ScanPRE72H(Message message, ExcelReader reader)
@ -242,14 +366,40 @@ namespace ENI2.Excel
throw new NotImplementedException();
}
private static bool ScanPOBD(Message message, ExcelReader reader)
private static bool ScanPOBD(Message pobdMessage, ExcelReader reader)
{
throw new NotImplementedException();
if (pobdMessage.Elements.Count == 0)
{
POBD newPOBD = new POBD();
newPOBD.MessageHeader = pobdMessage;
pobdMessage.Elements.Add(newPOBD);
}
private static bool ScanPOBA(Message message, ExcelReader reader)
POBD pobd = pobdMessage.Elements[0] as POBD;
pobd.TotalPersonsOnBoardUponDeparture = (int?)reader.ReadCellAsDecimal("traffic message on departure", "C8");
pobd.TotalCrewMembersOnBoardUponDeparture = (int?)reader.ReadCellAsDecimal("traffic message on departure", "C9");
pobd.TotalPassengersOnBoardUponDeparture = (int?)reader.ReadCellAsDecimal("traffic message on departure", "C10");
pobd.TotalStowawaysOnBoardUponDeparture = (int?)reader.ReadCellAsDecimal("traffic message on departure", "C11");
return true;
}
private static bool ScanPOBA(Message pobaMessage, ExcelReader reader)
{
throw new NotImplementedException();
if (pobaMessage.Elements.Count == 0)
{
POBA newPOBA = new POBA();
newPOBA.MessageHeader = pobaMessage;
pobaMessage.Elements.Add(newPOBA);
}
POBA poba = pobaMessage.Elements[0] as POBA;
poba.TotalPersonsOnBoardUponArrival = (int?) reader.ReadCellAsDecimal("traffic message on arrival", "C8");
poba.TotalCrewMembersOnBoardUponArrival = (int?) reader.ReadCellAsDecimal("traffic message on arrival", "C9");
poba.TotalPassengersOnBoardUponArrival = (int?) reader.ReadCellAsDecimal("traffic message on arrival", "C10");
poba.TotalStowawaysOnBoardUponArrival = (int?) reader.ReadCellAsDecimal("traffic message on arrival", "C11");
return true;
}
private static bool ScanPASD(Message message, ExcelReader reader)
@ -329,9 +479,39 @@ namespace ENI2.Excel
throw new NotImplementedException();
}
private static bool ScanLADG(Message message, ExcelReader reader)
private static bool ScanLADG(Message ladgMessage, ExcelReader reader)
{
throw new NotImplementedException();
bool result = false;
for (int i = 0; i < 10000; i++)
{
string operation = reader.ReadCellAsText("cargo", string.Format("B{0}", i + 9));
byte? ladgOperation = null;
if (operation.Equals("LOAD", StringComparison.OrdinalIgnoreCase)) ladgOperation = 0;
if (operation.Equals("DISCHARGE", StringComparison.OrdinalIgnoreCase)) ladgOperation = 1;
if (operation.Equals("TRANSIT", StringComparison.OrdinalIgnoreCase)) ladgOperation = 2;
if (!ladgOperation.HasValue) break;
if (!(ladgMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is LADG ladg))
{
ladg = new LADG();
ladg.MessageHeader = ladgMessage;
ladg.Identifier = (i + 1).ToString();
ladgMessage.Elements.Add(ladg);
}
ladg.CargoHandlingType = ladgOperation;
ladg.CargoLACode = (int?) reader.ReadCellAsDecimal("cargo", string.Format("C{0}", i + 9));
ladg.CargoCodeNST = reader.ReadCellAsText("cargo", string.Format("D{0}", i + 9))?.Substring(0, 2);
ladg.CargoCodeNST_3 = reader.ReadCellAsText("cargo", string.Format("E{0}", i + 9));
ladg.CargoNumberOfItems = (int?)reader.ReadCellAsDecimal("cargo", string.Format("F{0}", i + 9));
ladg.CargoGrossQuantity_TNE = reader.ReadCellAsDecimal("cargo", string.Format("G{0}", i + 9));
ladg.PortOfLoading = reader.ReadCellAsText("cargo", string.Format("H{0}", i + 9));
ladg.PortOfDischarge = reader.ReadCellAsText("cargo", string.Format("I{0}", i + 9));
result = true;
}
return result;
}
private static bool ScanINFO(Message infoMessage, ExcelReader reader)
@ -389,24 +569,82 @@ namespace ENI2.Excel
throw new NotImplementedException();
}
private static bool ScanBKRD(Message message, ExcelReader reader)
private static bool ScanBKRD(Message brkdMessage, ExcelReader reader)
{
throw new NotImplementedException();
bool result = false;
for (int i = 0; i < 10000; i++)
{
string fuelType = reader.ReadCellAsText("traffic message on departure", string.Format("B{0}", i + 28));
double? quantity = reader.ReadCellAsDecimal("traffic message on departure", string.Format("C{0}", i + 28));
if (fuelType.IsNullOrEmpty()) break;
if (!(brkdMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is BRKD brkd))
{
brkd = new BRKD();
brkd.MessageHeader = brkdMessage;
brkd.Identifier = (i + 1).ToString();
brkdMessage.Elements.Add(brkd);
}
brkd.BunkerFuelType = fuelType;
brkd.BunkerFuelQuantity_TNE = quantity;
result = true;
}
private static bool ScanBKRA(Message message, ExcelReader reader)
{
throw new NotImplementedException();
return result;
}
private static bool ScanATD(Message message, ExcelReader reader)
private static bool ScanBKRA(Message bkraMessage, ExcelReader reader)
{
throw new NotImplementedException();
bool result = false;
for (int i = 0; i < 10000; i++)
{
string fuelType = reader.ReadCellAsText("traffic message on arrival", string.Format("B{0}", i + 28));
double? quantity = reader.ReadCellAsDecimal("traffic message on arrival", string.Format("C{0}", i + 28));
if (fuelType.IsNullOrEmpty()) break;
if (!(bkraMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is BRKA brka))
{
brka = new BRKA();
brka.MessageHeader = bkraMessage;
brka.Identifier = (i + 1).ToString();
bkraMessage.Elements.Add(brka);
}
brka.BunkerFuelType = fuelType;
brka.BunkerFuelQuantity_TNE = quantity;
result = true;
}
private static bool ScanATA(Message message, ExcelReader reader)
return result;
}
private static bool ScanATD(Message atdMessage, ExcelReader reader)
{
throw new NotImplementedException();
if (atdMessage.Elements.Count == 0)
{
ATD newATD = new ATD();
newATD.MessageHeader = atdMessage;
atdMessage.Elements.Add(newATD);
}
ATD atd = atdMessage.Elements[0] as ATD;
atd.ATDPortOfCall = reader.ReadCellAsDateTime("traffic message on departure", "C20");
return atd.ATDPortOfCall.HasValue;
}
private static bool ScanATA(Message ataMessage, 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;
ata.ATAPortOfCall = reader.ReadCellAsDateTime("traffic message on arrival", "C20");
return ata.ATAPortOfCall.HasValue;
}
#region AGNT