zusätzlicher Export in neues Formblatt als Last-Minute Wunsch

This commit is contained in:
Daniel Schick 2022-03-25 09:43:27 +01:00
parent ba8f65865b
commit 521d7a3967
15 changed files with 250 additions and 71 deletions

View File

@ -75,6 +75,12 @@
<Label HorizontalAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textTicketNo}" Margin="0,0,10,0" /> <Label HorizontalAlignment="Right" Grid.Row="4" Grid.Column="0" Content="{x:Static p:Resources.textTicketNo}" Margin="0,0,10,0" />
<Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="3" Content="{x:Static p:Resources.textCreated}" Margin="0,0,10,0" /> <Label HorizontalContentAlignment="Right" Grid.Row="4" Grid.Column="3" Content="{x:Static p:Resources.textCreated}" Margin="0,0,10,0" />
<Label Name="labelCreated" Grid.Column="4" Grid.Row="4" Margin="2, 0, 0, 0" /> <Label Name="labelCreated" Grid.Column="4" Grid.Row="4" Margin="2, 0, 0, 0" />
<Button Name="buttonFormblattNeu" Grid.Column="5" Grid.Row="4" Margin="2" Click="buttonFormblattNeu_Click" >
<StackPanel Orientation="Horizontal">
<TextBlock Text="Formblatt neu"></TextBlock>
<Image Source="../Resources/excel.png" Margin="10,0,5,0" Height="16"/>
</StackPanel>
</Button>
<TextBox Name="textBoxTicketNo" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="2" Text="{Binding TicketNo, Mode=TwoWay}" Margin="2" VerticalContentAlignment="Center" MaxLength="50"/> <TextBox Name="textBoxTicketNo" Grid.Column="1" Grid.Row="4" Grid.ColumnSpan="2" Text="{Binding TicketNo, Mode=TwoWay}" Margin="2" VerticalContentAlignment="Center" MaxLength="50"/>
<Label Grid.Column="0" Grid.Row="6" Margin="0,0,10,0" HorizontalContentAlignment="Right" Name="labelBSMDStatusInternal" Content="{Binding BSMDStatusInternal, StringFormat={}{0}}" VerticalContentAlignment="Center" FontWeight="Bold" /> <Label Grid.Column="0" Grid.Row="6" Margin="0,0,10,0" HorizontalContentAlignment="Right" Name="labelBSMDStatusInternal" Content="{Binding BSMDStatusInternal, StringFormat={}{0}}" VerticalContentAlignment="Center" FontWeight="Bold" />

View File

@ -766,6 +766,20 @@ namespace ENI2.DetailViewControls
private void buttonExcelExport_Click(object sender, RoutedEventArgs e) private void buttonExcelExport_Click(object sender, RoutedEventArgs e)
{ {
string filename = string.Format("{0}_{1}_ref.xlsx", this.Core.Shipname, this.Core.DisplayId); string filename = string.Format("{0}_{1}_ref.xlsx", this.Core.Shipname, this.Core.DisplayId);
this.ExportData(filename, true);
}
/// <summary>
/// Export all classes in "new" sheet version (>= 7.0).. this to return the current format to the ships
/// </summary>
private void buttonFormblattNeu_Click(object sender, RoutedEventArgs e)
{
string filename = string.Format("{0}_{1}_EU-NoAD-Data-Collecting-Tool-5_0.xlsx", this.Core.Shipname, this.Core.DisplayId);
this.ExportData(filename, false);
}
private void ExportData(string filename, bool isRefSheet)
{
SaveFileDialog sfd = new SaveFileDialog() SaveFileDialog sfd = new SaveFileDialog()
{ {
Filter = "Excel Files|*.xls;*.xlsx", Filter = "Excel Files|*.xls;*.xlsx",
@ -779,7 +793,7 @@ namespace ENI2.DetailViewControls
try try
{ {
em.Export(sfd.FileName, this.Core, this.Messages, out string resultMessage); em.Export(sfd.FileName, this.Core, this.Messages, out string resultMessage, isRefSheet);
MessageBox.Show("Exported " + sfd.FileName, "Export successful", MessageBoxButton.OK, MessageBoxImage.Information); MessageBox.Show("Exported " + sfd.FileName, "Export successful", MessageBoxButton.OK, MessageBoxImage.Information);
Process.Start(sfd.FileName); Process.Start(sfd.FileName);
} }

View File

@ -36,8 +36,8 @@
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion> <MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish> <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage> <WebPage>publish.html</WebPage>
<ApplicationRevision>12</ApplicationRevision> <ApplicationRevision>13</ApplicationRevision>
<ApplicationVersion>7.0.0.12</ApplicationVersion> <ApplicationVersion>7.0.0.13</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut> <CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>
@ -730,6 +730,10 @@
<Link>Excel\Reference_Sheet_DE.xlsx</Link> <Link>Excel\Reference_Sheet_DE.xlsx</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="..\misc\EU-NoAD-Data-Collecting-Tool-5_0.xlsx">
<Link>Excel\EU-NoAD-Data-Collecting-Tool-5_0.xlsx</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="codesigning.pfx" /> <None Include="codesigning.pfx" />
<None Include="ENI2_2_TemporaryKey.pfx" /> <None Include="ENI2_2_TemporaryKey.pfx" />
<None Include="ENI2_3_TemporaryKey.pfx" /> <None Include="ENI2_3_TemporaryKey.pfx" />

View File

@ -33,6 +33,8 @@ namespace ENI2.EditControls
this.comboBoxGender.ItemsSource = GlobalStructures.GenderList; this.comboBoxGender.ItemsSource = GlobalStructures.GenderList;
//this.comboBoxGender.KeyUp += ComboBox_KeyUp; //this.comboBoxGender.KeyUp += ComboBox_KeyUp;
this.comboBoxGender.SelectedIndex = this.CREW.CrewMemberGender ?? -1; this.comboBoxGender.SelectedIndex = this.CREW.CrewMemberGender ?? -1;
if (this.CREW.CrewMemberGender == 9)
this.comboBoxGender.SelectedIndex = 3;
this.textBoxPlaceOfBirth.Text = this.CREW.CrewMemberPlaceOfBirth; this.textBoxPlaceOfBirth.Text = this.CREW.CrewMemberPlaceOfBirth;
this.comboBoxNationality.ItemsSource = bsmd.database.CREW.NationalityDict; this.comboBoxNationality.ItemsSource = bsmd.database.CREW.NationalityDict;
//this.comboBoxNationality.KeyUp += ComboBox_KeyUp; //this.comboBoxNationality.KeyUp += ComboBox_KeyUp;
@ -60,6 +62,7 @@ namespace ENI2.EditControls
this.CREW.CrewMemberLastName = this.textBoxLastName.Text.Trim(); this.CREW.CrewMemberLastName = this.textBoxLastName.Text.Trim();
this.CREW.CrewMemberFirstName = this.textBoxFirstName.Text.Trim(); this.CREW.CrewMemberFirstName = this.textBoxFirstName.Text.Trim();
this.CREW.CrewMemberGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?) this.comboBoxGender.SelectedIndex; this.CREW.CrewMemberGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?) this.comboBoxGender.SelectedIndex;
if (this.CREW.CrewMemberGender == 3) this.CREW.CrewMemberGender = 9;
this.CREW.CrewMemberPlaceOfBirth = this.textBoxPlaceOfBirth.Text.Trim(); this.CREW.CrewMemberPlaceOfBirth = this.textBoxPlaceOfBirth.Text.Trim();
this.CREW.CrewMemberNationality = (this.comboBoxNationality.SelectedValue == null) ? "" : (string)this.comboBoxNationality.SelectedValue; this.CREW.CrewMemberNationality = (this.comboBoxNationality.SelectedValue == null) ? "" : (string)this.comboBoxNationality.SelectedValue;
this.CREW.CrewMemberDateOfBirth = this.datePickerDateOfBirth.SelectedDate; this.CREW.CrewMemberDateOfBirth = this.datePickerDateOfBirth.SelectedDate;

View File

@ -32,6 +32,8 @@ namespace ENI2.EditControls
this.comboBoxGender.ItemsSource = GlobalStructures.GenderList; this.comboBoxGender.ItemsSource = GlobalStructures.GenderList;
//this.comboBoxGender.KeyUp += ComboBox_KeyUp; //this.comboBoxGender.KeyUp += ComboBox_KeyUp;
this.comboBoxGender.SelectedIndex = this.PAS.PassengerGender ?? -1; this.comboBoxGender.SelectedIndex = this.PAS.PassengerGender ?? -1;
if (this.PAS.PassengerGender == 9)
this.comboBoxGender.SelectedIndex = 3;
this.textBoxPlaceOfBirth.Text = this.PAS.PassengerPlaceOfBirth; this.textBoxPlaceOfBirth.Text = this.PAS.PassengerPlaceOfBirth;
this.comboBoxNationality.ItemsSource = bsmd.database.CREW.NationalityDict; this.comboBoxNationality.ItemsSource = bsmd.database.CREW.NationalityDict;
//this.comboBoxNationality.KeyUp += ComboBox_KeyUp; //this.comboBoxNationality.KeyUp += ComboBox_KeyUp;
@ -64,6 +66,8 @@ namespace ENI2.EditControls
this.PAS.PassengerLastName = this.textBoxLastName.Text.Trim(); this.PAS.PassengerLastName = this.textBoxLastName.Text.Trim();
this.PAS.PassengerFirstName = this.textBoxFirstName.Text.Trim(); this.PAS.PassengerFirstName = this.textBoxFirstName.Text.Trim();
this.PAS.PassengerGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?)this.comboBoxGender.SelectedIndex; this.PAS.PassengerGender = (this.comboBoxGender.SelectedIndex == -1) ? null : (byte?)this.comboBoxGender.SelectedIndex;
if (this.PAS.PassengerGender == 3)
this.PAS.PassengerGender = 9;
this.PAS.PassengerPlaceOfBirth = this.textBoxPlaceOfBirth.Text.Trim(); this.PAS.PassengerPlaceOfBirth = this.textBoxPlaceOfBirth.Text.Trim();
this.PAS.PassengerNationality = (this.comboBoxNationality.SelectedValue == null) ? "" : (string)this.comboBoxNationality.SelectedValue; this.PAS.PassengerNationality = (this.comboBoxNationality.SelectedValue == null) ? "" : (string)this.comboBoxNationality.SelectedValue;
this.PAS.PassengerDateOfBirth = this.datePickerDateOfBirth.SelectedDate; this.PAS.PassengerDateOfBirth = this.datePickerDateOfBirth.SelectedDate;

View File

@ -54,14 +54,14 @@ namespace ENI2.Excel
return result; return result;
} }
internal void Export(string fileName, MessageCore core, List<Message> messages, out string resultMessage) internal void Export(string fileName, MessageCore core, List<Message> messages, out string resultMessage, bool isRefSheet)
{ {
resultMessage = ""; resultMessage = "";
// Create ExcelWriter // Create ExcelWriter
using (ExcelWriter ew = new ExcelWriter(fileName)) using (ExcelWriter ew = new ExcelWriter(fileName, isRefSheet))
{ {
ew.WriteData(messages, core, out resultMessage); ew.WriteData(messages, core, out resultMessage, isRefSheet);
ew.Save(); ew.Save();
} }
} }

View File

@ -108,15 +108,20 @@ namespace ENI2.Excel
if (val != null) if (val != null)
{ {
if (val.Equals("m", StringComparison.CurrentCultureIgnoreCase) || val.Equals("male", StringComparison.CurrentCultureIgnoreCase)) { if (val.Equals("m", StringComparison.CurrentCultureIgnoreCase) || val.Equals("male", StringComparison.CurrentCultureIgnoreCase)) {
result = 0; result = 1;
} }
else if (val.Equals("f", StringComparison.CurrentCultureIgnoreCase) || val.Equals("female", StringComparison.CurrentCultureIgnoreCase)) else if (val.Equals("f", StringComparison.CurrentCultureIgnoreCase) || val.Equals("female", StringComparison.CurrentCultureIgnoreCase))
{ {
result = 1; result = 2;
}
else if (val.Equals("n", StringComparison.CurrentCultureIgnoreCase) || val.Equals("not applicable", StringComparison.CurrentCultureIgnoreCase) ||
val.Equals("d", StringComparison.CurrentCultureIgnoreCase) || val.Equals("diverse", StringComparison.CurrentCultureIgnoreCase))
{
result = 9;
} }
else else
{ {
result = 2; result = 0;
} }
} }
if(result == null) if(result == null)

View File

@ -10,6 +10,8 @@ using System.Linq;
using System.Reflection; using System.Reflection;
using bsmd.database; using bsmd.database;
using ENI2.Report;
using ENI2.Util;
namespace ENI2.Excel namespace ENI2.Excel
{ {
@ -24,9 +26,12 @@ namespace ENI2.Excel
#region Construction #region Construction
public ExcelWriter(string filePath) : base(filePath) public ExcelWriter(string filePath, bool isRefSheet) : base(filePath)
{ {
string refFilePath = System.IO.Path.Combine(Environment.CurrentDirectory, @"Excel\Reference_Sheet_DE.xlsx"); string filename = @"Excel\EU-NoAD-Data-Collecting-Tool-5_0.xlsx";
if (isRefSheet) filename = @"Excel\Reference_Sheet_DE.xlsx";
string refFilePath = System.IO.Path.Combine(Environment.CurrentDirectory, filename);
this._workBook = _excelWorkbooks.Open(refFilePath, 0, true, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false); this._workBook = _excelWorkbooks.Open(refFilePath, 0, true, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false);
this.InitNameFields(); this.InitNameFields();
@ -37,7 +42,7 @@ namespace ENI2.Excel
#region public methods #region public methods
public void WriteData(List<Message> messages, MessageCore core, out string resultMessage) public void WriteData(List<Message> messages, MessageCore core, out string resultMessage, bool isRefSheet)
{ {
resultMessage = ""; resultMessage = "";
@ -78,10 +83,10 @@ namespace ENI2.Excel
} }
break; break;
case Message.NotificationClass.CREW: case Message.NotificationClass.CREW:
this.WriteCREW(message, true); this.WriteCREW(message, true, isRefSheet);
break; break;
case Message.NotificationClass.CREWD: case Message.NotificationClass.CREWD:
this.WriteCREW(message, false); this.WriteCREW(message, false, isRefSheet);
break; break;
case Message.NotificationClass.HAZA: case Message.NotificationClass.HAZA:
this.WriteHAZ(message, true); this.WriteHAZ(message, true);
@ -93,11 +98,11 @@ namespace ENI2.Excel
if (message.Elements[0] is INFO info) if (message.Elements[0] is INFO info)
{ {
this.WriteMessage(info); this.WriteMessage(info);
this.WriteINFO(info); this.WriteINFO(info, isRefSheet);
} }
break; break;
case Message.NotificationClass.LADG: case Message.NotificationClass.LADG:
this.WriteLADG(message); this.WriteLADG(message, isRefSheet);
break; break;
case Message.NotificationClass.MDH: case Message.NotificationClass.MDH:
if (message.Elements[0] is MDH mdh) if (message.Elements[0] is MDH mdh)
@ -110,13 +115,13 @@ namespace ENI2.Excel
if (message.Elements[0] is NAME name) this.WriteMessage(name); if (message.Elements[0] is NAME name) this.WriteMessage(name);
break; break;
case Message.NotificationClass.NOA_NOD: case Message.NotificationClass.NOA_NOD:
if (message.Elements[0] is NOA_NOD noa_nod) this.WriteNOA_NOD(noa_nod, core.IsTransit); if (message.Elements[0] is NOA_NOD noa_nod) this.WriteNOA_NOD(noa_nod, core.IsTransit, isRefSheet);
break; break;
case Message.NotificationClass.PAS: case Message.NotificationClass.PAS:
this.WritePAS(message, true); this.WritePAS(message, true, isRefSheet);
break; break;
case Message.NotificationClass.PASD: case Message.NotificationClass.PASD:
this.WritePAS(message, false); this.WritePAS(message, false, isRefSheet);
break; break;
case Message.NotificationClass.POBA: case Message.NotificationClass.POBA:
if (message.Elements[0] is POBA poba) this.WriteMessage(poba); if (message.Elements[0] is POBA poba) this.WriteMessage(poba);
@ -133,7 +138,7 @@ namespace ENI2.Excel
break; break;
case Message.NotificationClass.SEC: case Message.NotificationClass.SEC:
if (message.Elements[0] is SEC sec) this.WriteMessage(sec); if (message.Elements[0] is SEC sec) this.WriteMessage(sec);
this.WriteSEC(message); this.WriteSEC(message, isRefSheet);
break; break;
case Message.NotificationClass.SERV: case Message.NotificationClass.SERV:
this.WriteSERV(message); this.WriteSERV(message);
@ -142,7 +147,7 @@ namespace ENI2.Excel
if (message.Elements[0] is STAT stat) if (message.Elements[0] is STAT stat)
{ {
this.WriteMessage(stat); this.WriteMessage(stat);
WriteText("STAT.TransportMode", stat.TransportModeDisplay); this.WriteSTAT(stat, isRefSheet);
} }
break; break;
case Message.NotificationClass.STO: case Message.NotificationClass.STO:
@ -163,14 +168,14 @@ namespace ENI2.Excel
} }
break; break;
case Message.NotificationClass.TOWA: case Message.NotificationClass.TOWA:
WriteTOWA(message); WriteTOWA(message, isRefSheet);
break; break;
case Message.NotificationClass.TOWD: case Message.NotificationClass.TOWD:
WriteTOWD(message); WriteTOWD(message, isRefSheet);
break; break;
case Message.NotificationClass.WAS: case Message.NotificationClass.WAS:
if (message.Elements[0] is WAS was) this.WriteMessage(was); if (message.Elements[0] is WAS was) this.WriteMessage(was);
WriteWAS(message); WriteWAS(message, isRefSheet);
break; break;
case Message.NotificationClass.WAS_RCPT: case Message.NotificationClass.WAS_RCPT:
WriteWAS_RCPT(message); WriteWAS_RCPT(message);
@ -275,7 +280,7 @@ namespace ENI2.Excel
#region LADG #region LADG
private void WriteLADG(Message ladgMessage) private void WriteLADG(Message ladgMessage, bool isRefSheet)
{ {
for (int i = 0; i < Math.Min(ladgMessage.NumberOfExcelRows, ladgMessage.Elements.Count); i++) for (int i = 0; i < Math.Min(ladgMessage.NumberOfExcelRows, ladgMessage.Elements.Count); i++)
{ {
@ -300,12 +305,20 @@ namespace ENI2.Excel
} }
} }
if (isRefSheet)
{
WriteText(lnType, ladg.CargoCodeNST); WriteText(lnType, ladg.CargoCodeNST);
}
else
{
if (ReportDocument.cargoCodesNST.TryGetValue(ladg.CargoCodeNST, out string cargoCode))
WriteText(lnType, cargoCode);
}
WriteText(lnZusatz, ladg.CargoCodeNST_3); WriteText(lnZusatz, ladg.CargoCodeNST_3);
WriteNumber(lnCNOI, ladg.CargoNumberOfItems); WriteNumber(lnCNOI, ladg.CargoNumberOfItems);
WriteNumber(lnCGQ, ladg.CargoGrossQuantity_TNE); WriteNumber(lnCGQ, ladg.CargoGrossQuantity_TNE);
WriteText(lnLoad, ladg.PortOfLoading); WriteText(lnLoad, isRefSheet ? ladg.PortOfLoading : Locode.LocodeDB.LocationNameFromLocode(ladg.PortOfLoading));
WriteText(lnDis, ladg.PortOfDischarge); WriteText(lnDis, isRefSheet ? ladg.PortOfDischarge : Locode.LocodeDB.LocationNameFromLocode(ladg.PortOfDischarge));
WriteNumber(lnLACode, ladg.CargoLACode); WriteNumber(lnLACode, ladg.CargoLACode);
} }
} }
@ -369,7 +382,7 @@ namespace ENI2.Excel
#region CREW #region CREW
private void WriteCREW(Message crewMessage, bool isArrival) private void WriteCREW(Message crewMessage, bool isArrival, bool isRefSheet)
{ {
if (crewMessage.Elements.Count > 0) if (crewMessage.Elements.Count > 0)
@ -408,8 +421,25 @@ namespace ENI2.Excel
WriteText(crewIdentDocType, crew.CrewMemberIdentityDocumentTypeDisplay); WriteText(crewIdentDocType, crew.CrewMemberIdentityDocumentTypeDisplay);
WriteText(crewIdentDocId, crew.CrewMemberIdentityDocumentId); WriteText(crewIdentDocId, crew.CrewMemberIdentityDocumentId);
WriteText(crewVisaNo, crew.CrewMemberVisaNumber); WriteText(crewVisaNo, crew.CrewMemberVisaNumber);
if (isRefSheet)
{
WriteText(crewIssuingState, crew.CrewMemberIdentityDocumentIssuingState); WriteText(crewIssuingState, crew.CrewMemberIdentityDocumentIssuingState);
}
else
{
if(!crew.CrewMemberIdentityDocumentIssuingState.Equals("XX"))
WriteText(crewIssuingState, crew.CrewMemberIdentityDocumentIssuingState);
}
if(isRefSheet)
{
WriteDate(crewExpiry, crew.CrewMemberIdentityDocumentExpiryDate); WriteDate(crewExpiry, crew.CrewMemberIdentityDocumentExpiryDate);
}
else
{
if(crew.CrewMemberIdentityDocumentExpiryDate != new DateTime(2100, 12, 31))
WriteDate(crewExpiry, crew.CrewMemberIdentityDocumentExpiryDate);
}
WriteText(crewCountry, crew.CrewMemberCountryOfBirth); WriteText(crewCountry, crew.CrewMemberCountryOfBirth);
if (isArrival) if (isArrival)
WriteText(effects, crew.Effects); WriteText(effects, crew.Effects);
@ -701,7 +731,7 @@ namespace ENI2.Excel
#region NOA_NOD #region NOA_NOD
private void WriteNOA_NOD(NOA_NOD noa_nod, bool isTransit) private void WriteNOA_NOD(NOA_NOD noa_nod, bool isTransit, bool isRefSheet)
{ {
if(noa_nod.ETAToPortOfCall.HasValue) if(noa_nod.ETAToPortOfCall.HasValue)
{ {
@ -735,8 +765,8 @@ namespace ENI2.Excel
} }
} }
WriteText("NOA_NOD.LastPort", noa_nod.LastPort); WriteText("NOA_NOD.LastPort", isRefSheet ? noa_nod.LastPort : Locode.LocodeDB.LocationNameFromLocode(noa_nod.LastPort));
WriteText("NOA_NOD.NextPort", noa_nod.NextPort); WriteText("NOA_NOD.NextPort", isRefSheet ? noa_nod.NextPort : Locode.LocodeDB.LocationNameFromLocode(noa_nod.NextPort));
if(noa_nod.ETDFromLastPort.HasValue) if(noa_nod.ETDFromLastPort.HasValue)
{ {
@ -758,7 +788,7 @@ namespace ENI2.Excel
#region PAS #region PAS
private void WritePAS(Message pasMessage, bool isArrival) private void WritePAS(Message pasMessage, bool isArrival, bool isRefSheet)
{ {
if(pasMessage.Elements.Count > 0) if(pasMessage.Elements.Count > 0)
{ {
@ -801,8 +831,24 @@ namespace ENI2.Excel
WriteText(pasIdentDocType, pas.PassengerIdentityDocumentTypeDisplay); WriteText(pasIdentDocType, pas.PassengerIdentityDocumentTypeDisplay);
WriteText(pasIdentDocId, pas.PassengerIdentityDocumentId); WriteText(pasIdentDocId, pas.PassengerIdentityDocumentId);
WriteText(pasVisaNo, pas.PassengerVisaNumber); WriteText(pasVisaNo, pas.PassengerVisaNumber);
if (isRefSheet)
{
WriteText(pasIssuing, pas.PassengerIdentityDocumentIssuingState); WriteText(pasIssuing, pas.PassengerIdentityDocumentIssuingState);
}
else
{
if(!pas.PassengerIdentityDocumentIssuingState.Equals("XX"))
WriteText(pasIssuing, pas.PassengerIdentityDocumentIssuingState);
}
if (isRefSheet)
{
WriteDate(pasExpiry, pas.PassengerIdentityDocumentExpiryDate); WriteDate(pasExpiry, pas.PassengerIdentityDocumentExpiryDate);
}
else
{
if (pas.PassengerIdentityDocumentExpiryDate != new DateTime(2100, 12, 31))
WriteDate(pasExpiry, pas.PassengerIdentityDocumentExpiryDate);
}
WriteText(pasCountry, pas.PassengerCountryOfBirth); WriteText(pasCountry, pas.PassengerCountryOfBirth);
WriteText(pasEmergencyCare, pas.EmergencyCare); WriteText(pasEmergencyCare, pas.EmergencyCare);
WriteText(pasEmergencyContact, pas.EmergencyContactNumber); WriteText(pasEmergencyContact, pas.EmergencyContactNumber);
@ -813,7 +859,7 @@ namespace ENI2.Excel
#region SEC #region SEC
private void WriteSEC(Message secMessage) private void WriteSEC(Message secMessage, bool isRefSheet)
{ {
if (secMessage.Elements.Count == 0) return; if (secMessage.Elements.Count == 0) return;
SEC sec = secMessage.Elements[0] as SEC; SEC sec = secMessage.Elements[0] as SEC;
@ -904,9 +950,18 @@ namespace ENI2.Excel
WriteDate(s2sToDate, s2s.ShipToShipActivityDateTo.Value); WriteDate(s2sToDate, s2s.ShipToShipActivityDateTo.Value);
WriteText(s2sSec, s2s.ShipToShipActivitySecurityMattersToReport); WriteText(s2sSec, s2s.ShipToShipActivitySecurityMattersToReport);
if (s2s.ShipToShipActivityTypeCode.HasValue) if (s2s.ShipToShipActivityTypeCode.HasValue)
{
if (isRefSheet)
{
WriteText(s2sActivityString, s2s.ShipToShipActivityTypeCode.Value.ToString()); WriteText(s2sActivityString, s2s.ShipToShipActivityTypeCode.Value.ToString());
} }
else
{
if (GlobalStructures.Edifact8025.TryGetValue(s2s.ShipToShipActivityTypeCode.Value, out string code))
WriteText(s2sActivityString, code);
}
}
}
} }
#endregion #endregion
@ -951,7 +1006,7 @@ namespace ENI2.Excel
#region TOWA #region TOWA
private void WriteTOWA(Message towaMessage) private void WriteTOWA(Message towaMessage, bool isRefSheet)
{ {
for(int i = 0; i < Math.Min(towaMessage.Elements.Count, towaMessage.NumberOfExcelRows); i++) for(int i = 0; i < Math.Min(towaMessage.Elements.Count, towaMessage.NumberOfExcelRows); i++)
{ {
@ -967,7 +1022,16 @@ namespace ENI2.Excel
TOWA towa = towaMessage.Elements[i] as TOWA; TOWA towa = towaMessage.Elements[i] as TOWA;
WriteText(tName, towa.TowageOnArrivalName); WriteText(tName, towa.TowageOnArrivalName);
if(isRefSheet)
{
WriteText(tFlag, towa.TowageOnArrivalFlag); WriteText(tFlag, towa.TowageOnArrivalFlag);
}
else
{
if(CREW.NationalityDict.TryGetValue(towa.TowageOnArrivalFlag, out string country))
WriteText(tFlag, country.Substring(3));
}
WriteText(tPoC, towa.TowageOnArrivalPurposeOfCall); WriteText(tPoC, towa.TowageOnArrivalPurposeOfCall);
if (towa.TowageOnArrivalDraught_DMT.HasValue) if (towa.TowageOnArrivalDraught_DMT.HasValue)
WriteNumber(tDraft, towa.TowageOnArrivalDraught_DMT.Value); WriteNumber(tDraft, towa.TowageOnArrivalDraught_DMT.Value);
@ -985,7 +1049,7 @@ namespace ENI2.Excel
#region TOWD #region TOWD
private void WriteTOWD(Message towdMessage) private void WriteTOWD(Message towdMessage, bool isRefSheet)
{ {
for (int i = 0; i < Math.Min(towdMessage.Elements.Count, towdMessage.NumberOfExcelRows); i++) for (int i = 0; i < Math.Min(towdMessage.Elements.Count, towdMessage.NumberOfExcelRows); i++)
{ {
@ -1000,7 +1064,15 @@ namespace ENI2.Excel
TOWD towd = towdMessage.Elements[i] as TOWD; TOWD towd = towdMessage.Elements[i] as TOWD;
WriteText(tName, towd.TowageOnDepartureName); WriteText(tName, towd.TowageOnDepartureName);
if (isRefSheet)
{
WriteText(tFlag, towd.TowageOnDepartureFlag); WriteText(tFlag, towd.TowageOnDepartureFlag);
}
else
{
if (CREW.NationalityDict.TryGetValue(towd.TowageOnDepartureFlag, out string country))
WriteText(tFlag, country.Substring(3));
}
if (towd.TowageOnDepartureDraught_DMT.HasValue) if (towd.TowageOnDepartureDraught_DMT.HasValue)
WriteNumber(tDraft, towd.TowageOnDepartureDraught_DMT.Value); WriteNumber(tDraft, towd.TowageOnDepartureDraught_DMT.Value);
if (towd.TowageOnDepartureLengthOverall_MTR.HasValue) if (towd.TowageOnDepartureLengthOverall_MTR.HasValue)
@ -1016,7 +1088,7 @@ namespace ENI2.Excel
#region WAS #region WAS
private void WriteWAS(Message wasMessage) private void WriteWAS(Message wasMessage, bool isRefSheet)
{ {
if (wasMessage.Elements.Count == 0) return; if (wasMessage.Elements.Count == 0) return;
WAS was = wasMessage.Elements[0] as WAS; WAS was = wasMessage.Elements[0] as WAS;
@ -1064,7 +1136,7 @@ namespace ENI2.Excel
WriteNumber(wasteCapacity, waste.WasteCapacity_MTQ.Value); WriteNumber(wasteCapacity, waste.WasteCapacity_MTQ.Value);
if (waste.WasteAmountRetained_MTQ.HasValue) if (waste.WasteAmountRetained_MTQ.HasValue)
WriteNumber(wasteRetained, waste.WasteAmountRetained_MTQ.Value); WriteNumber(wasteRetained, waste.WasteAmountRetained_MTQ.Value);
WriteText(wastePort, waste.WasteDisposalPort); WriteText(wastePort, isRefSheet ? waste.WasteDisposalPort : Locode.LocodeDB.LocationNameFromLocode(waste.WasteDisposalPort));
if (waste.WasteAmountGeneratedTillNextPort_MTQ.HasValue) if (waste.WasteAmountGeneratedTillNextPort_MTQ.HasValue)
WriteNumber(amountGen, waste.WasteAmountGeneratedTillNextPort_MTQ.Value); WriteNumber(amountGen, waste.WasteAmountGeneratedTillNextPort_MTQ.Value);
} }
@ -1115,7 +1187,7 @@ namespace ENI2.Excel
#region INFO #region INFO
private void WriteINFO(INFO info) private void WriteINFO(INFO info, bool isRefSheet)
{ {
if (info != null) if (info != null)
{ {
@ -1130,6 +1202,46 @@ namespace ENI2.Excel
case 2: this.WriteText("INFO.ShippingArea", "OVERSEAS"); break; case 2: this.WriteText("INFO.ShippingArea", "OVERSEAS"); break;
} }
} }
if(isRefSheet)
{
WriteText("INFO.PortArea", info.PortArea);
}
else
{
WriteText("INFO.PortArea", LocalizedLookup.GetPortAreaFromCode(info.PortArea));
}
}
}
#endregion
#region STAT
private void WriteSTAT(STAT stat, bool isRefSheet)
{
if (stat != null)
{
WriteText("STAT.PortOfRegistry", isRefSheet ? stat.PortOfRegistry : Locode.LocodeDB.LocationNameFromLocode(stat.PortOfRegistry));
WriteText("STAT.TransportMode", stat.TransportModeDisplay);
if(isRefSheet)
{
WriteText("STAT.Flag", stat.Flag);
}
else
{
if (CREW.NationalityDict.TryGetValue(stat.Flag, out string country))
WriteText("STAT.Flag", country.Substring(3));
}
if(isRefSheet)
{
WriteText("STAT.ShipType", stat.ShipType);
}
else
{
if (LocalizedLookup.getVesselTypes().TryGetValue(stat.ShipType, out string shipType))
WriteText("STAT.ShipType", shipType);
}
} }
} }
@ -1172,9 +1284,10 @@ namespace ENI2.Excel
{ {
if(gender.HasValue) if(gender.HasValue)
{ {
if (gender == 0) WriteText(label, "m"); if (gender == 0) WriteText(label, "?");
if (gender == 1) WriteText(label, "w"); if (gender == 1) WriteText(label, "m");
if (gender == 2) WriteText(label, "d"); if (gender == 2) WriteText(label, "f");
if (gender == 9) WriteText(label, "d");
} }
} }

View File

@ -3316,6 +3316,15 @@ namespace ENI2.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to not applicable.
/// </summary>
public static string textNotApplicable {
get {
return ResourceManager.GetString("textNotApplicable", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Notification class. /// Looks up a localized string similar to Notification class.
/// </summary> /// </summary>
@ -3361,6 +3370,15 @@ namespace ENI2.Properties {
} }
} }
/// <summary>
/// Looks up a localized string similar to not known.
/// </summary>
public static string textNotKnown {
get {
return ResourceManager.GetString("textNotKnown", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Number of deaths. /// Looks up a localized string similar to Number of deaths.
/// </summary> /// </summary>

View File

@ -1831,4 +1831,10 @@
<data name="textPas" xml:space="preserve"> <data name="textPas" xml:space="preserve">
<value>Pas</value> <value>Pas</value>
</data> </data>
<data name="textNotApplicable" xml:space="preserve">
<value>not applicable</value>
</data>
<data name="textNotKnown" xml:space="preserve">
<value>not known</value>
</data>
</root> </root>

View File

@ -33,7 +33,7 @@ namespace ENI2.Report
private static Dictionary<string, string> _cargoCodesNST = null; private static Dictionary<string, string> _cargoCodesNST = null;
private static Dictionary<string, string> cargoCodesNST public static Dictionary<string, string> cargoCodesNST
{ {
get get
{ {

View File

@ -16,9 +16,10 @@ namespace ENI2.Util
public static string[] GenderList = public static string[] GenderList =
{ {
Properties.Resources.textNotKnown,
Properties.Resources.textMale, Properties.Resources.textMale,
Properties.Resources.textFemale, Properties.Resources.textFemale,
Properties.Resources.textOther Properties.Resources.textNotApplicable
}; };
public static string[] IDDocTypeList = public static string[] IDDocTypeList =
@ -168,15 +169,20 @@ namespace ENI2.Util
{ {
if (val.Equals("m", StringComparison.CurrentCultureIgnoreCase) || val.Equals("male", StringComparison.CurrentCultureIgnoreCase)) if (val.Equals("m", StringComparison.CurrentCultureIgnoreCase) || val.Equals("male", StringComparison.CurrentCultureIgnoreCase))
{ {
result = 0; result = 1;
} }
else if (val.Equals("f", StringComparison.CurrentCultureIgnoreCase) || val.Equals("female", StringComparison.CurrentCultureIgnoreCase)) else if (val.Equals("f", StringComparison.CurrentCultureIgnoreCase) || val.Equals("female", StringComparison.CurrentCultureIgnoreCase))
{ {
result = 1; result = 2;
}
else if (val.Equals("d", StringComparison.CurrentCultureIgnoreCase) || val.Equals("diverse", StringComparison.CurrentCultureIgnoreCase) ||
val.Equals("n", StringComparison.CurrentCultureIgnoreCase) || val.Equals("not applicable", StringComparison.CurrentCultureIgnoreCase))
{
result = 9;
} }
else else
{ {
result = 2; result = 0;
} }
} }
return result; return result;

View File

@ -229,7 +229,6 @@ namespace ENI2.Locode
return result; return result;
} }
public static void CloseDB() public static void CloseDB()
{ {
_con.Close(); _con.Close();

View File

@ -40,14 +40,15 @@ namespace bsmd.database
{ {
switch (val) switch (val)
{ {
case 0: return "Male"; case 0: return "not known";
case 1: return "Female"; case 1: return "male";
default: return "Other"; case 2: return "female";
default: return "not applicable";
} }
} }
else else
{ {
return "Unknown"; return "unknown";
} }
} }

Binary file not shown.