From 0fa6e1369066bbde881bc42a465720b1250b5795 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Thu, 16 Nov 2023 16:58:51 +0100 Subject: [PATCH] more fixes for import --- ENI2/ENI2.csproj | 2 +- ENI2/Excel/DakosyUtil.cs | 30 ++++++++++++++++++++---------- ENI2/Excel/ExcelReader.cs | 19 +------------------ bsmd.database/CREW.cs | 2 ++ bsmd.database/PAS.cs | 2 ++ 5 files changed, 26 insertions(+), 29 deletions(-) diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj index 7e80bd39..4f4ab7f8 100644 --- a/ENI2/ENI2.csproj +++ b/ENI2/ENI2.csproj @@ -36,7 +36,7 @@ 5.4.0.0 true publish.html - 4 + 5 7.2.0.%2a false true diff --git a/ENI2/Excel/DakosyUtil.cs b/ENI2/Excel/DakosyUtil.cs index 3552a131..9951e1b4 100644 --- a/ENI2/Excel/DakosyUtil.cs +++ b/ENI2/Excel/DakosyUtil.cs @@ -740,11 +740,14 @@ 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.NormalizeNationality(reader.ReadCellAsText("passenger departure", string.Format("E{0}", i + 16))); + pas.PassengerCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger departure", string.Format("E{0}", i + 16)), out bool canceled); + if (canceled) return false; 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.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.PassengerNationality = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger departure", string.Format("H{0}", i + 16)), out canceled); + if (canceled) return false; + pas.PassengerIdentityDocumentIssuingState = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger departure", string.Format("O{0}", i + 16)), out canceled); + if (canceled) return false; pas.PassengerIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("passenger departure", string.Format("P{0}", i + 16)); @@ -797,11 +800,14 @@ 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.NormalizeNationality(reader.ReadCellAsText("passenger arrival", string.Format("E{0}", i + 16))); + pas.PassengerCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger arrival", string.Format("E{0}", i + 16)), out bool canceled); + if (canceled) return false; 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.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.PassengerNationality = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger arrival", string.Format("H{0}", i + 16)), out canceled); + if(canceled) return false; + pas.PassengerIdentityDocumentIssuingState = ExcelUtil.ReadNationality(reader.ReadCellAsText("passenger arrival", string.Format("O{0}", i + 16)), out canceled); + if (!canceled) return false; pas.PassengerIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("passenger arrival", string.Format("P{0}", i + 16)); pas.EmergencyCare = reader.ReadCellAsText("passenger arrival", string.Format("Q{0}", i + 16)); @@ -1178,7 +1184,8 @@ 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.NormalizeNationality(reader.ReadCellAsText("crew departure", string.Format("E{0}", i + 15))); + crew.CrewMemberCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew departure", string.Format("E{0}", i + 15)), out bool canceled); + if (canceled) return false; 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); @@ -1190,7 +1197,8 @@ 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.NormalizeNationality(reader.ReadCellAsText("crew departure", string.Format("M{0}", i + 15))); + crew.CrewMemberIdentityDocumentIssuingState = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew departure", string.Format("M{0}", i + 15)), out canceled); + if (canceled) return false; crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime("crew departure", string.Format("N{0}", i + 15)); } @@ -1227,7 +1235,8 @@ 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.NormalizeNationality(reader.ReadCellAsText("crew arrival", string.Format("E{0}", i + 15))); + crew.CrewMemberCountryOfBirth = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew arrival", string.Format("E{0}", i + 15)), out bool canceled); + if (canceled) return false; 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); @@ -1237,7 +1246,8 @@ namespace ENI2.Excel 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.CrewMemberIdentityDocumentIssuingState = ExcelUtil.ReadNationality(reader.ReadCellAsText("crew arrival", string.Format("M{0}", i + 15)), out canceled); + if (canceled) return false; 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 ad0c4bff..07aa71fc 100644 --- a/ENI2/Excel/ExcelReader.cs +++ b/ENI2/Excel/ExcelReader.cs @@ -283,24 +283,7 @@ 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) { diff --git a/bsmd.database/CREW.cs b/bsmd.database/CREW.cs index fe27cc12..98aa3915 100644 --- a/bsmd.database/CREW.cs +++ b/bsmd.database/CREW.cs @@ -490,6 +490,8 @@ namespace bsmd.database cmd.CommandText = query; } + public override string Title => "CREWD"; + public override List LoadList(System.Data.IDataReader reader) { List result = new List(); diff --git a/bsmd.database/PAS.cs b/bsmd.database/PAS.cs index fe524fa1..bddd83ad 100644 --- a/bsmd.database/PAS.cs +++ b/bsmd.database/PAS.cs @@ -551,6 +551,8 @@ namespace bsmd.database cmd.CommandText = query; } + public override string Title => "PASD"; + public override List LoadList(System.Data.IDataReader reader) { List result = new List();