Fehlerkorrekturen bei WAS und INFO

This commit is contained in:
Daniel Schick 2022-03-02 10:30:23 +01:00
parent da7b586258
commit 4cf91200df
7 changed files with 115 additions and 123 deletions

View File

@ -745,25 +745,28 @@ namespace ENI2
} }
} }
if (crewdMessage.Elements.Count > 0) if (crewdMessage != null)
{ {
CREWD crewdFirst = crewdMessage.Elements[0] as CREWD; if (crewdMessage.Elements.Count > 0)
bool crewdIsSchengen = crewdFirst.NotificationSchengen ?? false;
if (!((crewdFirst.NotificationPAX ?? false) || crewdIsSchengen)) // mindestens eins der beiden
{ {
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.V181, "Wrong selection", null, "CREWD", null, "CREWD"); CREWD crewdFirst = crewdMessage.Elements[0] as CREWD;
mv.MessageGroupName = Properties.Resources.textOverview; bool crewdIsSchengen = crewdFirst.NotificationSchengen ?? false;
vViolations.Add(mv); if (!((crewdFirst.NotificationPAX ?? false) || crewdIsSchengen)) // mindestens eins der beiden
}
foreach (CREWD crewd in crewdMessage.Elements)
{
if (crewdIsSchengen && !crewd.HasSchengenDetails)
{ {
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.V182, "No Schengen details", null, "CREWD", crewd.Identifier, "CREWD"); MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.V181, "Wrong selection", null, "CREWD", null, "CREWD");
mv.MessageGroupName = Properties.Resources.textOverview; mv.MessageGroupName = Properties.Resources.textOverview;
vViolations.Add(mv); vViolations.Add(mv);
} }
foreach (CREWD crewd in crewdMessage.Elements)
{
if (crewdIsSchengen && !crewd.HasSchengenDetails)
{
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.V182, "No Schengen details", null, "CREWD", crewd.Identifier, "CREWD");
mv.MessageGroupName = Properties.Resources.textOverview;
vViolations.Add(mv);
}
}
} }
} }
@ -796,31 +799,34 @@ namespace ENI2
} }
} }
if (pasdMessage.Elements.Count > 0) if (pasdMessage != null)
{ {
PASD pasdFirst = pasdMessage.Elements[0] as PASD; if (pasdMessage.Elements.Count > 0)
bool pasdIsSchengen = pasdFirst.NotificationSchengen ?? false;
bool pasdIsPAX = pasdFirst.NotificationPAX ?? false;
if (!(pasdIsPAX || pasdIsSchengen)) // mindestens eins der beiden
{ {
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.V201, "Wrong selection", null, "PASD", null, "PASD"); PASD pasdFirst = pasdMessage.Elements[0] as PASD;
mv.MessageGroupName = Properties.Resources.textOverview; bool pasdIsSchengen = pasdFirst.NotificationSchengen ?? false;
vViolations.Add(mv); bool pasdIsPAX = pasdFirst.NotificationPAX ?? false;
} if (!(pasdIsPAX || pasdIsSchengen)) // mindestens eins der beiden
foreach (PASD pasd in pasdMessage.Elements)
{
if (pasdIsSchengen && !pasd.HasSchengenDetails)
{ {
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.V202, "No Schengen details", null, "PASD", pasd.Identifier, "PASD"); MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.V201, "Wrong selection", null, "PASD", null, "PASD");
mv.MessageGroupName = Properties.Resources.textOverview; mv.MessageGroupName = Properties.Resources.textOverview;
vViolations.Add(mv); vViolations.Add(mv);
} }
if (pasdIsPAX && !pasd.HasPAXDetails)
foreach (PASD pasd in pasdMessage.Elements)
{ {
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.V203, "No PAX details", null, "PASD", pasd.Identifier, "PASD"); if (pasdIsSchengen && !pasd.HasSchengenDetails)
mv.MessageGroupName = Properties.Resources.textOverview; {
vViolations.Add(mv); MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.V202, "No Schengen details", null, "PASD", pasd.Identifier, "PASD");
mv.MessageGroupName = Properties.Resources.textOverview;
vViolations.Add(mv);
}
if (pasdIsPAX && !pasd.HasPAXDetails)
{
MessageViolation mv = RuleEngine.CreateViolation(ValidationCode.V203, "No PAX details", null, "PASD", pasd.Identifier, "PASD");
mv.MessageGroupName = Properties.Resources.textOverview;
vViolations.Add(mv);
}
} }
} }
} }

View File

@ -466,54 +466,62 @@ namespace ENI2.DetailViewControls
{ {
do do
{ {
// skip first two rows // skip first three rows
reader.Read();
reader.Read(); reader.Read();
reader.Read(); reader.Read();
int cnt = 0; int cnt = 0;
object o = null; object o = null;
while (reader.Read() && (cnt < 15)) // Diese Funktion kann das "alte" Sheet Format nicht mehr einlesen!
{
if (((IExcelDataReader)reader).FieldCount < 10)
{
throw new InvalidDataException("Sheet must have 10 Columns of data");
}
Waste waste = new Waste();
while (reader.Read() && (cnt < 35))
{
if (reader.FieldCount < 9)
{
throw new InvalidDataException("Sheet must have 9 Columns of data");
}
if (!reader.IsDBNull(1)) o = reader.GetValue(1); else o = null; if (!reader.IsDBNull(1)) o = reader.GetValue(1); else o = null;
if (o != null) if ((o != null) && Int32.TryParse(o.ToString(), out int wasteType))
{ {
waste.WasteType = Convert.ToInt32(o); Waste waste = _was.GetWasteForType(wasteType);
if (waste.WasteType == 2313) waste.WasteType = 2600; if (waste == null)
{
waste = new Waste();
waste.WasteType = wasteType;
waste.WAS = this._was;
waste.IsDirty = true;
waste.Identifier = Waste.GetNewIdentifier(this._was.Waste);
this._was.Waste.Add(waste);
}
else
{
waste.IsDirty = true;
}
if (!reader.IsDBNull(4)) waste.WasteDescription = reader.GetString(4);
if (waste.WasteDescription.IsNullOrEmpty())
waste.WasteDescription = "-";
if (!reader.IsDBNull(5)) o = reader.GetValue(5); else o = null;
if (o != null) waste.WasteDisposalAmount_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(6)) o = reader.GetValue(6); else o = null;
if (o != null) waste.WasteCapacity_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(7)) o = reader.GetValue(7); else o = null;
if (o != null) waste.WasteAmountRetained_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(8)) waste.WasteDisposalPort = reader.GetString(8);
if (!reader.IsDBNull(9)) o = reader.GetValue(9); else o = null;
if (o != null) waste.WasteAmountGeneratedTillNextPort_MTQ = Convert.ToDouble(o);
importWasteList.Add(waste);
cnt++;
} }
if (!reader.IsDBNull(3)) waste.WasteDescription = reader.GetString(3);
if (!reader.IsDBNull(4)) o = reader.GetValue(4); else o = null;
if (o != null) waste.WasteDisposalAmount_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(5)) o = reader.GetValue(5); else o = null;
if (o != null) waste.WasteCapacity_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(6)) o = reader.GetValue(6); else o = null;
if (o != null) waste.WasteAmountRetained_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(7)) waste.WasteDisposalPort = reader.GetString(7);
if (!reader.IsDBNull(8)) o = reader.GetValue(8); else o = null;
if (o != null) waste.WasteAmountGeneratedTillNextPort_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(9)) o = reader.GetValue(9); else o = null;
if (o != null) waste.WasteDisposedAtLastPort_MTQ = Convert.ToDouble(o);
waste.WAS = this._was;
waste.IsDirty = true;
waste.Identifier = Waste.GetNewIdentifier(this._was.Waste);
this._was.Waste.Add(waste);
importWasteList.Add(waste);
cnt++;
} }
} while (reader.NextResult()); } while (reader.NextResult());
@ -526,7 +534,7 @@ namespace ENI2.DetailViewControls
if (importWasteList.Count > 0) if (importWasteList.Count > 0)
{ {
this.dataGridWaste.Items.Refresh(); this.dataGridWaste.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.SEC); this.SublistElementChanged(Message.NotificationClass.WAS);
MessageBox.Show(String.Format(Properties.Resources.textWasteImported, importWasteList.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show(String.Format(Properties.Resources.textWasteImported, importWasteList.Count), Properties.Resources.textCaptionInformation, MessageBoxButton.OK, MessageBoxImage.Information);
} }
} }

View File

@ -1038,9 +1038,12 @@ namespace ENI2.Excel
Waste waste = was.Waste[i]; Waste waste = was.Waste[i];
if(waste.WasteType.HasValue) if (waste.WasteType.HasValue)
{
WriteNumber(wasteCode, waste.WasteType.Value); WriteNumber(wasteCode, waste.WasteType.Value);
WriteText(wastetype, waste.WasteTypeDisplay); if (WAS.WasteCodeDict.ContainsKey(waste.WasteType.Value.ToString()))
WriteText(wastetype, WAS.WasteCodeDict[waste.WasteType.Value.ToString()]);
}
WriteText(wasteDescription, waste.WasteDescription); WriteText(wasteDescription, waste.WasteDescription);
if (waste.WasteDisposalAmount_MTQ.HasValue) if (waste.WasteDisposalAmount_MTQ.HasValue)
WriteNumber(wasteAmount, waste.WasteDisposalAmount_MTQ.Value); WriteNumber(wasteAmount, waste.WasteDisposalAmount_MTQ.Value);

View File

@ -427,7 +427,7 @@ namespace bsmd.database
List<DatabaseEntity> portAreas = pa.LoadList(reader); List<DatabaseEntity> portAreas = pa.LoadList(reader);
DBManager.allPortAreas = new Dictionary<string, PortArea>(); DBManager.allPortAreas = new Dictionary<string, PortArea>();
foreach (PortArea aPa in portAreas) foreach (PortArea aPa in portAreas)
DBManager.allPortAreas.Add(aPa.Code, aPa); DBManager.allPortAreas[aPa.Code] = aPa; // TODO da gibt es doppelte Einträge
} }
return DBManager.allPortAreas; return DBManager.allPortAreas;
} }

View File

@ -150,9 +150,7 @@ namespace bsmd.database
{ {
if(isDE) if(isDE)
{ {
if ((notificationClass == Message.NotificationClass.CREWD) || if (notificationClass == Message.NotificationClass.STO) continue;
(notificationClass == Message.NotificationClass.PASD) ||
(notificationClass == Message.NotificationClass.STO)) continue;
} }
if(isDK) if(isDK)
{ {

View File

@ -516,6 +516,14 @@ namespace bsmd.database
#region public convenience method #region public convenience method
public Waste GetWasteForType(int wasteType)
{
foreach (Waste waste in this.Waste)
if (waste.WasteType.HasValue && waste.WasteType.Value == wasteType)
return waste;
return null;
}
public List<Waste> AddRemainingWasteTypes() public List<Waste> AddRemainingWasteTypes()
{ {
List<Waste> result = new List<Waste>(); List<Waste> result = new List<Waste>();

View File

@ -30,31 +30,7 @@ namespace bsmd.database
[JsonIgnore] [JsonIgnore]
[Browsable(false)] [Browsable(false)]
public WAS WAS { get; set; } public WAS WAS { get; set; }
[JsonIgnore]
[Browsable(false)]
[ShowReport]
public string WasteTypeDisplay
{
get
{
if (!WasteType.HasValue) return "";
switch (WasteType.Value)
{
case 1: return "WASTE_OILS-SLUDGE";
case 2: return "WASTE_OILS-BILGE_WATER";
case 3: return "WASTE_OILS-OTHERS";
case 4: return "GARBAGE-FOOD_WASTE";
case 5: return "GARBATE-PLASTIC";
case 6: return "GARBAGE-OTHER";
case 7: return "SEWAGE";
case 8: return "CARGO-ASSOCIATED_WASTE";
case 9: return "CARGO-RESIDUES";
default: return "";
}
}
}
[ShowReport] [ShowReport]
[JsonIgnore] [JsonIgnore]
@ -62,9 +38,10 @@ namespace bsmd.database
{ {
get get
{ {
if (!WasteType.HasValue) return ""; if (!WasteType.HasValue) return string.Empty;
switch(WasteType.Value) switch(WasteType.Value)
{ {
// "old" waste codes (pre V7), used to display old data
case 1100: return "Oily residues (sludge)"; case 1100: return "Oily residues (sludge)";
case 1200: return "Oily bilge water"; case 1200: return "Oily bilge water";
case 1300: return "Waste oil - others (specify)"; case 1300: return "Waste oil - others (specify)";
@ -79,9 +56,9 @@ namespace bsmd.database
case 3000: return "Sewage"; case 3000: return "Sewage";
case 5100: return "Cargo residues - Marpol Annex I"; case 5100: return "Cargo residues - Marpol Annex I";
case 5200: return "Cargo residues - Marpol Annex II"; case 5200: return "Cargo residues - Marpol Annex II";
case 5300: return "Cargo residues - Marpol Annex V"; case 5300: return "Cargo residues - Marpol Annex V";
default: return "Others (specify)"; default: return string.Empty;
} }
} }
} }
@ -91,7 +68,14 @@ namespace bsmd.database
{ {
get get
{ {
return string.Format("{0} {1}", WasteType, WasteTypeDisplayV4); if (!this.WasteType.HasValue) return string.Empty;
string code = WasteTypeDisplayV4;
if(code.IsNullOrEmpty())
{
if (WAS.WasteCodeDict.ContainsKey(this.WasteType.ToString()))
code = WAS.WasteCodeDict[this.WasteType.ToString()];
}
return string.Format("{0} {1}", WasteType, code);
} }
} }
@ -149,27 +133,12 @@ namespace bsmd.database
get get
{ {
if (!this.WasteType.HasValue) return false; if (!this.WasteType.HasValue) return false;
switch(this.WasteType.Value) foreach(string wasteCode in WAS.WasteCodes)
{ {
case 1100: if (wasteCode.Equals(this.WasteType.Value.ToString()))
case 1200:
case 1300:
case 2100:
case 2200:
case 2300:
case 2311:
case 2308:
case 2313:
case 2600:
case 2309:
case 3000:
case 5100:
case 5200:
case 5300:
return true; return true;
default: }
return false; return false;
}
} }
} }