From a70e5024eec3760896613a8962f79bea5df0aa08 Mon Sep 17 00:00:00 2001 From: Daniel Schick Date: Sun, 19 Nov 2017 18:09:22 +0000 Subject: [PATCH] =?UTF-8?q?Aktueller=20Stand=20f=C3=BCr=20eine=20neue=20Wo?= =?UTF-8?q?che=20(mit=20Validierungs-Check=20der=20Meldeklassen=20auf=20"S?= =?UTF-8?q?USPEND"=20setzt)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ENI-2/ENI2/ENI2/App.config | 8 +-- ENI-2/ENI2/ENI2/DetailBaseControl.cs | 12 +++- ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs | 57 ++++++++++++++----- .../OverViewDetailControl.xaml.cs | 1 + ENI-2/ENI2/ENI2/ENI2.csproj | 4 +- .../ENI2/EditControls/ErrorListDialog.xaml | 8 ++- .../EditControls/ViolationListDialog.xaml | 9 ++- .../ENI2/Properties/Resources.Designer.cs | 9 +++ ENI-2/ENI2/ENI2/Properties/Resources.resx | 3 + .../bsmd.LockingService/ServerStatus.cs | 29 ++++++++++ .../bsmd.LockingService.csproj | 1 + nsw/Source/bsmd.database/IBCPosition.cs | 2 +- nsw/Source/bsmd.database/IMDGPosition.cs | 4 +- nsw/Source/bsmd.database/LADG.cs | 2 +- .../LastTenPortFacilitiesCalled.cs | 2 +- .../bsmd.database/MARPOL_Annex_I_Position.cs | 3 +- nsw/Source/bsmd.database/MDH.cs | 16 +++--- nsw/Source/bsmd.database/MessageError.cs | 4 ++ nsw/Source/bsmd.database/MessageViolation.cs | 4 ++ nsw/Source/bsmd.database/PAS.cs | 4 +- nsw/Source/bsmd.database/PRE72H.cs | 4 +- .../bsmd.database/PortOfCallLast30Days.cs | 2 +- nsw/Source/bsmd.database/RuleEngine.cs | 52 +++++++++++------ nsw/Source/bsmd.database/SEC.cs | 4 +- nsw/Source/bsmd.database/STAT.cs | 2 +- ...vitiesDuringLastTenPortFacilitiesCalled.cs | 2 +- nsw/Source/bsmd.database/Waste.cs | 2 +- 27 files changed, 180 insertions(+), 70 deletions(-) create mode 100644 nsw/Source/bsmd.LockingService/ServerStatus.cs diff --git a/ENI-2/ENI2/ENI2/App.config b/ENI-2/ENI2/ENI2/App.config index 77790c5b..59067348 100644 --- a/ENI-2/ENI2/ENI2/App.config +++ b/ENI-2/ENI2/ENI2/App.config @@ -26,12 +26,12 @@ 1000 - - http://heupferd/bsmd.LockingService/LockingService.svc + http://192.168.2.4/LockingService/LockingService.svc + - - Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False + Data Source=192.168.2.12;Initial Catalog=nsw;Uid=dfuser;Pwd=dfpasswd;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False + diff --git a/ENI-2/ENI2/ENI2/DetailBaseControl.cs b/ENI-2/ENI2/ENI2/DetailBaseControl.cs index 669f0dd7..9a00551e 100644 --- a/ENI-2/ENI2/ENI2/DetailBaseControl.cs +++ b/ENI-2/ENI2/ENI2/DetailBaseControl.cs @@ -62,10 +62,15 @@ namespace ENI2 public event Action RequestReload; /// - /// Damit kann ein Listenelement eine Validierung der gesamten Anmeldung auslösen (inkl. Highlighting) + /// Damit kann ein Listenelement eine Validierung der gesamten Anmeldung auslösen (inkl. Highlighting) (auf Knopfdruck) /// public event Action RequestValidate; + /// + /// Alle Meldeklassen die auf "zu versenden" stehen werden validiert und falls die Validierung scheitert auf "SUSPEND" gestellt + /// + public event Action RequestSendValidation; + /// /// Damit kann signalisiert werden, dass die Anmeldung readonly wird (z.B. bei Storno) /// @@ -150,6 +155,11 @@ namespace ENI2 this.RequestValidate?.Invoke(); } + protected virtual void OnRequestSendValidation() + { + this.RequestSendValidation?.Invoke(); + } + protected virtual void OnRequestDisable() { this.RequestDisable?.Invoke(); diff --git a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs index dc11b925..b8bb7e2d 100644 --- a/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailRootControl.xaml.cs @@ -139,6 +139,7 @@ namespace ENI2 detailControl.ResetControlCache += DetailControl_ResetControlCache; detailControl.RequestValidate += DetailControl_RequestValidate; detailControl.RequestDisable += DetailControl_RequestDisable; + detailControl.RequestSendValidation += DetailControl_RequestSendValidation; detailControl.Initialize(); bool isEnabled = !this.LockedByOtherUser; @@ -171,7 +172,7 @@ namespace ENI2 detailView.Children.Add(controlCache[mg.MessageGroupName]); } - } + } private void DetailControl_RequestDisable() { @@ -346,7 +347,31 @@ namespace ENI2 this.OnHighlightReset(); } + private void DetailControl_RequestSendValidation() + { + this.Validate(false); + foreach(Message aMessage in this._messages) + { + if(aMessage.InternalStatus == Message.BSMDStatus.TOSEND) + { + foreach(MessageError messageError in this._vErrors) + { + if(messageError.NotificationClass == aMessage.MessageNotificationClassDisplay) + { + aMessage.InternalStatus = Message.BSMDStatus.SUSPENDED; + aMessage.StatusInfo = string.Format("Validation error: {0}", messageError.ErrorText); + } + } + } + } + } + private void DetailControl_RequestValidate() + { + this.Validate(true); + } + + private void Validate(bool showMessages) { this._vErrors.Clear(); this._vViolations.Clear(); @@ -412,23 +437,25 @@ namespace ENI2 } } - // Show error and violation dialog - if(this._vErrors.Count > 0) + if (showMessages) { - ErrorListDialog eld = new ErrorListDialog(); - eld.IsModal = false; - eld.Errors = this._vErrors; - eld.Show(); - } + // Show error and violation dialog + if (this._vErrors.Count > 0) + { + ErrorListDialog eld = new ErrorListDialog(); + eld.IsModal = false; + eld.Errors = this._vErrors; + eld.Show(); + } - if(this._vViolations.Count > 0) - { - ViolationListDialog vld = new ViolationListDialog(); - vld.IsModal = false; - vld.Violations = this._vViolations; - vld.Show(); + if (this._vViolations.Count > 0) + { + ViolationListDialog vld = new ViolationListDialog(); + vld.IsModal = false; + vld.Violations = this._vViolations; + vld.Show(); + } } - } #endregion diff --git a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs index ab9a6175..f46576d4 100644 --- a/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs +++ b/ENI-2/ENI2/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs @@ -457,6 +457,7 @@ namespace ENI2.DetailViewControls this.Core.DefaultReportingPartyId = App.UserId; DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(this.Core); + this.OnRequestSendValidation(); this.dataGridMessages.Items.Refresh(); } } diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj index 5c38a899..bed34011 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 - 3.8.6.%2a + 0 + 3.8.7.%2a false true true diff --git a/ENI-2/ENI2/ENI2/EditControls/ErrorListDialog.xaml b/ENI-2/ENI2/ENI2/EditControls/ErrorListDialog.xaml index c5041d02..78fc0d3f 100644 --- a/ENI-2/ENI2/ENI2/EditControls/ErrorListDialog.xaml +++ b/ENI-2/ENI2/ENI2/EditControls/ErrorListDialog.xaml @@ -15,9 +15,11 @@ - - - + + + + + diff --git a/ENI-2/ENI2/ENI2/EditControls/ViolationListDialog.xaml b/ENI-2/ENI2/ENI2/EditControls/ViolationListDialog.xaml index 897be7f3..2beb993c 100644 --- a/ENI-2/ENI2/ENI2/EditControls/ViolationListDialog.xaml +++ b/ENI-2/ENI2/ENI2/EditControls/ViolationListDialog.xaml @@ -8,7 +8,7 @@ xmlns:p="clr-namespace:ENI2.Properties" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" mc:Ignorable="d" - Title="{x:Static p:Resources.textViolations}" Height="300" Width="600" Background="AliceBlue"> + Title="{x:Static p:Resources.textViolations}" Height="300" Width="600" Background="AliceBlue" Icon="/ENI2;component/Resources/bullet_ball_yellow.ico"> @@ -20,8 +20,11 @@ - - + + + + + diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs index 75cf0f87..c882068e 100644 --- a/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs +++ b/ENI-2/ENI2/ENI2/Properties/Resources.Designer.cs @@ -1157,6 +1157,15 @@ namespace ENI2.Properties { } } + /// + /// Looks up a localized string similar to Class. + /// + public static string textClass { + get { + return ResourceManager.GetString("textClass", resourceCulture); + } + } + /// /// Looks up a localized string similar to Clear. /// diff --git a/ENI-2/ENI2/ENI2/Properties/Resources.resx b/ENI-2/ENI2/ENI2/Properties/Resources.resx index 9c68af82..6dcefee5 100644 --- a/ENI-2/ENI2/ENI2/Properties/Resources.resx +++ b/ENI-2/ENI2/ENI2/Properties/Resources.resx @@ -1585,4 +1585,7 @@ Sent by + + Class + \ No newline at end of file diff --git a/nsw/Source/bsmd.LockingService/ServerStatus.cs b/nsw/Source/bsmd.LockingService/ServerStatus.cs new file mode 100644 index 00000000..1bdf54a1 --- /dev/null +++ b/nsw/Source/bsmd.LockingService/ServerStatus.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2017 schick Informatik +// Description: Struktur zur Rückgabe der aktuellen Serverstatistik + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; + +namespace bsmd.LockingService +{ + public class ServerStatus + { + /// + /// Flag zeigt an ob ExcelReader läuft + /// + public bool? Excel { get; set; } + + /// + /// Flag zeigt an, ob NSWSendService läuft + /// + public bool? Transmitter { get; set; } + + /// + /// Flag zeigt an, ob ReportServer läuft + /// + public bool? Report { get; set; } + + } +} \ No newline at end of file diff --git a/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj b/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj index 866a08e7..edf1b003 100644 --- a/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj +++ b/nsw/Source/bsmd.LockingService/bsmd.LockingService.csproj @@ -89,6 +89,7 @@ + diff --git a/nsw/Source/bsmd.database/IBCPosition.cs b/nsw/Source/bsmd.database/IBCPosition.cs index a0aa4d05..a526c4aa 100644 --- a/nsw/Source/bsmd.database/IBCPosition.cs +++ b/nsw/Source/bsmd.database/IBCPosition.cs @@ -249,7 +249,7 @@ namespace bsmd.database { if (this.FlashpointInformation.HasValue && (this.FlashpointInformation.Value == 2) && this.Flashpoint_CEL.IsNullOrEmpty()) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V804, "Flashpoint_CEL", null, this.Title, this.Identifier)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V804, "Flashpoint_CEL", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); } #endregion diff --git a/nsw/Source/bsmd.database/IMDGPosition.cs b/nsw/Source/bsmd.database/IMDGPosition.cs index d6eb413f..acabe840 100644 --- a/nsw/Source/bsmd.database/IMDGPosition.cs +++ b/nsw/Source/bsmd.database/IMDGPosition.cs @@ -435,10 +435,10 @@ namespace bsmd.database { if (!this.NetQuantity_KGM.HasValue && !this.GrossQuantity_KGM.HasValue && !this.Volume_MTQ.HasValue) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V802, null, null, this.Title, this.Identifier)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V802, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA")); if ((this.GeneralCargoIBC ?? false) && this.ContainerNumber.IsNullOrEmpty() && this.VehicleLicenseNumber.IsNullOrEmpty()) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V808, null, null, this.Title, this.Identifier)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V808, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD": "HAZA")); foreach (SubsidiaryRisks sr in this.SubsidiaryRiskList) RuleEngine.ValidateProperties(sr, errors); diff --git a/nsw/Source/bsmd.database/LADG.cs b/nsw/Source/bsmd.database/LADG.cs index 968c7dda..ebbff642 100644 --- a/nsw/Source/bsmd.database/LADG.cs +++ b/nsw/Source/bsmd.database/LADG.cs @@ -224,7 +224,7 @@ namespace bsmd.database (this.CargoCodeNST.Equals("11") || this.CargoCodeNST.Equals("12") || this.CargoCodeNST.Equals("16") || this.CargoCodeNST.Equals("19")) && !this.CargoNumberOfItems.HasValue) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V721, "CargoNumberOfItems" , null, this.Title, this.Identifier)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V721, "CargoNumberOfItems" , null, this.Title, this.Identifier, this.Tablename)); } #endregion diff --git a/nsw/Source/bsmd.database/LastTenPortFacilitiesCalled.cs b/nsw/Source/bsmd.database/LastTenPortFacilitiesCalled.cs index 2249a476..96a64720 100644 --- a/nsw/Source/bsmd.database/LastTenPortFacilitiesCalled.cs +++ b/nsw/Source/bsmd.database/LastTenPortFacilitiesCalled.cs @@ -168,7 +168,7 @@ namespace bsmd.database { string val = string.Format("LoCode:{0} Port:{1} Country:{2}", this.PortFacilityPortLoCode ?? "", this.PortFacilityPortName ?? "", this.PortFacilityPortCountry ?? ""); - RuleEngine.CreateViolation(ValidationCode.V703, null, val, this.Title, this.Identifier); + RuleEngine.CreateViolation(ValidationCode.V703, null, val, this.Title, this.Identifier, this.SEC.Tablename); } } diff --git a/nsw/Source/bsmd.database/MARPOL_Annex_I_Position.cs b/nsw/Source/bsmd.database/MARPOL_Annex_I_Position.cs index 548d5461..e38d018d 100644 --- a/nsw/Source/bsmd.database/MARPOL_Annex_I_Position.cs +++ b/nsw/Source/bsmd.database/MARPOL_Annex_I_Position.cs @@ -175,7 +175,8 @@ namespace bsmd.database { if (this.FlashpointInformation.HasValue && (this.FlashpointInformation.Value == 2) && this.Flashpoint_CEL.IsNullOrEmpty()) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V804, "Flashpoint_CEL", null, this.Title, this.Identifier)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V804, "Flashpoint_CEL", null, this.Title, this.Identifier, + this.HAZ.IsDeparture ? "HAZD" : "HAZA")); } #endregion diff --git a/nsw/Source/bsmd.database/MDH.cs b/nsw/Source/bsmd.database/MDH.cs index ad66f240..33db3209 100644 --- a/nsw/Source/bsmd.database/MDH.cs +++ b/nsw/Source/bsmd.database/MDH.cs @@ -523,36 +523,36 @@ namespace bsmd.database if (this.GetValidationBlock() == ValidationBlock.BLOCK1) { if (this.PortOfCallWhereCompleteMDHNotified.IsNullOrEmpty()) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V768, "PortOfCallWhereCompleteMDHNotified missing", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V768, "PortOfCallWhereCompleteMDHNotified missing", null, this.Title, null, this.Tablename)); } else { if ((this.NonAccidentalDeathsDuringVoyage ?? false) && ((this.NonAccidentalDeathsDuringVoyageCount ?? 0) == 0)) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V761, "NonAccidentalDeathsDuringVoyageCount missing", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V761, "NonAccidentalDeathsDuringVoyageCount missing", null, this.Title, null, this.Tablename)); if ((this.NumberOfIllPersonsHigherThanExpected ?? false) && ((this.NumberOfIllPersons ?? 0) == 0)) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V762, "Number of ill persons missing", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V762, "Number of ill persons missing", null, this.Title, null, this.Tablename)); if ((this.SanitaryMeasuresApplied ?? false) && ( this.SanitaryMeasuresType.IsNullOrEmpty() || !this.SanitaryMeasuresDate.HasValue || this.SanitaryMeasuresLocation.IsNullOrEmpty())) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V763, "Sanitary measure details missing", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V763, "Sanitary measure details missing", null, this.Title, null, this.Tablename)); if ((this.StowawaysDetected ?? false) && this.StowawaysJoiningLocation.IsNullOrEmpty()) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V764, "Stowaways joining location missing", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V764, "Stowaways joining location missing", null, this.Title, null, this.Tablename)); if ((this.ValidSanitaryControlExemptionOrCertificateOnBoard ?? false) && (this.PlaceOfIssue.IsNullOrEmpty() || !this.DateOfIssue.HasValue)) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V765, "Cert. Place or Date of issue missing", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V765, "Cert. Place or Date of issue missing", null, this.Title, null, this.Tablename)); if ((this.InfectedAreaVisited ?? false) && (!this.InfectedAreaDate.HasValue || this.InfectedAreaPort.IsNullOrEmpty())) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V766, "Infected area date or port missing", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V766, "Infected area date or port missing", null, this.Title, null, this.Tablename)); if (this.portOfCallLast30Days.Count == 0) { - errors.Add(RuleEngine.CreateError(ValidationCode.NOT_NULL, "Port of Call last 30 day list is EMPTY", null, this.Title, null)); + errors.Add(RuleEngine.CreateError(ValidationCode.NOT_NULL, "Port of Call last 30 day list is EMPTY", null, this.Title, null, this.Tablename)); } foreach (PortOfCallLast30Days poc30d in this.portOfCallLast30Days) diff --git a/nsw/Source/bsmd.database/MessageError.cs b/nsw/Source/bsmd.database/MessageError.cs index 1c3bf173..b2d71961 100644 --- a/nsw/Source/bsmd.database/MessageError.cs +++ b/nsw/Source/bsmd.database/MessageError.cs @@ -38,6 +38,10 @@ namespace bsmd.database public string MessageGroupName { get; set; } + public string NotificationClass { get; set; } + + public string Identifier { get; set; } + #endregion #region IDatabaseEntity implementation diff --git a/nsw/Source/bsmd.database/MessageViolation.cs b/nsw/Source/bsmd.database/MessageViolation.cs index 1c2a0c87..e126caf2 100644 --- a/nsw/Source/bsmd.database/MessageViolation.cs +++ b/nsw/Source/bsmd.database/MessageViolation.cs @@ -36,6 +36,10 @@ namespace bsmd.database public string MessageGroupName { get; set; } + public string NotificationClass { get; set; } + + public string Identifier { get; set; } + #endregion #region DatabaseEntity implementation diff --git a/nsw/Source/bsmd.database/PAS.cs b/nsw/Source/bsmd.database/PAS.cs index 18a11b89..b61a853e 100644 --- a/nsw/Source/bsmd.database/PAS.cs +++ b/nsw/Source/bsmd.database/PAS.cs @@ -238,13 +238,13 @@ namespace bsmd.database if (this.PassengerPortOfDisembarkation != null) { if (this.PassengerPortOfDisembarkation.Equals("ZZUKN")) - violations.Add(RuleEngine.CreateViolation(ValidationCode.NOT_NULL, "PassengerPortOfDisembarkation", null, this.Title, this.Identifier)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.NOT_NULL, "PassengerPortOfDisembarkation", null, this.Title, this.Identifier, this.Tablename)); } if (this.PassengerPortOfEmbarkation != null) { if (this.PassengerPortOfEmbarkation.Equals("ZZUKN")) - violations.Add(RuleEngine.CreateViolation(ValidationCode.NOT_NULL, "PassengerPortOfEmbarkation", null, this.Title, this.Identifier)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.NOT_NULL, "PassengerPortOfEmbarkation", null, this.Title, this.Identifier, this.Tablename)); } } diff --git a/nsw/Source/bsmd.database/PRE72H.cs b/nsw/Source/bsmd.database/PRE72H.cs index 9e84a726..167c0903 100644 --- a/nsw/Source/bsmd.database/PRE72H.cs +++ b/nsw/Source/bsmd.database/PRE72H.cs @@ -185,9 +185,9 @@ namespace bsmd.database if (this.Tanker ?? false) { if (!this.TankerHullConfiguration.HasValue) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V741, "TankerHullConfiguration", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V741, "TankerHullConfiguration", null, this.Title, null, this.Tablename)); if (!this.ConditionCargoBallastTanks.HasValue) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V741, "ConditionCargoBallastTanks", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V741, "ConditionCargoBallastTanks", null, this.Title, null, this.Tablename)); } } diff --git a/nsw/Source/bsmd.database/PortOfCallLast30Days.cs b/nsw/Source/bsmd.database/PortOfCallLast30Days.cs index d00b7680..7c7b2067 100644 --- a/nsw/Source/bsmd.database/PortOfCallLast30Days.cs +++ b/nsw/Source/bsmd.database/PortOfCallLast30Days.cs @@ -247,7 +247,7 @@ namespace bsmd.database public override void Validate(List errors, List violations) { if((this.PortOfCallLast30DaysCrewMembersJoined ?? false) && (this.CrewJoinedShip.Count == 0)) - RuleEngine.CreateViolation(ValidationCode.V767, "PortOfCallLast30DaysCrewMembersJoined", null, this.Title, this.Identifier); + RuleEngine.CreateViolation(ValidationCode.V767, "PortOfCallLast30DaysCrewMembersJoined", null, this.Title, this.Identifier, this.MDH.Tablename); if (this.PortOfCallLast30DaysCrewMembersJoined ?? false) { diff --git a/nsw/Source/bsmd.database/RuleEngine.cs b/nsw/Source/bsmd.database/RuleEngine.cs index b146d6d0..9ef0ab33 100644 --- a/nsw/Source/bsmd.database/RuleEngine.cs +++ b/nsw/Source/bsmd.database/RuleEngine.cs @@ -179,94 +179,94 @@ namespace bsmd.database switch (validationCode) { case ValidationCode.NOT_NULL: - if (value.Length == 0) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + if (value.Length == 0) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); break; case ValidationCode.LOCODE: { Regex rgx = new Regex("[A-Z]{2}[A-Z0-9]{3}"); - if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.LOCODE_GER: { if(!RuleEngine.gerLocodeList.Contains(value)) - errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.INT_GT_ZERO: { int intVal = 0; if (!Int32.TryParse(value, out intVal) || intVal <= 0) - errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.DOUBLE_GT_ZERO: { double dVal = 0; if (!Double.TryParse(value, out dVal) || dVal <= 0) - errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.GISIS: { Regex rgx = new Regex("[0-9]{4}"); - if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } 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)); + if(!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.TWO_DIGIT: { Regex rgx = new Regex("[0-9]{2}"); - if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.STRING_EXACT_LEN: { if (value.Length != maxlen) - errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.STRING_MAXLEN: { if (value.Length > maxlen) - errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.STRING_IMOCLASS: { Regex rgx = new Regex(@"[1-9]{1}(\.[1-9]{1})?"); - if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.STRING_UNNUMBER: { Regex rgx = new Regex("[0-9]{4}"); - if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + if (!rgx.IsMatch(value)) errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.DRAUGHT_IMPLAUSIBLE: { double dVal = 0; if (!Double.TryParse(value, out dVal) || dVal <= 0) - errors.Add(RuleEngine.CreateError(ValidationCode.DOUBLE_GT_ZERO, property.Name, value, entity.Title, identifier)); + errors.Add(RuleEngine.CreateError(ValidationCode.DOUBLE_GT_ZERO, property.Name, value, entity.Title, identifier, entity.Tablename)); else if ((dVal < 20) || (dVal > 150)) - errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } break; case ValidationCode.TIME_IMPLAUSIBLE: { DateTime aTime; - if (value.Length == 0) errors.Add(RuleEngine.CreateError(ValidationCode.NOT_NULL, property.Name, value, entity.Title, identifier)); + if (value.Length == 0) errors.Add(RuleEngine.CreateError(ValidationCode.NOT_NULL, property.Name, value, entity.Title, identifier, entity.Tablename)); if (DateTime.TryParse(value, out aTime)) { if ((aTime - DateTime.UtcNow).Minutes > 30) - errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier)); + errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename)); } } break; @@ -359,7 +359,8 @@ namespace bsmd.database #region private helper - internal static MessageError CreateError(ValidationCode validationCode, string p, string value, string entityName, string identifier) + internal static MessageError CreateError(ValidationCode validationCode, string p, string value, string entityName, + string identifier = "", string notificationClass = "") { MessageError error = new MessageError(); @@ -370,7 +371,14 @@ namespace bsmd.database error.FullName = string.Format("{0}.{1}_{2}", entityName, p, identifier); error.ErrorCode = (int)validationCode; + error.Identifier = identifier; error.PropertyName = p; + + var match = Regex.Match(notificationClass, @"\[*\]\.\[(.*)\]"); + if (match.Success) + error.NotificationClass = match.Groups[1].Value; + else + error.NotificationClass = notificationClass; if (errorTextList.ContainsKey((int)validationCode)) { @@ -385,7 +393,8 @@ namespace bsmd.database return error; } - internal static MessageViolation CreateViolation(ValidationCode validationCode, string p, string value, string entityName, string identifier) + internal static MessageViolation CreateViolation(ValidationCode validationCode, string p, + string value, string entityName, string identifier = "", string notificationClass = "") { MessageViolation violation = new MessageViolation(); @@ -396,8 +405,15 @@ namespace bsmd.database violation.FullName = string.Format("{0}.{1}_{2}", entityName, p, identifier); violation.ViolationCode = (int)validationCode; + violation.Identifier = identifier; violation.PropertyName = p; + var match = Regex.Match(notificationClass, @"\[*\]\.\[(.*)\]"); + if (match.Success) + violation.NotificationClass = match.Groups[1].Value; + else + violation.NotificationClass = notificationClass; + if (violationTextList.ContainsKey((int)validationCode)) { violation.ViolationText = string.Format(violationTextList[(int)validationCode], p, value); diff --git a/nsw/Source/bsmd.database/SEC.cs b/nsw/Source/bsmd.database/SEC.cs index 502c1830..4b1ed998 100644 --- a/nsw/Source/bsmd.database/SEC.cs +++ b/nsw/Source/bsmd.database/SEC.cs @@ -348,12 +348,12 @@ namespace bsmd.database if (this.GetValidationBlock() == ValidationBlock.BLOCK1) { if (this.PortOfCallWhereCompleteSECNotified.IsNullOrEmpty()) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V704, "PortOfCallWhereCompleteSECNotified", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V704, "PortOfCallWhereCompleteSECNotified", null, this.Title, null, this.Tablename)); } else { if((!this.ValidISSCOnBoard ?? true) && this.ReasonsForNoValidISSC.IsNullOrEmpty()) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V702, "ReasonsForNoValidISSC", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V702, "ReasonsForNoValidISSC", null, this.Title, null, this.Tablename)); } diff --git a/nsw/Source/bsmd.database/STAT.cs b/nsw/Source/bsmd.database/STAT.cs index 4c843a34..e472d3aa 100644 --- a/nsw/Source/bsmd.database/STAT.cs +++ b/nsw/Source/bsmd.database/STAT.cs @@ -302,7 +302,7 @@ namespace bsmd.database public override void Validate(List errors, List violations) { if (this.ISMCompanyName.IsNullOrEmpty() || this.ISMCompanyId.IsNullOrEmpty()) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V821, "ISMCompanyName", null, this.Title, null)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V821, "ISMCompanyName", null, this.Title, null, this.Tablename)); } #endregion diff --git a/nsw/Source/bsmd.database/ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.cs b/nsw/Source/bsmd.database/ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.cs index 1857402a..c002ac49 100644 --- a/nsw/Source/bsmd.database/ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.cs +++ b/nsw/Source/bsmd.database/ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.cs @@ -173,7 +173,7 @@ namespace bsmd.database if (locationInsufficient) { - violations.Add(RuleEngine.CreateViolation(ValidationCode.V701, null, null , this.Title, this.Identifier)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V701, null, null , this.Title, this.Identifier, this.SEC.Tablename)); } } diff --git a/nsw/Source/bsmd.database/Waste.cs b/nsw/Source/bsmd.database/Waste.cs index 5b4f3ab1..2c341de0 100644 --- a/nsw/Source/bsmd.database/Waste.cs +++ b/nsw/Source/bsmd.database/Waste.cs @@ -214,7 +214,7 @@ namespace bsmd.database if (this.WasteType.HasValue && ((this.WasteType.Value == (int)3) || (this.WasteType.Value == (int)8) || (this.WasteType.Value == (int)9)) && this.WasteDescription.IsNullOrEmpty()) - violations.Add(RuleEngine.CreateViolation(ValidationCode.V781, "WasteDescription", null, this.Title, this.Identifier)); + violations.Add(RuleEngine.CreateViolation(ValidationCode.V781, "WasteDescription", null, this.Title, this.Identifier, this.Tablename)); // TODO: 782 }