Merge branch 'release/eni_7.3'

This commit is contained in:
Daniel Schick 2022-07-05 09:05:57 +02:00
commit 9288ee3056
35 changed files with 660 additions and 132 deletions

View File

@ -233,7 +233,7 @@ namespace ENI2.Controls
// suche auslösen
this.searchResult = DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).GetMessageCoresWithFilters(filterDict);
// alle anderen Häfen weg
this.searchResult.RemoveAll(item => !item.PoC.Equals("DEBRV") && !item.PoC.Equals("DEWHV") && !item.PoC.Equals("DEWVN"));
this.searchResult.RemoveAll(item => (item.PoC == null) || (!item.PoC.Equals("DEBRV") && !item.PoC.Equals("DEWHV") && !item.PoC.Equals("DEWVN")));
// rückwärts iterieren um nach ETA und ATA zu filtern
if (this.searchResult.Count > 0)

View File

@ -280,7 +280,9 @@ namespace ENI2
int minute = Int32.Parse(timevalText.Substring(10, 2));
thePicker.Value = new DateTime(year, month, day, hour, minute, 0);
}
catch (Exception) { }
catch (Exception) {
thePicker.Value = null;
}
}
}

View File

@ -636,7 +636,7 @@ namespace ENI2
DBManager.GetSingleCon(Properties.Settings.Default.ConnectionString).Save(aMessage);
}
if (!ata_queued_or_sent)
if ((!ata_queued_or_sent ) && !DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsAdmin)
{
aMessage.InternalStatus = Message.BSMDStatus.SUSPENDED;
aMessage.ChangedBy = "";

View File

@ -768,20 +768,20 @@ namespace ENI2.DetailViewControls
}
CREW crew = new CREW();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) crew.CrewMemberLastName = reader.GetString(0);
if (!reader.IsDBNull(0)) crew.CrewMemberLastName = reader.GetString(0).Clean();
if (crew.CrewMemberLastName.Equals("Family Name") || (crew.CrewMemberLastName.Trim().Length == 0)) continue;
if (!reader.IsDBNull(1)) crew.CrewMemberFirstName = reader.GetString(1);
if (!reader.IsDBNull(1)) crew.CrewMemberFirstName = reader.GetString(1).Clean();
if (!reader.IsDBNull(2)) crew.CrewMemberGender = GlobalStructures.ParseGender(reader.GetString(2));
if (!reader.IsDBNull(3)) crew.CrewMemberDuty = reader.GetString(3);
if (!reader.IsDBNull(3)) crew.CrewMemberDuty = reader.GetString(3).Clean();
if (!reader.IsDBNull(4)) crew.CrewMemberNationality = reader.GetString(4).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(5)) crew.CrewMemberPlaceOfBirth = reader.GetString(5);
if (!reader.IsDBNull(5)) crew.CrewMemberPlaceOfBirth = reader.GetString(5).Clean();
if (!reader.IsDBNull(6)) crew.CrewMemberCountryOfBirth = reader.GetString(6).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(7)) crew.CrewMemberDateOfBirth = reader.GetDateTime(7);
if (!reader.IsDBNull(8)) crew.CrewMemberIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(8));
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = this.getValueAsString(reader, 9);
if (!reader.IsDBNull(9)) crew.CrewMemberIdentityDocumentId = this.getValueAsString(reader, 9).Clean();
if (!reader.IsDBNull(10)) crew.CrewMemberIdentityDocumentIssuingState = reader.GetString(10).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(11)) crew.CrewMemberIdentityDocumentExpiryDate = reader.GetDateTime(11);
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = this.getValueAsString(reader, 12);
if (!reader.IsDBNull(12)) crew.CrewMemberVisaNumber = this.getValueAsString(reader, 12).Clean();
crew.MessageHeader = this._crewMessage;
crew.IsDirty = true;
@ -925,28 +925,28 @@ namespace ENI2.DetailViewControls
PAS pas = new PAS();
if (reader.IsDBNull(0) && reader.IsDBNull(1)) continue;
if (!reader.IsDBNull(0)) pas.PassengerLastName = reader.GetValue(0).ToString();
if (!reader.IsDBNull(0)) pas.PassengerLastName = reader.GetValue(0).ToString().Clean();
if (pas.PassengerLastName.Equals("Family Name") || (pas.PassengerLastName.Trim().Length == 0)) continue;
if (!reader.IsDBNull(1)) pas.PassengerFirstName = reader.GetValue(1).ToString();
if (!reader.IsDBNull(1)) pas.PassengerFirstName = reader.GetValue(1).ToString().Clean();
if (!reader.IsDBNull(2)) pas.PassengerGender = GlobalStructures.ParseGender(reader.GetString(2));
if (!reader.IsDBNull(3)) pas.PassengerPortOfEmbarkation = reader.GetString(3);
if (!reader.IsDBNull(3)) pas.PassengerPortOfEmbarkation = reader.GetString(3).Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfEmbarkation) == null)
pas.PassengerPortOfEmbarkation = null;
if (!reader.IsDBNull(4)) pas.PassengerPortOfDisembarkation = reader.GetString(4);
if (!reader.IsDBNull(4)) pas.PassengerPortOfDisembarkation = reader.GetString(4).Clean();
if (LocodeDB.PortNameFromLocode(pas.PassengerPortOfDisembarkation) == null)
pas.PassengerPortOfDisembarkation = null;
if (!reader.IsDBNull(5)) pas.PassengerInTransit = GlobalStructures.ReadBoolean(reader.GetString(5));
if (!reader.IsDBNull(6)) pas.PassengerNationality = reader.GetString(6).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(7)) pas.PassengerPlaceOfBirth = reader.GetString(7);
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(7)) pas.PassengerPlaceOfBirth = reader.GetString(7).Clean();
if (!reader.IsDBNull(8)) pas.PassengerCountryOfBirth = reader.GetString(8).Substring(0, 2).ToUpper().Clean();
if (!reader.IsDBNull(9)) pas.PassengerDateOfBirth = reader.GetDateTime(9);
if (!reader.IsDBNull(10)) pas.PassengerIdentityDocumentType = GlobalStructures.ReadIdentityDocumentType(reader.GetString(10));
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = this.getValueAsString(reader, 11);
if (!reader.IsDBNull(11)) pas.PassengerIdentityDocumentId = this.getValueAsString(reader, 11).Clean();
if (!reader.IsDBNull(12)) pas.PassengerIdentityDocumentIssuingState = reader.GetString(12).Substring(0, 2).ToUpper();
if (!reader.IsDBNull(13)) pas.PassengerIdentityDocumentExpiryDate = reader.GetDateTime(13);
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = this.getValueAsString(reader, 14);
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15);
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = this.getValueAsString(reader, 16);
if (!reader.IsDBNull(14)) pas.PassengerVisaNumber = this.getValueAsString(reader, 14).Clean();
if (!reader.IsDBNull(15)) pas.EmergencyCare = reader.GetString(15).Clean();
if (!reader.IsDBNull(16)) pas.EmergencyContactNumber = this.getValueAsString(reader, 16).Clean();
pas.MessageHeader = this._pasMessage;
pas.IsDirty = true;

View File

@ -63,13 +63,14 @@
<DataGridTextColumn Header="{x:Static p:Resources.textSubsidiaryRisk}" Binding="{Binding SubsidiaryRiskText}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textControlTemperature}" Binding="{Binding ControlTemperature_CEL, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textEmergencyTemperature}" Binding="{Binding EmergencyTemperature_CEL, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textMarinePollutant}" Binding="{Binding Class7Category}" IsReadOnly="True" Width="auto" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textMarinePollutant}" Binding="{Binding MarinePollutant}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textNumberOfPackages}" Binding="{Binding NumberOfPackages}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textPackageType}" Binding="{Binding PackageType}" IsReadOnly="True" Width="auto" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textLimitedQuantity}" Binding="{Binding LimitedQuantities}" IsReadOnly="True" Width="auto" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textExceptedQuantities}" Binding="{Binding ExceptedQuantities}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textNetQuantity}" Binding="{Binding NetQuantity_KGM, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textExceptedQuantities}" Binding="{Binding ExceptedQuantities, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textGrossQuantity}" Binding="{Binding GrossQuantity_KGM, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<!--DataGridTextColumn Header="{x:Static p:Resources.textExceptedQuantities}" Binding="{Binding ExceptedQuantities, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" /-->
<DataGridTextColumn Header="{x:Static p:Resources.textCargoVolume}" Binding="{Binding Volume_MTQ, StringFormat={}{0:N2}}" IsReadOnly="True" Width="auto" />
<DataGridCheckBoxColumn Header="{x:Static p:Resources.textGeneralCargo}" Binding="{Binding GeneralCargoIBC}" IsReadOnly="True" Width="auto" />
<DataGridTextColumn Header="{x:Static p:Resources.textContainerNo}" Binding="{Binding ContainerNumber}" IsReadOnly="True" Width="auto" />

View File

@ -220,9 +220,9 @@ namespace ENI2.DetailViewControls
copyMARPOL.CopyFromMARPOL(selectedMARPOL);
copyMARPOL.Identifier = DatabaseEntity.GetNewIdentifier(target_haz.MARPOLPositions, "MARPOL-");
target_haz.MARPOLPositions.Add(copyMARPOL);
target_haz.NoDPGOnBoardOnArrival = false;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZA : Message.NotificationClass.HAZD);
this.OnControlCacheReset(Properties.Resources.textDGDeparture);
this.SetHAZGlobalFlags();
this.OnControlCacheReset(this.IsDeparture ? Properties.Resources.textDGArrival : Properties.Resources.textDGDeparture);
}
}
}
@ -241,9 +241,9 @@ namespace ENI2.DetailViewControls
copyIMSBC.CopyFromIMSBC(selectedIMSBC);
copyIMSBC.Identifier = DatabaseEntity.GetNewIdentifier(target_haz.IMSBCPositions, "IMSBC-");
target_haz.IMSBCPositions.Add(copyIMSBC);
target_haz.NoDPGOnBoardOnArrival = false;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZA : Message.NotificationClass.HAZD);
this.OnControlCacheReset(Properties.Resources.textDGDeparture);
this.SetHAZGlobalFlags();
this.OnControlCacheReset(this.IsDeparture ? Properties.Resources.textDGArrival : Properties.Resources.textDGDeparture);
}
}
}
@ -262,9 +262,9 @@ namespace ENI2.DetailViewControls
copyIMDG.CopyFromIMDG(selectedIMDG);
copyIMDG.Identifier = DatabaseEntity.GetNewIdentifier(target_haz.IMDGPositions, "IMDG-");
target_haz.IMDGPositions.Add(copyIMDG);
target_haz.NoDPGOnBoardOnArrival = false;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZA : Message.NotificationClass.HAZD);
this.OnControlCacheReset(Properties.Resources.textDGDeparture);
this.SetHAZGlobalFlags();
this.OnControlCacheReset(this.IsDeparture ? Properties.Resources.textDGArrival : Properties.Resources.textDGDeparture);
}
}
}
@ -283,9 +283,9 @@ namespace ENI2.DetailViewControls
copyIGC.CopyFromIGC(selectedIGC);
copyIGC.Identifier = DatabaseEntity.GetNewIdentifier(target_haz.IGCPositions, "IGC-");
target_haz.IGCPositions.Add(copyIGC);
target_haz.NoDPGOnBoardOnArrival = false;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZA : Message.NotificationClass.HAZD);
this.OnControlCacheReset(Properties.Resources.textDGDeparture);
this.SetHAZGlobalFlags();
this.OnControlCacheReset(this.IsDeparture ? Properties.Resources.textDGArrival : Properties.Resources.textDGDeparture);
}
}
}
@ -306,9 +306,9 @@ namespace ENI2.DetailViewControls
copyIBC.CopyFromIBC(selectedIBC);
copyIBC.Identifier = DatabaseEntity.GetNewIdentifier(target_haz.IBCPositions, "IBC-");
target_haz.IBCPositions.Add(copyIBC);
target_haz.NoDPGOnBoardOnArrival = false;
this.SublistElementChanged(this.IsDeparture ? Message.NotificationClass.HAZA : Message.NotificationClass.HAZD);
this.OnControlCacheReset(Properties.Resources.textDGDeparture);
this.SetHAZGlobalFlags();
this.OnControlCacheReset(this.IsDeparture ? Properties.Resources.textDGArrival : Properties.Resources.textDGDeparture);
}
}
}
@ -322,20 +322,14 @@ namespace ENI2.DetailViewControls
void SetHAZGlobalFlags()
{
HAZ haz = this.IsDeparture ? this.hazd : this.haza;
int totalCount = haz.MARPOLPositions.Count + haz.IMDGPositions.Count + haz.IGCPositions.Count + haz.IBCPositions.Count + haz.IMSBCPositions.Count;
if(totalCount == 1)
{
if (!this.IsDeparture)
{
if (!(this.checkBoxDangerousGoodsOnBoard.IsChecked ?? false)) this.checkBoxDangerousGoodsOnBoard.IsChecked = true;
if (this.checkBoxMoUBaltic.IsChecked ?? true) this.checkBoxMoUBaltic.IsChecked = false;
}
else
{
haz.NoDPGOnBoardOnArrival = false;
// theHAZ.DPGManifestOnBoardOnArrival = true;
haz.MOUBaltic = false;
}
if (!(this.checkBoxDangerousGoodsOnBoard.IsChecked ?? false)) this.checkBoxDangerousGoodsOnBoard.IsChecked = true;
if (this.checkBoxMoUBaltic.IsChecked ?? true) this.checkBoxMoUBaltic.IsChecked = false;
haz.NoDPGOnBoardOnArrival = false;
haz.MOUBaltic = false;
}
}

View File

@ -62,15 +62,17 @@ namespace ENI2.DetailViewControls
public override void Initialize()
{
bool iAmAdmin = DBManager.Instance.GetReportingPartyDict()[App.UserId.Value].IsAdmin;
base.Initialize();
Message.NotificationClass notificationClass = this.Core.IsTransit ? Message.NotificationClass.TRANSIT : Message.NotificationClass.VISIT;
if (this.Messages == null) return;
if (this.Core == null) return;
this.textBoxENI.IsReadOnly = false;
this.textBoxIMO.IsReadOnly = false;
this.locodePoC.IsEnabled = true;
this.textBoxDisplayId.IsReadOnly = false;
this.textBoxENI.IsReadOnly = !iAmAdmin;
this.textBoxIMO.IsReadOnly = !iAmAdmin;
this.locodePoC.IsEnabled = iAmAdmin;
this.textBoxDisplayId.IsReadOnly = !iAmAdmin;
this.textBoxENI.DataContext = this.Core;
this.textBoxIMO.DataContext = this.Core;

View File

@ -423,7 +423,7 @@ namespace ENI2.DetailViewControls
{
SERV newServ = new SERV();
newServ.ServiceBeneficiary = "Sealand Europe A/S, Dampfaergevej 10, 3.tv, DK- 2100 Copenhagen, VAT-ID: DK53139655";
newServ.ServiceInvoiceRecipient = "Sealand Europe Deutschland A/S & Co. KG, Ericusspitze 2-4, 20457 Hamburg";
newServ.ServiceInvoiceRecipient = "Maersk Deutschland A/S & Co. KG on behalf of Sealand Europe A/S, Ericusspitze 2-4, 20457 Hamburg";
newServ.ServiceName = "SeaGo BHV";
newServ.MessageHeader = this._servMessage;
newServ.Identifier = SERV.GetNewIdentifier(_servMessage.Elements);

View File

@ -77,9 +77,9 @@ namespace ENI2.DetailViewControls
foreach (TOWD selectedTOWD in this.dataGridTowageOnDeparture.SelectedItems)
{
TOWA copyTOWA = new TOWA();
copyTOWA.MessageHeader = _towdMessage;
copyTOWA.MessageHeader = _towaMessage;
copyTOWA.CopyFromTOWD(selectedTOWD);
copyTOWA.Identifier = TOWD.GetNewIdentifier(this._towdMessage.Elements);
copyTOWA.Identifier = TOWA.GetNewIdentifier(this._towaMessage.Elements);
this._towaMessage.Elements.Add(copyTOWA);
this.dataGridTowageOnArrival.Items.Refresh();
this.SublistElementChanged(Message.NotificationClass.TOWA);

View File

@ -548,7 +548,7 @@ namespace ENI2.DetailViewControls
if (!reader.IsDBNull(7)) o = reader.GetValue(7); else o = null;
if (o != null) waste.WasteAmountRetained_MTQ = Convert.ToDouble(o);
if (!reader.IsDBNull(8)) waste.WasteDisposalPort = reader.GetString(8);
if (!reader.IsDBNull(8)) waste.WasteDisposalPort = reader.GetString(8).ToUpper();
if (!reader.IsDBNull(9)) o = reader.GetValue(9); else o = null;
if (o != null) waste.WasteAmountGeneratedTillNextPort_MTQ = Convert.ToDouble(o);

View File

@ -36,8 +36,8 @@
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage>
<ApplicationRevision>2</ApplicationRevision>
<ApplicationVersion>7.2.0.2</ApplicationVersion>
<ApplicationRevision>3</ApplicationRevision>
<ApplicationVersion>7.3.0.3</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
@ -228,6 +228,9 @@
<Compile Include="Controls\LocodeControl.xaml.cs">
<DependentUpon>LocodeControl.xaml</DependentUpon>
</Compile>
<Compile Include="EditControls\CompareExcelDialog.xaml.cs">
<DependentUpon>CompareExcelDialog.xaml</DependentUpon>
</Compile>
<Compile Include="EditControls\EditWasteReceiptDialog.xaml.cs">
<DependentUpon>EditWasteReceiptDialog.xaml</DependentUpon>
</Compile>
@ -236,6 +239,7 @@
</Compile>
<Compile Include="Excel\DakosyUtil.cs" />
<Compile Include="Excel\ExcelBase.cs" />
<Compile Include="Excel\ExcelComparer.cs" />
<Compile Include="Excel\ExcelManager.cs" />
<Compile Include="Excel\ExcelReader.cs" />
<Compile Include="Excel\ExcelUtil.cs" />
@ -532,6 +536,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\CompareExcelDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="EditControls\CopyDeclarationDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@ -777,10 +785,10 @@
<None Include="Resources\lightbulb_on.png" />
<None Include="Resources\rotate_left.png" />
<Resource Include="Resources\sign_warning.png" />
<None Include="Resources\trafficlight_green.png" />
<None Include="Resources\trafficlight_off.png" />
<None Include="Resources\trafficlight_red.png" />
<None Include="Resources\trafficlight_yellow.png" />
<Resource Include="Resources\trafficlight_green.png" />
<Resource Include="Resources\trafficlight_off.png" />
<Resource Include="Resources\trafficlight_red.png" />
<Resource Include="Resources\trafficlight_yellow.png" />
<None Include="Resources\user_edit.png" />
<Resource Include="Resources\delete2.png" />
<None Include="Resources\mail_new.png" />
@ -814,6 +822,8 @@
<Resource Include="Resources\Logo.gif" />
<Resource Include="Resources\excel.png" />
<Resource Include="Resources\logo_eni.png" />
<Resource Include="Resources\import1.png" />
<Resource Include="Resources\import2.png" />
<Content Include="x64\SQLite.Interop.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -0,0 +1,43 @@
<enictrl:StatusWindowBase x:Class="ENI2.EditControls.CompareExcelDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:ENI2.EditControls"
xmlns:enictrl="clr-namespace:ENI2.Controls"
xmlns:p="clr-namespace:ENI2.Properties"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
mc:Ignorable="d"
Title="{x:Static p:Resources.textCompareExcel}" Height="260" Width="600" Background="AliceBlue" Icon="/ENI2;component/Resources/bullet_ball_grey.ico">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="32" />
<RowDefinition Height="60" />
<RowDefinition Height="60" />
<RowDefinition Height="28" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="80" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBlock Grid.Row="0" Grid.Column="1" TextWrapping="Wrap" HorizontalAlignment="Center" TextAlignment="Center">Drop your Excel file here</TextBlock>
<Label VerticalAlignment="Center" Grid.Row="1" Grid.Column="0">
<AccessText TextWrapping="Wrap">
First (original) sheet
</AccessText>
</Label>
<Image x:Name="imageSource" Grid.Row="1" Grid.Column="1" Margin="4" Source="../Resources/import2.png" AllowDrop="True" Drop="imageSource_Drop" DragEnter="imageSource_DragEnter"/>
<TextBox TextWrapping="Wrap" x:Name="textBoxSource" Grid.Row="1" Grid.Column="2" IsReadOnly="True" Margin="2" Drop="imageSource_Drop" AllowDrop="True" DragEnter="imageSource_DragEnter" PreviewDragOver="textBoxSource_PreviewDragOver"/>
<Label VerticalAlignment="Center" Grid.Row="2" Grid.Column="0">
<AccessText TextWrapping="Wrap">
Second (updated) sheet
</AccessText>
</Label>
<Image x:Name="imageTarget" Grid.Row="2" Grid.Column="1" Margin="4" Source="../Resources/import1.png" AllowDrop="True" Drop="imageTarget_Drop" DragEnter="imageSource_DragEnter"/>
<TextBox TextWrapping="Wrap" x:Name="textBoxTarget" Grid.Row="2" Grid.Column="2" IsReadOnly="True" Margin="2" AllowDrop="True" Drop="imageTarget_Drop" DragEnter="imageSource_DragEnter" PreviewDragOver="textBoxSource_PreviewDragOver"/>
<Button x:Name="buttonCompare" Margin="2" Grid.Row="3" Grid.Column="1" Content="Compare" IsEnabled="False" Click="buttonCompare_Click"/>
</Grid>
</enictrl:StatusWindowBase>

View File

@ -0,0 +1,143 @@
// Copyright (c) 2017- schick Informatik
// Description: Dialogbox zum Vergleichen zweier Excel via Named cells
//
using bsmd.database;
using System;
using System.Diagnostics;
using System.IO;
using System.Windows;
namespace ENI2.EditControls
{
/// <summary>
/// Interaction logic for CompareExcelDialog.xaml
/// </summary>
public partial class CompareExcelDialog : Controls.StatusWindowBase
{
#region Fields
private string _sourcePath = null;
private string _targetPath = null;
#endregion
public CompareExcelDialog()
{
InitializeComponent();
}
#region Drag&Drop event handler
private void imageSource_Drop(object sender, DragEventArgs e)
{
string[] files = (string[]) e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
Console.WriteLine(file);
if(files.Length > 0)
{
if(File.Exists(files[0]))
{
if(files[0].EndsWith("xls") || files[0].EndsWith("xlsx"))
{
_sourcePath = files[0];
textBoxSource.Text = _sourcePath;
}
else
{
textBoxSource.Text = null;
_sourcePath = null;
}
}
else
{
textBoxSource.Text = null;
_sourcePath = null;
}
EnableCompareButton();
}
}
private void imageTarget_Drop(object sender, DragEventArgs e)
{
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
foreach (string file in files)
Console.WriteLine(file);
if (files.Length > 0)
{
if (File.Exists(files[0]))
{
if (files[0].EndsWith("xls") || files[0].EndsWith("xlsx"))
{
_targetPath = files[0];
textBoxTarget.Text = _targetPath;
}
else
{
_targetPath = null;
textBoxTarget.Text = null;
}
}
else
{
_targetPath = null;
textBoxTarget.Text = null;
}
EnableCompareButton();
}
}
private void imageSource_DragEnter(object sender, DragEventArgs e)
{
if (e.Data.GetDataPresent(DataFormats.FileDrop))
{
e.Effects = DragDropEffects.Copy;
}
}
private void textBoxSource_PreviewDragOver(object sender, DragEventArgs e)
{
e.Handled = true;
}
#endregion
#region private methods
private void EnableCompareButton()
{
this.buttonCompare.IsEnabled = (_targetPath != null) && (_sourcePath != null);
}
#endregion
#region Comparison button handler logic
private void buttonCompare_Click(object sender, RoutedEventArgs e)
{
Util.UIHelper.SetBusyState();
string resultPath = Excel.ExcelComparer.Compare(_sourcePath, _targetPath, out string errorMessage);
if(!errorMessage.IsNullOrEmpty()) {
MessageBox.Show(errorMessage, "Comparison error", MessageBoxButton.OK, MessageBoxImage.Warning);
}
if(File.Exists(resultPath))
{
if(new FileInfo(resultPath).Length > 0)
{
Process.Start(resultPath);
}
}
// reset input values
this.textBoxSource.Text = null;
this.textBoxTarget.Text = null;
this._sourcePath = null;
this._targetPath = null;
EnableCompareButton();
this.Close();
}
#endregion
}
}

View File

@ -254,6 +254,11 @@ namespace ENI2.Excel
for (int i = 1; i <= 25; i++)
{
int? wasteType = (int?)reader.ReadCellAsDecimal("waste", string.Format("C{0}", i + 18));
if (!wasteType.HasValue) continue;
if (!WAS.WasteCodesInt.find(wasteType.Value)) continue;
if (!(was.GetSublistElementWithIdentifier(i.ToString()) is Waste waste))
{
waste = new Waste();
@ -261,7 +266,8 @@ namespace ENI2.Excel
waste.WAS = was;
was.Waste.Add(waste);
}
waste.WasteType = (int?)reader.ReadCellAsDecimal("waste", string.Format("C{0}", i + 18));
waste.WasteType = wasteType;
waste.WasteDescription = reader.ReadCellAsText("waste", string.Format("D{0}", i + 18));
waste.WasteDisposalAmount_MTQ = reader.ReadCellAsDecimal("waste", string.Format("E{0}", i + 18));
waste.WasteCapacity_MTQ = reader.ReadCellAsDecimal("waste", string.Format("F{0}", i + 18));

View File

@ -25,11 +25,11 @@ namespace ENI2.Excel
protected Dictionary<string, Name> _nameDict;
protected ILog _log;
#endregion
#endregion Fields
#region Construction
public ExcelBase(string filePath)
public ExcelBase()
{
_log = LogManager.GetLogger(this.GetType().Name);
@ -39,12 +39,16 @@ namespace ENI2.Excel
this._excelWorkbooks = _excelApp.Workbooks;
}
#endregion
#endregion Construction
#region Properties
internal CountryMode Mode { get { return _countryMode; } }
internal Dictionary<string, Name> NameDict { get { return _nameDict; } }
internal Sheets Worksheets { get { return _workBook.Worksheets; } }
#endregion
#region protected methods
@ -136,6 +140,32 @@ namespace ENI2.Excel
return result;
}
internal void Colorize(string lookup, int color)
{
if(_nameDict.ContainsKey(lookup))
{
var range = _nameDict[lookup].RefersToRange;
Colorize(range, color);
}
}
internal void Colorize(Range range, int color)
{
range.Interior.Color = color;
range.Worksheet.Tab.Color = color;
}
#endregion
#region public methods
public void Save(string path)
{
this._workBook.SaveAs(path, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
this._workBook.Saved = true;
}
#endregion
#region Dispose

192
ENI2/Excel/ExcelComparer.cs Normal file
View File

@ -0,0 +1,192 @@
// Copyright (c) 2022- schick Informatik
// Description: Compares excel files and highlights changes
//
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Drawing;
using Microsoft.Office.Interop.Excel;
namespace ENI2.Excel
{
/// <summary>
/// Diese Klasse beinhaltet den von Anmeldungen unabhängigen Vergleich von Excel Sheets. Damit
/// können dann Updates von "außen" einfacher abgearbeitet werden. Zellen und sheets werden bei
/// Aktualisierung bunt eingefärbt
/// </summary>
public static class ExcelComparer
{
private static int diffColor = ColorTranslator.ToOle(Color.FromArgb(150, 150, 255)); // blue
private static bool GetSheetRange(Worksheet sheet, out int lastUsedRow, out int lastUsedColumn)
{
try
{
Range last = sheet.Cells.SpecialCells(XlCellType.xlCellTypeLastCell, Type.Missing);
Range range = sheet.get_Range("A1", last);
lastUsedRow = last.Row;
lastUsedColumn = last.Column;
return true;
}
catch(Exception)
{
lastUsedColumn = 0;
lastUsedRow = 0;
return false;
}
}
private static string GetExcelColumnName(int columnNumber)
{
string columnName = "";
while (columnNumber > 0)
{
int modulo = (columnNumber - 1) % 26;
columnName = Convert.ToChar('A' + modulo) + columnName;
columnNumber = (columnNumber - modulo) / 26;
}
return columnName;
}
public static string Compare(string sourcePath, string targetPath, out string errorMessage)
{
string fileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".xlsx";
errorMessage = "";
int counter = 0;
try
{
File.Copy(targetPath, fileName);
ExcelReader source = new ExcelReader(sourcePath, true, false);
ExcelReader comparison = new ExcelReader(fileName, false, false);
/* erste Variante Vergleich über Namen der Zellen
// loop through named cells
foreach (string name in comparison.NameDict.Keys)
{
if (!source.NameDict.ContainsKey(name)) continue;
string sourceText = source.ReadText(name);
string targetText = comparison.ReadText(name);
if (sourceText == null)
{
if (targetText != null)
{
comparison.Colorize(name, diffColor);
counter++;
}
}
else if (targetText == null)
{
if (sourceText != null)
{
comparison.Colorize(name, diffColor);
counter++;
}
}
else if ((sourceText != null) && (targetText != null))
{
if (!sourceText.Equals(targetText))
{
// turn cell blue
comparison.Colorize(name, diffColor);
counter++;
}
}
}
*/
// Zweite Version durch alle Sheets werden Zellen der "used range" miteinander verglichen
foreach(Worksheet sourceSheet in source.Worksheets)
{
Worksheet targetSheet = null;
foreach(Worksheet sheet in comparison.Worksheets)
{
if (sourceSheet.Name.Equals(sheet.Name))
{
targetSheet = sheet;
break;
}
}
if (targetSheet == null) continue;
System.Diagnostics.Trace.WriteLine(string.Format("Processing sheet {0}", targetSheet.Name));
if(GetSheetRange(sourceSheet, out int sourceRows, out int sourceCols) && GetSheetRange(targetSheet, out int targetRows, out int targetCols))
{
// read source into 2 dim array
string rangeString = string.Format("A1:{0}{1}", GetExcelColumnName(Math.Max(sourceCols, targetCols)), Math.Max(sourceRows, targetRows));
object[,] sourceArray = sourceSheet.get_Range(rangeString).Value;
// read target into 2 dim array
object[,] targetArray = targetSheet.get_Range(rangeString).Value;
for (int rowidx = 1; rowidx <= Math.Max(sourceRows, targetRows); rowidx++)
{
for( int colidx = 1; colidx <= Math.Max(sourceCols, targetCols); colidx++)
{
string sourceText = null;
if(sourceArray[rowidx,colidx] != null) sourceText = sourceArray[rowidx,colidx].ToString();
string targetText = null;
if(targetArray[rowidx,colidx] != null) targetText = targetArray[rowidx, colidx].ToString();
if (sourceText == null)
{
if (targetText != null)
{
string targetRangeName = string.Format("{0}{1}", GetExcelColumnName(colidx), rowidx);
comparison.Colorize(targetSheet.Range[targetRangeName], diffColor);
counter++;
}
}
else if (targetText == null)
{
if (sourceText != null)
{
string targetRangeName = string.Format("{0}{1}", GetExcelColumnName(colidx), rowidx);
comparison.Colorize(targetSheet.Range[targetRangeName], diffColor);
counter++;
}
}
else if ((sourceText != null) && (targetText != null))
{
if (!sourceText.Equals(targetText))
{
string targetRangeName = string.Format("{0}{1}", GetExcelColumnName(colidx), rowidx);
// turn cell blue
comparison.Colorize(targetSheet.Range[targetRangeName], diffColor);
counter++;
}
}
}
}
}
else
{
errorMessage = "failed to get sheet ranges";
}
}
comparison.Save(fileName);
errorMessage = string.Format("{0} differences found", counter);
}
catch (Exception ex)
{
errorMessage = ex.Message;
}
return fileName;
}
}
}

View File

@ -83,7 +83,7 @@ namespace ENI2.Excel
using (ExcelWriter ew = new ExcelWriter(fileName, isRefSheet))
{
ew.WriteData(messages, core, out resultMessage, isRefSheet);
ew.Save();
ew.Save(fileName);
}
}
}

View File

@ -18,11 +18,12 @@ using System.Linq;
using System.Runtime.InteropServices;
using ENI2.Locode;
using bsmd.database;
using System.Text.RegularExpressions;
namespace ENI2.Excel
{
internal class ExcelReader : ExcelBase
{
{
internal enum ReadState { NONE, OK, WARN, FAIL };
@ -32,13 +33,15 @@ namespace ENI2.Excel
internal Dictionary<string, string> ImportValues { get; } = new Dictionary<string, string>();
public ExcelReader(string filePath) : base(filePath)
public ExcelReader(string filePath, bool openReadonly = true, bool createNameFields = true)
{
this._workBook = _excelWorkbooks.Open(filePath, 0, true, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false);
this.InitNameFields();
this._workBook = _excelWorkbooks.Open(filePath, 0, openReadonly, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false);
if(createNameFields)
this.InitNameFields();
// Determine if this is a Dakosy or BSMD Sheet
_sheetType = (_nameDict.Count > 10) ? SheetTypeEnum.BSMD : SheetTypeEnum.DAKOSY;
if(createNameFields)
_sheetType = (_nameDict.Count > 10) ? SheetTypeEnum.BSMD : SheetTypeEnum.DAKOSY;
}
public SheetTypeEnum SheetType { get { return _sheetType; } }
@ -77,6 +80,10 @@ namespace ENI2.Excel
if (result != null)
{
result = result.Trim();
if(result.Length > 0)
{
result = result.Clean();
}
this.ImportValues[lookup] = result;
}
@ -95,7 +102,7 @@ namespace ENI2.Excel
string val = this.ReadText(lookup);
if (!val.IsNullOrEmpty())
{
val = val.ToUpper();
val = val.ToUpper();
string portName = LocodeDB.PortNameFromLocode(val);
if (!justPorts) portName = LocodeDB.NameFromLocode(val);
if (portName.IsNullOrEmpty())
@ -569,7 +576,7 @@ namespace ENI2.Excel
Worksheet workSheet = (Worksheet) _workBook.Worksheets[sheetName];
string result = workSheet.Range[range].Text.ToString();
if (!result.IsNullOrEmpty())
result = result.Trim();
result = result.Trim().Clean();
return result;
}
catch(Exception e)
@ -579,6 +586,23 @@ namespace ENI2.Excel
return null;
}
internal string ReadCellAsText(string sheetName, int row, int col)
{
try
{
Worksheet workSheet = (Worksheet)_workBook.Worksheets[sheetName];
string result = workSheet.Range[row, col].Text.ToString();
if (!result.IsNullOrEmpty())
result = result.Trim().Clean();
return result;
}
catch (Exception e)
{
_log.Warn(e.Message);
}
return null;
}
// TODO THIS IS NOT WORKING
internal string ReadTextFromDropdown(string sheetName, string range)
{

View File

@ -21,6 +21,8 @@ namespace ENI2.Excel
{
private static readonly ILog _log = LogManager.GetLogger(typeof(ExcelUtil));
#region Process Sheet (normal BSMD sheet import)
internal static bool ProcessSheet(ExcelReader reader, out string readMessage, MessageCore messageCore, List<Message.NotificationClass> notificationClasses)
{
bool result = true;
@ -134,7 +136,9 @@ namespace ENI2.Excel
}
return result;
}
}
#endregion
#region ATA
@ -427,8 +431,8 @@ namespace ENI2.Excel
imdgPosition.GrossQuantity_KGM = reader.ReadNumber(imdg_grossQuantity);
imdgPosition.VehicleLicenseNumber = reader.ReadText(imdg_number);
imdgPosition.StowagePosition = reader.ReadText(imdg_stowagePosition);
imdgPosition.PortOfLoading = reader.ReadText(imdg_portOfLoading);
imdgPosition.PortOfDischarge = reader.ReadText(imdg_portOfDischarge);
imdgPosition.PortOfLoading = reader.ReadLoCode(imdg_portOfLoading);
imdgPosition.PortOfDischarge = reader.ReadLoCode(imdg_portOfDischarge);
imdgPosition.ContainerNumber = reader.ReadText(imdg_containerNumber);
imdgPosition.Remarks = reader.ReadText(imdg_remarks);
}
@ -491,8 +495,8 @@ namespace ENI2.Excel
ibcPosition.Quantity_KGM = (int ?) reader.ReadNumber(ibc_quantity);
ibcPosition.StowagePosition = reader.ReadText(ibc_stowagePosition);
ibcPosition.PortOfLoading = reader.ReadText(ibc_portOfLoading);
ibcPosition.PortOfDischarge = reader.ReadText(ibc_portOfDischarge);
ibcPosition.PortOfLoading = reader.ReadLoCode(ibc_portOfLoading);
ibcPosition.PortOfDischarge = reader.ReadLoCode(ibc_portOfDischarge);
ibcPosition.Hazards = reader.ReadHazards(ibc_hazards);
ibcPosition.SpecRef15_19 = reader.ReadBoolean(ibc_specrefs);
ibcPosition.Remarks = reader.ReadText(ibc_remarks);
@ -529,8 +533,8 @@ namespace ENI2.Excel
igcPosition.ProductName = productName;
igcPosition.Quantity_KGM = reader.ReadNumber(igc_quantity);
igcPosition.StowagePosition = reader.ReadText(igc_stowagePosition);
igcPosition.PortOfLoading = reader.ReadText(igc_portOfLoading);
igcPosition.PortOfDischarge = reader.ReadText(igc_portOfDischarge);
igcPosition.PortOfLoading = reader.ReadLoCode(igc_portOfLoading);
igcPosition.PortOfDischarge = reader.ReadLoCode(igc_portOfDischarge);
igcPosition.UNNumber = reader.ReadText(igc_unnumber);
igcPosition.IMOClass = reader.ReadText(igc_imoclass);
igcPosition.Remarks = reader.ReadText(igc_remarks);
@ -570,8 +574,8 @@ namespace ENI2.Excel
imsbcPosition.MHB = reader.ReadBoolean(imsbc_mhb);
imsbcPosition.Quantity_KGM = reader.ReadNumber(imsbc_quantity);
imsbcPosition.StowagePosition = reader.ReadText(imsbc_stowagePosition);
imsbcPosition.PortOfLoading = reader.ReadText(imsbc_portOfLoading);
imsbcPosition.PortOfDischarge = reader.ReadText(imsbc_portOfDischarge);
imsbcPosition.PortOfLoading = reader.ReadLoCode(imsbc_portOfLoading);
imsbcPosition.PortOfDischarge = reader.ReadLoCode(imsbc_portOfDischarge);
imsbcPosition.IMOHazardClass = reader.ReadHazardClass(imsbc_hazardclass);
imsbcPosition.UNNumber = reader.ReadText(imsbc_unnumber);
imsbcPosition.IMOClass = reader.ReadText(imsbc_imoclass);
@ -622,8 +626,8 @@ namespace ENI2.Excel
marpolPosition.Quantity_KGM = reader.ReadNumber(marpol_quantity);
marpolPosition.StowagePosition = reader.ReadText(marpol_stowagePosition);
marpolPosition.PortOfLoading = reader.ReadText(marpol_portOfLoading);
marpolPosition.PortOfDischarge = reader.ReadText(marpol_portOfDischarge);
marpolPosition.PortOfLoading = reader.ReadLoCode(marpol_portOfLoading);
marpolPosition.PortOfDischarge = reader.ReadLoCode(marpol_portOfDischarge);
marpolPosition.Remarks = reader.ReadText(marpol_remarks);
}
@ -715,8 +719,8 @@ namespace ENI2.Excel
imdgPosition.GrossQuantity_KGM = reader.ReadNumber(imdg_grossQuantity);
imdgPosition.VehicleLicenseNumber = reader.ReadText(imdg_number);
imdgPosition.StowagePosition = reader.ReadText(imdg_stowagePosition);
imdgPosition.PortOfLoading = reader.ReadText(imdg_portOfLoading);
imdgPosition.PortOfDischarge = reader.ReadText(imdg_portOfDischarge);
imdgPosition.PortOfLoading = reader.ReadLoCode(imdg_portOfLoading);
imdgPosition.PortOfDischarge = reader.ReadLoCode(imdg_portOfDischarge);
imdgPosition.ContainerNumber = reader.ReadText(imdg_containerNumber);
imdgPosition.Remarks = reader.ReadText(imdg_remarks);
}
@ -777,8 +781,8 @@ namespace ENI2.Excel
ibcPosition.Quantity_KGM = (int?)reader.ReadNumber(ibc_quantity);
ibcPosition.StowagePosition = reader.ReadText(ibc_stowagePosition);
ibcPosition.PortOfLoading = reader.ReadText(ibc_portOfLoading);
ibcPosition.PortOfDischarge = reader.ReadText(ibc_portOfDischarge);
ibcPosition.PortOfLoading = reader.ReadLoCode(ibc_portOfLoading);
ibcPosition.PortOfDischarge = reader.ReadLoCode(ibc_portOfDischarge);
ibcPosition.Hazards = reader.ReadHazards(ibc_hazards);
ibcPosition.SpecRef15_19 = reader.ReadBoolean(ibc_specref);
ibcPosition.Remarks = reader.ReadText(ibc_remarks);
@ -815,8 +819,8 @@ namespace ENI2.Excel
igcPosition.ProductName = productName;
igcPosition.Quantity_KGM = reader.ReadNumber(igc_quantity);
igcPosition.StowagePosition = reader.ReadText(igc_stowagePosition);
igcPosition.PortOfLoading = reader.ReadText(igc_portOfLoading);
igcPosition.PortOfDischarge = reader.ReadText(igc_portOfDischarge);
igcPosition.PortOfLoading = reader.ReadLoCode(igc_portOfLoading);
igcPosition.PortOfDischarge = reader.ReadLoCode(igc_portOfDischarge);
igcPosition.UNNumber = reader.ReadText(igc_unnumber);
igcPosition.IMOClass = reader.ReadText(igc_imoclass);
igcPosition.Remarks = reader.ReadText(igc_remarks);
@ -856,8 +860,8 @@ namespace ENI2.Excel
imsbcPosition.MHB = reader.ReadBoolean(imsbc_mhb);
imsbcPosition.Quantity_KGM = reader.ReadNumber(imsbc_quantity);
imsbcPosition.StowagePosition = reader.ReadText(imsbc_stowagePosition);
imsbcPosition.PortOfLoading = reader.ReadText(imsbc_portOfLoading);
imsbcPosition.PortOfDischarge = reader.ReadText(imsbc_portOfDischarge);
imsbcPosition.PortOfLoading = reader.ReadLoCode(imsbc_portOfLoading);
imsbcPosition.PortOfDischarge = reader.ReadLoCode(imsbc_portOfDischarge);
imsbcPosition.IMOHazardClass = reader.ReadHazardClass(imsbc_hazardclass);
imsbcPosition.UNNumber = reader.ReadText(imsbc_unnumber);
imsbcPosition.IMOClass = reader.ReadText(imsbc_imoclass);
@ -907,8 +911,8 @@ namespace ENI2.Excel
marpolPosition.Quantity_KGM = reader.ReadNumber(marpol_quantity);
marpolPosition.StowagePosition = reader.ReadText(marpol_stowagePosition);
marpolPosition.PortOfLoading = reader.ReadText(marpol_portOfLoading);
marpolPosition.PortOfDischarge = reader.ReadText(marpol_portOfDischarge);
marpolPosition.PortOfLoading = reader.ReadLoCode(marpol_portOfLoading);
marpolPosition.PortOfDischarge = reader.ReadLoCode(marpol_portOfDischarge);
marpolPosition.Remarks = reader.ReadText(marpol_remarks);
}
@ -955,7 +959,7 @@ namespace ENI2.Excel
#region STAT
private static bool ScanSTAT(Message statMessage, MessageCore messageCore, List<Message> messages, ExcelReader reader)
{
{
if(statMessage.Elements.Count == 0)
{
STAT newSTAT = new STAT();
@ -978,14 +982,11 @@ namespace ENI2.Excel
}
}
stat.PortOfRegistry = reader.ReadLoCode("STAT.PortOfRegistry", false);
if (stat.PortOfRegistry.Length == 5)
stat.Flag = stat.PortOfRegistry.Substring(0, 2);
stat.MMSINumber = reader.ReadTextNoWhitespace("STAT.MMSINumber");
stat.CallSign = reader.ReadTextNoWhitespace("STAT.CallSign");
stat.ISMCompanyId = reader.ReadTextNoWhitespace("STAT.ISMCompanyId");
stat.MMSINumber = reader.ReadTextNoWhitespace("STAT.MMSINumber");
stat.CallSign = reader.ReadTextNoWhitespace("STAT.CallSign");
stat.ISMCompanyId = reader.ReadTextNoWhitespace("STAT.ISMCompanyId");
if (!stat.ISMCompanyId.IsNullOrEmpty())
if (!stat.ISMCompanyId.IsNullOrEmpty())
{
// strip "ISM" at the beginning if it is there (27.12.21)
if (stat.ISMCompanyId.StartsWith("imo", StringComparison.OrdinalIgnoreCase))
@ -1005,12 +1006,12 @@ namespace ENI2.Excel
if (transportMode.Contains("inland", StringComparison.OrdinalIgnoreCase)) stat.TransportMode = "8";
if (transportMode.Equals("8")) stat.TransportMode = transportMode;
}
}
// Vessel Email as HerbergEmail sichern
messageCore.HerbergEmailContactReportingVessel = reader.ReadText("ShipMail");
return true;
return true;
}
#endregion
@ -2335,7 +2336,7 @@ namespace ENI2.Excel
if (sheetValue != null)
{
property.SetValue(dbEntity, sheetValue);
}
}
}
else if (property.PropertyType == typeof(double?))
{
@ -2343,7 +2344,7 @@ namespace ENI2.Excel
if (sheetValue != null)
{
property.SetValue(dbEntity, sheetValue);
}
}
}
else if (property.PropertyType == typeof(string))
{
@ -2351,7 +2352,7 @@ namespace ENI2.Excel
if (sheetValue != null)
{
property.SetValue(dbEntity, sheetValue);
}
}
}
else if (property.PropertyType == typeof(int?))
{
@ -2359,7 +2360,7 @@ namespace ENI2.Excel
if (sheetValue.HasValue)
{
property.SetValue(dbEntity, (int)sheetValue.Value);
}
}
}
else if (property.PropertyType == typeof(byte?))
{
@ -2367,7 +2368,7 @@ namespace ENI2.Excel
if (sheetValue.HasValue)
{
property.SetValue(dbEntity, (byte)sheetValue.Value);
}
}
}
else if (property.PropertyType == typeof(Boolean?))
{
@ -2375,7 +2376,7 @@ namespace ENI2.Excel
string boolStringValue = reader.ReadText(lookupNameAttribute.LookupName);
if (sheetValue.HasValue) {
property.SetValue(dbEntity, sheetValue);
}
}
}
else
{

View File

@ -18,15 +18,11 @@ namespace ENI2.Excel
internal class ExcelWriter : ExcelBase
{
#region Fields
private readonly string _saveFilePath;
#endregion
#region Construction
public ExcelWriter(string filePath, bool isRefSheet) : base(filePath)
public ExcelWriter(string filePath, bool isRefSheet)
{
string filename = @"Excel\EU-NoAD-Data-Collecting-Tool-5_0.xlsx";
if (isRefSheet) filename = @"Excel\Reference_Sheet_DE.xlsx";
@ -35,7 +31,7 @@ namespace ENI2.Excel
this._workBook = _excelWorkbooks.Open(refFilePath, 0, true, 5, "", "", false, XlPlatform.xlWindows, "", false, false, 0, false, false, false);
this.InitNameFields();
_saveFilePath = filePath;
}
#endregion
@ -196,13 +192,6 @@ namespace ENI2.Excel
WriteCore(core, isRefSheet);
}
public void Save()
{
this._workBook.SaveAs(_saveFilePath, XlFileFormat.xlOpenXMLWorkbook, Type.Missing, Type.Missing, Type.Missing, Type.Missing, XlSaveAsAccessMode.xlNoChange,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
this._workBook.Saved = true;
}
#endregion

View File

@ -72,6 +72,7 @@
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="auto"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
@ -84,7 +85,8 @@
<RadioButton Grid.Column="3" x:Name="buttonStatus" Content="{x:Static p:Resources.textServerStatus}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="auto" Click="radioButton_Click" Background="Transparent" Margin="2,5,0,0" Grid.RowSpan="2" />
<RadioButton Grid.Column="4" x:Name="buttonUserAdmin" Content="{x:Static p:Resources.textUserAdministration}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="auto" Click="radioButton_Click" Background="Transparent" Visibility="Hidden" Margin="2,5,0,0" Grid.RowSpan="2"/>
<RadioButton Grid.Column="5" x:Name="buttonPOListe" Content="{x:Static p:Resources.textPOLists}" HorizontalAlignment="Left" VerticalAlignment="Top" Width="auto" Click="radioButton_Click" Background="Transparent" Visibility="Hidden" Margin="2,5,0,0" Grid.RowSpan="2" />
<Button Grid.Column="5" x:Name="buttonAbout" Content="?" HorizontalAlignment="Right" VerticalAlignment="Top" Background="Transparent" Margin="0,2,2,0" Padding="5,0,5,0" Click="buttonAbout_Click" Grid.RowSpan="2"/>
<Button Grid.Column="6" x:Name="buttonCompareSheets" Content="{x:Static p:Resources.textCompareExcel}" HorizontalAlignment="Left" VerticalAlignment="Top" Click="buttonCompareSheets_Click" Background="Transparent" Margin="2,2,0,0" />
<Button Grid.Column="7" x:Name="buttonAbout" Content="?" HorizontalAlignment="Right" VerticalAlignment="Top" Background="Transparent" Margin="0,2,2,0" Padding="5,0,5,0" Click="buttonAbout_Click" Grid.RowSpan="2"/>
<Label Grid.Column="0" Grid.Row="1" x:Name="labelStatusId" Grid.ColumnSpan="3" Margin="2,2,0,0" HorizontalAlignment="Left"/>
</Grid>
</Grid>

View File

@ -38,7 +38,8 @@ namespace ENI2
private POListControl poControl;
private ServerStatusControl statusControl;
private readonly SucheControl sucheControl;
private CompareExcelDialog compareExcelDialog;
private bool efMode = false;
private bool dbConnected;
private readonly ScaleTransform _transform = new ScaleTransform(1.0, 1.0);
@ -287,6 +288,22 @@ namespace ENI2
this.buttonNewWithId.Visibility = newButtonsVisible ? Visibility.Visible : Visibility.Hidden;
}
private void buttonCompareSheets_Click(object sender, RoutedEventArgs ev)
{
// Open compare dialog
if(compareExcelDialog == null)
{
this.compareExcelDialog = new CompareExcelDialog();
this.compareExcelDialog.Closed += (o, e) => this.compareExcelDialog = null;
compareExcelDialog.Show();
}
else
{
compareExcelDialog.BringUp();
}
}
#endregion
#region window lifetime event handler
@ -691,6 +708,6 @@ namespace ENI2
}
#endregion
}
}

View File

@ -500,6 +500,26 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap import1 {
get {
object obj = ResourceManager.GetObject("import1", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
public static System.Drawing.Bitmap import2 {
get {
object obj = ResourceManager.GetObject("import2", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
@ -1345,6 +1365,15 @@ namespace ENI2.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to Compare excel sheets.
/// </summary>
public static string textCompareExcel {
get {
return ResourceManager.GetString("textCompareExcel", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Condition.
/// </summary>

View File

@ -1840,4 +1840,13 @@
<data name="textCopyTo" xml:space="preserve">
<value>Copy to {0}</value>
</data>
<data name="textCompareExcel" xml:space="preserve">
<value>Compare excel sheets</value>
</data>
<data name="import1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\import1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="import2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\import2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

BIN
ENI2/Resources/import1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
ENI2/Resources/import2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -121,7 +121,7 @@ namespace bsmd.database
[ShowReport]
[ReportDisplayName("Expiry date")]
[Validation(ValidationCode.NOT_NULL)]
[Validation(ValidationCode.PAST_DATE)]
[ENI2Validation]
public DateTime? CrewMemberIdentityDocumentExpiryDate { get; set; }

View File

@ -15,6 +15,7 @@ using System.Text.RegularExpressions;
using log4net;
using System.Linq;
using System.Collections;
using System.Text;
namespace bsmd.database
{
@ -77,6 +78,17 @@ namespace bsmd.database
return false;
}
public static string Clean(this String str)
{
StringBuilder sb = new StringBuilder();
foreach (char c in str)
{
if (!char.IsControl(c) || c == ' ' || c == '\t' || c == '\n')
sb.Append(c);
}
return sb.ToString();
}
public static bool Contains(this string source, string toCheck, StringComparison comp)
{
return source.IndexOf(toCheck, comp) >= 0;
@ -195,6 +207,9 @@ namespace bsmd.database
}
}
}
public static bool find<T>(this T[] array, T target)
{
return array.Contains(target);
}
}
}

View File

@ -125,7 +125,7 @@ namespace bsmd.database
[ShowReport]
[ReportDisplayName("Expiry date")]
[Validation(ValidationCode.NOT_NULL)]
[Validation(ValidationCode.PAST_DATE)]
[ENI2Validation]
public DateTime? PassengerIdentityDocumentExpiryDate { get; set; }

View File

@ -2,6 +2,6 @@
[assembly: AssemblyCompany("schick Informatik")]
[assembly: AssemblyProduct("BSMD NSW interface")]
[assembly: AssemblyInformationalVersion("7.2.0")]
[assembly: AssemblyInformationalVersion("7.3.0")]
[assembly: AssemblyCopyright("Copyright © 2014-2022 schick Informatik")]
[assembly: AssemblyTrademark("")]

View File

@ -1,4 +1,4 @@
using System.Reflection;
[assembly: AssemblyVersion("7.2.0.*")]
[assembly: AssemblyVersion("7.3.0.*")]

View File

@ -354,6 +354,16 @@ namespace bsmd.database
}
}
break;
case ValidationCode.PAST_DATE:
{
if (value.Length == 0) errors.Add(RuleEngine.CreateError(ValidationCode.NOT_NULL, property.Name, value, entity.Title, identifier, entity.Tablename));
if (DateTime.TryParse(value, out DateTime aTime))
{
if (aTime < DateTime.UtcNow)
errors.Add(RuleEngine.CreateError(validationCode, property.Name, value, entity.Title, identifier, entity.Tablename));
}
}
break;
case ValidationCode.DOT_NO_COMMA:
{
if(!value.IsNullOrEmpty() && (value.Contains(",")))

View File

@ -42,7 +42,7 @@ namespace bsmd.database
STRING_UNNUMBER = 23,
STRING_IMOCLASS = 24,
DRAUGHT_IMPLAUSIBLE = 25,
TIME_IMPLAUSIBLE = 26,
TIME_IMPLAUSIBLE = 26,
PORTAREA,
TRUNCATE = 28,
MMSI = 29,
@ -50,8 +50,9 @@ namespace bsmd.database
OPTIONAL_FLAG_CODE,
WORDOVERFLOW,
VALUE_TOO_LARGE,
PAST_DATE,
V181 = 181,
V182,
V182,
E121 = 121,
E122 = 122,
E123 = 123,

View File

@ -54,6 +54,8 @@ namespace bsmd.database
"101", "102", "103", "104", "105", "999", "201", "202", "203", "204", "401", "501", "502", "503", "504", "505", "506", "507", "508", "509", "510", "511", "601", "602", "991"
};
public static int[] WasteCodesInt { get; } = { 101, 102, 103, 104, 105, 999, 201, 202, 203, 204, 401, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 601, 602, 991 };
/// <summary>
/// NSW 7.0 Waste descriptions
/// </summary>

View File

@ -711,8 +711,10 @@ namespace bsmd.hisnord
lu.CargoNumberOfItems = ladg.CargoNumberOfItems.Value.ToString();
if (ladg.CargoGrossQuantity_TNE.HasValue)
lu.CargoGrossQuantity_TNE = Math.Round((decimal)ladg.CargoGrossQuantity_TNE.Value, 3);
lu.CargoPortOfLoading = ladg.PortOfLoading;
lu.CargoPortOfDischarge = ladg.PortOfDischarge;
if(!ladg.PortOfLoading.IsNullOrEmpty())
lu.CargoPortOfLoading = ladg.PortOfLoading;
if(!ladg.PortOfDischarge.IsNullOrEmpty())
lu.CargoPortOfDischarge = ladg.PortOfDischarge;
hn_generalcargo.Cargo[i] = lu;
}
@ -1217,9 +1219,13 @@ namespace bsmd.hisnord
{
for (int i = 0; i < was.Waste.Count; i++)
{
waste hn_waste = new waste();
Waste waste = was.Waste[i];
if (!waste.WasteType.HasValue) continue;
if (!WAS.WasteCodesInt.find<int>(waste.WasteType.Value)) continue;
waste hn_waste = new waste();
if (waste.WasteDisposalAmount_MTQ.HasValue)
hn_waste.WasteDisposalAmount_MTQ = Math.Round((decimal)waste.WasteDisposalAmount_MTQ.Value, 3);