Aktueller Stand für eine neue Woche (mit Validierungs-Check der Meldeklassen auf "SUSPEND" setzt)

This commit is contained in:
Daniel Schick 2017-11-19 18:09:22 +00:00
parent d61886daef
commit a70e5024ee
27 changed files with 180 additions and 70 deletions

View File

@ -26,12 +26,12 @@
<value>1000</value>
</setting>
<setting name="LockingServerAddress" serializeAs="String">
<!--value>http://192.168.2.4/LockingService/LockingService.svc</value-->
<value>http://heupferd/bsmd.LockingService/LockingService.svc</value>
<value>http://192.168.2.4/LockingService/LockingService.svc</value>
<!--value>http://heupferd/bsmd.LockingService/LockingService.svc</value-->
</setting>
<setting name="ConnectionString" serializeAs="String">
<!--value>Data Source=192.168.2.12;Initial Catalog=nsw;Uid=dfuser;Pwd=dfpasswd;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False</value-->
<value>Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False</value>
<value>Data Source=192.168.2.12;Initial Catalog=nsw;Uid=dfuser;Pwd=dfpasswd;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False</value>
<!--value>Data Source=(localdb)\Projects;Initial Catalog=nsw;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=False</value-->
</setting>
</ENI2.Properties.Settings>
</applicationSettings>

View File

@ -62,10 +62,15 @@ namespace ENI2
public event Action RequestReload;
/// <summary>
/// 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)
/// </summary>
public event Action RequestValidate;
/// <summary>
/// Alle Meldeklassen die auf "zu versenden" stehen werden validiert und falls die Validierung scheitert auf "SUSPEND" gestellt
/// </summary>
public event Action RequestSendValidation;
/// <summary>
/// Damit kann signalisiert werden, dass die Anmeldung readonly wird (z.B. bei Storno)
/// </summary>
@ -150,6 +155,11 @@ namespace ENI2
this.RequestValidate?.Invoke();
}
protected virtual void OnRequestSendValidation()
{
this.RequestSendValidation?.Invoke();
}
protected virtual void OnRequestDisable()
{
this.RequestDisable?.Invoke();

View File

@ -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;
@ -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

View File

@ -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();
}
}

View File

@ -35,8 +35,8 @@
<MinimumRequiredVersion>3.5.1.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>3.8.6.%2a</ApplicationVersion>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>3.8.7.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>

View File

@ -15,9 +15,11 @@
</Grid.RowDefinitions>
<enictrl:ENIDataGrid Grid.Row="0" Grid.Column="0" SelectionMode="Single" AutoGenerateColumns="False" Margin="5,5,5,0" x:Name="dataGridErrors">
<DataGrid.Columns>
<DataGridTextColumn Header="{x:Static p:Resources.textCode}" Binding="{Binding ErrorCode}" IsReadOnly="True" Width="0.1*" />
<DataGridTextColumn Header="{x:Static p:Resources.textProperty}" Binding="{Binding PropertyName}" IsReadOnly="True" Width="0.3*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDescription}" Binding="{Binding ErrorText}" IsReadOnly="True" Width="0.6*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCode}" Binding="{Binding ErrorCode}" IsReadOnly="True" Width="0.05*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdentifier}" Binding="{Binding Identifier}" IsReadOnly="True" Width="0.08*" />
<DataGridTextColumn Header="{x:Static p:Resources.textClass}" Binding="{Binding NotificationClass}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textGroup}" Binding="{Binding MessageGroupName}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDescription}" Binding="{Binding ErrorText}" IsReadOnly="True" Width="0.5*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>

View File

@ -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">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
@ -20,8 +20,11 @@
<enictrl:ENIDataGrid Grid.Row="0" Grid.Column="0" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
SelectionMode="Single" AutoGenerateColumns="False" Margin="5,5,5,0" x:Name="dataGridViolations">
<DataGrid.Columns>
<DataGridTextColumn Header="{x:Static p:Resources.textCode}" Binding="{Binding ViolationCode}" IsReadOnly="True" Width="0.3*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDescription}" Binding="{Binding ViolationText}" IsReadOnly="True" Width="0.7*" />
<DataGridTextColumn Header="{x:Static p:Resources.textCode}" Binding="{Binding ViolationCode}" IsReadOnly="True" Width="0.05*" />
<DataGridTextColumn Header="{x:Static p:Resources.textIdentifier}" Binding="{Binding Identifier}" IsReadOnly="True" Width="0.08*" />
<DataGridTextColumn Header="{x:Static p:Resources.textClass}" Binding="{Binding NotificationClass}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textGroup}" Binding="{Binding MessageGroupName}" IsReadOnly="True" Width="0.15*" />
<DataGridTextColumn Header="{x:Static p:Resources.textDescription}" Binding="{Binding ViolationText}" IsReadOnly="True" Width="0.5*" />
</DataGrid.Columns>
</enictrl:ENIDataGrid>
</Grid>

View File

@ -1157,6 +1157,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Class.
/// </summary>
public static string textClass {
get {
return ResourceManager.GetString("textClass", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Clear.
/// </summary>

View File

@ -1585,4 +1585,7 @@
<data name="textSentBy" xml:space="preserve">
<value>Sent by</value>
</data>
<data name="textClass" xml:space="preserve">
<value>Class</value>
</data>
</root>

View File

@ -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
{
/// <summary>
/// Flag zeigt an ob ExcelReader läuft
/// </summary>
public bool? Excel { get; set; }
/// <summary>
/// Flag zeigt an, ob NSWSendService läuft
/// </summary>
public bool? Transmitter { get; set; }
/// <summary>
/// Flag zeigt an, ob ReportServer läuft
/// </summary>
public bool? Report { get; set; }
}
}

View File

@ -89,6 +89,7 @@
</Compile>
<Compile Include="IService.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ServerStatus.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="App_Data\" />

View File

@ -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

View File

@ -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);

View File

@ -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

View File

@ -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);
}
}

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -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));
}
}

View File

@ -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));
}
}

View File

@ -247,7 +247,7 @@ namespace bsmd.database
public override void Validate(List<MessageError> errors, List<MessageViolation> 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)
{

View File

@ -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,8 +371,15 @@ 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))
{
error.ErrorText = string.Format(errorTextList[(int)validationCode], p, value);
@ -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);

View File

@ -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));
}

View File

@ -302,7 +302,7 @@ namespace bsmd.database
public override void Validate(List<MessageError> errors, List<MessageViolation> 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

View File

@ -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));
}
}

View File

@ -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
}