Dakosy sheet: MDH
This commit is contained in:
parent
942b8f6dcb
commit
5b5fd61638
@ -78,11 +78,11 @@ namespace ENI2.Excel
|
|||||||
if ((message.MessageNotificationClass == Message.NotificationClass.LADG) && notificationClasses.Contains(Message.NotificationClass.LADG))
|
if ((message.MessageNotificationClass == Message.NotificationClass.LADG) && notificationClasses.Contains(Message.NotificationClass.LADG))
|
||||||
{ if (ScanLADG(message, reader)) ExcelReader.SaveMessage(message); continue; }
|
{ if (ScanLADG(message, reader)) ExcelReader.SaveMessage(message); continue; }
|
||||||
if ((message.MessageNotificationClass == Message.NotificationClass.MDH) && notificationClasses.Contains(Message.NotificationClass.MDH))
|
if ((message.MessageNotificationClass == Message.NotificationClass.MDH) && notificationClasses.Contains(Message.NotificationClass.MDH))
|
||||||
{ if (ScanMDH(message, messages, messageCore, reader)) ExcelReader.SaveMessage(message); continue; }
|
{ if (ScanMDH(message, reader)) ExcelReader.SaveMessage(message); continue; }
|
||||||
if ((message.MessageNotificationClass == Message.NotificationClass.NAME) && notificationClasses.Contains(Message.NotificationClass.NAME))
|
if ((message.MessageNotificationClass == Message.NotificationClass.NAME) && notificationClasses.Contains(Message.NotificationClass.NAME))
|
||||||
{ if (ScanNAME(message, reader)) ExcelReader.SaveMessage(message); continue; }
|
{ if (ScanNAME(message, reader)) ExcelReader.SaveMessage(message); continue; }
|
||||||
if ((message.MessageNotificationClass == Message.NotificationClass.NOA_NOD) && notificationClasses.Contains(Message.NotificationClass.NOA_NOD))
|
if ((message.MessageNotificationClass == Message.NotificationClass.NOA_NOD) && notificationClasses.Contains(Message.NotificationClass.NOA_NOD))
|
||||||
{ if (ScanNOA_NOD(message, messageCore, reader)) ExcelReader.SaveMessage(message); continue; }
|
{ if (ScanNOA_NOD(message, reader)) ExcelReader.SaveMessage(message); continue; }
|
||||||
if ((message.MessageNotificationClass == Message.NotificationClass.PAS) && notificationClasses.Contains(Message.NotificationClass.PAS))
|
if ((message.MessageNotificationClass == Message.NotificationClass.PAS) && notificationClasses.Contains(Message.NotificationClass.PAS))
|
||||||
{ if (ScanPAS(message, reader)) ExcelReader.SaveMessage(message); continue; }
|
{ if (ScanPAS(message, reader)) ExcelReader.SaveMessage(message); continue; }
|
||||||
if ((message.MessageNotificationClass == Message.NotificationClass.PASD) && notificationClasses.Contains(Message.NotificationClass.PASD))
|
if ((message.MessageNotificationClass == Message.NotificationClass.PASD) && notificationClasses.Contains(Message.NotificationClass.PASD))
|
||||||
@ -412,7 +412,7 @@ namespace ENI2.Excel
|
|||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool ScanNOA_NOD(Message noa_nodMessage, MessageCore messageCore, ExcelReader reader)
|
private static bool ScanNOA_NOD(Message noa_nodMessage, ExcelReader reader)
|
||||||
{
|
{
|
||||||
if (noa_nodMessage.Elements.Count == 0)
|
if (noa_nodMessage.Elements.Count == 0)
|
||||||
{
|
{
|
||||||
@ -473,12 +473,177 @@ namespace ENI2.Excel
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
#region MDH
|
||||||
|
|
||||||
private static bool ScanMDH(Message message, List<Message> messages, MessageCore messageCore, ExcelReader reader)
|
private static bool ScanMDH(Message mdhMessage, ExcelReader reader)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
if (mdhMessage.Elements.Count == 0)
|
||||||
|
{
|
||||||
|
MDH newMDH = new MDH();
|
||||||
|
newMDH.MessageHeader = mdhMessage;
|
||||||
|
mdhMessage.Elements.Add(newMDH);
|
||||||
|
}
|
||||||
|
MDH mdh = mdhMessage.Elements[0] as MDH;
|
||||||
|
mdh.MDHSimplification = reader.ReadCellAsBool("health", "D8");
|
||||||
|
if(mdh.MDHSimplification ?? false)
|
||||||
|
{
|
||||||
|
mdh.PortOfCallWhereCompleteMDHNotified = reader.ReadCellAsText("health", "D9");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
// general fields
|
||||||
|
|
||||||
|
mdh.NonAccidentalDeathsDuringVoyage = reader.ReadCellAsBool("health", "D11");
|
||||||
|
if (mdh.NonAccidentalDeathsDuringVoyage ?? false)
|
||||||
|
mdh.NonAccidentalDeathsDuringVoyageCount = (int?)reader.ReadCellAsDecimal("health", "D12");
|
||||||
|
mdh.SuspisionInfectiousNature = reader.ReadCellAsBool("health", "D13");
|
||||||
|
mdh.NumberOfIllPersonsHigherThanExpected = reader.ReadCellAsBool("health", "D14");
|
||||||
|
if (mdh.NumberOfIllPersonsHigherThanExpected ?? false)
|
||||||
|
mdh.NumberOfIllPersons = (int?)reader.ReadCellAsDecimal("health", "D15");
|
||||||
|
mdh.SickPersonsOnBoard = reader.ReadCellAsBool("health", "D16");
|
||||||
|
mdh.MedicalConsulted = reader.ReadCellAsBool("health", "D17");
|
||||||
|
mdh.AwareOfFurtherInfections = reader.ReadCellAsBool("health", "D18");
|
||||||
|
mdh.SickAnimalOrPetOnBoard = reader.ReadCellAsBool("health", "D20");
|
||||||
|
mdh.ValidSanitaryControlExemptionOrCertificateOnBoard = reader.ReadCellAsBool("health", "D22");
|
||||||
|
if(mdh.ValidSanitaryControlExemptionOrCertificateOnBoard ?? false)
|
||||||
|
{
|
||||||
|
mdh.PlaceOfIssue = reader.ReadCellAsText("health", "D23");
|
||||||
|
mdh.DateOfIssue = reader.ReadCellAsDateTime("health", "D24");
|
||||||
|
}
|
||||||
|
mdh.SanitaryControlReinspectionRequired = reader.ReadCellAsBool("health", "D25");
|
||||||
|
|
||||||
|
// sanitary measures
|
||||||
|
mdh.SanitaryMeasuresApplied = reader.ReadCellAsBool("health", "J8");
|
||||||
|
if (mdh.SanitaryMeasuresApplied ?? false)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= 10; i++)
|
||||||
|
{
|
||||||
|
if (!(mdh.GetSanitaryMeasuresDetailWithIdentifier(i.ToString()) is SanitaryMeasuresDetail snd))
|
||||||
|
{
|
||||||
|
snd = new SanitaryMeasuresDetail();
|
||||||
|
snd.Identifier = i.ToString();
|
||||||
|
snd.MDH = mdh;
|
||||||
|
mdh.SanitaryMeasuresDetails.Add(snd);
|
||||||
|
}
|
||||||
|
snd.SanitaryMeasuresType = reader.ReadCellAsText("health", string.Format("H{0}", i + 9));
|
||||||
|
if (snd.SanitaryMeasuresType.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
mdh.SanitaryMeasuresDetails.Remove(snd);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
snd.SanitaryMeasuresLocation = reader.ReadCellAsText("health", string.Format("I{0}", i + 9));
|
||||||
|
snd.SanitaryMeasuresDate = reader.ReadCellAsDateTime("health", string.Format("J{0}", i + 9));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// stowaways
|
||||||
|
mdh.StowawaysDetected = reader.ReadCellAsBool("health", "I22");
|
||||||
|
if (mdh.StowawaysDetected ?? false)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= 10; i++)
|
||||||
|
{
|
||||||
|
string stowawayLocation = reader.ReadCellAsText("health", string.Format("H{0}", i + 23));
|
||||||
|
if(!stowawayLocation.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
if(!(mdh.GetStowawaysJoiningLocationWithIdentifier(i.ToString()) is StowawaysJoiningLocation sjl))
|
||||||
|
{
|
||||||
|
sjl = new StowawaysJoiningLocation();
|
||||||
|
sjl.Identifier = i.ToString();
|
||||||
|
sjl.MDH = mdh;
|
||||||
|
mdh.StowawaysJoiningLocations.Add(sjl);
|
||||||
|
}
|
||||||
|
sjl.StowawayJoiningLocation = stowawayLocation;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// infected area
|
||||||
|
mdh.InfectedAreaVisited = reader.ReadCellAsBool("health", "L22");
|
||||||
|
if (mdh.InfectedAreaVisited ?? false)
|
||||||
|
{
|
||||||
|
for (int i = 1; i <= 10; i++)
|
||||||
|
{
|
||||||
|
string iaPort = reader.ReadCellAsText("health", string.Format("K{0}", i + 23));
|
||||||
|
if(!iaPort.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
if(!(mdh.GetInfectedAreaWithIdentifier(i.ToString()) is InfectedArea ia))
|
||||||
|
{
|
||||||
|
ia = new InfectedArea();
|
||||||
|
ia.Identifier = i.ToString();
|
||||||
|
ia.MDH = mdh;
|
||||||
|
mdh.InfectedAreas.Add(ia);
|
||||||
|
}
|
||||||
|
ia.InfectedAreaPort = iaPort;
|
||||||
|
ia.InfectedAreaDate = reader.ReadCellAsDateTime("health", string.Format("L{0}", i + 23));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// PoC last 30 days
|
||||||
|
// this crazy logic is necessary to interpret the double tables in the dakosy sheet
|
||||||
|
|
||||||
|
// collect all crew members
|
||||||
|
Dictionary<string, List<string>> crewmembers = new Dictionary<string, List<string>>();
|
||||||
|
for (int i = 1; i <= 1000; i++)
|
||||||
|
{
|
||||||
|
string posRef = reader.ReadCellAsText("health", string.Format("G{0}", i + 45));
|
||||||
|
if(posRef.IsNullOrEmpty())
|
||||||
|
posRef = reader.ReadCellAsText("health", string.Format("H{0}", i + 45));
|
||||||
|
if (posRef.IsNullOrEmpty()) break; // we are done with this loop
|
||||||
|
string crewMember = reader.ReadCellAsText("health", string.Format("I{0}", i + 45));
|
||||||
|
if (!crewMember.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
if(!crewmembers.ContainsKey(posRef))
|
||||||
|
crewmembers.Add(posRef, new List<string>());
|
||||||
|
crewmembers[posRef].Add(crewMember);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= 1000; i++)
|
||||||
|
{
|
||||||
|
string posRef = reader.ReadCellAsText("health", string.Format("B{0}", i + 45));
|
||||||
|
string locode = reader.ReadCellAsText("health", string.Format("C{0}", i + 45));
|
||||||
|
if (locode.IsNullOrEmpty()) break;
|
||||||
|
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.PortOfCallLast30DaysLocode = locode;
|
||||||
|
poc30d.PortOfCallLast30DaysDateOfDeparture = reader.ReadCellAsDateTime("health", string.Format("D{0}", i + 45));
|
||||||
|
poc30d.PortOfCallLast30DaysCrewMembersJoined = reader.ReadCellAsBool("health", string.Format("E{0}", i + 45));
|
||||||
|
poc30d.CrewJoinedShip.Clear();
|
||||||
|
List<string> crewJoined = new List<string>();
|
||||||
|
if (crewmembers.ContainsKey(posRef)) {
|
||||||
|
crewJoined = crewmembers[posRef];
|
||||||
|
}
|
||||||
|
else if (crewmembers.ContainsKey(locode))
|
||||||
|
{
|
||||||
|
crewJoined = crewmembers[locode];
|
||||||
|
}
|
||||||
|
for(int j = 0; j < crewJoined.Count; j++)
|
||||||
|
{
|
||||||
|
PortOfCallLast30DaysCrewJoinedShip p = new PortOfCallLast30DaysCrewJoinedShip();
|
||||||
|
p.PortOfCallLast30Days = poc30d;
|
||||||
|
p.Identifier = (j + 1).ToString();
|
||||||
|
poc30d.CrewJoinedShip.Add(p);
|
||||||
|
p.PortOfCallLast30DaysCrewJoinedShipName = crewJoined[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region LADG
|
||||||
|
|
||||||
private static bool ScanLADG(Message ladgMessage, ExcelReader reader)
|
private static bool ScanLADG(Message ladgMessage, ExcelReader reader)
|
||||||
{
|
{
|
||||||
bool result = false;
|
bool result = false;
|
||||||
@ -514,6 +679,10 @@ namespace ENI2.Excel
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region INFO
|
||||||
|
|
||||||
private static bool ScanINFO(Message infoMessage, ExcelReader reader)
|
private static bool ScanINFO(Message infoMessage, ExcelReader reader)
|
||||||
{
|
{
|
||||||
if (infoMessage.Elements.Count == 0)
|
if (infoMessage.Elements.Count == 0)
|
||||||
@ -544,6 +713,8 @@ namespace ENI2.Excel
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
private static bool ScanHAZD(Message message, ExcelReader reader)
|
private static bool ScanHAZD(Message message, ExcelReader reader)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
@ -583,6 +583,8 @@ namespace ENI2.Excel
|
|||||||
{
|
{
|
||||||
if (boolString.Equals("TRUE", StringComparison.OrdinalIgnoreCase)) return true;
|
if (boolString.Equals("TRUE", StringComparison.OrdinalIgnoreCase)) return true;
|
||||||
if (boolString.Equals("FALSE", StringComparison.OrdinalIgnoreCase)) return false;
|
if (boolString.Equals("FALSE", StringComparison.OrdinalIgnoreCase)) return false;
|
||||||
|
if (boolString.Equals("YES", StringComparison.OrdinalIgnoreCase)) return true;
|
||||||
|
if (boolString.Equals("NO", StringComparison.OrdinalIgnoreCase)) return false;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else return null;
|
else return null;
|
||||||
@ -628,9 +630,12 @@ namespace ENI2.Excel
|
|||||||
if (dateString != null)
|
if (dateString != null)
|
||||||
{
|
{
|
||||||
CultureInfo provider = CultureInfo.InvariantCulture;
|
CultureInfo provider = CultureInfo.InvariantCulture;
|
||||||
const string format = "yyyy/MM/dd HH:mm";
|
const string dateTimeFormat = "yyyy/MM/dd HH:mm";
|
||||||
if (DateTime.TryParseExact(dateString, format, provider, DateTimeStyles.None, out DateTime tmpDate))
|
if (DateTime.TryParseExact(dateString, dateTimeFormat, provider, DateTimeStyles.None, out DateTime tmpDate))
|
||||||
return tmpDate;
|
return tmpDate;
|
||||||
|
const string dateFormat = "yyyy/MM/dd";
|
||||||
|
if (DateTime.TryParseExact(dateString, dateFormat, provider, DateTimeStyles.None, out DateTime tmpDate2))
|
||||||
|
return tmpDate2;
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user