619 lines
26 KiB
C#
619 lines
26 KiB
C#
//
|
|
// Class: IMDGPosition
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 5/26/2015 8:56:57 PM
|
|
//
|
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
|
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Text;
|
|
using System.Text.RegularExpressions;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace bsmd.database
|
|
{
|
|
|
|
[TypeConverter(typeof(MessageClassConverter<IMDGPosition>))]
|
|
[JsonConverter(typeof(NoTypeConverterJsonConverter<IMDGPosition>))]
|
|
public class IMDGPosition : DatabaseEntity, ISublistElement, ISublistContainer
|
|
{
|
|
public IMDGPosition()
|
|
{
|
|
this.tablename = "[dbo].[IMDGPosition]";
|
|
}
|
|
|
|
#region Properties
|
|
|
|
[JsonIgnore]
|
|
[Browsable(false)]
|
|
public HAZ HAZ { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.STRING_EXACT_LEN, 4)]
|
|
[MaxLength(10)]
|
|
[ENI2Validation]
|
|
public string UNNumber { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public byte? PackingGroup { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[MaxLength(255)]
|
|
[ENI2Validation]
|
|
public string ProperShippingName { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[MaxLength(10)]
|
|
[ENI2Validation]
|
|
public string IMOClass { get; set; }
|
|
|
|
[MaxLength(10)]
|
|
[ENI2Validation]
|
|
public string CompatibilityGroup { get; set; }
|
|
|
|
[ShowReport]
|
|
[MaxLength(255)]
|
|
[ENI2Validation]
|
|
public string TechnicalName { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public double? NetExplosiveMass_KGM { get; set; }
|
|
|
|
[ShowReport]
|
|
[MaxLength(10)]
|
|
[ENI2Validation]
|
|
[Validation(ValidationCode.DOT_NO_COMMA)]
|
|
public string Flashpoint_CEL { get; set; }
|
|
|
|
[ShowReport]
|
|
[MaxLength(100)]
|
|
[ENI2Validation]
|
|
public string Class7NuclideName { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public double? Class7MaxActivity_BQL { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public int? Class7Category { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public double? Class7TransportIndex { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public int? Class7CSI { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public double? ControlTemperature_CEL { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public double? EmergencyTemperature_CEL { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[ENI2Validation]
|
|
public bool? MarinePollutant { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[ENI2Validation]
|
|
public int? NumberOfPackages { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[MaxLength(255)]
|
|
[ENI2Validation]
|
|
public string PackageType { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[ENI2Validation]
|
|
public bool? LimitedQuantities { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[ENI2Validation]
|
|
public bool? ExceptedQuantities { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public double? NetQuantity_KGM { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public double? GrossQuantity_KGM { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public double? Volume_MTQ { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public bool? GeneralCargoIBC { get; set; }
|
|
|
|
[ShowReport]
|
|
[MaxLength(24)]
|
|
[MaxWordLength(15)]
|
|
[ENI2Validation]
|
|
public string ContainerNumber { get; set; }
|
|
|
|
[ShowReport]
|
|
[MaxLength(24)]
|
|
[MaxWordLength(15)]
|
|
[ENI2Validation]
|
|
public string VehicleLicenseNumber { get; set; }
|
|
|
|
[ShowReport]
|
|
[MaxLength(24)]
|
|
[ENI2Validation]
|
|
[MaxWordLength(9)]
|
|
public string StowagePosition { get; set; }
|
|
|
|
[ShowReport]
|
|
[MaxLength(5)]
|
|
[ENI2Validation]
|
|
public string Bay { get; set; }
|
|
|
|
[ShowReport]
|
|
[MaxLength(5)]
|
|
[ENI2Validation]
|
|
public string Row { get; set; }
|
|
|
|
[ShowReport]
|
|
[MaxLength(5)]
|
|
[ENI2Validation]
|
|
public string Tier { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.LOCODE)]
|
|
[MaxLength(5)]
|
|
[ENI2Validation]
|
|
public string PortOfLoading { get; set; }
|
|
|
|
[ShowReport]
|
|
[Validation(ValidationCode.LOCODE)]
|
|
[MaxLength(5)]
|
|
[ENI2Validation]
|
|
public string PortOfDischarge { get; set; }
|
|
|
|
[ShowReport]
|
|
[MaxLength(255)]
|
|
[MaxWordLength(50)]
|
|
[ENI2Validation]
|
|
public string Remarks { get; set; }
|
|
|
|
public List<SubsidiaryRisks> SubsidiaryRiskList { get; private set; } = new List<SubsidiaryRisks>();
|
|
|
|
/// <summary>
|
|
/// Hilfsproperty, um subsidiary risks als kommaseparierte Liste anzuzeigen (ENI-2)
|
|
/// </summary>
|
|
[ENI2Validation]
|
|
[JsonIgnore]
|
|
public string SubsidiaryRiskText
|
|
{
|
|
get
|
|
{
|
|
StringBuilder sb = new StringBuilder();
|
|
for (int i = 0; i < this.SubsidiaryRiskList.Count; i++)
|
|
{
|
|
if (i > 0)
|
|
sb.Append(", ");
|
|
sb.Append(this.SubsidiaryRiskList[i].SubsidiaryRisk);
|
|
}
|
|
return sb.ToString();
|
|
}
|
|
set
|
|
{
|
|
if (value.IsNullOrEmpty())
|
|
{
|
|
foreach (SubsidiaryRisks sr in this.SubsidiaryRiskList)
|
|
DBManager.Instance.Delete(sr);
|
|
this.SubsidiaryRiskList.Clear();
|
|
}
|
|
else
|
|
{
|
|
string[] risks = value.Split(',');
|
|
List<SubsidiaryRisks> foundList = new List<SubsidiaryRisks>();
|
|
|
|
for (int i = 0; i < risks.Length; i++)
|
|
{
|
|
string risk = risks[i].Trim();
|
|
if (risk.Length > 0)
|
|
{
|
|
SubsidiaryRisks matchingRisk = null;
|
|
foreach (SubsidiaryRisks sr in this.SubsidiaryRiskList)
|
|
{
|
|
if (sr.SubsidiaryRisk.Equals(risk, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
matchingRisk = sr;
|
|
break;
|
|
}
|
|
}
|
|
if (matchingRisk != null)
|
|
{
|
|
foundList.Add(matchingRisk);
|
|
this.SubsidiaryRiskList.Remove(matchingRisk);
|
|
}
|
|
else
|
|
{
|
|
SubsidiaryRisks newRisk = new SubsidiaryRisks();
|
|
newRisk.IMDGPosition = this;
|
|
newRisk.SubsidiaryRisk = risk;
|
|
foundList.Add(newRisk);
|
|
}
|
|
}
|
|
}
|
|
|
|
// remove remaining risk (no longer valid)
|
|
foreach (SubsidiaryRisks remainingRisk in this.SubsidiaryRiskList)
|
|
DBManager.Instance.Delete(remainingRisk);
|
|
this.SubsidiaryRiskList.Clear();
|
|
// add existing and new risk
|
|
this.SubsidiaryRiskList.AddRange(foundList);
|
|
}
|
|
}
|
|
}
|
|
|
|
public string Identifier { get; set; }
|
|
|
|
[JsonIgnore]
|
|
public string SublistCollectionKey { get { return "imdg"; } }
|
|
|
|
#endregion
|
|
|
|
#region DatabaseEntity implementation
|
|
|
|
public override void PrepareSave(IDbCommand cmd)
|
|
{
|
|
SqlCommand scmd = cmd as SqlCommand;
|
|
|
|
scmd.Parameters.AddWithValue("@P1", this.HAZ.Id);
|
|
scmd.Parameters.AddWithNullableValue("@P2", this.UNNumber);
|
|
scmd.Parameters.AddWithNullableValue("@P3", this.PackingGroup);
|
|
scmd.Parameters.AddWithNullableValue("@P4", this.ProperShippingName);
|
|
scmd.Parameters.AddWithNullableValue("@P5", this.IMOClass);
|
|
scmd.Parameters.AddWithNullableValue("@P6", this.CompatibilityGroup);
|
|
scmd.Parameters.AddWithNullableValue("@P7", this.TechnicalName);
|
|
scmd.Parameters.AddWithNullableValue("@P8", this.NetExplosiveMass_KGM);
|
|
scmd.Parameters.AddWithNullableValue("@P9", this.Flashpoint_CEL);
|
|
scmd.Parameters.AddWithNullableValue("@P10", this.Class7NuclideName);
|
|
scmd.Parameters.AddWithNullableValue("@P11", this.Class7MaxActivity_BQL);
|
|
scmd.Parameters.AddWithNullableValue("@P12", this.Class7Category);
|
|
scmd.Parameters.AddWithNullableValue("@P13", this.Class7TransportIndex);
|
|
scmd.Parameters.AddWithNullableValue("@P14", this.Class7CSI);
|
|
scmd.Parameters.AddWithNullableValue("@P15", this.ControlTemperature_CEL);
|
|
scmd.Parameters.AddWithNullableValue("@P16", this.EmergencyTemperature_CEL);
|
|
scmd.Parameters.AddWithNullableValue("@P17", this.MarinePollutant);
|
|
scmd.Parameters.AddWithNullableValue("@P18", this.NumberOfPackages);
|
|
scmd.Parameters.AddWithNullableValue("@P19", this.PackageType);
|
|
scmd.Parameters.AddWithNullableValue("@P20", this.LimitedQuantities);
|
|
scmd.Parameters.AddWithNullableValue("@P21", this.ExceptedQuantities);
|
|
scmd.Parameters.AddWithNullableValue("@P22", this.NetQuantity_KGM);
|
|
scmd.Parameters.AddWithNullableValue("@P23", this.GrossQuantity_KGM);
|
|
scmd.Parameters.AddWithNullableValue("@P24", this.Volume_MTQ);
|
|
scmd.Parameters.AddWithNullableValue("@P25", this.GeneralCargoIBC);
|
|
scmd.Parameters.AddWithNullableValue("@P26", this.ContainerNumber);
|
|
scmd.Parameters.AddWithNullableValue("@P27", this.VehicleLicenseNumber);
|
|
scmd.Parameters.AddWithNullableValue("@P28", this.StowagePosition);
|
|
scmd.Parameters.AddWithNullableValue("@P29", this.PortOfLoading);
|
|
scmd.Parameters.AddWithNullableValue("@P30", this.PortOfDischarge);
|
|
scmd.Parameters.AddWithNullableValue("@P31", this.Remarks);
|
|
scmd.Parameters.AddWithNullableValue("@P32", this.Identifier);
|
|
scmd.Parameters.AddWithNullableValue("@P33", this.Bay);
|
|
scmd.Parameters.AddWithNullableValue("@P34", this.Row);
|
|
scmd.Parameters.AddWithNullableValue("@P35", this.Tier);
|
|
|
|
if (this.IsNew)
|
|
{
|
|
this.CreateId();
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
scmd.CommandText = string.Format("INSERT INTO {0} (HAZId, UNNumber, " +
|
|
"PackingGroup, ProperShippingName, IMOClass, CompatibilityGroup, TechnicalName, NetExplosiveMass_KGM," +
|
|
"Flashpoint_CEL, Class7NuclideName, Class7MaxActivity_BQL, Class7Category, Class7TransportIndex, " +
|
|
"Class7CSI, ControlTemperature_CEL, EmergencyTemperature_CEL, MarinePollutant, NumberOfPackages, " +
|
|
"PackageType, LimitedQuantities, ExceptedQuantities, NetQuantity_KGM, GrossQuantity_KGM, Volume_MTQ, " +
|
|
"GeneralCargoIBC, ContainerNumber, VehicleLicenseNumber, StowagePosition, PortOfLoading, PortOfDischarge, " +
|
|
"Remarks, Identifier, Bay, [Row], Tier) VALUES (@P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13, " +
|
|
"@P14, @P15, @P16, @P17, @P18, @P19, @P20, @P21, @P22, @P23, @P24, @P25, @P26, @P27, @P28, @P29, @P30, " +
|
|
"@P31, @P32, @P33, @P34, @P35)", this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
scmd.CommandText = string.Format("UPDATE {0} SET UNNumber = @P2, PackingGroup = @P3, ProperShippingName = @P4, " +
|
|
"IMOClass = @P5, CompatibilityGroup = @P6, TechnicalName = @P7, NetExplosiveMass_KGM = @P8, " +
|
|
"Flashpoint_CEL = @P9, Class7NuclideName = @P10, Class7MaxActivity_BQL = @P11, Class7Category = @P12, " +
|
|
"Class7TransportIndex = @P13, Class7CSI = @P14, ControlTemperature_CEL = @P15, EmergencyTemperature_CEL = @P16, " +
|
|
"MarinePollutant = @P17, NumberOfPackages = @P18, PackageType = @P19, LimitedQuantities = @P20, ExceptedQuantities = @P21, " +
|
|
"NetQuantity_KGM = @P22, GrossQuantity_KGM = @P23, Volume_MTQ = @P24, GeneralCargoIBC = @P25, ContainerNumber = @P26, " +
|
|
"VehicleLicenseNumber = @P27, StowagePosition = @P28, PortOfLoading = @P29, PortOfDischarge = @P30, Remarks = @P31, " +
|
|
"Identifier = @P32, Bay = @P33, [Row] = @P34, Tier = @P35 WHERE Id = @ID", this.Tablename);
|
|
}
|
|
|
|
}
|
|
|
|
public override void PrepareLoadCommand(IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
|
{
|
|
string query = string.Format("SELECT Id, UNNumber, PackingGroup, ProperShippingName, IMOClass, CompatibilityGroup, " +
|
|
"TechnicalName, NetExplosiveMass_KGM, Flashpoint_CEL, Class7NuclideName, Class7MaxActivity_BQL, Class7Category, " +
|
|
"Class7TransportIndex, Class7CSI, ControlTemperature_CEL, EmergencyTemperature_CEL, MarinePollutant, NumberOfPackages, " +
|
|
"PackageType, LimitedQuantities, ExceptedQuantities, NetQuantity_KGM, GrossQuantity_KGM, Volume_MTQ, GeneralCargoIBC, " +
|
|
"ContainerNumber, VehicleLicenseNumber, StowagePosition, PortOfLoading, PortOfDischarge, Remarks, Identifier, Bay, [Row], Tier " +
|
|
"FROM {0} ", this.Tablename);
|
|
|
|
switch (filter)
|
|
{
|
|
case Message.LoadFilter.HAZ_ID:
|
|
query += " WHERE HAZId = @HAZID";
|
|
((SqlCommand)cmd).Parameters.AddWithValue("@HAZID", criteria[0]);
|
|
break;
|
|
case Message.LoadFilter.ALL:
|
|
default:
|
|
|
|
break;
|
|
}
|
|
|
|
query += " ORDER BY Identifier";
|
|
|
|
cmd.CommandText = query;
|
|
}
|
|
|
|
public override List<DatabaseEntity> LoadList(IDataReader reader)
|
|
{
|
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
|
|
|
while (reader.Read())
|
|
{
|
|
IMDGPosition imdg = new IMDGPosition();
|
|
|
|
imdg.id = reader.GetGuid(0);
|
|
if(!reader.IsDBNull(1)) imdg.UNNumber = reader.GetString(1);
|
|
if (!reader.IsDBNull(2)) imdg.PackingGroup = reader.GetByte(2);
|
|
if (!reader.IsDBNull(3)) imdg.ProperShippingName = reader.GetString(3);
|
|
if (!reader.IsDBNull(4)) imdg.IMOClass = reader.GetString(4);
|
|
if (!reader.IsDBNull(5)) imdg.CompatibilityGroup = reader.GetString(5);
|
|
if (!reader.IsDBNull(6)) imdg.TechnicalName = reader.GetString(6);
|
|
if (!reader.IsDBNull(7)) imdg.NetExplosiveMass_KGM = reader.GetDouble(7);
|
|
if (!reader.IsDBNull(8)) imdg.Flashpoint_CEL = reader.GetString(8);
|
|
if (!reader.IsDBNull(9)) imdg.Class7NuclideName = reader.GetString(9);
|
|
if (!reader.IsDBNull(10)) imdg.Class7MaxActivity_BQL = reader.GetDouble(10);
|
|
if (!reader.IsDBNull(11)) imdg.Class7Category = reader.GetInt32(11);
|
|
if (!reader.IsDBNull(12)) imdg.Class7TransportIndex = reader.GetDouble(12);
|
|
if (!reader.IsDBNull(13)) imdg.Class7CSI = reader.GetInt32(13);
|
|
if (!reader.IsDBNull(14)) imdg.ControlTemperature_CEL = reader.GetDouble(14);
|
|
if (!reader.IsDBNull(15)) imdg.EmergencyTemperature_CEL = reader.GetDouble(15);
|
|
if (!reader.IsDBNull(16)) imdg.MarinePollutant = reader.GetBoolean(16);
|
|
if (!reader.IsDBNull(17)) imdg.NumberOfPackages = reader.GetInt32(17);
|
|
if (!reader.IsDBNull(18)) imdg.PackageType = reader.GetString(18);
|
|
if (!reader.IsDBNull(19)) imdg.LimitedQuantities = reader.GetBoolean(19);
|
|
if (!reader.IsDBNull(20)) imdg.ExceptedQuantities = reader.GetBoolean(20);
|
|
if (!reader.IsDBNull(21)) imdg.NetQuantity_KGM = reader.GetDouble(21);
|
|
if (!reader.IsDBNull(22)) imdg.GrossQuantity_KGM = reader.GetDouble(22);
|
|
if (!reader.IsDBNull(23)) imdg.Volume_MTQ = reader.GetDouble(23);
|
|
if (!reader.IsDBNull(24)) imdg.GeneralCargoIBC = reader.GetBoolean(24);
|
|
if (!reader.IsDBNull(25)) imdg.ContainerNumber = reader.GetString(25);
|
|
if (!reader.IsDBNull(26)) imdg.VehicleLicenseNumber = reader.GetString(26);
|
|
if (!reader.IsDBNull(27)) imdg.StowagePosition = reader.GetString(27);
|
|
if (!reader.IsDBNull(28)) imdg.PortOfLoading = reader.GetString(28);
|
|
if (!reader.IsDBNull(29)) imdg.PortOfDischarge = reader.GetString(29);
|
|
if (!reader.IsDBNull(30)) imdg.Remarks = reader.GetString(30);
|
|
if (!reader.IsDBNull(31)) imdg.Identifier = reader.GetString(31);
|
|
if (!reader.IsDBNull(32)) imdg.Bay = reader.GetString(32);
|
|
if (!reader.IsDBNull(33)) imdg.Row = reader.GetString(33);
|
|
if (!reader.IsDBNull(34)) imdg.Tier = reader.GetString(34);
|
|
|
|
result.Add(imdg);
|
|
}
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IMessageParagraph implementation
|
|
|
|
public override List<IMessageParagraph> ChildParagraphs
|
|
{
|
|
get
|
|
{
|
|
List<IMessageParagraph> result = new List<IMessageParagraph>();
|
|
foreach (IMessageParagraph imp in this.SubsidiaryRiskList)
|
|
result.Add(imp);
|
|
return result;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ISublistContainer implementation
|
|
|
|
public ISublistElement GetSublistElementWithIdentifier(string identifier)
|
|
{
|
|
foreach (ISublistElement sElem in this.SubsidiaryRiskList)
|
|
if (sElem.Identifier.Equals(identifier))
|
|
return sElem;
|
|
return null;
|
|
}
|
|
|
|
[Browsable(false)]
|
|
[JsonIgnore]
|
|
public int NumberOfExcelRows
|
|
{
|
|
get { return 1; }
|
|
}
|
|
|
|
public void SaveElements()
|
|
{
|
|
foreach (SubsidiaryRisks sr in this.SubsidiaryRiskList)
|
|
{
|
|
DBManager.Instance.Save(sr);
|
|
}
|
|
}
|
|
|
|
public void DeleteElements()
|
|
{
|
|
foreach (SubsidiaryRisks sr in this.SubsidiaryRiskList)
|
|
{
|
|
DBManager.GetSingleCon(DBManager.Instance.ConnectionString).Delete(sr);
|
|
}
|
|
this.SubsidiaryRiskList.Clear();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Validation
|
|
|
|
public override void Validate(List<MessageError> errors, List<MessageViolation> violations)
|
|
{
|
|
|
|
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, 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, this.HAZ.IsDeparture ? "HAZD": "HAZA"));
|
|
|
|
if((this.NetQuantity_KGM >= 1000000000) ||
|
|
(this.GrossQuantity_KGM >= 1000000000) ||
|
|
(this.Volume_MTQ >= 1000000000))
|
|
violations.Add(RuleEngine.CreateViolation(ValidationCode.V809, null, null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
|
|
|
|
|
|
foreach (SubsidiaryRisks sr in this.SubsidiaryRiskList)
|
|
RuleEngine.ValidateProperties(sr, errors, violations);
|
|
|
|
if (!this.Flashpoint_CEL.IsNullOrEmpty())
|
|
{
|
|
const string pattern = @"^[<>]?\-?[0-9]+(\.[0-9]+)?$";
|
|
Regex regex = new Regex(pattern);
|
|
|
|
if (!regex.IsMatch(this.Flashpoint_CEL))
|
|
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "Flashpoint_CEL", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
|
|
}
|
|
|
|
if(!this.IMOClass.IsNullOrEmpty())
|
|
{
|
|
const string pattern = @"^[1-9]{1}(\.[1-9]{1}([A-Z]{1})?)?$";
|
|
Regex regex = new Regex(pattern);
|
|
|
|
if (!regex.IsMatch(this.IMOClass))
|
|
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "IMOClass", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
|
|
}
|
|
|
|
if (!this.StowagePosition.IsNullOrEmpty() && (!this.Bay.IsNullOrEmpty() || !this.Row.IsNullOrEmpty() || !this.Tier.IsNullOrEmpty()))
|
|
{
|
|
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "StowagePosition AND Bay/Row/Tier SET", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
|
|
}
|
|
else
|
|
{
|
|
if (StowagePosition.IsNullOrEmpty())
|
|
{
|
|
if (!this.Bay.IsNullOrEmpty())
|
|
{
|
|
const string pattern = @"^[0-9]{3}$";
|
|
Regex regex = new Regex(pattern);
|
|
if (!regex.IsMatch(this.Bay))
|
|
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "Bay", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
|
|
}
|
|
|
|
if (!this.Row.IsNullOrEmpty())
|
|
{
|
|
const string pattern = @"^[0-9]{2}$";
|
|
Regex regex = new Regex(pattern);
|
|
if (!regex.IsMatch(this.Row))
|
|
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "Row", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
|
|
}
|
|
|
|
if (!this.Tier.IsNullOrEmpty())
|
|
{
|
|
const string pattern = @"^[0-9]{2}$";
|
|
Regex regex = new Regex(pattern);
|
|
if (!regex.IsMatch(this.Tier))
|
|
errors.Add(RuleEngine.CreateError(ValidationCode.IMPLAUSIBLE, "Tier", null, this.Title, this.Identifier, this.HAZ.IsDeparture ? "HAZD" : "HAZA"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region public methods
|
|
|
|
public void CopyFromIMDG(IMDGPosition selectedIMDG)
|
|
{
|
|
if (selectedIMDG == null) return;
|
|
this.Bay = selectedIMDG.Bay;
|
|
this.Class7Category = selectedIMDG.Class7Category;
|
|
this.Class7CSI = selectedIMDG.Class7CSI;
|
|
this.Class7MaxActivity_BQL = selectedIMDG.Class7MaxActivity_BQL;
|
|
this.Class7NuclideName = selectedIMDG.Class7NuclideName;
|
|
this.Class7TransportIndex = selectedIMDG.Class7TransportIndex;
|
|
this.CompatibilityGroup = selectedIMDG.CompatibilityGroup;
|
|
this.ContainerNumber = selectedIMDG.ContainerNumber;
|
|
this.ControlTemperature_CEL = selectedIMDG.ControlTemperature_CEL;
|
|
this.EmergencyTemperature_CEL = selectedIMDG.EmergencyTemperature_CEL;
|
|
this.ExceptedQuantities = selectedIMDG.ExceptedQuantities;
|
|
this.Flashpoint_CEL = selectedIMDG.Flashpoint_CEL;
|
|
this.GeneralCargoIBC = selectedIMDG.GeneralCargoIBC;
|
|
this.GrossQuantity_KGM = selectedIMDG.GrossQuantity_KGM;
|
|
this.IMOClass = selectedIMDG.IMOClass;
|
|
this.LimitedQuantities = selectedIMDG.LimitedQuantities;
|
|
this.MarinePollutant = selectedIMDG.MarinePollutant;
|
|
this.NetExplosiveMass_KGM = selectedIMDG.NetExplosiveMass_KGM;
|
|
this.NetQuantity_KGM = selectedIMDG.NetQuantity_KGM;
|
|
this.NumberOfPackages = selectedIMDG.NumberOfPackages;
|
|
this.PackageType = selectedIMDG.PackageType;
|
|
this.PackingGroup = selectedIMDG.PackingGroup;
|
|
this.PortOfDischarge = selectedIMDG.PortOfDischarge;
|
|
this.PortOfLoading = selectedIMDG.PortOfLoading;
|
|
this.ProperShippingName = selectedIMDG.ProperShippingName;
|
|
this.Remarks = selectedIMDG.Remarks;
|
|
this.Row = selectedIMDG.Row;
|
|
this.StowagePosition = selectedIMDG.StowagePosition;
|
|
this.SubsidiaryRiskText = selectedIMDG.SubsidiaryRiskText;
|
|
this.TechnicalName = selectedIMDG.TechnicalName;
|
|
this.Tier = selectedIMDG.Tier;
|
|
this.UNNumber = selectedIMDG.UNNumber;
|
|
this.VehicleLicenseNumber = selectedIMDG.VehicleLicenseNumber;
|
|
this.Volume_MTQ = selectedIMDG.Volume_MTQ;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IClone implementation
|
|
|
|
public override object Clone()
|
|
{
|
|
IMDGPosition imdg = this.MemberwiseClone() as IMDGPosition;
|
|
imdg.id = null;
|
|
imdg.SubsidiaryRiskList = new List<SubsidiaryRisks>();
|
|
|
|
foreach (SubsidiaryRisks sr in this.SubsidiaryRiskList)
|
|
{
|
|
SubsidiaryRisks clonedSR = sr.Clone() as SubsidiaryRisks;
|
|
clonedSR.IMDGPosition = imdg;
|
|
imdg.SubsidiaryRiskList.Add(clonedSR);
|
|
}
|
|
return imdg;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|