614 lines
25 KiB
C#
614 lines
25 KiB
C#
//
|
|
// Class: HAZ
|
|
// Current CLR: 4.0.30319.34209
|
|
// System: Microsoft Visual Studio 10.0
|
|
// Author: dani
|
|
// Created: 5/26/2015 8:13:35 PM
|
|
//
|
|
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
|
|
|
|
using Newtonsoft.Json;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Data.SqlClient;
|
|
|
|
namespace bsmd.database
|
|
{
|
|
|
|
[TypeConverter(typeof(MessageClassConverter<HAZ>))]
|
|
[JsonConverter(typeof(NoTypeConverterJsonConverter<HAZ>))]
|
|
public class HAZ : DatabaseEntity, ISublistContainer
|
|
{
|
|
|
|
public HAZ()
|
|
{ }
|
|
|
|
#region Properties
|
|
|
|
[Validation(ValidationCode.NOT_NULL)]
|
|
[ENI2Validation]
|
|
public bool? NoDPGOnBoardOnArrival { get; set; } = true;
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public bool? DPGManifestOnBoardOnArrival { get; set; } = false;
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public byte? INFShipClass { get; set; }
|
|
|
|
[ShowReport]
|
|
[ENI2Validation]
|
|
public bool? MOUBaltic { get; set; } = false;
|
|
|
|
[ENI2Validation]
|
|
public bool? DPGClassificationIMDG { get; set; }
|
|
|
|
[ENI2Validation]
|
|
public bool? DPGClassificationIGC { get; set; }
|
|
|
|
[ENI2Validation]
|
|
public bool? DPGClassificationIBC { get; set; }
|
|
|
|
[ENI2Validation]
|
|
public bool? DPGClassificationIMSBC { get; set; }
|
|
|
|
[ENI2Validation]
|
|
public bool? DPGClassificationMARPOL_ANNEX_I { get; set; }
|
|
|
|
// DK
|
|
[ENI2Validation]
|
|
[MaxLength(128)]
|
|
public string DPGContactFamilyName { get; set; }
|
|
|
|
// DK
|
|
[ENI2Validation]
|
|
[MaxLength(64)]
|
|
public string DPGContactPhone { get; set; }
|
|
|
|
public ObservableCollection<IMDGPosition> IMDGPositions { get; private set; } = new ObservableCollection<IMDGPosition>();
|
|
|
|
public ObservableCollection<IBCPosition> IBCPositions { get; private set; } = new ObservableCollection<IBCPosition>();
|
|
|
|
public ObservableCollection<IGCPosition> IGCPositions { get; private set; } = new ObservableCollection<IGCPosition>();
|
|
|
|
public ObservableCollection<IMSBCPosition> IMSBCPositions { get; private set; } = new ObservableCollection<IMSBCPosition>();
|
|
|
|
public ObservableCollection<MARPOL_Annex_I_Position> MARPOLPositions { get; private set; } = new ObservableCollection<MARPOL_Annex_I_Position>();
|
|
|
|
// selektor HAZA / HAZD
|
|
[ENI2Validation]
|
|
public bool IsDeparture { get; set; }
|
|
|
|
/// <summary>
|
|
/// No NSW field! Set to determine whether HAZ info should be reported to the NSW
|
|
/// </summary>
|
|
[ENI2Validation]
|
|
public string TransmissionType { get; set; }
|
|
|
|
[Browsable(false)]
|
|
[JsonIgnore]
|
|
public bool HasPositions
|
|
{
|
|
get
|
|
{
|
|
if (this.IMDGPositions.Count > 0) return true;
|
|
if (this.IBCPositions.Count > 0) return true;
|
|
if (this.IGCPositions.Count > 0) return true;
|
|
if (this.IMSBCPositions.Count > 0) return true;
|
|
if (this.MARPOLPositions.Count > 0) return true;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Hilfsstruktur für Packagetype Darstellung (IMDG) im ENI-2
|
|
/// </summary>
|
|
[JsonIgnore]
|
|
[Browsable(false)]
|
|
public static Dictionary<string, string> PackageTypes { get; set; }
|
|
|
|
#endregion
|
|
|
|
#region DatabaseEntity implementation
|
|
|
|
public override string Tablename
|
|
{
|
|
get
|
|
{
|
|
if (this.IsDeparture)
|
|
return "[dbo].[HAZD]";
|
|
else
|
|
return "[dbo].[HAZA]";
|
|
}
|
|
}
|
|
|
|
public override void PrepareSave(System.Data.IDbCommand cmd)
|
|
{
|
|
SqlCommand scmd = cmd as SqlCommand;
|
|
|
|
scmd.Parameters.AddWithValue("@P1", this.MessageHeader.Id);
|
|
scmd.Parameters.AddWithNullableValue("@P2", this.NoDPGOnBoardOnArrival);
|
|
scmd.Parameters.AddWithNullableValue("@P3", this.DPGManifestOnBoardOnArrival);
|
|
scmd.Parameters.AddWithNullableValue("@P4", this.INFShipClass);
|
|
scmd.Parameters.AddWithNullableValue("@P5", this.DPGClassificationIMDG);
|
|
scmd.Parameters.AddWithNullableValue("@P6", this.DPGClassificationIGC);
|
|
scmd.Parameters.AddWithNullableValue("@P7", this.DPGClassificationIBC);
|
|
scmd.Parameters.AddWithNullableValue("@P8", this.DPGClassificationIMSBC);
|
|
scmd.Parameters.AddWithNullableValue("@P9", this.DPGClassificationMARPOL_ANNEX_I);
|
|
scmd.Parameters.AddWithNullableValue("@P10", this.TransmissionType);
|
|
scmd.Parameters.AddWithNullableValue("@P11", this.MOUBaltic);
|
|
scmd.Parameters.AddWithNullableValue("@P12", this.DPGContactFamilyName);
|
|
scmd.Parameters.AddWithNullableValue("@P13", this.DPGContactPhone);
|
|
|
|
if (this.IsNew)
|
|
{
|
|
this.CreateId();
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
if (IsDeparture)
|
|
{
|
|
scmd.CommandText = string.Format("INSERT INTO {0} (Id, MessageHeaderId, NoDPGOnBoardOnDeparture, DPGManifestOnBoardOnDeparture, " +
|
|
"INFShipClass, DPGClassificationIMDG, DPGClassificationIGC, DPGClassificationIBC, DPGClassificationIMSBC, " +
|
|
"DPGClassificationMARPOL_ANNEX_I, TransmissionType, MOUBaltic, DPGContactFamilyName, DPGContactPhone) VALUES (@ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13)",
|
|
this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
scmd.CommandText = string.Format("INSERT INTO {0} (Id, MessageHeaderId, NoDPGOnBoardOnArrival, DPGManifestOnBoardOnArrival, " +
|
|
"INFShipClass, DPGClassificationIMDG, DPGClassificationIGC, DPGClassificationIBC, DPGClassificationIMSBC, " +
|
|
"DPGClassificationMARPOL_ANNEX_I, TransmissionType, MOUBaltic, DPGContactFamilyName, DPGContactPhone) VALUES (@ID, @P1, @P2, @P3, @P4, @P5, @P6, @P7, @P8, @P9, @P10, @P11, @P12, @P13)",
|
|
this.Tablename);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
scmd.Parameters.AddWithValue("@ID", this.Id);
|
|
if (IsDeparture)
|
|
{
|
|
scmd.CommandText = string.Format("UPDATE {0} SET NODPGOnBoardOnDeparture = @P2, DPGManifestOnBoardOnDeparture = @P3, " +
|
|
"INFShipClass = @P4, DPGClassificationIMDG = @P5, DPGClassificationIGC = @P6, DPGClassificationIBC = @P7, " +
|
|
"DPGClassificationIMSBC = @P8, DPGClassificationMARPOL_ANNEX_I = @P9, TransmissionType = @P10, MOUBaltic = @P11, DPGContactFamilyName = @P12, DPGContactPhone = @P13 WHERE Id = @ID", this.Tablename);
|
|
}
|
|
else
|
|
{
|
|
scmd.CommandText = string.Format("UPDATE {0} SET NODPGOnBoardOnArrival = @P2, DPGManifestOnBoardOnArrival = @P3, " +
|
|
"INFShipClass = @P4, DPGClassificationIMDG = @P5, DPGClassificationIGC = @P6, DPGClassificationIBC = @P7, " +
|
|
"DPGClassificationIMSBC = @P8, DPGClassificationMARPOL_ANNEX_I = @P9, TransmissionType = @P10, MOUBaltic = @P11, DPGContactFamilyName = @P12, DPGContactPhone = @P13 WHERE Id = @ID", this.Tablename);
|
|
}
|
|
}
|
|
}
|
|
|
|
public override void PrepareLoadCommand(System.Data.IDbCommand cmd, Message.LoadFilter filter, params object[] criteria)
|
|
{
|
|
string query = string.Format("SELECT Id, NoDPGOnBoardOnArrival, DPGManifestOnBoardOnArrival, INFShipClass, " +
|
|
"DPGClassificationIMDG, DPGClassificationIGC, DPGClassificationIBC, DPGClassificationIMSBC, " +
|
|
"DPGClassificationMARPOL_ANNEX_I, TransmissionType, MOUBaltic, DPGContactFamilyName, DPGContactPhone FROM {0} ", this.Tablename);
|
|
|
|
if (this.IsDeparture)
|
|
{
|
|
query = string.Format("SELECT Id, NoDPGOnBoardOnDeparture, DPGManifestOnBoardOnDeparture, INFShipClass, " +
|
|
"DPGClassificationIMDG, DPGClassificationIGC, DPGClassificationIBC, DPGClassificationIMSBC, " +
|
|
"DPGClassificationMARPOL_ANNEX_I, TransmissionType, MOUBaltic, DPGContactFamilyName, DPGContactPhone FROM {0} ", this.Tablename);
|
|
}
|
|
|
|
switch (filter)
|
|
{
|
|
case Message.LoadFilter.MESSAGEHEADER:
|
|
query += "WHERE MessageHeaderId = @MHID";
|
|
((SqlCommand)cmd).Parameters.AddWithValue("@MHID", criteria[0]);
|
|
break;
|
|
case Message.LoadFilter.ALL:
|
|
default:
|
|
|
|
break;
|
|
}
|
|
|
|
cmd.CommandText = query;
|
|
}
|
|
|
|
public override List<DatabaseEntity> LoadList(System.Data.IDataReader reader)
|
|
{
|
|
List<DatabaseEntity> result = new List<DatabaseEntity>();
|
|
|
|
while (reader.Read())
|
|
{
|
|
HAZ haz = new HAZ();
|
|
|
|
haz.id = reader.GetGuid(0);
|
|
if (!reader.IsDBNull(1)) haz.NoDPGOnBoardOnArrival = reader.GetBoolean(1);
|
|
if (!reader.IsDBNull(2)) haz.DPGManifestOnBoardOnArrival = reader.GetBoolean(2);
|
|
if (!reader.IsDBNull(3)) haz.INFShipClass = reader.GetByte(3);
|
|
if (!reader.IsDBNull(4)) haz.DPGClassificationIMDG = reader.GetBoolean(4);
|
|
if (!reader.IsDBNull(5)) haz.DPGClassificationIGC = reader.GetBoolean(5);
|
|
if (!reader.IsDBNull(6)) haz.DPGClassificationIBC = reader.GetBoolean(6);
|
|
if (!reader.IsDBNull(7)) haz.DPGClassificationIMSBC = reader.GetBoolean(7);
|
|
if (!reader.IsDBNull(8)) haz.DPGClassificationMARPOL_ANNEX_I = reader.GetBoolean(8);
|
|
if (!reader.IsDBNull(9)) haz.TransmissionType = reader.GetString(9);
|
|
if (!reader.IsDBNull(10)) haz.MOUBaltic = reader.GetBoolean(10);
|
|
if (!reader.IsDBNull(11)) haz.DPGContactFamilyName = reader.GetString(11);
|
|
if (!reader.IsDBNull(12)) haz.DPGContactPhone = reader.GetString(12);
|
|
|
|
result.Add(haz);
|
|
}
|
|
reader.Close();
|
|
return result;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Overrides
|
|
|
|
public override void OverwriteWith(DatabaseEntity otherEntity)
|
|
{
|
|
if (otherEntity is HAZ otherHAZ)
|
|
{
|
|
base.OverwriteWith(otherEntity);
|
|
|
|
// overwrite IMGD
|
|
|
|
foreach (IMDGPosition imdg in this.IMDGPositions)
|
|
DBManager.Instance.Delete(imdg);
|
|
this.IMDGPositions.Clear();
|
|
|
|
foreach (IMDGPosition imdg in otherHAZ.IMDGPositions)
|
|
{
|
|
IMDGPosition newIMDG = imdg.Clone() as IMDGPosition;
|
|
newIMDG.HAZ = this;
|
|
DBManager.Instance.Save(newIMDG);
|
|
this.IMDGPositions.Add(newIMDG);
|
|
}
|
|
|
|
// overwrite IBC
|
|
|
|
foreach (IBCPosition ibc in this.IBCPositions)
|
|
DBManager.Instance.Delete(ibc);
|
|
this.IBCPositions.Clear();
|
|
|
|
foreach (IBCPosition ibc in otherHAZ.IBCPositions)
|
|
{
|
|
IBCPosition newIBC = ibc.Clone() as IBCPosition;
|
|
newIBC.HAZ = this;
|
|
DBManager.Instance.Save(newIBC);
|
|
this.IBCPositions.Add(newIBC);
|
|
}
|
|
|
|
// overwrite IGC
|
|
|
|
foreach (IGCPosition igc in this.IGCPositions)
|
|
DBManager.Instance.Delete(igc);
|
|
this.IGCPositions.Clear();
|
|
|
|
foreach (IGCPosition igc in otherHAZ.IGCPositions)
|
|
{
|
|
IGCPosition newIGC = igc.Clone() as IGCPosition;
|
|
newIGC.HAZ = this;
|
|
DBManager.Instance.Save(newIGC);
|
|
this.IGCPositions.Add(newIGC);
|
|
}
|
|
|
|
// IMSBC
|
|
|
|
foreach (IMSBCPosition imsbc in this.IMSBCPositions)
|
|
DBManager.Instance.Delete(imsbc);
|
|
this.IMSBCPositions.Clear();
|
|
|
|
foreach (IMSBCPosition imsbc in otherHAZ.IMSBCPositions)
|
|
{
|
|
IMSBCPosition newIMSBC = imsbc.Clone() as IMSBCPosition;
|
|
newIMSBC.HAZ = this;
|
|
DBManager.Instance.Save(newIMSBC);
|
|
this.IMSBCPositions.Add(newIMSBC);
|
|
}
|
|
|
|
// Marpol
|
|
|
|
foreach (MARPOL_Annex_I_Position marpol in this.MARPOLPositions)
|
|
DBManager.Instance.Delete(marpol);
|
|
this.MARPOLPositions.Clear();
|
|
|
|
foreach (MARPOL_Annex_I_Position marpol in otherHAZ.MARPOLPositions)
|
|
{
|
|
MARPOL_Annex_I_Position newMarpol = marpol.Clone() as MARPOL_Annex_I_Position;
|
|
newMarpol.HAZ = this;
|
|
DBManager.Instance.Save(newMarpol);
|
|
this.MARPOLPositions.Add(newMarpol);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region ISublistContainer implementation
|
|
|
|
public ISublistElement GetSublistElementWithIdentifier(string identifier)
|
|
{
|
|
|
|
foreach (ISublistElement sublist in this.IMDGPositions)
|
|
{
|
|
if (sublist.Identifier.Equals(identifier))
|
|
return sublist;
|
|
}
|
|
return null;
|
|
}
|
|
|
|
[Browsable(false)]
|
|
[JsonIgnore]
|
|
public int NumberOfExcelRows { get { return 0; } }
|
|
|
|
public IGCPosition GetIGCPositionWithIdentifier(string identifier)
|
|
{
|
|
foreach (IGCPosition igcPosition in this.IGCPositions)
|
|
if (igcPosition.Identifier.Equals(identifier))
|
|
return igcPosition;
|
|
return null;
|
|
}
|
|
|
|
public IMDGPosition GetIMDGPositionWithIdentifier(string identifier)
|
|
{
|
|
foreach (IMDGPosition imdgPosition in this.IMDGPositions)
|
|
if (imdgPosition.Identifier.Equals(identifier))
|
|
return imdgPosition;
|
|
return null;
|
|
}
|
|
|
|
public IBCPosition GetIBCPositionWithIdentifier(string identifier)
|
|
{
|
|
foreach (IBCPosition ibcPosition in this.IBCPositions)
|
|
if (ibcPosition.Identifier.Equals(identifier))
|
|
return ibcPosition;
|
|
return null;
|
|
}
|
|
|
|
public IMSBCPosition GetIMSBCPositionWithIdentifier(string identifier)
|
|
{
|
|
foreach (IMSBCPosition imsbcPosition in this.IMSBCPositions)
|
|
if (imsbcPosition.Identifier.Equals(identifier))
|
|
return imsbcPosition;
|
|
return null;
|
|
}
|
|
|
|
public MARPOL_Annex_I_Position GetMARPOLPositionWithIdentifier(string identifier)
|
|
{
|
|
foreach (MARPOL_Annex_I_Position marpolPosition in this.MARPOLPositions)
|
|
if (marpolPosition.Identifier.Equals(identifier))
|
|
return marpolPosition;
|
|
return null;
|
|
}
|
|
|
|
public void SaveElements()
|
|
{
|
|
foreach (IMDGPosition imdg in this.IMDGPositions)
|
|
{
|
|
DBManager.Instance.Save(imdg);
|
|
((ISublistContainer)imdg).SaveElements();
|
|
}
|
|
foreach (IMSBCPosition imsbc in this.IMSBCPositions)
|
|
DBManager.Instance.Save(imsbc);
|
|
foreach (IBCPosition ibc in this.IBCPositions)
|
|
DBManager.Instance.Save(ibc);
|
|
foreach (IGCPosition igc in this.IGCPositions)
|
|
DBManager.Instance.Save(igc);
|
|
foreach (MARPOL_Annex_I_Position marpol in this.MARPOLPositions)
|
|
DBManager.Instance.Save(marpol);
|
|
}
|
|
|
|
|
|
public void DeleteElements()
|
|
{
|
|
foreach (IMDGPosition imdg in this.IMDGPositions)
|
|
DBManager.Instance.Delete(imdg);
|
|
this.IMDGPositions.Clear();
|
|
|
|
foreach (IMSBCPosition imsbc in this.IMSBCPositions)
|
|
DBManager.Instance.Delete(imsbc);
|
|
this.IMSBCPositions.Clear();
|
|
|
|
foreach (IBCPosition ibc in this.IBCPositions)
|
|
DBManager.Instance.Delete(ibc);
|
|
this.IBCPositions.Clear();
|
|
|
|
foreach (IGCPosition igc in this.IGCPositions)
|
|
DBManager.Instance.Delete(igc);
|
|
this.IBCPositions.Clear();
|
|
|
|
foreach (MARPOL_Annex_I_Position marpol in this.MARPOLPositions)
|
|
DBManager.Instance.Delete(marpol);
|
|
this.MARPOLPositions.Clear();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IMessageParagraph implementation
|
|
|
|
public override string Title
|
|
{
|
|
get
|
|
{
|
|
return this.IsDeparture ? "HAZD" : "HAZA";
|
|
}
|
|
}
|
|
|
|
public override string Subtitle
|
|
{
|
|
get
|
|
{
|
|
return this.IsDeparture ? "Hazardous items on departure" : "Hazardous items on arrival";
|
|
}
|
|
}
|
|
|
|
public override List<IMessageParagraph> ChildParagraphs
|
|
{
|
|
get
|
|
{
|
|
List<IMessageParagraph> allChildParagraphs = new List<IMessageParagraph>();
|
|
|
|
if(this.IMDGPositions.Count > 0)
|
|
{
|
|
MessageParagraph containerParagraph = new MessageParagraph();
|
|
containerParagraph.Title = "IMDGPositions";
|
|
//List<IMessageParagraph> sublist = new List<IMessageParagraph>();
|
|
foreach (IMessageParagraph imp in this.IMDGPositions)
|
|
containerParagraph.ChildParagraphs.Add(imp);
|
|
allChildParagraphs.Add(containerParagraph);
|
|
}
|
|
|
|
if(this.IBCPositions.Count > 0)
|
|
{
|
|
MessageParagraph containerParagraph = new MessageParagraph();
|
|
containerParagraph.Title = "IBCPositions";
|
|
//List<IMessageParagraph> sublist = new List<IMessageParagraph>();
|
|
foreach (IMessageParagraph imp in this.IBCPositions)
|
|
containerParagraph.ChildParagraphs.Add(imp);
|
|
allChildParagraphs.Add(containerParagraph);
|
|
}
|
|
|
|
if(this.IGCPositions.Count > 0)
|
|
{
|
|
MessageParagraph containerParagraph = new MessageParagraph();
|
|
containerParagraph.Title = "IGCPositions";
|
|
//List<IMessageParagraph> sublist = new List<IMessageParagraph>();
|
|
foreach (IMessageParagraph imp in this.IGCPositions)
|
|
containerParagraph.ChildParagraphs.Add(imp);
|
|
allChildParagraphs.Add(containerParagraph);
|
|
}
|
|
|
|
if(this.IMSBCPositions.Count > 0)
|
|
{
|
|
MessageParagraph containerParagraph = new MessageParagraph();
|
|
containerParagraph.Title = "IMSBCPositions";
|
|
//List<IMessageParagraph> sublist = new List<IMessageParagraph>();
|
|
foreach (IMessageParagraph imp in this.IMSBCPositions)
|
|
containerParagraph.ChildParagraphs.Add(imp);
|
|
allChildParagraphs.Add(containerParagraph);
|
|
}
|
|
|
|
if(this.MARPOLPositions.Count > 0)
|
|
{
|
|
MessageParagraph containerParagraph = new MessageParagraph();
|
|
containerParagraph.Title = "MARPOLPositions";
|
|
//List<IMessageParagraph> sublist = new List<IMessageParagraph>();
|
|
foreach (IMessageParagraph imp in this.MARPOLPositions)
|
|
containerParagraph.ChildParagraphs.Add(imp);
|
|
allChildParagraphs.Add(containerParagraph);
|
|
}
|
|
|
|
return allChildParagraphs;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Validation
|
|
|
|
public override DatabaseEntity.ValidationBlock GetValidationBlock()
|
|
{
|
|
return (this.NoDPGOnBoardOnArrival ?? false) ? ValidationBlock.BLOCK1 : ValidationBlock.BLOCK2;
|
|
}
|
|
|
|
public override void Validate(List<MessageError> errors, List<MessageViolation> violations)
|
|
{
|
|
|
|
if (!(this.NoDPGOnBoardOnArrival ?? true) && !this.HasPositions)
|
|
{
|
|
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "No DPG on board set", null, this.Title, null, this.Tablename));
|
|
}
|
|
|
|
if((NoDPGOnBoardOnArrival ?? false) && this.HasPositions)
|
|
{
|
|
violations.Add(RuleEngine.CreateViolation(ValidationCode.IMPLAUSIBLE, "HAZ Positions but Dangerous Goods on Board NOT set!", null, this.Title, null, this.Tablename));
|
|
}
|
|
|
|
if (this.GetValidationBlock() == ValidationBlock.BLOCK2)
|
|
{
|
|
/*
|
|
if ((this.IMDGPositions.Count == 0) && (this.IBCPositions.Count == 0) && (this.IGCPositions.Count == 0) &&
|
|
(this.IMSBCPositions.Count == 0) && (this.MARPOLPositions.Count == 0))
|
|
violations.Add(RuleEngine.CreateViolation(ValidationCode.V805, "At least one DPG item has to be provided!", null));
|
|
*/
|
|
|
|
foreach (IMDGPosition imdg in this.IMDGPositions)
|
|
{
|
|
RuleEngine.ValidateProperties(imdg, errors, violations);
|
|
imdg.Validate(errors, violations);
|
|
}
|
|
|
|
foreach(IBCPosition ibc in this.IBCPositions)
|
|
{
|
|
RuleEngine.ValidateProperties(ibc, errors, violations);
|
|
ibc.Validate(errors, violations);
|
|
}
|
|
|
|
foreach(IGCPosition igc in this.IGCPositions)
|
|
{
|
|
RuleEngine.ValidateProperties(igc, errors, violations);
|
|
igc.Validate(errors, violations);
|
|
}
|
|
|
|
foreach(IMSBCPosition imsbc in this.IMSBCPositions)
|
|
{
|
|
RuleEngine.ValidateProperties(imsbc, errors, violations);
|
|
imsbc.Validate(errors, violations);
|
|
}
|
|
|
|
foreach(MARPOL_Annex_I_Position marpol in this.MARPOLPositions)
|
|
{
|
|
RuleEngine.ValidateProperties(marpol, errors, violations);
|
|
marpol.Validate(errors, violations);
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region IClone implementation
|
|
|
|
public override object Clone()
|
|
{
|
|
HAZ haz = this.MemberwiseClone() as HAZ;
|
|
haz.id = null;
|
|
haz.IMDGPositions = new ObservableCollection<IMDGPosition>();
|
|
haz.IBCPositions = new ObservableCollection<IBCPosition>();
|
|
haz.IGCPositions = new ObservableCollection<IGCPosition>();
|
|
haz.IMSBCPositions = new ObservableCollection<IMSBCPosition>();
|
|
haz.MARPOLPositions = new ObservableCollection<MARPOL_Annex_I_Position>();
|
|
|
|
foreach (IMDGPosition imdgPosition in this.IMDGPositions)
|
|
{
|
|
IMDGPosition clonedIMDG = imdgPosition.Clone() as IMDGPosition;
|
|
clonedIMDG.HAZ = haz;
|
|
haz.IMDGPositions.Add(clonedIMDG);
|
|
}
|
|
foreach (IGCPosition igcPosition in this.IGCPositions)
|
|
{
|
|
IGCPosition clonedIGC = igcPosition.Clone() as IGCPosition;
|
|
clonedIGC.HAZ = haz;
|
|
haz.IGCPositions.Add(clonedIGC);
|
|
}
|
|
foreach (IBCPosition ibcPosition in this.IBCPositions)
|
|
{
|
|
IBCPosition clonedIBC = ibcPosition.Clone() as IBCPosition;
|
|
clonedIBC.HAZ = haz;
|
|
haz.IBCPositions.Add(clonedIBC);
|
|
}
|
|
foreach (IMSBCPosition imsbcPosition in this.IMSBCPositions)
|
|
{
|
|
IMSBCPosition clonedIMSBC = imsbcPosition.Clone() as IMSBCPosition;
|
|
clonedIMSBC.HAZ = haz;
|
|
haz.IMSBCPositions.Add(clonedIMSBC);
|
|
}
|
|
foreach (MARPOL_Annex_I_Position marpolPosition in this.MARPOLPositions)
|
|
{
|
|
MARPOL_Annex_I_Position clonedMARPOL = marpolPosition.Clone() as MARPOL_Annex_I_Position;
|
|
clonedMARPOL.HAZ = haz;
|
|
haz.MARPOLPositions.Add(clonedMARPOL);
|
|
}
|
|
return haz;
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
}
|