Batch Excel import für PAS / CREW weiter.. Testversion 2

This commit is contained in:
Daniel Schick 2022-09-12 08:46:35 +02:00
parent 3c6201bad7
commit eb001c78bc
3 changed files with 97 additions and 113 deletions

View File

@ -36,7 +36,7 @@
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>7.5.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>

View File

@ -2,21 +2,9 @@
// Description: Dialog to confirm values during excel import (e.g. CREW/PAS)
//
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ENI2.Controls;
using System.Collections.Generic;
using System.Windows;
namespace ENI2.EditControls
{
@ -55,6 +43,7 @@ namespace ENI2.EditControls
private void EditWindowBase_Loaded(object sender, RoutedEventArgs e)
{
this.comboBoxValues.ItemsSource = this.SelectionValues;
this.comboBoxValues.Focus();
}
}
}

View File

@ -22,9 +22,9 @@ namespace ENI2.Excel
{
private static readonly ILog _log = LogManager.GetLogger(typeof(ExcelUtil));
private static Dictionary<string, string> _countryImportDict = new Dictionary<string, string>();
private static Dictionary<string, string> _genderImportDict = new Dictionary<string, string>();
private static Dictionary<string, string> _documentTypeImportDict = new Dictionary<string, string>();
private static readonly Dictionary<string, string> _countryImportDict = new Dictionary<string, string>();
private static readonly Dictionary<string, string> _genderImportDict = new Dictionary<string, string>();
private static readonly Dictionary<string, string> _documentTypeImportDict = new Dictionary<string, string>();
#region Process Sheet (normal BSMD sheet import)
@ -2067,7 +2067,7 @@ namespace ENI2.Excel
bool? notificationSchengen = reader.ReadBoolean("CREW.NotificationSchengen");
bool? notificationPax = reader.ReadBoolean("CREW.NotificationPAX");
for (int i = 0; i < 1000; i++)
for (int i = 0; i < 5000; i++)
{
string lastName = reader.ReadCellAsText(sheetTitle, string.Format("C{0}", i + 18));
@ -2115,56 +2115,52 @@ namespace ENI2.Excel
private static bool ScanCREWD(Message crewdMessage, ExcelReader reader)
{
crewdMessage.DeleteElements();
string sheetTitle = "7. CREW - Departure";
// CREW DEPARTURE
bool? notificationSchengen = reader.ReadBoolean("CREWD.NotificationSchengen");
bool? notificationPax = reader.ReadBoolean("CREWD.NotificationPAX");
for (int i = 0; i < crewdMessage.NumberOfExcelRows; i++)
for (int i = 0; i < 5000; i++)
{
string crewLastName = string.Format("CREWD.CrewMemberLastName_{0}", i + 1);
string crewFirstName = string.Format("CREWD.CrewMemberFirstName_{0}", i + 1);
string crewGender = string.Format("CREWD.CrewMemberGender_{0}", i + 1);
string crewNationality = string.Format("CREWD.CrewMemberNationality_{0}", i + 1);
string crewDuty = string.Format("CREWD.CrewMemberDuty_{0}", i + 1);
string crewPlaceOfBirth = string.Format("CREWD.CrewMemberPlaceOfBirth_{0}", i + 1);
string crewDateOfBirth = string.Format("CREWD.CrewMemberDateOfBirth_{0}", i + 1);
string crewIdentDocType = string.Format("CREWD.CrewMemberIdentityDocumentType_{0}", i + 1);
string crewIdentDocId = string.Format("CREWD.CrewMemberIdentityDocumentId_{0}", i + 1);
string crewVisaNo = string.Format("CREWD.CrewMemberVisaNumber_{0}", i + 1);
string crewIssuing = string.Format("CREWD.CrewMemberIdentityDocumentIssuingState_{0}", i + 1);
string crewIdentDocExpiry = string.Format("CREWD.CrewmemberIdentityDocumentExpiryDate_{0}", i + 1);
string crewCountryOfBirth = string.Format("CREWD.CountryOfBirth_{0}", i + 1);
string lastName = reader.ReadText(crewLastName);
if (!lastName.IsNullOrEmpty())
string lastName = reader.ReadCellAsText(sheetTitle, string.Format("C{0}", i + 18));
if (lastName.IsNullOrEmpty()) break;
if (!(crewdMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is CREWD crewd))
{
if (!(crewdMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is CREWD crew))
{
crew = new CREWD();
crew.IsDeparture = true;
crew.Identifier = (i + 1).ToString();
crew.MessageHeader = crewdMessage;
crewdMessage.Elements.Add(crew);
}
crew.IsDeparture = true;
crew.NotificationSchengen = notificationSchengen;
crew.NotificationPAX = notificationPax;
crew.CrewMemberLastName = lastName;
crew.CrewMemberFirstName = reader.ReadText(crewFirstName);
crew.CrewMemberGender = reader.ReadGender(crewGender);
crew.CrewMemberDuty = reader.ReadText(crewDuty);
crew.CrewMemberNationality = reader.ReadNationality(crewNationality);
crew.CrewMemberPlaceOfBirth = reader.ReadText(crewPlaceOfBirth);
crew.CrewMemberDateOfBirth = reader.ReadBirthDate(crewDateOfBirth);
crew.CrewMemberIdentityDocumentType = reader.ReadIdentityDocumentType(crewIdentDocType);
crew.CrewMemberIdentityDocumentId = reader.ReadText(crewIdentDocId);
crew.CrewMemberVisaNumber = reader.ReadText(crewVisaNo);
crew.CrewMemberIdentityDocumentIssuingState = reader.ReadNationality(crewIssuing);
crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadDate(crewIdentDocExpiry);
crew.CrewMemberCountryOfBirth = reader.ReadNationality(crewCountryOfBirth);
crewd = new CREWD();
crewd.Identifier = (i + 1).ToString();
crewd.MessageHeader = crewdMessage;
crewdMessage.Elements.Add(crewd);
}
crewd.NotificationSchengen = notificationSchengen;
crewd.NotificationPAX = notificationPax;
crewd.CrewMemberLastName = lastName;
crewd.CrewMemberFirstName = reader.ReadCellAsText(sheetTitle, string.Format("D{0}", i + 18));
crewd.CrewMemberGender = ReadGender(reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 18)));
crewd.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 18));
crewd.CrewMemberNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18)));
crewd.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 18));
crewd.CrewMemberCountryOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18));
crewd.CrewMemberDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("J{0}", i + 18));
crewd.CrewMemberIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 18)));
crewd.CrewMemberIdentityDocumentId = reader.ReadCellAsText(sheetTitle, string.Format("L{0}", i + 18));
crewd.CrewMemberVisaNumber = reader.ReadCellAsText(sheetTitle, string.Format("O{0}", i + 18));
crewd.CrewMemberIdentityDocumentIssuingState = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("M{0}", i + 18)));
if (crewd.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty())
crewd.CrewMemberIdentityDocumentIssuingState = "XX";
crewd.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("N{0}", i + 18));
if (!crewd.CrewMemberIdentityDocumentExpiryDate.HasValue)
crewd.CrewMemberIdentityDocumentExpiryDate = new DateTime(2100, 12, 31);
crewd.Effects = reader.ReadCellAsText("2. PORT", string.Format("C{0}", i + 142));
}
return true;
}
@ -2176,68 +2172,48 @@ namespace ENI2.Excel
private static bool ScanPAS(Message pasMessage, ExcelReader reader, bool isOldVersion)
{
pasMessage.DeleteElements();
string sheetTitle = "8. PAX - Arrival";
bool? notificationSchengen = reader.ReadBoolean("PAS.NotificationSchengen");
bool? notificationPax = reader.ReadBoolean("PAS.NotificationPAX");
for (int i = 0; i < pasMessage.NumberOfExcelRows; i++)
for (int i = 0; i < 5000; i++)
{
string pasLastName = string.Format("PAS.PassengerLastName_{0}", i + 1);
string pasFirstName = string.Format("PAS.PassengerFirstName_{0}", i + 1);
string pasGender = string.Format("PAS.PassengerGender_{0}", i + 1);
string pasNationality = string.Format("PAS.PassengerNationality_{0}", i + 1);
string pasEmbarkation = string.Format("PAS.PassengerPortOfEmbarkation_{0}", i + 1);
string pasDebarkation = string.Format("PAS.PassengerPortOfDisembarkation_{0}", i + 1);
string pasTransit = string.Format("PAS.PassengerInTransit_{0}", i + 1);
string pasPlaceOfBirth = string.Format("PAS.PassengerPlaceOfBirth_{0}", i + 1);
string pasDateOfBirth = string.Format("PAS.PassengerDateOfBirth_{0}", i + 1);
string pasIdentDocType = string.Format("PAS.PassengerIdentityDocumentType_{0}", i + 1);
string pasIdentDocId = string.Format("PAS.PassengerIdentityDocumentId_{0}", i + 1);
string pasVisaNo = string.Format("PAS.PassengerVisaNumber_{0}", i + 1);
string pasIssuing = string.Format("PAS.PassengerIdentityDocumentIssuingState_{0}", i + 1);
string pasExpiryDate = string.Format("PAS.PassengerIdentityDocumentExpiryDate_{0}", i + 1);
string pasCountryOfBirth = string.Format("PAS.CountryOfBirth_{0}", i + 1);
string pasEmergencyCare = string.Format("PAS.EmergencyCare_{0}", i + 1);
string pasEmergencyContact = string.Format("PAS.EmergencyContactNumber_{0}", i + 1);
string lastName = reader.ReadText(pasLastName);
string firstName = reader.ReadText(pasFirstName);
string lastName = reader.ReadCellAsText(sheetTitle, string.Format("C{0}", i + 17));
if (lastName.IsNullOrEmpty()) break;
if (!lastName.IsNullOrEmpty() || !firstName.IsNullOrEmpty())
if (!(pasMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is PAS pas))
{
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 = notificationSchengen;
pas.NotificationPAX = notificationPax;
pas.PassengerLastName = lastName;
pas.PassengerFirstName = firstName;
pas.PassengerGender = reader.ReadGender(pasGender);
pas.PassengerNationality = reader.ReadNationality(pasNationality);
// TODO: Nicht klar ob hier LOCODEs kommen oder nicht
pas.PassengerPortOfEmbarkation = reader.ReadLoCode(pasEmbarkation);
pas.PassengerPortOfDisembarkation = reader.ReadLoCode(pasDebarkation);
pas.PassengerInTransit = reader.ReadBoolean(pasTransit);
pas.PassengerPlaceOfBirth = reader.ReadText(pasPlaceOfBirth);
pas.PassengerDateOfBirth = reader.ReadBirthDate(pasDateOfBirth);
pas.PassengerIdentityDocumentType = reader.ReadIdentityDocumentType(pasIdentDocType);
pas.PassengerIdentityDocumentId = reader.ReadText(pasIdentDocId);
pas.PassengerVisaNumber = reader.ReadText(pasVisaNo);
pas.PassengerIdentityDocumentIssuingState = reader.ReadNationality(pasIssuing);
if (pas.PassengerIdentityDocumentIssuingState.IsNullOrEmpty() && isOldVersion)
pas.PassengerIdentityDocumentIssuingState = "XX";
pas.PassengerIdentityDocumentExpiryDate = reader.ReadDate(pasExpiryDate);
if (!pas.PassengerIdentityDocumentExpiryDate.HasValue && isOldVersion)
pas.PassengerIdentityDocumentExpiryDate = new DateTime(2100, 12, 31);
pas.PassengerCountryOfBirth = reader.ReadNationality(pasCountryOfBirth);
pas.EmergencyCare = reader.ReadText(pasEmergencyCare);
pas.EmergencyContactNumber = reader.ReadText(pasEmergencyContact);
pas = new PAS();
pas.Identifier = (i + 1).ToString();
pas.MessageHeader = pasMessage;
pasMessage.Elements.Add(pas);
}
pas.NotificationSchengen = notificationSchengen;
pas.NotificationPAX = notificationPax;
pas.PassengerLastName = lastName;
pas.PassengerFirstName = reader.ReadCellAsText(sheetTitle, string.Format("D{0}", i + 17));
pas.PassengerGender = ReadGender(reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 17)));
pas.PassengerPortOfEmbarkation = ReadLocode(reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 17)));
pas.PassengerPortOfDisembarkation = ReadLocode(reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 17)));
pas.PassengerInTransit = reader.ReadCellAsBool(sheetTitle, string.Format("H{0}", i + 17));
pas.PassengerNationality = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 17)));
pas.PassengerPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("J{0}", i + 17));
pas.PassengerCountryOfBirth = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("K{0}", i + 17)));
pas.PassengerDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("L{0}", i + 17));
pas.PassengerIdentityDocumentType = ReadDocumentType(reader.ReadCellAsText(sheetTitle, string.Format("M{0}", i + 17)));
pas.PassengerIdentityDocumentId = reader.ReadCellAsText(sheetTitle, string.Format("N{0}", i + 17));
pas.PassengerIdentityDocumentIssuingState = ReadNationality(reader.ReadCellAsText(sheetTitle, string.Format("O{0}", i + 17)));
pas.PassengerIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("P{0}", i + 17));
pas.PassengerVisaNumber = reader.ReadCellAsText(sheetTitle, string.Format("Q{0}", i + 17));
pas.EmergencyCare = reader.ReadCellAsText(sheetTitle, string.Format("R{0}", i + 17));
pas.EmergencyContactNumber = reader.ReadCellAsText(sheetTitle, string.Format("S{0}", i + 17));
}
return true;
@ -2533,6 +2509,25 @@ namespace ENI2.Excel
return result;
}
public static string ReadLocode(string val)
{
string result = null;
val = val.ToUpper();
string portName = LocodeDB.PortNameFromLocode(val);
if (portName.IsNullOrEmpty())
{
_log.WarnFormat("unknown Locode {0}", val);
val = "";
}
// reverse search: if this is a name lookup port code
// LocodeDB.LocodeFromCity() ??
return result;
}
#endregion
}