git_bsmd/ENI2/Report/ReportDocument.cs

2089 lines
92 KiB
C#

//
// Class: Document
// Current CLR: 4.0.30319.34209
// System: Microsoft Visual Studio 10.0
// Author: dani
// Created: 5/27/2015 8:52:50 PM
//
// Copyright (c) 2015 Informatikbüro Daniel Schick. All rights reserved.
// Description: Helper class to create a PDF file
using System;
using System.Collections.Generic;
using System.IO;
using MigraDoc;
using MigraDoc.DocumentObjectModel;
using MigraDoc.DocumentObjectModel.Shapes;
using MigraDoc.DocumentObjectModel.Tables;
using MigraDoc.Rendering;
using bsmd.database;
using ENI2.Locode;
using System.Text;
namespace ENI2.Report
{
public class ReportDocument
{
private static Orientation _lastOrientation = Orientation.Portrait;
#region static lookup helpers
private static Dictionary<string, string> _cargoCodesNST = null;
private static Dictionary<string, string> cargoCodesNST
{
get
{
if(_cargoCodesNST == null)
{
_cargoCodesNST = LocalizedLookup.getCargoCodesNST();
}
return _cargoCodesNST;
}
}
public static Dictionary<int, string> Edifact8025 = new Dictionary<int, string> {
{1, "Cargo operations" },
{2, "Passenger movement" },
{3, "Taking bunkers" },
{4, "Changing crew" },
{5, "Goodwill visit" },
{6, "Taking supplies" },
{7, "Repair" },
{8, "Laid-up" },
{9, "Awaiting orders" },
{10, "Miscellaneous" },
{11, "Crew movement" },
{12, "Cruise, leisure and recreation" },
{13, "Under government order" },
{14, "Quarantine inspection" },
{15, "Refuge" },
{16, "Unloading cargo" },
{17, "Loading cargo" },
{18, "Repair in dry dock" },
{19, "Repair in wet dock" },
{20, "Cargo tank cleaning" },
{21, "Means of transport customs clearance" },
{22, "De-gassing" },
{23, "Waste disposal" },
{98, "Pass through" }
};
#endregion
#region create document
internal static Document CreateSingleClassDocument(MessageCore reportCore, Dictionary<string, string> coverInfos, string classes, ReportingParty rp)
{
Document document = new Document();
document.Info.Title = string.Format("{0} for {1}", classes, reportCore.DisplayId);
document.Info.Subject = "Reporting class info";
document.Info.Author = Properties.Settings.Default.ReportAuthor;
DefineSingleStyle(document);
DefineSingleHeader(document, coverInfos, rp);
DefineContentSectionInitial(document);
DatabaseEntity.ReportReplacer += DatabaseEntity_ReportReplacer; // ist das ein Leak?
_lastOrientation = Orientation.Portrait; // Reset orientation (if last page was landscape..)
return document;
}
/// <summary>
/// create the final output document
/// </summary>
/// <param name="document">document to render</param>
/// <param name="filename">full path of bla.pdf output file</param>
public static void RenderDocument(Document document, string filename)
{
string filenameCore = Path.GetFileNameWithoutExtension(filename);
string migraTempFile = string.Format("{1}\\{0}.mdddl", filenameCore, Path.GetDirectoryName(filename));
MigraDoc.DocumentObjectModel.IO.DdlWriter.WriteToFile(document, migraTempFile);
PdfDocumentRenderer renderer = new PdfDocumentRenderer(true);
renderer.Document = document;
renderer.RenderDocument();
renderer.PdfDocument.Save(filename);
File.Delete(migraTempFile); // dont need that
}
#endregion
#region Style
public static void DefineStyles(Document document)
{
// Get the predefined style Normal.
Style style = document.Styles["Normal"];
// Because all styles are derived from Normal, the next line changes the
// font of the whole document. Or, more exactly, it changes the font of
// all styles and paragraphs that do not redefine the font.
style.Font.Name = "Times New Roman";
// Heading1 to Heading9 are predefined styles with an outline level. An outline level
// other than OutlineLevel.BodyText automatically creates the outline (or bookmarks)
// in PDF.
style = document.Styles["Heading1"];
style.Font.Name = "Tahoma";
style.Font.Size = 14;
style.Font.Bold = true;
style.Font.Color = Colors.DarkBlue;
style.ParagraphFormat.PageBreakBefore = true;
style.ParagraphFormat.SpaceAfter = 6;
style = document.Styles["Heading2"];
style.Font.Size = 12;
style.Font.Bold = true;
style.ParagraphFormat.PageBreakBefore = false;
style.ParagraphFormat.SpaceBefore = 6;
style.ParagraphFormat.SpaceAfter = 6;
style = document.Styles["Heading3"];
style.Font.Size = 10;
style.Font.Bold = true;
style.Font.Italic = true;
style.ParagraphFormat.SpaceBefore = 6;
style.ParagraphFormat.SpaceAfter = 3;
style = document.Styles[StyleNames.Header];
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right);
style = document.Styles[StyleNames.Footer];
style.ParagraphFormat.AddTabStop("8cm", TabAlignment.Center);
// Create a new style called TextBox based on style Normal
style = document.Styles.AddStyle("TextBox", "Normal");
style.ParagraphFormat.Alignment = ParagraphAlignment.Justify;
style.ParagraphFormat.Borders.Width = 2.5;
style.ParagraphFormat.Borders.Distance = "3pt";
style.ParagraphFormat.Shading.Color = Colors.SkyBlue;
// Create a new style called TOC based on style Normal
style = document.Styles.AddStyle("TOC", "Normal");
style.ParagraphFormat.AddTabStop("16cm", TabAlignment.Right, TabLeader.Dots);
style.ParagraphFormat.Font.Color = Colors.Blue;
}
static void DefineSingleStyle(Document doc)
{
Style style = doc.Styles["Normal"];
style.Font.Name = "Verdana";
Style grayStyle = doc.Styles.AddStyle("Gray", "Normal");
grayStyle.Font.Size = 9;
grayStyle.Font.Color = Colors.Gray;
Style tableStyle = doc.Styles.AddStyle("Table", "Normal");
tableStyle.Font.Name = "Verdana";
tableStyle.Font.Size = 9;
// usw
Style tableHeaderStyle = doc.Styles.AddStyle("TableHeader", "Normal");
//tableHeaderStyle.Font.Name = "Verdana";
tableHeaderStyle.Font.Size = 10;
tableHeaderStyle.Font.Bold = true;
Style tableValueStyle = doc.Styles.AddStyle("TableValue", "Normal");
tableValueStyle.Font.Size = 9;
tableValueStyle.Font.Bold = true;
style = doc.Styles["Heading2"];
style.Font.Size = 12;
style.Font.Bold = true;
style.ParagraphFormat.SpaceBefore = 6;
style.ParagraphFormat.SpaceAfter = 6;
style = doc.Styles["Heading3"];
style.Font.Size = 10;
style.Font.Bold = true;
style.Font.Italic = true;
style.ParagraphFormat.SpaceBefore = 6;
style.ParagraphFormat.SpaceAfter = 3;
}
#endregion
#region Label DB
static List<KeyValuePair<string, string>> ReplaceLabels(List<KeyValuePair<string, string>> messageText)
{
if (messageText == null) return null;
List<KeyValuePair<string, string>> result = new List<KeyValuePair<string, string>>();
foreach(KeyValuePair<string, string> field in messageText)
{
if (LabelStorage.FieldLabelDict.ContainsKey(field.Key))
result.Add(new KeyValuePair<string, string>(LabelStorage.FieldLabelDict[field.Key], field.Value));
else
result.Add(field);
}
return result;
}
static string ReplaceTitle(string title)
{
if (LabelStorage.CollectionLabelDict.ContainsKey(title))
return LabelStorage.CollectionLabelDict[title];
return title;
}
#endregion
#region "Neuer" EUREPORT Header Block für Einzelnachrichten
internal static void DefineSingleHeader(Document document, Dictionary<string, string> coverInfos, ReportingParty rp)
{
Section section = document.AddSection();
section.PageSetup.StartingNumber = 1;
Table table = document.LastSection.AddTable();
table.Style = "Table";
table.Borders.Color = Colors.LightGray;
table.Borders.Width = 0.25;
// Define Colums
Column col = table.AddColumn(90); // die Bildspalte
col.Format.Alignment = ParagraphAlignment.Center;
table.AddColumn(70);
table.AddColumn(140);
table.AddColumn(60);
table.AddColumn(140);
Row row = table.AddRow();
Image logoImage = row.Cells[0].AddImage(@"Report\Logo.gif"); // kann man offenbar nur von einem Pfad laden
logoImage.Width = 80;
row.Cells[0].MergeDown = 6;
Paragraph paragraph = row.Cells[1].AddParagraph("Visit Details");
row.Cells[1].MergeRight = 3;
row.Cells[1].Shading.Color = Colors.LightGray;
paragraph.Style = "TableHeader";
row = table.AddRow();
row.Cells[1].AddParagraph("Visit-ID");
paragraph = row.Cells[2].AddParagraph(coverInfos["Visit-ID"] ?? "");
paragraph.Style = "TableValue";
row.Cells[3].AddParagraph("Name");
paragraph = row.Cells[4].AddParagraph(coverInfos["Ship"] ?? "");
paragraph.Style = "TableValue";
row = table.AddRow();
row.Cells[1].AddParagraph("Port of call");
paragraph = row.Cells[2].AddParagraph(coverInfos["Port of call"] ?? "");
paragraph.Style = "TableValue";
row.Cells[3].AddParagraph("ETA");
paragraph = row.Cells[4].AddParagraph(coverInfos["ETA"] ?? "");
paragraph.Style = "TableValue";
row = table.AddRow();
row.Shading.Color = Colors.LightGray;
paragraph = row.Cells[1].AddParagraph("Reporting Party");
row.Cells[1].MergeRight = 3;
paragraph.Style = "TableHeader";
row = table.AddRow();
row.Cells[1].AddParagraph("Organization");
paragraph = row.Cells[2].AddParagraph(rp.Name ?? "");
paragraph.Style = "TableValue";
row.Cells[2].MergeRight = 2;
row = table.AddRow();
row.Cells[1].AddParagraph("Last name");
paragraph = row.Cells[2].AddParagraph(rp.LastName ?? "");
paragraph.Style = "TableValue";
row.Cells[3].AddParagraph("City");
paragraph = row.Cells[4].AddParagraph(rp.City ?? "");
paragraph.Style = "TableValue";
row = table.AddRow();
row.Cells[1].AddParagraph("Phone");
paragraph = row.Cells[2].AddParagraph(rp.Phone ?? "");
paragraph.Style = "TableValue";
row.Cells[3].AddParagraph("Email");
paragraph = row.Cells[4].AddParagraph(rp.EMail ?? "");
paragraph.Style = "TableValue";
}
#endregion
#region setup, header and footers
public static void DefineContentSectionInitial(Document document)
{
Section section = document.LastSection;
section.PageSetup.OddAndEvenPagesHeaderFooter = false;
section.PageSetup.Orientation = Orientation.Portrait;
HeaderFooter header = section.Headers.Primary;
header.AddParagraph(string.Format("Bremer Schiffsmeldedienst - created {0}", DateTime.Now.ToString()));
Paragraph paragraph = new Paragraph();
paragraph.AddTab();
paragraph.AddPageField();
paragraph.AddText(" / ");
paragraph.AddNumPagesField();
section.Footers.Primary.Add(paragraph);
}
/// <summary>
/// Defines page setup, headers, and footers.
/// </summary>
public static void DefineContentSection(Document document, Orientation orientation, bool isInitialSection)
{
Section section = document.AddSection();
section.PageSetup.OddAndEvenPagesHeaderFooter = true;
if(isInitialSection)
section.PageSetup.StartingNumber = 1;
section.PageSetup.Orientation = orientation;
HeaderFooter header = section.Headers.Primary;
header.AddParagraph("\tEU-NOAD receive receipt");
header = section.Headers.EvenPage;
header.AddParagraph("EU-NOAD receive receipt");
// Create a paragraph with centered page number. See definition of style "Footer".
Paragraph paragraph = new Paragraph();
paragraph.AddTab();
paragraph.AddPageField();
// Add paragraph to footer for odd pages.
section.Footers.Primary.Add(paragraph);
// Add clone of paragraph to footer for odd pages. Cloning is necessary because an object must
// not belong to more than one other object. If you forget cloning an exception is thrown.
section.Footers.EvenPage.Add(paragraph.Clone());
}
#endregion
#region NSW data
public static void AddNSWMessageParagraph(Document document, IMessageParagraph messageParagraph)
{
Message message = messageParagraph as Message;
#region Einzelne Seite in Landscape für CREW Meldung
if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.CREW))
{
// 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.CreateCrewTable(document, message);
return;
}
#endregion
#region Einzelne Seite in Landscape für PAS Meldung
if ((message != null) && (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 != null) && (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 != null) && (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
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.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 != null) && (message.MessageNotificationClass == Message.NotificationClass.WAS))
{
ReportDocument.CreateWASTable(document, message);
return;
}
#endregion
#region NOA_NOD
if ((message != null) && (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)
{
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);
return;
}
#endregion
#region BKRD
if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.BKRD))
{
ReportDocument.CreateBKRDTable(document, message);
return;
}
#endregion
#region BKRA
if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.BKRA))
{
ReportDocument.CreateBKRATable(document, message);
return;
}
#endregion
#region LADG
if((message != null) && (message.MessageNotificationClass == Message.NotificationClass.LADG))
{
ReportDocument.CreateLADGTable(document, message);
return;
}
#endregion
#region SERV
if ((message != null) && (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);
#region SEC
if((message != null) && (message.MessageNotificationClass == Message.NotificationClass.SEC))
{
ReportDocument.CreateLast10PortFacilitiesTable(document, message);
ReportDocument.CreateShip2ShipActivitiesTable(document, message);
return;
}
#endregion
#region BPOL
if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.BPOL))
{
ReportDocument.CreatePortOfItineraryTable(document, message);
}
#endregion
#region MDH
if ((message != null) && (message.MessageNotificationClass == Message.NotificationClass.MDH))
{
ReportDocument.CreateSanitaryMeasuresTable(document, message);
ReportDocument.CreateInfectedAreaTable(document, message);
ReportDocument.CreatePoCLast30DaysTable(document, message);
return;
}
#endregion
#region Child paragraphs (untergeordnete Tabellen..)
if (messageParagraph.ChildParagraphs != null)
{
foreach (IMessageParagraph childParagraph in messageParagraph.ChildParagraphs)
{
ReportDocument.AddActualTableParagraph(document, childParagraph, true);
}
}
#endregion
}
#region CREW
private static void CreateCrewTable(Document document, Message message)
{
Table table = AddGrayTable(document);
Column column = table.AddColumn();
column.Width = Unit.FromCentimeter(1);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2.5);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1.5);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3);
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Last name");
hRow.Cells[2].AddParagraph("First name");
hRow.Cells[3].AddParagraph("Place of birth");
hRow.Cells[4].AddParagraph("Date of birth");
hRow.Cells[5].AddParagraph("Gender");
hRow.Cells[6].AddParagraph("Nat.");
hRow.Cells[7].AddParagraph("Id doc. type");
hRow.Cells[8].AddParagraph("Id doc. number");
hRow.Cells[9].AddParagraph("Visa number");
hRow.Cells[10].AddParagraph("Duty");
for (int i = 0; i < message.Elements.Count; i++)
{
CREW crew = message.Elements[i] as CREW;
Row row = table.AddRow();
row.Cells[0].AddParagraph((i + 1).ToString());
row.Cells[1].AddParagraph(crew.CrewMemberLastName ?? "");
row.Cells[2].AddParagraph(crew.CrewMemberFirstName ?? "");
row.Cells[3].AddParagraph(crew.CrewMemberPlaceOfBirth ?? "");
row.Cells[4].AddParagraph(crew.CrewMemberDateOfBirthDisplay);
row.Cells[5].AddParagraph(crew.CrewMemberGenderDisplay);
row.Cells[6].AddParagraph(crew.CrewMemberNationality ?? "");
row.Cells[7].AddParagraph(crew.CrewMemberIdentityDocumentTypeDisplay);
row.Cells[8].AddParagraph(crew.CrewMemberIdentityDocumentId ?? "");
row.Cells[9].AddParagraph(crew.CrewMemberVisaNumber ?? "");
row.Cells[10].AddParagraph(crew.CrewMemberDuty ?? "");
}
}
#endregion
#region PAS
private static void CreatePassengerTable(Document document, Message message)
{
Table table = AddGrayTable(document);
Column column = table.AddColumn();
column.Width = Unit.FromCentimeter(0.8);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1.8);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1.5);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1.5);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(0.5);
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Last name");
hRow.Cells[2].AddParagraph("First name");
hRow.Cells[3].AddParagraph("Place of birth");
hRow.Cells[4].AddParagraph("Date of birth");
hRow.Cells[5].AddParagraph("Gender");
hRow.Cells[6].AddParagraph("Nat.");
hRow.Cells[7].AddParagraph("Id doc. type");
hRow.Cells[8].AddParagraph("Id doc. number");
hRow.Cells[9].AddParagraph("Visa number");
hRow.Cells[10].AddParagraph("Emb.");
hRow.Cells[11].AddParagraph("Disemb.");
hRow.Cells[12].AddParagraph("T");
for (int i = 0; i < message.Elements.Count; i++)
{
PAS pas = message.Elements[i] as PAS;
Row row = table.AddRow();
row.Cells[0].AddParagraph((i + 1).ToString());
row.Cells[1].AddParagraph(pas.PassengerLastName ?? "");
row.Cells[2].AddParagraph(pas.PassengerFirstName ?? "");
row.Cells[3].AddParagraph(pas.PassengerPlaceOfBirth ?? "");
row.Cells[4].AddParagraph(pas.PassengerDateOfBirthDisplay);
row.Cells[5].AddParagraph(pas.PassengerGenderDisplay);
row.Cells[6].AddParagraph(pas.PassengerNationality ?? "");
row.Cells[7].AddParagraph(pas.PassengerIdentityDocumentTypeDisplay);
row.Cells[8].AddParagraph(pas.PassengerIdentityDocumentId ?? "");
row.Cells[9].AddParagraph(pas.PassengerVisaNumber ?? "");
row.Cells[10].AddParagraph(pas.PassengerPortOfEmbarkation ?? "");
row.Cells[11].AddParagraph(pas.PassengerPortOfDisembarkation ?? "");
row.Cells[12].AddParagraph(pas.PassengerInTransit ?? false ? "X" : "");
}
}
#endregion
#region MDH
private static void CreatePoCLast30DaysTable(Document document, Message message)
{
MDH mdh = message.Elements[0] as MDH;
if (mdh.PortOfCallLast30Days.Count > 0)
{
document.LastSection.AddParagraph("Port of call last 30 days", "Heading3");
Table table = AddGrayTable(document);
table.AddColumn(20);
table.AddColumn(80);
table.AddColumn(70);
table.AddColumn(100);
table.AddColumn(220);
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Port");
hRow.Cells[2].AddParagraph("Date of departure");
hRow.Cells[3].AddParagraph("Crew members joined");
hRow.Cells[4].AddParagraph("Names of joining crew");
for (int i = 0; i < mdh.PortOfCallLast30Days.Count; i++)
{
Row row = table.AddRow();
ReportDocument.SetPoCLast30Days(((PortOfCallLast30Days) mdh.PortOfCallLast30Days[i]), row);
}
}
}
private static void CreateSanitaryMeasuresTable(Document document, Message message)
{
MDH mdh = message.Elements[0] as MDH;
if(mdh.SanitaryMeasuresApplied ?? false)
{
document.LastSection.AddParagraph("Sanitary measures", "Heading3");
Table table = document.LastSection.AddTable();
table.Rows.VerticalAlignment = VerticalAlignment.Center;
table.Borders.Visible = true;
table.Borders.Color = Colors.LightGray;
table.AddColumn(20);
table.AddColumn(200);
table.AddColumn(200);
table.AddColumn(70);
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Type");
hRow.Cells[2].AddParagraph("Location");
hRow.Cells[3].AddParagraph("Date");
for (int i = 0; i < mdh.SanitaryMeasuresDetails.Count; i++)
{
Row row = table.AddRow();
row.Cells[0].AddParagraph(mdh.SanitaryMeasuresDetails[i].Identifier);
row.Cells[1].AddParagraph(mdh.SanitaryMeasuresDetails[i].SanitaryMeasuresType);
row.Cells[2].AddParagraph(mdh.SanitaryMeasuresDetails[i].SanitaryMeasuresLocation);
row.Cells[3].AddParagraph(mdh.SanitaryMeasuresDetails[i].SanitaryMeasuresDate.HasValue ? mdh.SanitaryMeasuresDetails[i].SanitaryMeasuresDate.Value.ToShortDateString() : "");
}
}
}
private static void CreateInfectedAreaTable(Document document, Message message)
{
MDH mdh = message.Elements[0] as MDH;
if (mdh.InfectedAreaVisited ?? false)
{
document.LastSection.AddParagraph("Infected areas", "Heading3");
Table table = document.LastSection.AddTable();
table.Rows.VerticalAlignment = VerticalAlignment.Center;
table.Borders.Visible = true;
table.Borders.Color = Colors.LightGray;
table.AddColumn(20);
table.AddColumn(400);
table.AddColumn(70);
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Port");
hRow.Cells[2].AddParagraph("Date");
for (int i = 0; i < mdh.InfectedAreas.Count; i++)
{
Row row = table.AddRow();
row.Cells[0].AddParagraph(mdh.InfectedAreas[i].Identifier ?? i.ToString());
row.Cells[1].AddParagraph(mdh.InfectedAreas[i].InfectedAreaPort);
row.Cells[2].AddParagraph(mdh.InfectedAreas[i].InfectedAreaDate.HasValue ? mdh.InfectedAreas[i].InfectedAreaDate.Value.ToShortDateString() : "");
}
}
}
private static void SetPoCLast30Days(PortOfCallLast30Days portOfCallLast30Days, Row row)
{
row.Cells[0].AddParagraph(portOfCallLast30Days.Identifier ?? "");
row.Cells[1].AddParagraph(LocodeDB.LocationNameFromLocode(portOfCallLast30Days.PortOfCallLast30DaysLocode) ?? "");
row.Cells[2].AddParagraph(portOfCallLast30Days.PortOfCallLast30DaysDateOfDeparture.HasValue ?
portOfCallLast30Days.PortOfCallLast30DaysDateOfDeparture.Value.ToShortDateString() : "");
row.Cells[3].AddParagraph(portOfCallLast30Days.PortOfCallLast30DaysCrewMembersJoined.HasValue ?
portOfCallLast30Days.PortOfCallLast30DaysCrewMembersJoined.Value ? "Yes" : "No" : "");
for (int i = 0; i < portOfCallLast30Days.CrewJoinedShip.Count; i++)
{
row.Cells[4].AddParagraph(((PortOfCallLast30DaysCrewJoinedShip)portOfCallLast30Days.CrewJoinedShip[i]).PortOfCallLast30DaysCrewJoinedShipName ?? "");
}
}
#endregion
#region LADG
private static void CreateLADGTable(Document document, Message message)
{
Table table = AddGrayTable(document);
Column column = table.AddColumn();
column.Width = Unit.FromCentimeter(1);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(7);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(5.28);
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("handling type");
hRow.Cells[2].AddParagraph("Code (NST2007)");
hRow.Cells[3].AddParagraph("Number of items");
hRow.Cells[4].AddParagraph("Gross quantity (tons)");
for (int i = 0; i < message.Elements.Count; i++)
{
Row row = table.AddRow();
LADG ladg = message.Elements[i] as LADG;
row.Cells[0].AddParagraph((i + 1).ToString());
row.Cells[1].AddParagraph(ladg.CargoHandlingType.HasValue ? (ladg.CargoHandlingType.Value == 0) ? "Load" : "Discharge" : "");
if(!ladg.CargoCodeNST.IsNullOrEmpty() && cargoCodesNST.ContainsKey(ladg.CargoCodeNST))
row.Cells[2].AddParagraph(cargoCodesNST[ladg.CargoCodeNST].Substring(3));
row.Cells[3].AddParagraph(ladg.CargoNumberOfItems.HasValue ? ladg.CargoNumberOfItems.Value.ToString() : "");
row.Cells[4].AddParagraph(ladg.CargoGrossQuantity_TNE.HasValue ? ladg.CargoGrossQuantity_TNE.Value.ToString("N2") : "");
}
}
#endregion
#region SERV
private static void CreateSERVTable(Document document, Message message)
{
Table table = AddGrayTable(document);
table.AddColumn(30);
table.AddColumn(90);
table.AddColumn(200);
table.AddColumn(170);
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Name");
hRow.Cells[2].AddParagraph("Beneficiary");
hRow.Cells[3].AddParagraph("Invoice recipient");
for (int i = 0; i < message.Elements.Count; i++)
{
Row row = table.AddRow();
SERV serv = message.Elements[i] as SERV;
row.Cells[0].AddParagraph((i + 1).ToString());
row.Cells[1].AddParagraph(serv.ServiceName ?? "");
row.Cells[2].AddParagraph(serv.ServiceBeneficiary ?? "");
row.Cells[3].AddParagraph(serv.ServiceInvoiceRecipient ?? "");
}
}
#endregion
#region SEC
private static void CreateLast10PortFacilitiesTable(Document document, Message message)
{
SEC sec = message.Elements[0] as SEC;
if (sec.LastTenPortFacilitesCalled.Count > 0)
{
document.LastSection.AddParagraph("Last 10 port facilites called", "Heading3");
Table table = AddGrayTable(document);
table.Format.Font.Size = 8;
Column column = table.AddColumn();
column.Width = Unit.FromCentimeter(0.8);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3.9);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1.5);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1.0);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3.0);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1);
Row hRow = table.AddRow();
hRow.Cells[0].AddParagraph("No.");
hRow.Cells[1].AddParagraph("Port name");
hRow.Cells[2].AddParagraph("Country");
hRow.Cells[3].AddParagraph("LoCode");
hRow.Cells[4].AddParagraph("Arr.");
hRow.Cells[5].AddParagraph("Dep.");
hRow.Cells[6].AddParagraph("Ship sec. level");
hRow.Cells[7].AddParagraph("Sec. matter to report");
hRow.Cells[8].AddParagraph("GISIS");
for(int i=0;i<sec.LastTenPortFacilitesCalled.Count;i++) {
Row row = table.AddRow();
ReportDocument.SetLast10PortFacility((i + 1), ((LastTenPortFacilitiesCalled) sec.LastTenPortFacilitesCalled[i]), row);
}
}
}
private static void SetLast10PortFacility(int p, LastTenPortFacilitiesCalled lastTenPortFacilitiesCalled, Row row)
{
row.Cells[0].AddParagraph(p.ToString());
row.Cells[1].AddParagraph(lastTenPortFacilitiesCalled.PortFacilityPortName ?? "");
row.Cells[2].AddParagraph(lastTenPortFacilitiesCalled.PortFacilityPortCountry ?? "");
row.Cells[3].AddParagraph(lastTenPortFacilitiesCalled.PortFacilityPortLoCode ?? "");
row.Cells[4].AddParagraph(lastTenPortFacilitiesCalled.PortFacilityDateOfArrival.HasValue ? lastTenPortFacilitiesCalled.PortFacilityDateOfArrival.Value.ToShortDateString() : "");
row.Cells[5].AddParagraph(lastTenPortFacilitiesCalled.PortFacilityDateOfDeparture.HasValue ? lastTenPortFacilitiesCalled.PortFacilityDateOfDeparture.Value.ToShortDateString() : "");
row.Cells[6].AddParagraph(lastTenPortFacilitiesCalled.PortFacilityShipSecurityLevel.HasValue ? lastTenPortFacilitiesCalled.PortFacilityShipSecurityLevel.ToString() : "");
row.Cells[7].AddParagraph(lastTenPortFacilitiesCalled.PortFacilitySecurityMattersToReport ?? "");
row.Cells[8].AddParagraph(lastTenPortFacilitiesCalled.PortFacilityGISISCode ?? "");
}
private static void CreateShip2ShipActivitiesTable(Document document, Message message)
{
SEC sec = message.Elements[0] as SEC;
if(sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count > 0)
{
document.LastSection.AddParagraph("Ship-to-ship Activities", "Heading3");
Table table = document.LastSection.AddTable();
table.Format.Font.Size = 8;
table.Rows.VerticalAlignment = VerticalAlignment.Center;
table.Borders.Visible = true;
table.Borders.Color = Colors.LightGray;
Column column = table.AddColumn();
column.Width = Unit.FromCentimeter(0.8);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3.9);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1.5);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2.2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(2.2);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(1.5);
column = table.AddColumn();
column.Width = Unit.FromCentimeter(3);
// summe 490 pt = 17,29cm
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Location");
hRow.Cells[1].MergeRight = 3;
hRow = table.AddRow();
hRow.Cells[0].AddParagraph("No.");
hRow.Cells[1].AddParagraph("Name");
hRow.Cells[2].AddParagraph("LoCode");
hRow.Cells[3].AddParagraph("Lat");
hRow.Cells[4].AddParagraph("Lon");
hRow.Cells[5].AddParagraph("From");
hRow.Cells[6].AddParagraph("To");
hRow.Cells[7].AddParagraph("Activity");
hRow.Cells[8].AddParagraph("Sec. matter to report");
for (int i = 0; i < sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled.Count; i++)
{
Row row = table.AddRow();
ReportDocument.SetShip2ShipActivity((i + 1), ((ShipToShipActivitiesDuringLastTenPortFacilitiesCalled)sec.ShipToShipActivitiesDuringLastTenPortFacilitiesCalled[i]), row);
}
}
}
private static void SetShip2ShipActivity(int p, ShipToShipActivitiesDuringLastTenPortFacilitiesCalled s2sActivity, Row row)
{
row.Cells[0].AddParagraph(p.ToString());
row.Cells[1].AddParagraph(s2sActivity.ShipToShipActivityLocationName ?? "");
row.Cells[2].AddParagraph(s2sActivity.ShipToShipActivityLocationLoCode ?? "");
row.Cells[3].AddParagraph(s2sActivity.ShipToShipActivityLocationCoordinatesLatitude.HasValue ? s2sActivity.ShipToShipActivityLocationCoordinatesLatitude.ToString() : "");
row.Cells[4].AddParagraph(s2sActivity.ShipToShipActivityLocationCoordinatesLongitude.HasValue ? s2sActivity.ShipToShipActivityLocationCoordinatesLongitude.ToString() : "");
row.Cells[5].AddParagraph(s2sActivity.ShipToShipActivityDateFrom.HasValue ? s2sActivity.ShipToShipActivityDateFrom.Value.ToShortDateString() : "");
row.Cells[6].AddParagraph(s2sActivity.ShipToShipActivityDateTo.HasValue ? s2sActivity.ShipToShipActivityDateTo.Value.ToShortDateString() : "");
if(!s2sActivity.ShipToShipActivityType.IsNullOrEmpty())
{
if (Int32.TryParse(s2sActivity.ShipToShipActivityType, out int s2sCode) && Edifact8025.ContainsKey(s2sCode))
row.Cells[7].AddParagraph(Edifact8025[s2sCode]);
}
row.Cells[8].AddParagraph(s2sActivity.ShipToShipActivitySecurityMattersToReport ?? "");
}
private static void CreatePortOfItineraryTable(Document document, Message message)
{
BPOL bpol = message.Elements[0] as BPOL;
if ((bpol.CruiseShip ?? false) && (bpol.PortOfItineraries.Count > 0))
{
document.LastSection.AddParagraph("Port of itinerary (cruise)", "Heading3");
Table table = document.LastSection.AddTable();
table.Format.Font.Size = 8;
table.Rows.VerticalAlignment = VerticalAlignment.Center;
table.Borders.Visible = true;
table.Borders.Color = Colors.LightGray;
table.AddColumn(20);
table.AddColumn(350);
table.AddColumn(120);
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Name");
hRow.Cells[2].AddParagraph("ETA");
for (int i = 0; i < bpol.PortOfItineraries.Count; i++)
{
Row row = table.AddRow();
row.Cells[0].AddParagraph((i+1).ToString());
row.Cells[1].AddParagraph(bpol.PortOfItineraries[i].PortOfItineraryName ?? "");
row.Cells[2].AddParagraph(bpol.PortOfItineraries[i].PortOfItineraryETA.HasValue ? bpol.PortOfItineraries[i].PortOfItineraryETA.Value.ToString() : "");
}
}
}
#endregion
#region BKRD
private static void CreateBKRDTable(Document document, Message message)
{
Table table = AddGrayTable(document);
table.AddColumn(30);
table.AddColumn(290);
table.AddColumn(170);
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Name / type of fuel");
hRow.Cells[2].AddParagraph("Bunker fuel amount in tons");
for (int i = 0; i < message.Elements.Count; i++)
{
Row row = table.AddRow();
BRKD brkd = message.Elements[i] as BRKD;
row.Cells[0].AddParagraph((i + 1).ToString());
row.Cells[1].AddParagraph(brkd.BunkerFuelType ?? "");
row.Cells[2].AddParagraph(brkd.BunkerFuelQuantity_TNE.HasValue ? brkd.BunkerFuelQuantity_TNE.Value.ToString("N2") : "");
}
}
#endregion
#region BKRA
private static void CreateBKRATable(Document document, Message message)
{
Table table = AddGrayTable(document);
table.AddColumn(30);
table.AddColumn(290);
table.AddColumn(170);
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Name / type of fuel");
hRow.Cells[2].AddParagraph("Bunker fuel amount in tons");
for (int i = 0; i < message.Elements.Count; i++)
{
Row row = table.AddRow();
BRKA brkd = message.Elements[i] as BRKA;
row.Cells[0].AddParagraph((i + 1).ToString());
row.Cells[1].AddParagraph(brkd.BunkerFuelType ?? "");
row.Cells[2].AddParagraph(brkd.BunkerFuelQuantity_TNE.HasValue ? brkd.BunkerFuelQuantity_TNE.Value.ToString("N2") : "");
}
}
#endregion
#region WAS
private static void CreateWASTable(Document document, Message message)
{
WAS was = message.Elements[0] as WAS;
Table table = AddGrayTable(document);
table.AddColumn(290);
table.AddColumn(200);
Row row = table.AddRow();
row.Cells[0].AddParagraph("Valid exemption?");
row.Cells[1].AddParagraph("Confirmation of correctness");
row = table.AddRow();
row.Cells[0].AddParagraph(was.WasteDisposalValidExemption ?? false ? "Yes" : "No");
row.Cells[1].AddParagraph(was.ConfirmationOfCorrectness ?? false ? "Yes" : "No");
row = table.AddRow();
row.Cells[0].AddParagraph("Last port where waste or cargo residues were discharged");
row.Cells[1].AddParagraph("Date of last disposal");
row = table.AddRow();
row.Cells[0].AddParagraph(LocodeDB.PortNameFromLocode(was.LastWasteDisposalPort) ?? "");
if(was.LastWasteDisposalDate.HasValue)
row.Cells[1].AddParagraph(was.LastWasteDisposalDate?.ToShortDateString());
row = table.AddRow();
row.Cells[0].AddParagraph("Name of waste disposal service provider");
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");
table = document.LastSection.AddTable();
table.Rows.VerticalAlignment = VerticalAlignment.Top;
table.Borders.Visible = true;
table.Borders.Color = Colors.LightGray;
table.AddColumn(100);
table.AddColumn(65);
table.AddColumn(65);
table.AddColumn(65);
table.AddColumn(65);
table.AddColumn(65);
table.AddColumn(65);
row = table.AddRow();
row.Cells[0].AddParagraph("TYPE");
row.Cells[1].AddParagraph("Description");
row.Cells[2].AddParagraph("Amount to be disposed");
row.Cells[3].AddParagraph("Maximum dedicated storage capacity on board");
row.Cells[4].AddParagraph("Amount retained on board");
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);
}
private static void GetWasteForIndex(int index, WAS was, Row row)
{
foreach (Waste waste in was.Waste)
{
if (!waste.WasteType.HasValue) continue; // kaputt!
if (waste.WasteType.Value == index)
{
row.Cells[1].AddParagraph(waste.WasteDescription ?? "");
row.Cells[2].AddParagraph(waste.WasteDisposalAmount_MTQ.HasValue ? waste.WasteDisposalAmount_MTQ.Value.ToString("N3") : "");
row.Cells[3].AddParagraph(waste.WasteCapacity_MTQ.HasValue ? waste.WasteCapacity_MTQ.Value.ToString("N3") : "");
row.Cells[4].AddParagraph(waste.WasteAmountRetained_MTQ.HasValue ? waste.WasteAmountRetained_MTQ.Value.ToString("N3") : "");
row.Cells[5].AddParagraph(LocodeDB.PortNameFromLocode(waste.WasteDisposalPort) ?? "");
row.Cells[6].AddParagraph(waste.WasteAmountGeneratedTillNextPort_MTQ.HasValue ? waste.WasteAmountGeneratedTillNextPort_MTQ.Value.ToString("N3") : "");
}
}
}
#endregion
#region TOWA
private static void CreateTOWATable(Document document, Message message)
{
Table table = AddGrayTable(document);
table.AddColumn(20); // lfd. Nr.
table.AddColumn(50); // Name
table.AddColumn(30); // Flag
table.AddColumn(30); // Gross ton
table.AddColumn(30); // Length
table.AddColumn(30); // Beam
table.AddColumn(60); // Purpose of call
table.AddColumn(35); // Draft
table.AddColumn(70); // Remarks
table.AddColumn(60); // Company
table.AddColumn(70); // Street
table.AddColumn(40); // Postal code
table.AddColumn(25); // Country
table.AddColumn(60); // Phone
table.AddColumn(60); // Fax
table.AddColumn(70); // EMail
// 770
Row opRow = table.AddRow();
opRow.Cells[9].AddParagraph("Operator");
opRow.Cells[9].MergeRight = 6;
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Name");
hRow.Cells[2].AddParagraph("Flag");
hRow.Cells[3].AddParagraph("Gross ton.");
hRow.Cells[4].AddParagraph("Len (m)");
hRow.Cells[5].AddParagraph("Beam (m)");
hRow.Cells[6].AddParagraph("Purpose of call");
hRow.Cells[7].AddParagraph("Draft (dm)");
hRow.Cells[8].AddParagraph("Remarks");
hRow.Cells[9].AddParagraph("Company name");
hRow.Cells[10].AddParagraph("Street / No.");
hRow.Cells[11].AddParagraph("Postal Code");
hRow.Cells[12].AddParagraph("Co.");
hRow.Cells[13].AddParagraph("Phone");
hRow.Cells[14].AddParagraph("Fax");
hRow.Cells[15].AddParagraph("Email");
for (int i = 0; i < message.Elements.Count; i++)
{
TOWA towa = message.Elements[i] as TOWA;
Row row = table.AddRow();
row.Cells[0].AddParagraph((i + 1).ToString());
row.Cells[1].AddParagraph(towa.TowageOnArrivalName ?? "");
row.Cells[2].AddParagraph(towa.TowageOnArrivalFlag ?? "");
row.Cells[3].AddParagraph(towa.TowageOnArrivalGrossTonnage.HasValue ? towa.TowageOnArrivalGrossTonnage.Value.ToString() : "");
row.Cells[4].AddParagraph(towa.TowageOnArrivalLengthOverall_MTR.HasValue ? towa.TowageOnArrivalLengthOverall_MTR.Value.ToString("N1") : "");
row.Cells[5].AddParagraph(towa.TowageOnArrivalBeam_MTR.HasValue ? towa.TowageOnArrivalBeam_MTR.Value.ToString("N1") : "");
row.Cells[6].AddParagraph(towa.TowageOnArrivalPurposeOfCall ?? "");
row.Cells[7].AddParagraph(towa.TowageOnArrivalDraught_DMT.HasValue ? towa.TowageOnArrivalDraught_DMT.Value.ToString("N1") : "");
row.Cells[8].AddParagraph(towa.TowageOnArrivalRemarks ?? "");
row.Cells[9].AddParagraph(towa.TowageOnArrivalOperatorCompanyName ?? "");
row.Cells[10].AddParagraph(towa.TowageOnArrivalOperatorStreetNameAndNumber);
row.Cells[11].AddParagraph(towa.TowageOnArrivalOperatorPostalCode);
row.Cells[12].AddParagraph(towa.TowageOnArrivalOperatorCountry ?? "");
row.Cells[13].AddParagraph(towa.TowageOnArrivalOperatorPhone);
row.Cells[14].AddParagraph(towa.TowageOnArrivalOperatorFax ?? "");
row.Cells[15].AddParagraph(towa.TowageOnArrivalOperatorEmail ?? "");
}
}
#endregion
#region TOWD
private static void CreateTOWDTable(Document document, Message message)
{
Table table = AddGrayTable(document);
table.AddColumn(20); // lfd. Nr.
table.AddColumn(50); // Name
table.AddColumn(30); // Flag
table.AddColumn(30); // Length
table.AddColumn(30); // Beam
table.AddColumn(35); // Draft
table.AddColumn(120); // Remarks
table.AddColumn(60); // Company
table.AddColumn(70); // Street
table.AddColumn(40); // Postal code
table.AddColumn(65); // Country
table.AddColumn(60); // Phone
table.AddColumn(60); // Fax
table.AddColumn(70); // EMail
// 770
Row opRow = table.AddRow();
opRow.Cells[7].AddParagraph("Operator");
opRow.Cells[7].MergeRight = 6;
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Name");
hRow.Cells[2].AddParagraph("Flag");
hRow.Cells[3].AddParagraph("Len (m)");
hRow.Cells[4].AddParagraph("Beam (m)");
hRow.Cells[5].AddParagraph("Draft (dm)");
hRow.Cells[6].AddParagraph("Remarks");
hRow.Cells[7].AddParagraph("Company Name");
hRow.Cells[8].AddParagraph("Street / No.");
hRow.Cells[9].AddParagraph("Postal Code");
hRow.Cells[10].AddParagraph("Co.");
hRow.Cells[11].AddParagraph("Phone");
hRow.Cells[12].AddParagraph("Fax");
hRow.Cells[13].AddParagraph("Email");
for (int i = 0; i < message.Elements.Count; i++)
{
TOWD towd = message.Elements[i] as TOWD;
Row row = table.AddRow();
row.Cells[0].AddParagraph((i + 1).ToString());
row.Cells[1].AddParagraph(towd.TowageOnDepartureName ?? "");
row.Cells[2].AddParagraph(towd.TowageOnDepartureFlag ?? "");
row.Cells[3].AddParagraph(towd.TowageOnDepartureLengthOverall_MTR.HasValue ? towd.TowageOnDepartureLengthOverall_MTR.Value.ToString() : "");
row.Cells[4].AddParagraph(towd.TowageOnDepartureBeam_MTR.HasValue ? towd.TowageOnDepartureBeam_MTR.Value.ToString() : "");
row.Cells[5].AddParagraph(towd.TowageOnDepartureDraught_DMT.HasValue ? towd.TowageOnDepartureDraught_DMT.Value.ToString() : "");
row.Cells[6].AddParagraph(towd.TowageOnDepartureRemarks ?? "");
row.Cells[7].AddParagraph(towd.TowageOnDepartureOperatorCompanyName ?? "");
row.Cells[8].AddParagraph(towd.TowageOnDepartureOperatorStreetNameAndNumber ?? "");
row.Cells[9].AddParagraph(towd.TowageOnDepartureOperatorPostalCode ?? "");
row.Cells[10].AddParagraph(towd.TowageOnDepartureOperatorCountry ?? "");
row.Cells[11].AddParagraph(towd.TowageOnDepartureOperatorPhone ?? "");
row.Cells[12].AddParagraph(towd.TowageOnDepartureOperatorFax ?? "");
row.Cells[13].AddParagraph(towd.TowageOnDepartureOperatorEmail ?? "");
}
}
#endregion
#region HAZ
private static void CreateHAZPage(Document document, HAZ haz)
{
// für jede Liste (IMDG, IGC, IBC, IMSBC, Marpol) wird eine eigene Seite angelegt, falls > 0 Elemente vorhanden sind
bool didPage = false;
#region IMDG
if(haz.IMDGPositions.Count > 0)
{
Paragraph p = document.LastSection.AddParagraph("IMDG positions", "Heading4");
p.Format.Borders.Top = new Border() { Width = "1pt", Color = Colors.DarkGray };
Table table = AddGrayTable(document);
table.Format.Font.Size = 8;
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(3.2));
table.AddColumn(Unit.FromCentimeter(1.7));
table.AddColumn(Unit.FromCentimeter(0.9));
table.AddColumn(Unit.FromCentimeter(1.0)); //
table.AddColumn(Unit.FromCentimeter(0.6)); // 5
table.AddColumn(Unit.FromCentimeter(0.8)); // MP
table.AddColumn(Unit.FromCentimeter(0.8));
table.AddColumn(Unit.FromCentimeter(1.7));
table.AddColumn(Unit.FromCentimeter(1.4)); //10
table.AddColumn(Unit.FromCentimeter(0.6));
table.AddColumn(Unit.FromCentimeter(0.6));
table.AddColumn(Unit.FromCentimeter(2.3));
table.AddColumn(Unit.FromCentimeter(8.8));
Row hRow = table.AddRow();
hRow.Format.Font.Bold = true;
hRow.Format.Font.Size = 7;
hRow.Format.Alignment = ParagraphAlignment.Left;
hRow.Format.SpaceBefore = Unit.FromMillimeter(0.5);
hRow.Cells[0].AddParagraph("Id");
hRow.Cells[1].AddParagraph("Container- no/kind");
hRow.Cells[2].AddParagraph("Position");
hRow.Cells[3].AddParagraph("Class");
hRow.Cells[4].AddParagraph("UN No");
hRow.Cells[5].AddParagraph("PG");
hRow.Cells[6].AddParagraph("MP");
hRow.Cells[7].AddParagraph("Flp");
hRow.Cells[8].AddParagraph("Qty");
hRow.Cells[9].AddParagraph("Package type");
hRow.Cells[10].AddParagraph("LQ");
hRow.Cells[11].AddParagraph("EQ");
hRow.Cells[12].AddParagraph("Weight (kg)");
hRow.Cells[13].AddParagraph("Remarks");
for (int i = 0; i < haz.IMDGPositions.Count; i++)
{
IMDGPosition pos = haz.IMDGPositions[i];
Row row = table.AddRow();
row.Cells[0].AddParagraph(pos.Identifier ?? "");
row.Cells[1].AddParagraph(string.Format("{0}\n{1}",pos.ContainerNumber, pos.VehicleLicenseNumber));
row.Cells[2].AddParagraph(pos.StowagePosition.IsNullOrEmpty() ? string.Format("{0} {1} {2}", pos.Bay, pos.Row, pos.Tier) : pos.StowagePosition);
row.Cells[3].AddParagraph(pos.IMOClass ?? "");
row.Cells[4].AddParagraph(pos.UNNumber ?? "");
row.Cells[5].AddParagraph(DatabaseEntity_ReportReplacer("PackingGroup", pos.PackingGroup.ToString()));
row.Cells[6].AddParagraph((pos.MarinePollutant ?? false) ? "Y" : "N");
row.Cells[7].AddParagraph(pos.Flashpoint_CEL ?? "");
row.Cells[8].AddParagraph(pos.NumberOfPackages.ToString());
row.Cells[9].AddParagraph(pos.PackageType ?? "");
row.Cells[10].AddParagraph((pos.LimitedQuantities ?? false) ? "Y" : "N");
row.Cells[11].AddParagraph((pos.ExceptedQuantities ?? false) ? "Y" : "N");
row.Cells[12].AddParagraph(string.Format("GW:{0}\nNW:{1}", pos.GrossQuantity_KGM, pos.NetQuantity_KGM));
// if available, put remaining fields together in a single cell
StringBuilder sb = new StringBuilder();
if (!pos.ProperShippingName.IsNullOrEmpty()) { sb.Append("Ship. name:"); sb.Append(pos.ProperShippingName); sb.Append("\n"); }
if (!pos.TechnicalName.IsNullOrEmpty()) { sb.Append("Tech. name:"); sb.Append(pos.TechnicalName); sb.Append("\n"); }
if (pos.NetExplosiveMass_KGM.HasValue) { sb.Append("Net expl. mass:"); sb.Append(pos.NetExplosiveMass_KGM.Value); sb.Append("kgm\n"); }
if (!pos.Class7NuclideName.IsNullOrEmpty()) { sb.Append("Radionuclide:"); sb.Append(pos.Class7NuclideName); sb.Append("\n"); }
if (pos.Class7MaxActivity_BQL.HasValue) { sb.Append("Max Act.:"); sb.Append(pos.Class7MaxActivity_BQL.Value); sb.Append("BQL\n"); }
if (pos.Class7Category.HasValue) { sb.Append("C7 Cat.:"); sb.Append(pos.Class7Category.Value); sb.Append("\n"); }
if (pos.Class7TransportIndex.HasValue) { sb.Append("Tr. Ind.:"); sb.Append(pos.Class7TransportIndex.Value); sb.Append("\n"); }
if (pos.Class7CSI.HasValue) { sb.Append("CSI:"); sb.Append(pos.Class7CSI.Value); sb.Append("\n"); }
if (pos.ControlTemperature_CEL.HasValue) { sb.Append("Ctrl. Temp:"); sb.Append(pos.ControlTemperature_CEL.Value); sb.Append("°C\n"); }
if (pos.EmergencyTemperature_CEL.HasValue) { sb.Append("Em. Temp:"); sb.Append(pos.EmergencyTemperature_CEL.Value); sb.Append("°C\n"); }
if (!pos.SubsidiaryRiskText.IsNullOrEmpty()) { sb.Append("Sub. risks:"); sb.Append(pos.SubsidiaryRiskText); sb.Append("\n"); }
//if (pos.LimitedQuantities.HasValue) { sb.Append("Lim. quant:"); sb.Append(pos.LimitedQuantities.Value ? "Y\n" : "N\n"); }
//if (pos.ExceptedQuantities.HasValue) { sb.Append("Exp. quant:"); sb.Append(pos.ExceptedQuantities.Value ? "Y\n" : "N\n"); }
if (pos.Volume_MTQ.HasValue) { sb.Append("Vol:"); sb.Append(pos.Volume_MTQ.Value); sb.Append("m³\n"); }
//if (pos.GeneralCargoIBC.HasValue) { sb.Append("Gen.cargo:"); sb.Append(pos.GeneralCargoIBC.Value ? "Y\n" : "N\n"); }
if (!pos.PortOfLoading.IsNullOrEmpty()) { sb.Append("Port of L.:"); sb.Append(pos.PortOfLoading); sb.Append("\n"); }
if (!pos.PortOfDischarge.IsNullOrEmpty()) { sb.Append("Port of D.:"); sb.Append(pos.PortOfDischarge); sb.Append("\n"); }
if (!pos.Remarks.IsNullOrEmpty()) { sb.Append("Rem.:"); sb.Append(pos.Remarks); }
row.Cells[13].AddParagraph(sb.ToString());
}
didPage = true;
}
#endregion
#region IBC
if (haz.IBCPositions.Count > 0)
{
if (didPage)
{
document.LastSection.AddPageBreak();
}
document.LastSection.AddParagraph("IBC positions", "Heading4");
Table table = AddGrayTable(document);
table.Format.Font.Size = 8;
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(2.5));
table.AddColumn(Unit.FromCentimeter(1.0));
table.AddColumn(Unit.FromCentimeter(2.0));
table.AddColumn(Unit.FromCentimeter(1.8));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(2.5));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(2.2));
table.AddColumn(Unit.FromCentimeter(6.4));
Row hRow = table.AddRow();
hRow.Format.Font.Bold = true;
hRow.Format.Font.Size = 8;
hRow.Format.Alignment = ParagraphAlignment.Left;
hRow.Format.SpaceBefore = Unit.FromMillimeter(0.5);
hRow.Cells[0].AddParagraph("Id");
hRow.Cells[1].AddParagraph("Prod. name");
hRow.Cells[2].AddParagraph("Cat");
hRow.Cells[3].AddParagraph("Hazards");
hRow.Cells[4].AddParagraph("Fl I");
hRow.Cells[5].AddParagraph("Flp (C°)");
hRow.Cells[6].AddParagraph("Quant.(kgs)");
hRow.Cells[7].AddParagraph("Stow");
hRow.Cells[8].AddParagraph("PoL");
hRow.Cells[9].AddParagraph("PoD");
hRow.Cells[10].AddParagraph("15.19 in IBC column O");
hRow.Cells[11].AddParagraph("Remarks");
for (int i = 0; i < haz.IBCPositions.Count; i++)
{
IBCPosition pos = haz.IBCPositions[i];
Row row = table.AddRow();
row.Cells[0].AddParagraph(pos.Identifier ?? "");
row.Cells[1].AddParagraph(pos.ProductName ?? "");
row.Cells[2].AddParagraph(pos.PollutionCategoryDisplay);
row.Cells[3].AddParagraph(pos.HazardsDisplay);
row.Cells[4].AddParagraph(pos.FlashpointInformationDisplay);
row.Cells[5].AddParagraph(pos.Flashpoint_CEL ?? "");
row.Cells[6].AddParagraph(pos.Quantity_KGM.HasValue ? pos.Quantity_KGM.Value.ToString("N3") : "");
row.Cells[7].AddParagraph(pos.StowagePosition ?? "");
row.Cells[8].AddParagraph(pos.PortOfLoading ?? "");
row.Cells[9].AddParagraph(pos.PortOfDischarge ?? "");
row.Cells[10].AddParagraph(pos.SpecRef15_19.HasValue ? (pos.SpecRef15_19.Value ? "Y" : "N") : "");
row.Cells[11].AddParagraph(pos.Remarks ?? "");
}
didPage = true;
}
#endregion
#region IGC
if (haz.IGCPositions.Count > 0)
{
if (didPage)
{
document.LastSection.AddPageBreak();
}
document.LastSection.AddParagraph("IGC positions", "Heading4");
Table table = AddGrayTable(document);
table.Format.Font.Size = 8;
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(2.5));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(4.0));
table.AddColumn(Unit.FromCentimeter(2.5));
table.AddColumn(Unit.FromCentimeter(3.5));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(7.4));
Row hRow = table.AddRow();
hRow.Format.Font.Bold = true;
hRow.Format.Font.Size = 8;
hRow.Format.Alignment = ParagraphAlignment.Left;
hRow.Format.SpaceBefore = Unit.FromMillimeter(0.5);
hRow.Cells[0].AddParagraph("Id");
hRow.Cells[1].AddParagraph("UN No");
hRow.Cells[2].AddParagraph("IMO Class");
hRow.Cells[3].AddParagraph("Product name");
hRow.Cells[4].AddParagraph("Quant.(kgs)");
hRow.Cells[5].AddParagraph("Stow. pos");
hRow.Cells[6].AddParagraph("PoL");
hRow.Cells[7].AddParagraph("PoD");
hRow.Cells[8].AddParagraph("Remarks");
for (int i = 0; i < haz.IGCPositions.Count; i++)
{
IGCPosition pos = haz.IGCPositions[i];
Row row = table.AddRow();
row.Cells[0].AddParagraph(pos.Identifier ?? "");
row.Cells[1].AddParagraph(pos.UNNumber ?? "");
row.Cells[2].AddParagraph(pos.IMOClass ?? "");
row.Cells[3].AddParagraph(pos.ProductName ?? "");
row.Cells[4].AddParagraph(pos.Quantity_KGM.HasValue ? pos.Quantity_KGM.Value.ToString("N3") : "");
row.Cells[5].AddParagraph(pos.StowagePosition ?? "");
row.Cells[6].AddParagraph(pos.PortOfLoading ?? "");
row.Cells[7].AddParagraph(pos.PortOfDischarge ?? "");
row.Cells[8].AddParagraph(pos.Remarks ?? "");
}
didPage = true;
}
#endregion
#region IMSBC
if (haz.IMSBCPositions.Count > 0)
{
if (didPage)
{
document.LastSection.AddPageBreak();
}
document.LastSection.AddParagraph("IMSBC positions", "Heading4");
Table table = AddGrayTable(document);
table.Format.Font.Size = 8;
table.AddColumn(Unit.FromCentimeter(2.5));
table.AddColumn(Unit.FromCentimeter(3.0));
table.AddColumn(Unit.FromCentimeter(1.0));
table.AddColumn(Unit.FromCentimeter(1.0));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(2.5));
table.AddColumn(Unit.FromCentimeter(2.5));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(7.4));
Row hRow = table.AddRow();
hRow.Format.Font.Bold = true;
hRow.Format.Font.Size = 8;
hRow.Format.Alignment = ParagraphAlignment.Left;
hRow.Format.SpaceBefore = Unit.FromMillimeter(0.5);
hRow.Cells[0].AddParagraph("Id");
hRow.Cells[1].AddParagraph("Shipping name");
hRow.Cells[2].AddParagraph("Haz");
hRow.Cells[3].AddParagraph("MHB");
hRow.Cells[4].AddParagraph("UN No");
hRow.Cells[5].AddParagraph("IMO Class");
hRow.Cells[6].AddParagraph("Quant.(kgs)");
hRow.Cells[7].AddParagraph("Stow. pos");
hRow.Cells[8].AddParagraph("PoL");
hRow.Cells[9].AddParagraph("PoD");
hRow.Cells[10].AddParagraph("Remarks");
for (int i = 0; i < haz.IMSBCPositions.Count; i++)
{
IMSBCPosition pos = haz.IMSBCPositions[i];
Row row = table.AddRow();
row.Cells[0].AddParagraph(pos.Identifier ?? "");
row.Cells[1].AddParagraph(pos.BulkCargoShippingName ?? "");
row.Cells[2].AddParagraph(pos.IMOHazardClassDisplay);
row.Cells[3].AddParagraph(pos.MHB.HasValue ? (pos.MHB.Value ? "Y" : "N") : "");
row.Cells[4].AddParagraph(pos.UNNumber ?? "");
row.Cells[5].AddParagraph(pos.IMOClass ?? "");
row.Cells[6].AddParagraph(pos.Quantity_KGM.HasValue ? pos.Quantity_KGM.Value.ToString("N3") : "");
row.Cells[7].AddParagraph(pos.StowagePosition ?? "");
row.Cells[8].AddParagraph(pos.PortOfLoading ?? "");
row.Cells[9].AddParagraph(pos.PortOfDischarge ?? "");
row.Cells[10].AddParagraph(pos.Remarks ?? "");
}
didPage = true;
}
#endregion
#region Marpol
if (haz.MARPOLPositions.Count > 0)
{
if (didPage)
{
document.LastSection.AddPageBreak();
}
document.LastSection.AddParagraph("Marpol annex I positions", "Heading4");
Table table = AddGrayTable(document);
table.Format.Font.Size = 8;
table.AddColumn(Unit.FromCentimeter(2.5));
table.AddColumn(Unit.FromCentimeter(3.0));
table.AddColumn(Unit.FromCentimeter(2.0));
table.AddColumn(Unit.FromCentimeter(2.0));
table.AddColumn(Unit.FromCentimeter(3.0));
table.AddColumn(Unit.FromCentimeter(2.5));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(1.5));
table.AddColumn(Unit.FromCentimeter(8.0));
Row hRow = table.AddRow();
hRow.Format.Font.Bold = true;
hRow.Format.Font.Size = 8;
hRow.Format.Alignment = ParagraphAlignment.Left;
hRow.Format.SpaceBefore = Unit.FromMillimeter(0.5);
hRow.Cells[0].AddParagraph("Id");
hRow.Cells[1].AddParagraph("Name");
hRow.Cells[2].AddParagraph("Fl I");
hRow.Cells[3].AddParagraph("Flp (C°)");
hRow.Cells[4].AddParagraph("Quant.(kgs)");
hRow.Cells[5].AddParagraph("Stow. pos");
hRow.Cells[6].AddParagraph("PoL");
hRow.Cells[7].AddParagraph("PoD");
hRow.Cells[8].AddParagraph("Remarks");
for (int i = 0; i < haz.MARPOLPositions.Count; i++)
{
MARPOL_Annex_I_Position pos = haz.MARPOLPositions[i];
Row row = table.AddRow();
row.Cells[0].AddParagraph(pos.Identifier ?? "");
row.Cells[1].AddParagraph(pos.Name ?? "");
row.Cells[2].AddParagraph(pos.FlashpointInformationDisplay);
row.Cells[3].AddParagraph(pos.Flashpoint_CEL ?? "");
row.Cells[4].AddParagraph(pos.Quantity_KGM.HasValue ? pos.Quantity_KGM.Value.ToString("N3") : "");
row.Cells[5].AddParagraph(pos.StowagePosition ?? "");
row.Cells[6].AddParagraph(pos.PortOfLoading ?? "");
row.Cells[7].AddParagraph(pos.PortOfDischarge ?? "");
row.Cells[8].AddParagraph(pos.Remarks ?? "");
}
}
#endregion
}
#endregion
#region CallPurpose
static void CreateCallPurposeTable(Document document, Message message)
{
if (message.Elements[0] is NOA_NOD noa_nod && noa_nod.CallPurposes.Count > 0)
{
document.LastSection.AddParagraph("Call purposes", "Heading3");
Table table = AddGrayTable(document);
table.AddColumn(30);
table.AddColumn(460);
Row hRow = table.AddRow();
hRow.Cells[1].AddParagraph("Purpose (description)");
for (int i = 0; i < noa_nod.CallPurposes.Count; i++)
{
Row row = table.AddRow();
row.Cells[0].AddParagraph((i + 1).ToString());
row.Cells[1].AddParagraph(noa_nod.CallPurposes[i].CallPurposeDescription ?? "");
}
}
}
#endregion
#region Default message output
private static void AddActualTableParagraph(Document document, IMessageParagraph paragraph, bool isSubTable)
{
if(isSubTable)
{
if(!paragraph.Title.IsNullOrEmpty())
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(paragraph.Title), "Heading3");
if(!paragraph.Subtitle.IsNullOrEmpty())
document.LastSection.AddParagraph(ReportDocument.ReplaceTitle(paragraph.Subtitle), "Heading4");
}
List<KeyValuePair<string, string>> messageText = ReportDocument.ReplaceLabels(paragraph.MessageText);
Table table = document.LastSection.AddTable();
table.Borders.Color = Colors.LightGray;
Column leadColumn = table.AddColumn(200);
leadColumn.Format.Alignment = ParagraphAlignment.Left;
Column mainColumn = table.AddColumn(290);
mainColumn.Format.Alignment = ParagraphAlignment.Left;
for (int i = 0; i < messageText.Count; i++)
{
KeyValuePair<string, string> elem = messageText[i];
Row row = table.AddRow();
Cell cell = row.Cells[0];
cell.AddParagraph(elem.Key);
// if (elem.Value.IsNullOrEmpty()) // 14.6.21: CH: nichts ausgrauen
// aParagraph.Style = "Gray";
string val = elem.Value;
// funktioniert leider nicht, müsste das auf PDFsharp umstellen (http://www.pdfsharp.net/wiki/Unicode-sample.ashx)
if (val == "True") val = "Yes"; // @"\u2611"; // unicode ballot box with check
if (val == "False") val = "No"; // @"\u2610"; // unicode ballot box
row.Cells[1].AddParagraph(val);
}
if (isSubTable)
{
table.SetEdge(0, 0, 2, messageText.Count, Edge.Box, BorderStyle.DashLargeGap, new Unit(1.0, UnitType.Point));
}
document.LastSection.AddParagraph();
if (isSubTable)
{
if (paragraph.ChildParagraphs != null)
{
foreach (IMessageParagraph childParagraph in paragraph.ChildParagraphs)
AddActualTableParagraph(document, childParagraph, true);
}
}
}
#endregion
#endregion
#region Spezialbehandlung Ersetzen einzelner Felder durch Klartexte
/// <summary>
/// Auf besonderen Wunsch einer einzelnen Dame :D
/// </summary>
/// <param name="propertyName">Name des Felds (ohne Klassenname)</param>
/// <param name="value">Aktueller Wert / Wert aus der DB</param>
/// <returns>ggf. ersetzter Wert</returns>
private static string DatabaseEntity_ReportReplacer(string propertyName, string value)
{
if (propertyName.IsNullOrEmpty()) return value;
if (value.IsNullOrEmpty()) return value;
string result = value;
// ACHTUNG! Die Name (propertyName) sind die bereits in report.db *ersetzten* Namen, d.h. ändert man dort
// wieder etwas funktioniert es ggf. hier nicht mehr. Das ist leider aufwändig zu ändern, man müsste die Report
// Erzeugung komplett umbauen
switch(propertyName)
{
case "PackageType":
if (LocalizedLookup.getPackageTypes().ContainsKey(value))
result = string.Format("{0} - {1}", value, LocalizedLookup.getPackageTypes()[value]);
break;
case "PortOfLoading":
case "PortOfDischarge":
case "PoC":
{
string portName = LocodeDB.PortNameFromLocode(value);
if (!portName.IsNullOrEmpty())
{
result = string.Format("{0} - {1}", value, portName);
}
}
break;
case "ShipType":
if (LocalizedLookup.getVesselTypes().ContainsKey(value))
{
string codeAndText = LocalizedLookup.getVesselTypes()[value];
result = codeAndText.Substring(codeAndText.IndexOf(' ')); // snip off the code
}
break;
case "INFShipClass":
case "INF-Ship-Class":
case "INF - Ship - Class":
{
switch(value)
{
case "0": result = "INF1"; break;
case "1": result = "INF2"; break;
case "2": result = "INF3"; break;
default: break;
}
}
break;
case "PackingGroup":
case "Packing Group":
{
switch (value)
{
case "0": result = "I"; break;
case "1": result = "II"; break;
case "2": result = "III"; break;
default: break;
}
}
break;
case "IMOHazardClass":
{
switch(value)
{
case "0": result = "A"; break;
case "1": result = "B"; break;
case "2": result = "A and B"; break;
}
}
break;
case "GeneralDescriptionOfCargo":
{
switch(value)
{
case "0": result = "Container"; break;
case "1": result = "Vehicles"; break;
case "2": result = "Conventional general cargo"; break;
case "3": result = "Dry cargo in bulk"; break;
case "4": result = "Liquid cargo in bulk"; break;
default: result = "empty"; break;
}
}
break;
case "ShippingArea":
{
switch(value)
{
case "0": result = "North Sea / Baltic"; break;
case "1": result = "Europe"; break;
case "2": result = "Overseas"; break;
}
}
break;
case "PortArea":
{
string portArea = LocalizedLookup.GetPortAreaFromCode(value);
if (!portArea.IsNullOrEmpty()) result = portArea;
}
break;
case "FumigatedBulkCargo":
{
switch(value)
{
case "0": result = "No"; break;
case "1": result = "Yes"; break;
}
}
break;
case "TankerHullConfiguration":
{
switch (value)
{
case "0": result = "Single hull"; break;
case "1": result = "Single hull with SBT"; break;
case "2": result = "Double hull"; break;
}
}
break;
case "ConditionCargoBallastTanks":
{
switch(value)
{
case "0": result = "Full"; break;
case "1": result = "Empty"; break;
case "2": result = "Inerted"; break;
}
}
break;
default:
break;
}
if(propertyName.Contains("flag", StringComparison.OrdinalIgnoreCase))
if (LocalizedLookup.getNationalities().ContainsKey(value))
result = LocalizedLookup.getNationalities()[value].Substring(3); // remove code from result
if(propertyName.Contains("port", StringComparison.OrdinalIgnoreCase))
{
string portName = LocodeDB.PortNameFromLocode(value);
if (!portName.IsNullOrEmpty())
{
result = portName;
//result = string.Format("{0} - {1}", value, portName);
}
}
if (propertyName.Contains("nst2007", StringComparison.OrdinalIgnoreCase))
if (cargoCodesNST.ContainsKey(value))
result = cargoCodesNST[value];
return result;
}
#endregion
#region Document helper
static Table AddGrayTable(Document aDocument)
{
Table table = aDocument.LastSection.AddTable();
table.Rows.VerticalAlignment = VerticalAlignment.Center;
table.Borders.Visible = true;
table.Borders.Color = Colors.LightGray;
return table;
}
#endregion
}
}