refactured report document, updated WAS

This commit is contained in:
Daniel Schick 2022-03-03 08:31:14 +01:00
parent 585c400510
commit 9328998ff0

View File

@ -367,123 +367,24 @@ namespace ENI2.Report
public static void AddNSWMessageParagraph(Document document, IMessageParagraph messageParagraph)
{
Message message = messageParagraph as Message;
if ((!(messageParagraph is Message message)) || (message.Elements.Count == 0)) return;
#region Einzelne Seite in Landscape für CREW Meldung
#region setup page orientation depending on message class
if (message?.MessageNotificationClass == Message.NotificationClass.CREW)
switch (message.MessageNotificationClass)
{
// Landscape
if (_lastOrientation == Orientation.Portrait)
case Message.NotificationClass.CREW:
case Message.NotificationClass.CREWD:
case Message.NotificationClass.PAS:
case Message.NotificationClass.PASD:
case Message.NotificationClass.TOWA:
case Message.NotificationClass.TOWD:
case Message.NotificationClass.HAZA when (message.Elements[0] is HAZ haz) && ((haz.IMDGPositions.Count > 0) || (haz.IBCPositions.Count > 0) || (haz.IGCPositions.Count > 0) || (haz.IMSBCPositions.Count > 0) || (haz.MARPOLPositions.Count > 0)):
{
ReportDocument.DefineContentSection(document, Orientation.Landscape, false);
_lastOrientation = Orientation.Landscape;
}
else
{
document.LastSection.AddPageBreak();
}
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Title), "Heading2");
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Subtitle), "Heading3");
ReportDocument.CreateCrewTable(document, message);
return;
}
#endregion
#region Einzelne Seite in Landscape für PAS Meldung
if (message?.MessageNotificationClass == Message.NotificationClass.PAS)
{
// Landscape
if (_lastOrientation == Orientation.Portrait)
{
ReportDocument.DefineContentSection(document, Orientation.Landscape, false);
_lastOrientation = Orientation.Landscape;
}
else
{
document.LastSection.AddPageBreak();
}
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Title), "Heading2");
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Subtitle), "Heading3");
ReportDocument.CreatePassengerTable(document, message);
return;
}
#endregion
#region Einzelne Seite in Landscape für TOWA Meldung
if (message?.MessageNotificationClass == Message.NotificationClass.TOWA)
{
// Landscape
if (_lastOrientation == Orientation.Portrait)
{
ReportDocument.DefineContentSection(document, Orientation.Landscape, false);
_lastOrientation = Orientation.Landscape;
}
else
{
document.LastSection.AddPageBreak();
}
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Title), "Heading2");
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Subtitle), "Heading3");
ReportDocument.CreateTOWATable(document, message);
return;
}
#endregion
#region Einzelne Seite in Landscape für TOWD Meldung
if (message?.MessageNotificationClass == Message.NotificationClass.TOWD)
{
// Landscape
if (_lastOrientation == Orientation.Portrait)
{
ReportDocument.DefineContentSection(document, Orientation.Landscape, false);
_lastOrientation = Orientation.Landscape;
}
else
{
document.LastSection.AddPageBreak();
}
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Title), "Heading2");
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Subtitle), "Heading3");
ReportDocument.CreateTOWDTable(document, message);
return;
}
#endregion
#region Landscape für HAZ
if ((message != null) &&
((message.MessageNotificationClass == Message.NotificationClass.HAZA) || (message.MessageNotificationClass == Message.NotificationClass.HAZD)) &&
(message.Elements.Count > 0)
)
{
if ((message.Elements[0] is HAZ haz) &&
((haz.IMDGPositions.Count > 0) || (haz.IBCPositions.Count > 0) || (haz.IGCPositions.Count > 0) || (haz.IMSBCPositions.Count > 0) || (haz.MARPOLPositions.Count > 0)))
{
// Landscape
// Landscape if not set
if (_lastOrientation == Orientation.Portrait)
{
ReportDocument.DefineContentSection(document, Orientation.Landscape, false);
DefineContentSection(document, Orientation.Landscape, false);
_lastOrientation = Orientation.Landscape;
}
else
@ -491,131 +392,79 @@ namespace ENI2.Report
document.LastSection.AddPageBreak();
}
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Title), "Heading2");
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Subtitle), "Heading3");
document.LastSection.AddParagraph(ReplaceTitle(messageParagraph.Title), "Heading2");
document.LastSection.AddParagraph(ReplaceTitle(messageParagraph.Subtitle), "Heading3");
ReportDocument.CreateHAZPage(document, haz);
}
return;
}
#endregion
if(_lastOrientation == Orientation.Landscape)
{
ReportDocument.DefineContentSection(document, Orientation.Portrait, false);
_lastOrientation = Orientation.Portrait;
}
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Title), "Heading2");
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(messageParagraph.Subtitle), "Heading3");
#region Spezialbehandlung WAS Meldung
if (message?.MessageNotificationClass == Message.NotificationClass.WAS)
{
ReportDocument.CreateWASTable(document, message);
return;
}
#endregion
#region NOA_NOD
if (message?.MessageNotificationClass == Message.NotificationClass.NOA_NOD)
{
NOA_NOD noa_nod = message.Elements[0] as NOA_NOD;
Table table = document.LastSection.AddTable();
table.Rows.VerticalAlignment = VerticalAlignment.Center;
table.Borders.Visible = true;
table.Borders.Color = Colors.LightGray;
table.AddColumn(290);
table.AddColumn(200);
Row row = table.AddRow();
if (noa_nod.ETAToPortOfCall.HasValue)
break;
default:
{
row.Cells[0].AddParagraph("Estimated time of arrival (ETA) at port of call");
row.Cells[1].AddParagraph(noa_nod.ETAToPortOfCall.Value.ToLocalTime().ToString("g"));
row = table.AddRow();
row.Cells[0].AddParagraph("Estimated time of departure (ETD) from port of call");
row.Cells[1].AddParagraph(noa_nod.ETDFromPortOfCall.HasValue ? noa_nod.ETDFromPortOfCall.Value.ToLocalTime().ToString("g") : "");
if (_lastOrientation == Orientation.Landscape)
{
ReportDocument.DefineContentSection(document, Orientation.Portrait, false);
_lastOrientation = Orientation.Portrait;
}
document.LastSection.AddParagraph(ReplaceTitle(messageParagraph.Title), "Heading2");
document.LastSection.AddParagraph(ReplaceTitle(messageParagraph.Subtitle), "Heading3");
}
else // Kiel passage
{
row.Cells[0].AddParagraph("Estimated time of arrival (ETA) at Kiel Canal entrance (Transit)");
row.Cells[1].AddParagraph(noa_nod.ETAToKielCanal.HasValue ? noa_nod.ETAToKielCanal.Value.ToLocalTime().ToString("g") : "");
row = table.AddRow();
row.Cells[0].AddParagraph("Estimated time of departure (ETD) from Kiel Canal (Transit)");
row.Cells[1].AddParagraph(noa_nod.ETDFromKielCanal.HasValue ? noa_nod.ETDFromKielCanal.Value.ToLocalTime().ToString("g") : "");
}
row = table.AddRow();
row.Cells[0].AddParagraph("Last port");
row.Cells[1].AddParagraph(LocodeDB.PortNameFromLocode(noa_nod.LastPort) ?? "");
row = table.AddRow();
row.Cells[0].AddParagraph("Estimated time of departure from last port");
row.Cells[1].AddParagraph(noa_nod.ETDFromLastPort.HasValue ? noa_nod.ETDFromLastPort.Value.ToLocalTime().ToString("g") : "");
row = table.AddRow();
row.Cells[0].AddParagraph("Next port");
row.Cells[1].AddParagraph(LocodeDB.PortNameFromLocode(noa_nod.NextPort) ?? "");
row = table.AddRow();
row.Cells[0].AddParagraph("Estimated time of arrival at next port");
row.Cells[1].AddParagraph(noa_nod.ETAToNextPort.HasValue ? noa_nod.ETAToNextPort.Value.ToLocalTime().ToString("g") : "");
ReportDocument.CreateCallPurposeTable(document, message);
return;
break;
}
#endregion
#region BKRD
#region fill paragraph depending on message class
if (message?.MessageNotificationClass == Message.NotificationClass.BKRD)
switch(message.MessageNotificationClass)
{
ReportDocument.CreateBKRDTable(document, message);
return;
case Message.NotificationClass.CREW:
case Message.NotificationClass.CREWD:
CreateCrewTable(document, message);
return;
case Message.NotificationClass.PAS:
case Message.NotificationClass.PASD:
CreatePassengerTable(document, message);
return;
case Message.NotificationClass.TOWA:
CreateTOWATable(document, message);
return;
case Message.NotificationClass.TOWD:
CreateTOWDTable(document, message);
return;
case Message.NotificationClass.HAZA when (message.Elements[0] is HAZ haz) && ((haz.IMDGPositions.Count > 0) || (haz.IBCPositions.Count > 0) || (haz.IGCPositions.Count > 0) || (haz.IMSBCPositions.Count > 0) || (haz.MARPOLPositions.Count > 0)):
CreateHAZPage(document, haz);
return;
case Message.NotificationClass.WAS:
CreateWASTable(document, message);
return;
case Message.NotificationClass.NOA_NOD:
CreateNOANODTable(document, message);
return;
case Message.NotificationClass.BKRD:
CreateBKRDTable(document, message);
return;
case Message.NotificationClass.BKRA:
CreateBKRATable(document, message);
return;
case Message.NotificationClass.LADG:
CreateLADGTable(document, message);
return;
case Message.NotificationClass.SERV:
CreateSERVTable(document, message);
return;
case Message.NotificationClass.WAS_RCPT:
CreateWAS_RCPTTable(document, message);
return;
default:
if (messageParagraph.MessageText != null) // komplette Nachricht (z.B. STAT)
ReportDocument.AddActualTableParagraph(document, messageParagraph, false);
break;
}
#endregion
#region BKRA
if (message?.MessageNotificationClass == Message.NotificationClass.BKRA)
{
ReportDocument.CreateBKRATable(document, message);
return;
}
#endregion
#region LADG
if(message?.MessageNotificationClass == Message.NotificationClass.LADG)
{
ReportDocument.CreateLADGTable(document, message);
return;
}
#endregion
#region SERV
if (message?.MessageNotificationClass == Message.NotificationClass.SERV)
{
ReportDocument.CreateSERVTable(document, message);
return;
}
#endregion
if (messageParagraph.MessageText != null) // komplette Nachricht (z.B. STAT)
ReportDocument.AddActualTableParagraph(document, messageParagraph, false);
// Kopf - Listen Meldeklassen mit mehreren untergeordneten Listen fügen jetzt noch ihre Listen hinzu
#region SEC
@ -967,6 +816,60 @@ namespace ENI2.Report
#endregion
#region NOA_NOD
private static void CreateNOANODTable(Document document, Message message)
{
NOA_NOD noa_nod = message.Elements[0] as NOA_NOD;
Table table = document.LastSection.AddTable();
table.Rows.VerticalAlignment = VerticalAlignment.Center;
table.Borders.Visible = true;
table.Borders.Color = Colors.LightGray;
table.AddColumn(290);
table.AddColumn(200);
Row row = table.AddRow();
if (noa_nod.ETAToPortOfCall.HasValue)
{
row.Cells[0].AddParagraph("Estimated time of arrival (ETA) at port of call");
row.Cells[1].AddParagraph(noa_nod.ETAToPortOfCall.Value.ToLocalTime().ToString("g"));
row = table.AddRow();
row.Cells[0].AddParagraph("Estimated time of departure (ETD) from port of call");
row.Cells[1].AddParagraph(noa_nod.ETDFromPortOfCall.HasValue ? noa_nod.ETDFromPortOfCall.Value.ToLocalTime().ToString("g") : "");
}
else // Kiel passage
{
row.Cells[0].AddParagraph("Estimated time of arrival (ETA) at Kiel Canal entrance (Transit)");
row.Cells[1].AddParagraph(noa_nod.ETAToKielCanal.HasValue ? noa_nod.ETAToKielCanal.Value.ToLocalTime().ToString("g") : "");
row = table.AddRow();
row.Cells[0].AddParagraph("Estimated time of departure (ETD) from Kiel Canal (Transit)");
row.Cells[1].AddParagraph(noa_nod.ETDFromKielCanal.HasValue ? noa_nod.ETDFromKielCanal.Value.ToLocalTime().ToString("g") : "");
}
row = table.AddRow();
row.Cells[0].AddParagraph("Last port");
row.Cells[1].AddParagraph(LocodeDB.PortNameFromLocode(noa_nod.LastPort) ?? "");
row = table.AddRow();
row.Cells[0].AddParagraph("Estimated time of departure from last port");
row.Cells[1].AddParagraph(noa_nod.ETDFromLastPort.HasValue ? noa_nod.ETDFromLastPort.Value.ToLocalTime().ToString("g") : "");
row = table.AddRow();
row.Cells[0].AddParagraph("Next port");
row.Cells[1].AddParagraph(LocodeDB.PortNameFromLocode(noa_nod.NextPort) ?? "");
row = table.AddRow();
row.Cells[0].AddParagraph("Estimated time of arrival at next port");
row.Cells[1].AddParagraph(noa_nod.ETAToNextPort.HasValue ? noa_nod.ETAToNextPort.Value.ToLocalTime().ToString("g") : "");
ReportDocument.CreateCallPurposeTable(document, message);
}
#endregion
#region SEC
private static void CreateLast10PortFacilitiesTable(Document document, Message message)
@ -1214,9 +1117,7 @@ namespace ENI2.Report
row.Cells[1].AddParagraph("Waste disposal order (all, some, none)");
row = table.AddRow();
for (int i = 0; i < was.WasteDisposalServiceProvider.Count; i++)
row.Cells[0].AddParagraph(((WasteDisposalServiceProvider) was.WasteDisposalServiceProvider[i]).WasteDisposalServiceProviderName);
if (was.WasteDisposalDelivery.HasValue)
row.Cells[1].AddParagraph((was.WasteDisposalDelivery.Value == 0) ? "ALL" : (was.WasteDisposalDelivery == 1) ? "SOME" : "NONE");
row.Cells[0].AddParagraph(((WasteDisposalServiceProvider) was.WasteDisposalServiceProvider[i]).WasteDisposalServiceProviderName);
table = document.LastSection.AddTable();
table.Rows.VerticalAlignment = VerticalAlignment.Top;
@ -1241,62 +1142,15 @@ namespace ENI2.Report
row.Cells[5].AddParagraph("Port of delivery of remaining waste");
row.Cells[6].AddParagraph("Estimated waste/cargo residues amount generated between port of call and next port");
row = table.AddRow();
row.Cells[0].AddParagraph("1100 Oily residues (sludge)");
GetWasteForIndex(1100, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("1200 Oily bilge water");
GetWasteForIndex(1200, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("1300 Waste oil - others");
GetWasteForIndex(1300, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("2100 Food waste");
GetWasteForIndex(2100, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("2200 Plastic");
GetWasteForIndex(2200, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("2300 Domestic wastes");
GetWasteForIndex(2300, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("2311 Cooking oil");
GetWasteForIndex(2311, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("2308 Incinerator ashes");
GetWasteForIndex(2308, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("2600 Operational wastes");
GetWasteForIndex(2600, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("2309 Animal carcass(es)");
GetWasteForIndex(2309, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("3000 Sewage");
GetWasteForIndex(3000, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("5100 Cargo residues - Marpol Annex I");
GetWasteForIndex(5100, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("5200 Cargo residues - Marpol Annex II");
GetWasteForIndex(5200, was, row);
row = table.AddRow();
row.Cells[0].AddParagraph("5300 Cargo residues - Marpol Annex ");
GetWasteForIndex(5300, was, row);
for (int i = 0; i < WAS.WasteCodes.Length; i++)
{
row = table.AddRow();
row.Cells[0].AddParagraph(string.Format("{0} {1}", WAS.WasteCodes[i], WAS.WasteCodeDescriptions[i]));
if(Int32.TryParse(WAS.WasteCodes[i], out int wasteCode))
GetWasteForIndex(wasteCode, was, row);
}
}
private static void GetWasteForIndex(int index, WAS was, Row row)
@ -1318,6 +1172,18 @@ namespace ENI2.Report
#endregion
#region WAS_RCPT
private static void CreateWAS_RCPTTable(Document document, Message message)
{
foreach(WAS_RCPT was_rpct in message.Elements)
{
}
}
#endregion
#region TOWA
private static void CreateTOWATable(Document document, Message message)