CREW, CREWD, PAS, PASD

This commit is contained in:
Daniel Schick 2022-05-06 11:02:36 +02:00
parent d94a75d1a1
commit 39a314eeba

View File

@ -501,10 +501,50 @@ namespace ENI2.Excel
return true; return true;
} }
private static bool ScanPRE72H(Message message, ExcelReader reader) #region PRE72H
private static bool ScanPRE72H(Message pre72hMessage, ExcelReader reader)
{ {
throw new NotImplementedException(); if (pre72hMessage.Elements.Count == 0)
{
PRE72H newPRE72H = new PRE72H();
newPRE72H.MessageHeader = pre72hMessage;
pre72hMessage.Elements.Add(newPRE72H);
} }
PRE72H pre72h = pre72hMessage.Elements[0] as PRE72H;
pre72h.Tanker = reader.ReadCellAsBool("port state control", "C8");
if(pre72h.Tanker ?? false)
{
string hull = reader.ReadCellAsText("port state control", "C10");
if (hull.Equals("single_hull", StringComparison.OrdinalIgnoreCase))
pre72h.TankerHullConfiguration = 0;
if (hull.Equals("single_hull_with_sbt", StringComparison.OrdinalIgnoreCase))
pre72h.TankerHullConfiguration = 1;
if (hull.Equals("double_hull", StringComparison.OrdinalIgnoreCase))
pre72h.TankerHullConfiguration = 2;
string condition = reader.ReadCellAsText("port state control", "C11");
if (condition.Equals("full", StringComparison.OrdinalIgnoreCase))
pre72h.ConditionCargoBallastTanks = 0;
if (condition.Equals("empty", StringComparison.OrdinalIgnoreCase))
pre72h.ConditionCargoBallastTanks = 1;
if (condition.Equals("inerted", StringComparison.OrdinalIgnoreCase))
pre72h.ConditionCargoBallastTanks = 2;
pre72h.NatureOfCargo = reader.ReadCellAsText("port state control", "C12");
pre72h.VolumeOfCargo = reader.ReadCellAsDecimal("port state control", "C13");
}
pre72h.PlannedOperations = reader.ReadCellAsText("port state control", "C14");
pre72h.PlannedWorks = reader.ReadCellAsText("port state control", "C15");
pre72h.DateOfLastExpandedInspection = reader.ReadCellAsDateTime("port state control", "C16");
pre72h.PlannedPeriodOfStay_HUR = reader.ReadCellAsDecimal("port state control", "C17");
return true;
}
#endregion
private static bool ScanPOBD(Message pobdMessage, ExcelReader reader) private static bool ScanPOBD(Message pobdMessage, ExcelReader reader)
{ {
@ -542,14 +582,104 @@ namespace ENI2.Excel
return true; return true;
} }
private static bool ScanPASD(Message message, ExcelReader reader) private static bool ScanPASD(Message pasdMessage, ExcelReader reader)
{ {
throw new NotImplementedException(); bool result = false;
for (int i = 0; i < 1000; i++)
{
string lastName = reader.ReadCellAsText("passenger departure", string.Format("B{0}", i + 16));
if (lastName.IsNullOrEmpty()) break;
if (!(pasdMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is PAS pas))
{
pas = new PASD();
pas.Identifier = (i + 1).ToString();
pas.MessageHeader = pasdMessage;
pasdMessage.Elements.Add(pas);
} }
private static bool ScanPAS(Message message, ExcelReader reader) pas.NotificationSchengen = reader.ReadCellAsBool("passenger departure", "C10");
pas.NotificationPAX = reader.ReadCellAsBool("passenger departure", "C11");
pas.PassengerLastName = lastName;
pas.PassengerFirstName = reader.ReadCellAsText("passenger departure", string.Format("C{0}", i + 16));
pas.PassengerPlaceOfBirth = reader.ReadCellAsText("passenger departure", string.Format("D{0}", i + 16));
pas.PassengerCountryOfBirth = reader.ReadCellAsText("passenger departure", string.Format("E{0}", i + 16));
pas.PassengerDateOfBirth = reader.ReadCellAsDateTime("passenger departure", string.Format("F{0}", i + 16));
pas.PassengerGender = ParseGender(reader.ReadCellAsText("passenger departure", string.Format("G{0}", i + 16)));
pas.PassengerNationality = reader.ReadCellAsText("passenger departure", string.Format("H{0}", i + 16));
pas.PassengerIdentityDocumentIssuingState = reader.ReadCellAsText("passenger departure", string.Format("O{0}", i + 16));
pas.PassengerIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("passenger departure", string.Format("P{0}", i + 16));
if (pas.NotificationPAX ?? false)
{ {
throw new NotImplementedException(); pas.EmergencyCare = reader.ReadCellAsText("passenger departure", string.Format("Q{0}", i + 16));
pas.EmergencyContactNumber = reader.ReadCellAsText("passenger departure", string.Format("R{0}", i + 16));
}
if (pas.NotificationSchengen ?? false)
{
pas.PassengerIdentityDocumentType = ParseDocumentType(reader.ReadCellAsText("passenger departure", string.Format("I{0}", i + 16)));
pas.PassengerIdentityDocumentId = reader.ReadCellAsText("passenger departure", string.Format("J{0}", i + 16));
pas.PassengerVisaNumber = reader.ReadCellAsText("passenger departure", string.Format("K{0}", i + 16));
pas.PassengerPortOfEmbarkation = reader.ReadCellAsText("passenger departure", string.Format("L{0}", i + 16));
pas.PassengerPortOfDisembarkation = reader.ReadCellAsText("passenger departure", string.Format("M{0}", i + 16));
pas.PassengerInTransit = reader.ReadCellAsBool("passenger departure", string.Format("N{0}", i + 16));
}
result = true;
}
return result;
}
private static bool ScanPAS(Message pasMessage, ExcelReader reader)
{
bool result = false;
for (int i = 0; i < 1000; i++)
{
string lastName = reader.ReadCellAsText("passenger arrival", string.Format("B{0}", i + 16));
if (lastName.IsNullOrEmpty()) break;
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.NotificationSchengen = reader.ReadCellAsBool("passenger arrival", "C10");
pas.NotificationPAX = reader.ReadCellAsBool("passenger arrival", "C11");
pas.PassengerLastName = lastName;
pas.PassengerFirstName = reader.ReadCellAsText("passenger arrival", string.Format("C{0}", i + 16));
pas.PassengerPlaceOfBirth = reader.ReadCellAsText("passenger arrival", string.Format("D{0}", i + 16));
pas.PassengerCountryOfBirth = reader.ReadCellAsText("passenger arrival", string.Format("E{0}", i + 16));
pas.PassengerDateOfBirth = reader.ReadCellAsDateTime("passenger arrival", string.Format("F{0}", i + 16));
pas.PassengerGender = ParseGender(reader.ReadCellAsText("passenger arrival", string.Format("G{0}", i + 16)));
pas.PassengerNationality = reader.ReadCellAsText("passenger arrival", string.Format("H{0}", i + 16));
pas.PassengerIdentityDocumentIssuingState = reader.ReadCellAsText("passenger arrival", string.Format("O{0}", i + 16));
pas.PassengerIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("passenger arrival", string.Format("P{0}", i + 16));
if(pas.NotificationPAX ?? false)
{
pas.EmergencyCare = reader.ReadCellAsText("passenger arrival", string.Format("Q{0}", i + 16));
pas.EmergencyContactNumber = reader.ReadCellAsText("passenger arrival", string.Format("R{0}", i + 16));
}
if(pas.NotificationSchengen ?? false)
{
pas.PassengerIdentityDocumentType = ParseDocumentType(reader.ReadCellAsText("passenger arrival", string.Format("I{0}", i + 16)));
pas.PassengerIdentityDocumentId = reader.ReadCellAsText("passenger arrival", string.Format("J{0}", i + 16));
pas.PassengerVisaNumber = reader.ReadCellAsText("passenger arrival", string.Format("K{0}", i + 16));
pas.PassengerPortOfEmbarkation = reader.ReadCellAsText("passenger arrival", string.Format("L{0}", i + 16));
pas.PassengerPortOfDisembarkation = reader.ReadCellAsText("passenger arrival", string.Format("M{0}", i + 16));
pas.PassengerInTransit = reader.ReadCellAsBool("passenger arrival", string.Format("N{0}", i + 16));
}
result = true;
}
return result;
} }
private static bool ScanNOA_NOD(Message noa_nodMessage, ExcelReader reader) private static bool ScanNOA_NOD(Message noa_nodMessage, ExcelReader reader)
@ -865,16 +995,133 @@ namespace ENI2.Excel
throw new NotImplementedException(); throw new NotImplementedException();
} }
private static bool ScanCREWD(Message message, ExcelReader reader) #region CREWD
private static bool ScanCREWD(Message crewMessage, ExcelReader reader)
{ {
throw new NotImplementedException(); bool result = false;
for (int i = 0; i < 1000; i++)
{
string lastName = reader.ReadCellAsText("crew departure", string.Format("B{0}", i + 15));
if (lastName.IsNullOrEmpty()) break;
if (!(crewMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is CREW crew))
{
crew = new CREWD();
crew.Identifier = (i + 1).ToString();
crew.MessageHeader = crewMessage;
crewMessage.Elements.Add(crew);
} }
private static bool ScanCREW(Message message, ExcelReader reader) crew.NotificationSchengen = reader.ReadCellAsBool("crew departure", "C10");
crew.NotificationPAX = reader.ReadCellAsBool("crew departure", "C11");
crew.CrewMemberLastName = lastName;
crew.CrewMemberFirstName = reader.ReadCellAsText("crew departure", string.Format("C{0}", i + 15));
crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText("crew departure", string.Format("D{0}", i + 15));
crew.CrewMemberCountryOfBirth = reader.ReadCellAsText("crew departure", string.Format("E{0}", i + 15));
crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime("crew departure", string.Format("F{0}", i + 15));
string gender = reader.ReadCellAsText("crew departure", string.Format("G{0}", i + 15));
crew.CrewMemberGender = ParseGender(gender);
crew.CrewMemberNationality = reader.ReadCellAsText("crew departure", string.Format("H{0}", i + 15));
if (crew.NotificationSchengen ?? false)
{ {
throw new NotImplementedException(); string idDocType = reader.ReadCellAsText("crew departure", string.Format("I{0}", i + 15));
crew.CrewMemberIdentityDocumentType = ParseDocumentType(idDocType);
crew.CrewMemberIdentityDocumentId = reader.ReadCellAsText("crew departure", string.Format("J{0}", i + 15));
crew.CrewMemberVisaNumber = reader.ReadCellAsText("crew departure", string.Format("K{0}", i + 15));
crew.CrewMemberIdentityDocumentIssuingState = reader.ReadCellAsText("crew departure", string.Format("M{0}", i + 15));
crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("crew departure", string.Format("N{0}", i + 15));
} }
crew.CrewMemberDuty = reader.ReadCellAsText("crew departure", string.Format("L{0}", i + 15));
result = true;
}
return result;
}
#endregion
#region CREW
private static bool ScanCREW(Message crewMessage, ExcelReader reader)
{
bool result = false;
for (int i = 0; i < 1000; i++)
{
string lastName = reader.ReadCellAsText("crew arrival", string.Format("B{0}", i + 15));
if (lastName.IsNullOrEmpty()) break;
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.NotificationSchengen = reader.ReadCellAsBool("crew arrival", "C10");
crew.NotificationPAX = reader.ReadCellAsBool("crew arrival", "C11");
crew.CrewMemberLastName = lastName;
crew.CrewMemberFirstName = reader.ReadCellAsText("crew arrival", string.Format("C{0}", i + 15));
crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText("crew arrival", string.Format("D{0}", i + 15));
crew.CrewMemberCountryOfBirth = reader.ReadCellAsText("crew arrival", string.Format("E{0}", i + 15));
crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime("crew arrival", string.Format("F{0}", i + 15));
string gender = reader.ReadCellAsText("crew arrival", string.Format("G{0}", i + 15));
crew.CrewMemberGender = ParseGender(gender);
crew.CrewMemberNationality = reader.ReadCellAsText("crew arrival", string.Format("H{0}", i + 15));
if(crew.NotificationSchengen ?? false)
{
string idDocType = reader.ReadCellAsText("crew arrival", string.Format("I{0}", i + 15));
crew.CrewMemberIdentityDocumentType = ParseDocumentType(idDocType);
crew.CrewMemberIdentityDocumentId = reader.ReadCellAsText("crew arrival", string.Format("J{0}", i + 15));
crew.CrewMemberVisaNumber = reader.ReadCellAsText("crew arrival", string.Format("K{0}", i + 15));
crew.CrewMemberIdentityDocumentIssuingState = reader.ReadCellAsText("crew arrival", string.Format("M{0}", i + 15));
crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("crew arrival", string.Format("N{0}", i + 15));
}
crew.CrewMemberDuty = reader.ReadCellAsText("crew arrival", string.Format("L{0}", i + 15));
result = true;
}
return result;
}
private static byte? ParseGender(string gender)
{
byte? result = null;
if(!gender.IsNullOrEmpty())
{
if (gender.Equals("male", StringComparison.OrdinalIgnoreCase)) result = 1;
if (gender.Equals("female", StringComparison.OrdinalIgnoreCase)) result = 2;
if (gender.Equals("not_applicable", StringComparison.OrdinalIgnoreCase)) result = 9;
if (gender.Equals("not_known", StringComparison.OrdinalIgnoreCase)) result = 0;
if (gender.Equals("other", StringComparison.OrdinalIgnoreCase)) result = 9;
}
return result;
}
private static byte? ParseDocumentType(string docType)
{
byte? result = null;
if(!docType.IsNullOrEmpty())
{
if (docType.Equals("identity_card", StringComparison.OrdinalIgnoreCase)) result = 0;
if (docType.Equals("passport", StringComparison.OrdinalIgnoreCase)) result = 1;
if (docType.Equals("muster_book", StringComparison.OrdinalIgnoreCase)) result = 2;
if (docType.Equals("picture_id", StringComparison.OrdinalIgnoreCase)) result = 3;
if (docType.Equals("residental_permit", StringComparison.OrdinalIgnoreCase)) result = 4;
if (docType.Equals("other_legal_identity_document", StringComparison.OrdinalIgnoreCase)) result = 5;
}
return result;
}
#endregion
private static bool ScanBPOL(Message message, List<Message> messages, MessageCore messageCore, ExcelReader reader) private static bool ScanBPOL(Message message, List<Message> messages, MessageCore messageCore, ExcelReader reader)
{ {
throw new NotImplementedException(); throw new NotImplementedException();