|
|
|
|
@ -837,8 +837,7 @@ namespace ENI2
|
|
|
|
|
private ValidationResult ValidateCore(List<Message> messagesSnapshot)
|
|
|
|
|
{
|
|
|
|
|
List<MessageViolation> vViolations = new List<MessageViolation>();
|
|
|
|
|
List<MessageError> vErrors = new List<MessageError>();
|
|
|
|
|
Dictionary<Message, MessageValidationCounts> counts = new Dictionary<Message, MessageValidationCounts>();
|
|
|
|
|
List<MessageError> vErrors = new List<MessageError>();
|
|
|
|
|
|
|
|
|
|
RuleEngine ruleEngine = new RuleEngine();
|
|
|
|
|
foreach (Message aMessage in messagesSnapshot)
|
|
|
|
|
@ -847,15 +846,7 @@ namespace ENI2
|
|
|
|
|
|
|
|
|
|
List<MessageError> errors = new List<MessageError>();
|
|
|
|
|
List<MessageViolation> violations = new List<MessageViolation>();
|
|
|
|
|
ruleEngine.ValidateMessage(aMessage, out errors, out violations);
|
|
|
|
|
|
|
|
|
|
MessageValidationCounts messageCounts = new MessageValidationCounts
|
|
|
|
|
{
|
|
|
|
|
ErrorCount = errors.Count > 0 ? (int?)errors.Count : null,
|
|
|
|
|
ViolationCount = violations.Count > 0 ? (int?)violations.Count : null,
|
|
|
|
|
PositionViolationCount = violations.Count > 0 ? (int?)violations.Count(v => !v.Identifier.IsNullOrEmpty()) : null
|
|
|
|
|
};
|
|
|
|
|
counts[aMessage] = messageCounts;
|
|
|
|
|
ruleEngine.ValidateMessage(aMessage, out errors, out violations);
|
|
|
|
|
|
|
|
|
|
string messageGroup = this.MessageGroupForMessage(aMessage);
|
|
|
|
|
|
|
|
|
|
@ -1267,7 +1258,7 @@ namespace ENI2
|
|
|
|
|
case 401:
|
|
|
|
|
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.5)
|
|
|
|
|
{
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "WAS", waste.Identifier, "WAS");
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
|
|
|
|
|
mv.MessageGroupName = wasMessageGroup;
|
|
|
|
|
vViolations.Add(mv);
|
|
|
|
|
}
|
|
|
|
|
@ -1285,7 +1276,7 @@ namespace ENI2
|
|
|
|
|
case 511:
|
|
|
|
|
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.25)
|
|
|
|
|
{
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "WAS", waste.Identifier, "WAS");
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
|
|
|
|
|
mv.MessageGroupName = wasMessageGroup;
|
|
|
|
|
vViolations.Add(mv);
|
|
|
|
|
}
|
|
|
|
|
@ -1294,7 +1285,7 @@ namespace ENI2
|
|
|
|
|
case 602:
|
|
|
|
|
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.75)
|
|
|
|
|
{
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "WAS", waste.Identifier, "WAS");
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
|
|
|
|
|
mv.MessageGroupName = wasMessageGroup;
|
|
|
|
|
vViolations.Add(mv);
|
|
|
|
|
}
|
|
|
|
|
@ -1315,7 +1306,7 @@ namespace ENI2
|
|
|
|
|
case 105:
|
|
|
|
|
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.25)
|
|
|
|
|
{
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "WAS", waste.Identifier, "WAS");
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
|
|
|
|
|
mv.MessageGroupName = wasMessageGroup;
|
|
|
|
|
vViolations.Add(mv);
|
|
|
|
|
}
|
|
|
|
|
@ -1323,7 +1314,7 @@ namespace ENI2
|
|
|
|
|
case 401:
|
|
|
|
|
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.5)
|
|
|
|
|
{
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "WAS", waste.Identifier, "WAS");
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
|
|
|
|
|
mv.MessageGroupName = wasMessageGroup;
|
|
|
|
|
vViolations.Add(mv);
|
|
|
|
|
}
|
|
|
|
|
@ -1341,7 +1332,7 @@ namespace ENI2
|
|
|
|
|
case 511:
|
|
|
|
|
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.2)
|
|
|
|
|
{
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "WAS", waste.Identifier, "WAS");
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
|
|
|
|
|
mv.MessageGroupName = wasMessageGroup;
|
|
|
|
|
vViolations.Add(mv);
|
|
|
|
|
}
|
|
|
|
|
@ -1350,7 +1341,7 @@ namespace ENI2
|
|
|
|
|
case 602:
|
|
|
|
|
if (waste.WasteAmountRetained_MTQ > waste.WasteCapacity_MTQ * 0.25)
|
|
|
|
|
{
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "WAS", waste.Identifier, "WAS");
|
|
|
|
|
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "Acc. to EU Regulation 2022/89 the amount retained on board is noticeably", null, "Waste", waste.Identifier, was.Tablename);
|
|
|
|
|
mv.MessageGroupName = wasMessageGroup;
|
|
|
|
|
vViolations.Add(mv);
|
|
|
|
|
}
|
|
|
|
|
@ -1393,9 +1384,70 @@ namespace ENI2
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Recompute per-message counts after all global validations
|
|
|
|
|
Dictionary<Message, MessageValidationCounts> counts = new Dictionary<Message, MessageValidationCounts>();
|
|
|
|
|
|
|
|
|
|
int assignViolationCounter = 0;
|
|
|
|
|
int assignErrorCounter = 0;
|
|
|
|
|
|
|
|
|
|
List<MessageViolation> tmpVList = new List<MessageViolation>(vViolations);
|
|
|
|
|
List<MessageError> tmpEList = new List<MessageError>(vErrors);
|
|
|
|
|
|
|
|
|
|
foreach (Message aMessage in messagesSnapshot)
|
|
|
|
|
{
|
|
|
|
|
counts[aMessage] = new MessageValidationCounts();
|
|
|
|
|
counts[aMessage].ErrorCount = tmpEList.Count(me => me.NotificationClass == aMessage.MessageNotificationClassDisplay); // generic
|
|
|
|
|
// special cases
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.WAS_RCPT) && (me.NotificationClass == "WasteReceived"));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IMDGPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IGCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IBCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IMSBCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "MARPOL_Annex_I_Position") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IMDGPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IGCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IBCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IMSBCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "MARPOL_Annex_I_Position") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.WAS) && (me.NotificationClass == "Waste"));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.SEC) && (me.NotificationClass == "LastTenPortFacilitiesCalled"));
|
|
|
|
|
counts[aMessage].ErrorCount += tmpEList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.SEC) && (me.NotificationClass == "ShipToShipActivitiesDuringLastTenPortFacilitiesCalled"));
|
|
|
|
|
|
|
|
|
|
if (counts[aMessage].ErrorCount == 0) counts[aMessage].ErrorCount = null; // set to empty if nothing counted
|
|
|
|
|
assignErrorCounter += counts[aMessage].ErrorCount ?? 0;
|
|
|
|
|
|
|
|
|
|
counts[aMessage].ViolationCount = vViolations.Count(mv => mv.NotificationClass == aMessage.MessageNotificationClassDisplay); // generic
|
|
|
|
|
// special cases
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.WAS_RCPT) && (me.NotificationClass == "WasteReceived"));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IMDGPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IGCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IBCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "IMSBCPosition") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZA) && (me.NotificationClass == "MARPOL_Annex_I_Position") && me.MessageGroupName.Contains("arrival", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IMDGPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IGCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IBCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "IMSBCPosition") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.HAZD) && (me.NotificationClass == "MARPOL_Annex_I_Position") && me.MessageGroupName.Contains("departure", StringComparison.OrdinalIgnoreCase));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.WAS) && (me.NotificationClass == "Waste"));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.SEC) && (me.NotificationClass == "LastTenPortFacilitiesCalled"));
|
|
|
|
|
counts[aMessage].ViolationCount += tmpVList.Count(me => (aMessage.MessageNotificationClass == Message.NotificationClass.SEC) && (me.NotificationClass == "ShipToShipActivitiesDuringLastTenPortFacilitiesCalled"));
|
|
|
|
|
|
|
|
|
|
if (counts[aMessage].ViolationCount == 0) counts[aMessage].ViolationCount = null;
|
|
|
|
|
|
|
|
|
|
assignViolationCounter += counts[aMessage].ViolationCount ?? 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Trace.WriteLine(string.Format("Unassigned errors: {0}, unassigned violations: {1}", vErrors.Count - assignErrorCounter, vViolations.Count - assignViolationCounter));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new ValidationResult(vViolations, vErrors, counts);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void ApplyValidationResult(ValidationResult result, bool showMessages)
|
|
|
|
|
{
|
|
|
|
|
// TODO: clear highlighting
|
|
|
|
|
@ -1404,8 +1456,7 @@ namespace ENI2
|
|
|
|
|
Message aMessage = entry.Key;
|
|
|
|
|
MessageValidationCounts messageCounts = entry.Value;
|
|
|
|
|
aMessage.ErrorCount = messageCounts.ErrorCount;
|
|
|
|
|
aMessage.ViolationCount = messageCounts.ViolationCount;
|
|
|
|
|
aMessage.PositionViolationCount = messageCounts.PositionViolationCount;
|
|
|
|
|
aMessage.ViolationCount = messageCounts.ViolationCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (MessageError me in result.Errors)
|
|
|
|
|
|