CREW/PAS Import Umbau nach Dakosy Style Part 1. Das wird noch nicht richtig funktionieren..
This commit is contained in:
parent
71000a4c24
commit
61d2ca7552
@ -6,6 +6,7 @@ using bsmd.database;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Windows;
|
||||
|
||||
@ -64,8 +65,16 @@ namespace ENI2.EditControls
|
||||
string link = (string)e.Data.GetData(DataFormats.Text);
|
||||
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
|
||||
if(Uri.TryCreate(link, UriKind.Absolute, out Uri uri))
|
||||
if (Uri.TryCreate(link, UriKind.Absolute, out Uri uri))
|
||||
{
|
||||
HttpClient client = new HttpClient();
|
||||
var response = await client.GetAsync(uri);
|
||||
@ -78,6 +87,7 @@ namespace ENI2.EditControls
|
||||
EnableCompareButton();
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1233,21 +1233,21 @@ namespace ENI2.Excel
|
||||
return result;
|
||||
}
|
||||
|
||||
private static byte? ParseGender(string gender)
|
||||
internal static byte? ParseGender(string gender)
|
||||
{
|
||||
byte? result = null;
|
||||
if(!gender.IsNullOrEmpty())
|
||||
{
|
||||
if (gender.Equals("male", StringComparison.OrdinalIgnoreCase)) result = 1;
|
||||
if (gender.Equals("female", StringComparison.OrdinalIgnoreCase)) result = 2;
|
||||
if (gender.Equals("not_applicable", StringComparison.OrdinalIgnoreCase)) result = 9;
|
||||
if (gender.Equals("male", StringComparison.OrdinalIgnoreCase) || gender.Equals("m", StringComparison.OrdinalIgnoreCase)) result = 1;
|
||||
if (gender.Equals("female", StringComparison.OrdinalIgnoreCase) || gender.Equals("f", StringComparison.OrdinalIgnoreCase)) result = 2;
|
||||
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("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;
|
||||
}
|
||||
|
||||
private static byte? ParseDocumentType(string docType)
|
||||
internal static byte? ParseDocumentType(string docType)
|
||||
{
|
||||
byte? result = null;
|
||||
if(!docType.IsNullOrEmpty())
|
||||
|
||||
@ -4,10 +4,6 @@
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Drawing;
|
||||
using Microsoft.Office.Interop.Excel;
|
||||
|
||||
|
||||
@ -146,8 +146,7 @@ namespace ENI2.Excel
|
||||
result = 2;
|
||||
}
|
||||
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("diverse", StringComparison.CurrentCultureIgnoreCase))
|
||||
{
|
||||
|
||||
@ -2055,61 +2055,60 @@ namespace ENI2.Excel
|
||||
private static bool ScanCREW(Message crewMessage, ExcelReader reader, bool isOldVersion)
|
||||
{
|
||||
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? 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 firstName = reader.ReadText(crewFirstName);
|
||||
string lastName = reader.ReadCellAsText(sheetTitle, string.Format("C{0}", i + 18));
|
||||
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.Identifier = (i + 1).ToString();
|
||||
crew.MessageHeader = crewMessage;
|
||||
crewMessage.Elements.Add(crew);
|
||||
}
|
||||
|
||||
crew.NotificationSchengen = notificationSchengen;
|
||||
crew.NotificationPAX = notificationPax;
|
||||
crew.CrewMemberLastName = lastName;
|
||||
crew.CrewMemberFirstName = firstName;
|
||||
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);
|
||||
if (crew.CrewMemberIdentityDocumentIssuingState.IsNullOrEmpty() && isOldVersion)
|
||||
crew.CrewMemberIdentityDocumentIssuingState = "XX";
|
||||
crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadDate(crewIdentDocExpiry);
|
||||
if (!crew.CrewMemberIdentityDocumentExpiryDate.HasValue && isOldVersion)
|
||||
crew.CrewMemberIdentityDocumentExpiryDate = new DateTime(2100, 12, 31);
|
||||
crew.CrewMemberCountryOfBirth = reader.ReadNationality(crewCountryOfBirth);
|
||||
crew.Effects = reader.ReadText(crewEffects);
|
||||
crew = new CREW();
|
||||
crew.Identifier = (i + 1).ToString();
|
||||
crew.MessageHeader = crewMessage;
|
||||
crewMessage.Elements.Add(crew);
|
||||
}
|
||||
|
||||
crew.NotificationSchengen = notificationSchengen;
|
||||
crew.NotificationPAX = notificationPax;
|
||||
crew.CrewMemberLastName = lastName;
|
||||
crew.CrewMemberFirstName = reader.ReadCellAsText(sheetTitle, string.Format("D{0}", i + 18));
|
||||
|
||||
string gender = reader.ReadCellAsText(sheetTitle, string.Format("E{0}", i + 18));
|
||||
crew.CrewMemberGender = DakosyUtil.ParseGender(gender);
|
||||
|
||||
if(!gender.IsNullOrEmpty() && !crew.CrewMemberGender.HasValue)
|
||||
{
|
||||
// special treatment / callback
|
||||
|
||||
}
|
||||
|
||||
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)
|
||||
crew.CrewMemberIdentityDocumentIssuingState = "XX";
|
||||
crew.CrewMemberIdentityDocumentExpiryDate = reader.ReadCellAsDateTime(sheetTitle, string.Format("N{0}", i + 18));
|
||||
if (!crew.CrewMemberIdentityDocumentExpiryDate.HasValue && isOldVersion)
|
||||
crew.CrewMemberIdentityDocumentExpiryDate = new DateTime(2100, 12, 31);
|
||||
|
||||
crew.Effects = reader.ReadCellAsText("2. PORT", string.Format("C{0}", i + 142));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
22
SQL/Optimization_Indices.sql
Normal file
22
SQL/Optimization_Indices.sql
Normal 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])
|
||||
Loading…
Reference in New Issue
Block a user