From 02f4c4397ce10c14a285a15d1cc9a47ecdc89341 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Sat, 22 Jan 2022 11:03:38 +0100 Subject: [PATCH] Refactorings, Bugfix IdentityDocumentType, Testversion 6.9.14 --- ENI2/ENI2.csproj | 2 +- ENI2/Excel/ExcelUtil.cs | 5 +- ENI2/Excel/ExcelWriter.cs | 21 +------- ENI2/Report/ReportDocument.cs | 50 +++++++++---------- bsmd.database/IMDGPosition.cs | 6 +-- bsmd.database/PAS.cs | 2 +- .../Properties/AssemblyProductInfo.cs | 2 +- .../Properties/AssemblyProjectInfo.cs | 2 +- bsmd.database/Util.cs | 5 +- 9 files changed, 36 insertions(+), 59 deletions(-) diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj index d1124d13..f9885464 100644 --- a/ENI2/ENI2.csproj +++ b/ENI2/ENI2.csproj @@ -37,7 +37,7 @@ true publish.html 0 - 6.9.13.0 + 6.9.14.0 false true true diff --git a/ENI2/Excel/ExcelUtil.cs b/ENI2/Excel/ExcelUtil.cs index 17466902..4ad75360 100644 --- a/ENI2/Excel/ExcelUtil.cs +++ b/ENI2/Excel/ExcelUtil.cs @@ -1253,10 +1253,7 @@ namespace ENI2.Excel bool? PortOfCallLast30DaysCrewMembersJoinedFlag = reader.ReadBoolean(crewJoined); string crewNameString = reader.ReadText(crewName); - if (!crewNameString.IsNullOrEmpty()) - poc30d.PortOfCallLast30DaysCrewMembersJoined = true; - else - poc30d.PortOfCallLast30DaysCrewMembersJoined = false; + poc30d.PortOfCallLast30DaysCrewMembersJoined = !crewNameString.IsNullOrEmpty(); if (poc30d.PortOfCallLast30DaysCrewMembersJoined ?? false) { diff --git a/ENI2/Excel/ExcelWriter.cs b/ENI2/Excel/ExcelWriter.cs index d671c050..b2aec87b 100644 --- a/ENI2/Excel/ExcelWriter.cs +++ b/ENI2/Excel/ExcelWriter.cs @@ -374,7 +374,7 @@ namespace ENI2.Excel WriteText(crewPlaceOfBirth, crew.CrewMemberPlaceOfBirth); if(crew.CrewMemberDateOfBirth.HasValue) WriteDate(crewDateOfBirth, crew.CrewMemberDateOfBirth.Value); - WriteIdentityDocumentType(crewIdentDocType, crew.CrewMemberIdentityDocumentType); + WriteText(crewIdentDocType, crew.CrewMemberIdentityDocumentTypeDisplay); WriteText(crewIdentDocId, crew.CrewMemberIdentityDocumentId); WriteText(crewVisaNo, crew.CrewMemberVisaNumber); } @@ -720,7 +720,7 @@ namespace ENI2.Excel WriteText(pasPlaceOfBirth, pas.PassengerPlaceOfBirth); if(pas.PassengerDateOfBirth.HasValue) WriteDate(pasDateOfBirth, pas.PassengerDateOfBirth); - WriteIdentityDocumentType(pasIdentDocType, pas.PassengerIdentityDocumentType); + WriteText(pasIdentDocType, pas.PassengerIdentityDocumentTypeDisplay); WriteText(pasIdentDocId, pas.PassengerIdentityDocumentId); WriteText(pasVisaNo, pas.PassengerVisaNumber); } @@ -1030,23 +1030,6 @@ namespace ENI2.Excel #region write simple things - private void WriteIdentityDocumentType(string label, byte? docType) - { - if(docType.HasValue) - { - switch(docType.Value) - { - case 1: WriteText(label, "identity_card"); break; - case 2: WriteText(label, "passport"); break; - case 3: WriteText(label, "muster_book"); break; - case 4: WriteText(label, "picture_id"); break; - case 5: WriteText(label, "residential_permit"); break; - case 6: WriteText(label, "other_legal_identity_document"); break; - default: WriteText(label, "ic"); break; - } - } - } - private void WriteGender(string label, byte? gender) { if(gender.HasValue) diff --git a/ENI2/Report/ReportDocument.cs b/ENI2/Report/ReportDocument.cs index 2d06dbf2..cf71511d 100644 --- a/ENI2/Report/ReportDocument.cs +++ b/ENI2/Report/ReportDocument.cs @@ -24,7 +24,7 @@ using System.Text; namespace ENI2.Report { - public class ReportDocument + public static class ReportDocument { private static Orientation _lastOrientation = Orientation.Portrait; @@ -37,11 +37,7 @@ namespace ENI2.Report { get { - if(_cargoCodesNST == null) - { - _cargoCodesNST = LocalizedLookup.getCargoCodesNST(); - } - return _cargoCodesNST; + return _cargoCodesNST ?? (_cargoCodesNST = LocalizedLookup.getCargoCodesNST()); } } @@ -171,7 +167,7 @@ namespace ENI2.Report style.ParagraphFormat.Font.Color = Colors.Blue; } - static void DefineSingleStyle(Document doc) + private static void DefineSingleStyle(Document doc) { Style style = doc.Styles["Normal"]; style.Font.Name = "Verdana"; @@ -213,7 +209,7 @@ namespace ENI2.Report #region Label DB - static List> ReplaceLabels(List> messageText) + private static List> ReplaceLabels(List> messageText) { if (messageText == null) return null; List> result = new List>(); @@ -227,7 +223,7 @@ namespace ENI2.Report return result; } - static string ReplaceTitle(string title) + private static string ReplaceTitle(string title) { if (LabelStorage.CollectionLabelDict.ContainsKey(title)) return LabelStorage.CollectionLabelDict[title]; @@ -375,7 +371,7 @@ namespace ENI2.Report #region Einzelne Seite in Landscape für CREW Meldung - if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.CREW)) + if (message?.MessageNotificationClass == Message.NotificationClass.CREW) { // Landscape if (_lastOrientation == Orientation.Portrait) @@ -400,7 +396,7 @@ namespace ENI2.Report #region Einzelne Seite in Landscape für PAS Meldung - if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.PAS)) + if (message?.MessageNotificationClass == Message.NotificationClass.PAS) { // Landscape if (_lastOrientation == Orientation.Portrait) @@ -425,7 +421,7 @@ namespace ENI2.Report #region Einzelne Seite in Landscape für TOWA Meldung - if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.TOWA)) + if (message?.MessageNotificationClass == Message.NotificationClass.TOWA) { // Landscape if (_lastOrientation == Orientation.Portrait) @@ -450,7 +446,7 @@ namespace ENI2.Report #region Einzelne Seite in Landscape für TOWD Meldung - if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.TOWD)) + if (message?.MessageNotificationClass == Message.NotificationClass.TOWD) { // Landscape if (_lastOrientation == Orientation.Portrait) @@ -516,7 +512,7 @@ namespace ENI2.Report #region Spezialbehandlung WAS Meldung - if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.WAS)) + if (message?.MessageNotificationClass == Message.NotificationClass.WAS) { ReportDocument.CreateWASTable(document, message); return; @@ -526,7 +522,7 @@ namespace ENI2.Report #region NOA_NOD - if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.NOA_NOD)) + if (message?.MessageNotificationClass == Message.NotificationClass.NOA_NOD) { NOA_NOD noa_nod = message.Elements[0] as NOA_NOD; @@ -580,7 +576,7 @@ namespace ENI2.Report #region BKRD - if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.BKRD)) + if (message?.MessageNotificationClass == Message.NotificationClass.BKRD) { ReportDocument.CreateBKRDTable(document, message); return; @@ -590,7 +586,7 @@ namespace ENI2.Report #region BKRA - if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.BKRA)) + if (message?.MessageNotificationClass == Message.NotificationClass.BKRA) { ReportDocument.CreateBKRATable(document, message); return; @@ -600,7 +596,7 @@ namespace ENI2.Report #region LADG - if((message != null) && (message.MessageNotificationClass == Message.NotificationClass.LADG)) + if(message?.MessageNotificationClass == Message.NotificationClass.LADG) { ReportDocument.CreateLADGTable(document, message); return; @@ -610,7 +606,7 @@ namespace ENI2.Report #region SERV - if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.SERV)) + if (message?.MessageNotificationClass == Message.NotificationClass.SERV) { ReportDocument.CreateSERVTable(document, message); return; @@ -623,7 +619,7 @@ namespace ENI2.Report #region SEC - if((message != null) && (message.MessageNotificationClass == Message.NotificationClass.SEC)) + if(message?.MessageNotificationClass == Message.NotificationClass.SEC) { ReportDocument.CreateLast10PortFacilitiesTable(document, message); ReportDocument.CreateShip2ShipActivitiesTable(document, message); @@ -634,7 +630,7 @@ namespace ENI2.Report #region BPOL - if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.BPOL)) + if (message?.MessageNotificationClass == Message.NotificationClass.BPOL) { ReportDocument.CreatePortOfItineraryTable(document, message); } @@ -643,7 +639,7 @@ namespace ENI2.Report #region MDH - if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.MDH)) + if (message?.MessageNotificationClass == Message.NotificationClass.MDH) { ReportDocument.CreateSanitaryMeasuresTable(document, message); ReportDocument.CreateInfectedAreaTable(document, message); @@ -819,7 +815,7 @@ namespace ENI2.Report for (int i = 0; i < mdh.PortOfCallLast30Days.Count; i++) { Row row = table.AddRow(); - ReportDocument.SetPoCLast30Days(((PortOfCallLast30Days) mdh.PortOfCallLast30Days[i]), row); + ReportDocument.SetPoCLast30Days((PortOfCallLast30Days) mdh.PortOfCallLast30Days[i], row); } } } @@ -1014,7 +1010,7 @@ namespace ENI2.Report for(int i=0;i 0) { @@ -2073,7 +2069,7 @@ namespace ENI2.Report #region Document helper - static Table AddGrayTable(Document aDocument) + private static Table AddGrayTable(Document aDocument) { Table table = aDocument.LastSection.AddTable(); table.Rows.VerticalAlignment = VerticalAlignment.Center; diff --git a/bsmd.database/IMDGPosition.cs b/bsmd.database/IMDGPosition.cs index ad14ca19..1bb638c4 100644 --- a/bsmd.database/IMDGPosition.cs +++ b/bsmd.database/IMDGPosition.cs @@ -452,9 +452,9 @@ namespace bsmd.database if (!(this.GeneralCargoIBC ?? false) && this.ContainerNumber.IsNullOrEmpty() && this.VehicleLicenseNumber.IsNullOrEmpty()) violations.Add(RuleEngine.CreateViolation(ValidationCode.V808, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD": "HAZA")); - if((this.NetQuantity_KGM.HasValue && this.NetQuantity_KGM.Value > 100000) || - (this.GrossQuantity_KGM.HasValue && this.GrossQuantity_KGM.Value > 100000) || - (this.Volume_MTQ.HasValue && this.Volume_MTQ.Value > 100)) + if((this.NetQuantity_KGM > 100000) || + (this.GrossQuantity_KGM > 100000) || + (this.Volume_MTQ > 100)) violations.Add(RuleEngine.CreateViolation(ValidationCode.V809, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); diff --git a/bsmd.database/PAS.cs b/bsmd.database/PAS.cs index 11767c37..14b4ff69 100644 --- a/bsmd.database/PAS.cs +++ b/bsmd.database/PAS.cs @@ -184,7 +184,7 @@ namespace bsmd.database } else { - scmd.Parameters.AddWithValue(@"ID", this.Id); + scmd.Parameters.AddWithValue("ID", this.Id); scmd.CommandText = string.Format("UPDATE {0} SET PassengerLastName = @P2, PassengerFirstName = @P3, " + "PassengerPlaceOfBirth = @P4, PassengerDateOfBirth = @P5, PassengerGender = @P6," + "PassengerNationality = @P7, PassengerIdentityDocumentType = @P8, PassengerIdentityDocumentId = @P9, " + diff --git a/bsmd.database/Properties/AssemblyProductInfo.cs b/bsmd.database/Properties/AssemblyProductInfo.cs index 47eecbe5..bd26a42f 100644 --- a/bsmd.database/Properties/AssemblyProductInfo.cs +++ b/bsmd.database/Properties/AssemblyProductInfo.cs @@ -2,6 +2,6 @@ [assembly: AssemblyCompany("schick Informatik")] [assembly: AssemblyProduct("BSMD NSW interface")] -[assembly: AssemblyInformationalVersion("6.9.13")] +[assembly: AssemblyInformationalVersion("6.9.14")] [assembly: AssemblyCopyright("Copyright © 2014-2022 schick Informatik")] [assembly: AssemblyTrademark("")] \ No newline at end of file diff --git a/bsmd.database/Properties/AssemblyProjectInfo.cs b/bsmd.database/Properties/AssemblyProjectInfo.cs index 6f4cf127..eacc2e50 100644 --- a/bsmd.database/Properties/AssemblyProjectInfo.cs +++ b/bsmd.database/Properties/AssemblyProjectInfo.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("6.9.13.*")] +[assembly: AssemblyVersion("6.9.14.*")] diff --git a/bsmd.database/Util.cs b/bsmd.database/Util.cs index 921769d3..a4c51e83 100644 --- a/bsmd.database/Util.cs +++ b/bsmd.database/Util.cs @@ -61,8 +61,9 @@ namespace bsmd.database case 1: return "Passport"; case 2: return "Muster book"; case 3: return "Picture ID"; - case 4: return "Residantal permit"; - default: return "Other legal identity document"; + case 4: return "Residental permit"; + case 5: return "Other legal identity document"; + default: return "unknown"; } } else