diff --git a/ENI-2/ENI2/ENI2/App.config b/ENI-2/ENI2/ENI2/App.config index ebb9b721..8fd27a4b 100644 --- a/ENI-2/ENI2/ENI2/App.config +++ b/ENI-2/ENI2/ENI2/App.config @@ -26,12 +26,12 @@ 1000 - http://192.168.2.4/LockingService/LockingService.svc - + + http://heupferd/bsmd.LockingService/LockingService.svc - Data Source=192.168.2.12;Initial Catalog=nsw;Uid=dfuser;Pwd=dfpasswd;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False - + + Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False diff --git a/ENI-2/ENI2/ENI2/App.xaml.cs b/ENI-2/ENI2/ENI2/App.xaml.cs index c9289697..4c4c46bf 100644 --- a/ENI-2/ENI2/ENI2/App.xaml.cs +++ b/ENI-2/ENI2/ENI2/App.xaml.cs @@ -82,6 +82,7 @@ namespace ENI2 List vFields = bsmd.database.ValidationRule.ValidationFields; RuleEngine.RegisterLocodeChecker(Util.GlobalStructures.IsValidLocode); RuleEngine.RegisterPortAreaChecker(LocalizedLookup.PortAreaExists); + RuleEngine.RegisterNationalityChecker(LocalizedLookup.CheckNationality); // Connect to locking service (if enabled) try @@ -108,8 +109,7 @@ namespace ENI2 private void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e) { - var dp = sender as DatePicker; - if (dp == null) return; + if (!(sender is DatePicker dp)) return; if (e.Key == Key.D && Keyboard.Modifiers == ModifierKeys.Control) { @@ -140,7 +140,6 @@ namespace ENI2 ResetSplashCreated.Set(); System.Windows.Threading.Dispatcher.Run(); - } - + } } } diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/WasteDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/WasteDetailControl.xaml.cs index d40d1e94..7af38dba 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/WasteDetailControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailViewControls/WasteDetailControl.xaml.cs @@ -24,7 +24,7 @@ namespace ENI2.DetailViewControls private Message _wasMessage; private WAS _was; - private static string[] _wasteDeliveryList = + private static readonly string[] _wasteDeliveryList = { "ALL", "SOME", @@ -144,8 +144,7 @@ namespace ENI2.DetailViewControls private void DataGridWaste_DeleteRequested(DatabaseEntity obj) { - Waste waste = obj as Waste; - if (waste != null) + if (obj is Waste waste) { // are you sure dialog is in base class _was.Waste.Remove(waste); diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj index 4c819638..fbe9d87d 100644 --- a/ENI-2/ENI2/ENI2/ENI2.csproj +++ b/ENI-2/ENI2/ENI2/ENI2.csproj @@ -35,8 +35,8 @@ 3.5.1.0 true publish.html - 1 - 5.1.4.%2a + 0 + 5.1.6.%2a false true true diff --git a/ENI-2/ENI2/ENI2/LocalizedLookup.cs b/ENI-2/ENI2/ENI2/LocalizedLookup.cs index a3253ab1..0a7d07fc 100644 --- a/ENI-2/ENI2/ENI2/LocalizedLookup.cs +++ b/ENI-2/ENI2/ENI2/LocalizedLookup.cs @@ -11,10 +11,11 @@ using bsmd.ExcelReadService; namespace ENI2 { - static class LocalizedLookup + internal static class LocalizedLookup { - private static SQLiteConnection _con; + private static readonly SQLiteConnection _con; private const string _locode_DB_NAME = "db.sqlite"; + private static Dictionary _nationalities = null; static LocalizedLookup() { @@ -71,6 +72,12 @@ namespace ENI2 return numResults > 0; } + public static bool CheckNationality(string nationality) + { + if (_nationalities == null) _nationalities = getNationalities(); + return _nationalities.ContainsKey(nationality); + } + public static Dictionary getNationalities() { Dictionary result = new Dictionary(); @@ -179,7 +186,7 @@ namespace ENI2 if (!reader.IsDBNull(0)) code = reader.GetString(0); if (!reader.IsDBNull(1)) description = reader.GetString(1); - if ((code != null) && (code.Length == 1)) + if (code?.Length == 1) code = string.Format("0{0}", code); // bei einstelligen Werten 0 voranstellen if ((code != null) && (description != null)) @@ -220,7 +227,7 @@ namespace ENI2 { List results = new List(); - string query = "SELECT LocationCode, LocationName FROM SSN_LOCODES WHERE LocationName like $PAR"; + const string query = "SELECT LocationCode, LocationName FROM SSN_LOCODES WHERE LocationName like $PAR"; SQLiteCommand cmd = new SQLiteCommand(query, _con); cmd.Parameters.AddWithValue("$PAR", city); IDataReader reader = cmd.ExecuteReader(); diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs index 4d2a9c47..f5616dd1 100644 --- a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs +++ b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs @@ -3708,7 +3708,7 @@ namespace ENI2.Properties { } /// - /// Looks up a localized string similar to Risks. + /// Looks up a localized string similar to Hazards. /// public static string textRisks { get { diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.resx b/ENI-2/ENI2/ENI2/Properties/Resources.resx index 73e214f0..9e7502cf 100644 --- a/ENI-2/ENI2/ENI2/Properties/Resources.resx +++ b/ENI-2/ENI2/ENI2/Properties/Resources.resx @@ -1298,7 +1298,7 @@ Radionuclide name - Risks + Hazards Stowage position diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index c23477cb..473b6e4e 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ diff --git a/nsw/Source/bsmd.ExcelReadService/Util.cs b/nsw/Source/bsmd.ExcelReadService/Util.cs index 8d18e72f..332aea21 100644 --- a/nsw/Source/bsmd.ExcelReadService/Util.cs +++ b/nsw/Source/bsmd.ExcelReadService/Util.cs @@ -1293,15 +1293,11 @@ namespace bsmd.ExcelReadService } WAS was = wasMessage.Elements[0] as WAS; was.DeleteElements(); + Util.ScanMessage(was, reader); + was.WasteDisposalDelivery = reader.ReadDelivery("WAS.WasteDisposalDelivery"); - if (was.LastWasteDisposalPort?.Length > 5) - { - string lastWasteDisposalPort = reader.ReadText("WAS.LastWasteDisposalPort"); - List deliveryLocodes = LocodeDB.AllLocodesForCityName(lastWasteDisposalPort); - if (deliveryLocodes.Count == 1) - was.LastWasteDisposalPort = deliveryLocodes[0]; - } + was.LastWasteDisposalPort = reader.ReadLoCode("WAS.LastWasteDisposalPort"); string wastedispServProvName = reader.ReadText("WAS.WasteDisposalServiceProviderName"); if (wastedispServProvName != null) diff --git a/nsw/Source/bsmd.database/CREW.cs b/nsw/Source/bsmd.database/CREW.cs index 23a2dc64..c7438f53 100644 --- a/nsw/Source/bsmd.database/CREW.cs +++ b/nsw/Source/bsmd.database/CREW.cs @@ -155,7 +155,7 @@ namespace bsmd.database } else { - scmd.Parameters.AddWithValue(@"ID", this.Id); + scmd.Parameters.AddWithValue("ID", this.Id); scmd.CommandText = string.Format("UPDATE {0} SET CrewMemberLastName = @P2, CrewMemberFirstName = @P3, " + "CrewMemberPlaceOfBirth = @P4, CrewMemberDateOfBirth = @P5, CrewMemberGender = @P6, CrewMemberNationality = @P7, "+ "CrewMemberIdentityDocumentType = @P8, CrewMemberIdentityDocumentId = @P9, CrewMemberVisaNumber = @P10, " + diff --git a/nsw/Source/bsmd.database/RuleEngine.cs b/nsw/Source/bsmd.database/RuleEngine.cs index ed67fa6f..5f7d75f2 100644 --- a/nsw/Source/bsmd.database/RuleEngine.cs +++ b/nsw/Source/bsmd.database/RuleEngine.cs @@ -106,12 +106,14 @@ namespace bsmd.database public delegate bool LocodeValidHandler(string locode, LocodeMode mode); public delegate bool PortAreaValidHandler(string locode, string portArea); + public delegate bool NationalityValidHandler(string nationality); private static readonly ILog log = LogManager.GetLogger(typeof(RuleEngine)); private static Dictionary errorTextList = null; private static Dictionary violationTextList = null; private static LocodeValidHandler _locodeChecker = null; private static PortAreaValidHandler _portAreaChecker = null; + private static NationalityValidHandler _nationalityChecker = null; public RuleEngine() { @@ -125,11 +127,14 @@ namespace bsmd.database public Dictionary> ViolationDict { get; } = new Dictionary>(); public static PortAreaValidHandler PortAreaChecker { get { return _portAreaChecker; } } + public static LocodeValidHandler LocodeChecker { get { return _locodeChecker; } } + public static NationalityValidHandler NationalityChecker { get { return _nationalityChecker; } } #region public static property validation public static void RegisterLocodeChecker(LocodeValidHandler handler) { _locodeChecker = handler; } public static void RegisterPortAreaChecker(PortAreaValidHandler handler) { _portAreaChecker = handler; } + public static void RegisterNationalityChecker(NationalityValidHandler handler) { _nationalityChecker = handler; } /// /// Test function checks decorated properties on an entity for errors (only errors, violations cannot @@ -271,9 +276,9 @@ namespace bsmd.database } break; case ValidationCode.FLAG_CODE: - { - Regex rgx = new Regex("[A-Z]{2}"); - if(!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); + { + if(!RuleEngine.NationalityChecker(value)) + errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.TWO_DIGIT: @@ -464,9 +469,7 @@ namespace bsmd.database public static bool IsGermanLocode(string val) { return gerLocodeList.Contains(val.ToUpper()); - } - - public static LocodeValidHandler LocodeChecker { get { return _locodeChecker; } } + } #endregion diff --git a/nsw/Source/bsmd.database/WAS.cs b/nsw/Source/bsmd.database/WAS.cs index 90dec340..b5529f20 100644 --- a/nsw/Source/bsmd.database/WAS.cs +++ b/nsw/Source/bsmd.database/WAS.cs @@ -43,8 +43,7 @@ namespace bsmd.database public bool? WasteDisposalValidExemption { get; set; } [ShowReport] - [Validation2(ValidationCode.LOCODE)] - [LookupName("WAS.LastWasteDisposalPort")] + [Validation2(ValidationCode.LOCODE)] [MaxLength(5)] [ENI2Validation] public string LastWasteDisposalPort { get; set; }