diff --git a/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs b/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs index 4e6f56df..f7f9ea1e 100644 --- a/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs +++ b/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs @@ -883,7 +883,7 @@ namespace ENI2.DetailViewControls if (obj is CREWD crewd) { // are you sure dialog is in base class - _crewMessage.Elements.Remove(crewd); + _crewdMessage.Elements.Remove(crewd); DBManager.Instance.Delete(crewd); } } diff --git a/ENI2/Excel/DakosyUtil.cs b/ENI2/Excel/DakosyUtil.cs index 98487058..cf0b01e8 100644 --- a/ENI2/Excel/DakosyUtil.cs +++ b/ENI2/Excel/DakosyUtil.cs @@ -4,7 +4,7 @@ using System; using System.Collections.Generic; - +using System.Linq; using bsmd.database; namespace ENI2.Excel @@ -740,34 +740,36 @@ namespace ENI2.Excel 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.PassengerCountryOfBirth = reader.NormalizeNationality(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.PassengerNationality = reader.NormalizeNationality(reader.ReadCellAsText("passenger departure", string.Format("H{0}", i + 16))); + pas.PassengerIdentityDocumentIssuingState = reader.NormalizeNationality(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) - //{ - 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)); - //} + + pas.EmergencyCare = reader.ReadCellAsText("passenger departure", string.Format("Q{0}", i + 16)); + pas.EmergencyContactNumber = reader.ReadCellAsText("passenger departure", string.Format("R{0}", i + 16)); + + 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)); if (pas.HasSchengenDetails) pas.NotificationSchengen = true; if (pas.HasPAXDetails) pas.NotificationPAX = true; result = true; } + + if(pasdMessage.Elements.Count >= 12) + { + foreach (PASD pasd in pasdMessage.Elements.Cast()) + pasd.NotificationPAX = true; + } + return result; } @@ -797,34 +799,36 @@ namespace ENI2.Excel 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.PassengerCountryOfBirth = reader.NormalizeNationality(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.PassengerNationality = reader.NormalizeNationality(reader.ReadCellAsText("passenger arrival", string.Format("H{0}", i + 16))); + pas.PassengerIdentityDocumentIssuingState = reader.NormalizeNationality(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)); - //} + + pas.EmergencyCare = reader.ReadCellAsText("passenger arrival", string.Format("Q{0}", i + 16)); + pas.EmergencyContactNumber = reader.ReadCellAsText("passenger arrival", string.Format("R{0}", i + 16)); + + 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)); + if (pas.HasSchengenDetails) pas.NotificationSchengen = true; if (pas.HasPAXDetails) pas.NotificationPAX = true; result = true; } + + if (pasMessage.Elements.Count >= 12) + { + foreach (PAS pasa in pasMessage.Elements.Cast()) + pasa.NotificationPAX = true; + } + return result; } @@ -1177,7 +1181,7 @@ namespace ENI2.Excel 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.CrewMemberCountryOfBirth = reader.NormalizeNationality(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); @@ -1189,7 +1193,7 @@ namespace ENI2.Excel 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.CrewMemberIdentityDocumentIssuingState = reader.NormalizeNationality(reader.ReadCellAsText("crew departure", string.Format("M{0}", i + 15))); crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("crew departure", string.Format("N{0}", i + 15)); } @@ -1226,21 +1230,18 @@ namespace ENI2.Excel 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.CrewMemberCountryOfBirth = reader.NormalizeNationality(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)); - //} + + 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.NormalizeNationality(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)); diff --git a/ENI2/Excel/ExcelReader.cs b/ENI2/Excel/ExcelReader.cs index bfac312f..ad0c4bff 100644 --- a/ENI2/Excel/ExcelReader.cs +++ b/ENI2/Excel/ExcelReader.cs @@ -285,6 +285,23 @@ namespace ENI2.Excel return val; } + /// + /// if nationality is read somewhere else (Dakosy?) check if it is ok + /// + internal string NormalizeNationality(string nationString) + { + if (nationString == null) return null; + if (nationString.Length < 2) return ""; + if(nationString.Length == 2) return nationString.ToUpper(); + string isoCode = LocodeDB.CountryCodeFromName(nationString); + if (isoCode == null) + { + _log.ErrorFormat("Wrong ISO code {0}", nationString); + return ""; + } + return isoCode; + } + internal byte? ReadHullConfiguration(string lookup) { string val = this.ReadText(lookup); diff --git a/ENI2/Excel/ExcelUtil.cs b/ENI2/Excel/ExcelUtil.cs index 80e01394..e6c2df49 100644 --- a/ENI2/Excel/ExcelUtil.cs +++ b/ENI2/Excel/ExcelUtil.cs @@ -2369,6 +2369,12 @@ namespace ENI2.Excel Util.UIHelper.SetBusyState(); // dialog might reset busy state } + + if(newPasList.Count >= 12) + { + foreach (PAS pas in newPasList) + pas.NotificationPAX = true; + } } else { @@ -2500,11 +2506,18 @@ namespace ENI2.Excel Util.UIHelper.SetBusyState(); // dialog might reset busy state } + + if (newPasList.Count >= 12) + { + foreach (PASD pasd in newPasList.Cast()) + pasd.NotificationPAX = true; + } + } DBManager.Instance.DeleteAllPASForMessage(pasMessage.Id); pasMessage.Elements.Clear(); - foreach (PASD pas in newPasList) + foreach (PASD pas in newPasList.Cast()) pasMessage.Elements.Add(pas); return true;