CREW/PAS Import Umbau nach Dakosy Style Part 1. Das wird noch nicht richtig funktionieren..

This commit is contained in:
Daniel Schick 2022-09-05 09:11:01 +02:00
parent 71000a4c24
commit 61d2ca7552
6 changed files with 85 additions and 59 deletions

View File

@ -6,6 +6,7 @@ using bsmd.database;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Net;
using System.Net.Http; using System.Net.Http;
using System.Windows; using System.Windows;
@ -64,8 +65,16 @@ namespace ENI2.EditControls
string link = (string)e.Data.GetData(DataFormats.Text); string link = (string)e.Data.GetData(DataFormats.Text);
if(link != null) if(link != null)
{ {
using (var client = new WebClient())
{
string fileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".xlsx";
client.DownloadFile(link, fileName);
}
/*
// check if it is really an url, try to download the file and open it // check if it is really an url, try to download the file and open it
if(Uri.TryCreate(link, UriKind.Absolute, out Uri uri)) if (Uri.TryCreate(link, UriKind.Absolute, out Uri uri))
{ {
HttpClient client = new HttpClient(); HttpClient client = new HttpClient();
var response = await client.GetAsync(uri); var response = await client.GetAsync(uri);
@ -78,6 +87,7 @@ namespace ENI2.EditControls
EnableCompareButton(); EnableCompareButton();
} }
} }
*/
} }
} }
} }

View File

@ -1233,21 +1233,21 @@ namespace ENI2.Excel
return result; return result;
} }
private static byte? ParseGender(string gender) internal static byte? ParseGender(string gender)
{ {
byte? result = null; byte? result = null;
if(!gender.IsNullOrEmpty()) if(!gender.IsNullOrEmpty())
{ {
if (gender.Equals("male", StringComparison.OrdinalIgnoreCase)) result = 1; if (gender.Equals("male", StringComparison.OrdinalIgnoreCase) || gender.Equals("m", StringComparison.OrdinalIgnoreCase)) result = 1;
if (gender.Equals("female", StringComparison.OrdinalIgnoreCase)) result = 2; if (gender.Equals("female", StringComparison.OrdinalIgnoreCase) || gender.Equals("f", StringComparison.OrdinalIgnoreCase)) result = 2;
if (gender.Equals("not_applicable", StringComparison.OrdinalIgnoreCase)) result = 9; if (gender.Equals("not_applicable", StringComparison.OrdinalIgnoreCase) || gender.Equals("n", StringComparison.OrdinalIgnoreCase)) result = 9;
if (gender.Equals("not_known", StringComparison.OrdinalIgnoreCase)) result = 0; if (gender.Equals("not_known", StringComparison.OrdinalIgnoreCase)) result = 0;
if (gender.Equals("other", StringComparison.OrdinalIgnoreCase)) result = 9; if (gender.Equals("other", StringComparison.OrdinalIgnoreCase) || gender.Equals("d", StringComparison.OrdinalIgnoreCase) || gender.Equals("diverse", StringComparison.OrdinalIgnoreCase)) result = 9;
} }
return result; return result;
} }
private static byte? ParseDocumentType(string docType) internal static byte? ParseDocumentType(string docType)
{ {
byte? result = null; byte? result = null;
if(!docType.IsNullOrEmpty()) if(!docType.IsNullOrEmpty())

View File

@ -4,10 +4,6 @@
using System; using System;
using System.IO; using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing; using System.Drawing;
using Microsoft.Office.Interop.Excel; using Microsoft.Office.Interop.Excel;

View File

@ -147,7 +147,6 @@ namespace ENI2.Excel
} }
else if (val.Equals("n", StringComparison.CurrentCultureIgnoreCase) || else if (val.Equals("n", StringComparison.CurrentCultureIgnoreCase) ||
val.Equals("not applicable", StringComparison.CurrentCultureIgnoreCase) || val.Equals("not applicable", StringComparison.CurrentCultureIgnoreCase) ||
val.Equals("not_applicable", StringComparison.CurrentCultureIgnoreCase) ||
val.Equals("d", StringComparison.CurrentCultureIgnoreCase) || val.Equals("d", StringComparison.CurrentCultureIgnoreCase) ||
val.Equals("diverse", StringComparison.CurrentCultureIgnoreCase)) val.Equals("diverse", StringComparison.CurrentCultureIgnoreCase))
{ {

View File

@ -2055,32 +2055,19 @@ namespace ENI2.Excel
private static bool ScanCREW(Message crewMessage, ExcelReader reader, bool isOldVersion) private static bool ScanCREW(Message crewMessage, ExcelReader reader, bool isOldVersion)
{ {
crewMessage.DeleteElements(); crewMessage.DeleteElements();
string sheetTitle = "6. CREW - Arrival";
// 6. CREW - Arrival
// 5.9.22: Changed this area to work like reading from a Dakosy Sheet (by values in rows, not cell names)
bool? notificationSchengen = reader.ReadBoolean("CREW.NotificationSchengen"); bool? notificationSchengen = reader.ReadBoolean("CREW.NotificationSchengen");
bool? notificationPax = reader.ReadBoolean("CREW.NotificationPAX"); bool? notificationPax = reader.ReadBoolean("CREW.NotificationPAX");
for (int i = 0; i < crewMessage.NumberOfExcelRows; i++) for (int i = 0; i < 1000; i++)
{ {
string crewLastName = string.Format("CREW.CrewMemberLastName_{0}", i + 1);
string crewFirstName = string.Format("CREW.CrewMemberFirstName_{0}", i + 1);
string crewGender = string.Format("CREW.CrewMemberGender_{0}", i + 1);
string crewNationality = string.Format("CREW.CrewMemberNationality_{0}", i + 1);
string crewDuty = string.Format("CREW.CrewMemberDuty_{0}", i + 1);
string crewPlaceOfBirth = string.Format("CREW.CrewMemberPlaceOfBirth_{0}", i + 1);
string crewDateOfBirth = string.Format("CREW.CrewMemberDateOfBirth_{0}", i + 1);
string crewIdentDocType = string.Format("CREW.CrewMemberIdentityDocumentType_{0}", i + 1);
string crewIdentDocId = string.Format("CREW.CrewMemberIdentityDocumentId_{0}", i + 1);
string crewVisaNo = string.Format("CREW.CrewMemberVisaNumber_{0}", i + 1);
string crewIssuing = string.Format("CREW.CrewMemberIdentityDocumentIssuingState_{0}", i + 1);
string crewIdentDocExpiry = string.Format("CREW.CrewmemberIdentityDocumentExpiryDate_{0}", i + 1);
string crewCountryOfBirth = string.Format("CREW.CountryOfBirth_{0}", i + 1);
string crewEffects = string.Format("CREW.Effects_{0}", i + 1);
string lastName = reader.ReadText(crewLastName); string lastName = reader.ReadCellAsText(sheetTitle, string.Format("C{0}", i + 18));
string firstName = reader.ReadText(crewFirstName); if (lastName.IsNullOrEmpty()) break;
if (!lastName.IsNullOrEmpty() || !firstName.IsNullOrEmpty())
{
if (!(crewMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is CREW crew)) if (!(crewMessage.GetSublistElementWithIdentifier((i + 1).ToString()) is CREW crew))
{ {
crew = new CREW(); crew = new CREW();
@ -2092,24 +2079,36 @@ namespace ENI2.Excel
crew.NotificationSchengen = notificationSchengen; crew.NotificationSchengen = notificationSchengen;
crew.NotificationPAX = notificationPax; crew.NotificationPAX = notificationPax;
crew.CrewMemberLastName = lastName; crew.CrewMemberLastName = lastName;
crew.CrewMemberFirstName = firstName; crew.CrewMemberFirstName = reader.ReadCellAsText(sheetTitle, string.Format("D{0}", i + 18));
crew.CrewMemberGender = reader.ReadGender(crewGender);
crew.CrewMemberDuty = reader.ReadText(crewDuty); string gender = reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 18));
crew.CrewMemberNationality = reader.ReadNationality(crewNationality); crew.CrewMemberGender = DakosyUtil.ParseGender(gender);
crew.CrewMemberPlaceOfBirth = reader.ReadText(crewPlaceOfBirth);
crew.CrewMemberDateOfBirth = reader.ReadBirthDate(crewDateOfBirth); if(!gender.IsNullOrEmpty() && !crew.CrewMemberGender.HasValue)
crew.CrewMemberIdentityDocumentType = reader.ReadIdentityDocumentType(crewIdentDocType); {
crew.CrewMemberIdentityDocumentId = reader.ReadText(crewIdentDocId); // special treatment / callback
crew.CrewMemberVisaNumber = reader.ReadText(crewVisaNo);
crew.CrewMemberIdentityDocumentIssuingState = reader.ReadNationality(crewIssuing); }
crew.CrewMemberDuty = reader.ReadCellAsText(sheetTitle, string.Format("F{0}", i + 18));
crew.CrewMemberNationality = reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18));
crew.CrewMemberPlaceOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("H{0}", i + 18));
crew.CrewMemberCountryOfBirth = reader.ReadCellAsText(sheetTitle, string.Format("G{0}", i + 18));
crew.CrewMemberDateOfBirth = reader.ReadCellAsDateTime(sheetTitle, string.Format("J{0}", i + 18));
string idDocType = reader.ReadCellAsText(sheetTitle, string.Format("I{0}", i + 18));
crew.CrewMemberIdentityDocumentType = DakosyUtil.ParseDocumentType(idDocType);
crew.CrewMemberIdentityDocumentId = reader.ReadCellAsText(sheetTitle, string.Format("L{0}", i + 18));
crew.CrewMemberVisaNumber = reader.ReadCellAsText(sheetTitle, string.Format("O{0}", i + 18));
crew.CrewMemberIdentityDocumentIssuingState = reader.ReadCellAsText(sheetTitle, string.Format("M{0}", i + 18));
if (crew.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty() && isOldVersion) if (crew.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty() && isOldVersion)
crew.CrewMemberIdentityDocumentIssuingState = "XX"; crew.CrewMemberIdentityDocumentIssuingState = "XX";
crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadDate(crewIdentDocExpiry); crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("N{0}", i + 18));
if (!crew.CrewMemberIdentityDocumentExpiryDate.HasValue && isOldVersion) if (!crew.CrewMemberIdentityDocumentExpiryDate.HasValue && isOldVersion)
crew.CrewMemberIdentityDocumentExpiryDate = new DateTime(2100, 12, 31); crew.CrewMemberIdentityDocumentExpiryDate = new DateTime(2100, 12, 31);
crew.CrewMemberCountryOfBirth = reader.ReadNationality(crewCountryOfBirth);
crew.Effects = reader.ReadText(crewEffects); crew.Effects = reader.ReadCellAsText("2. PORT", string.Format("C{0}", i + 142));
}
} }
return true; return true;

View File

@ -0,0 +1,22 @@
-- Some indices added during database optimization (Aug 22)
CREATE NONCLUSTERED INDEX IX_WAS_ID_WASTE ON [dbo].[Waste] ([WASId])
USE [nsw]
GO
SET ANSI_PADDING ON
GO
/****** Object: Index [IX_Visit_Transit_Core] Script Date: 25.08.2022 09:21:34 ******/
CREATE NONCLUSTERED INDEX [IX_Visit_Transit_Core] ON [dbo].[MessageCore]
(
[VisitId] ASC,
[TransitId] ASC
)
INCLUDE ( [QueryNSWStatus]) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, SORT_IN_TEMPDB = OFF, DROP_EXISTING = OFF, ONLINE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX IX_NOT_CLASS_MH ON [dbo].[MessageHeader] ([NotificationClass])