diff --git a/ENI2/Controls/POListControl.xaml.cs b/ENI2/Controls/POListControl.xaml.cs
index c6b0e3eb..0985b92f 100644
--- a/ENI2/Controls/POListControl.xaml.cs
+++ b/ENI2/Controls/POListControl.xaml.cs
@@ -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)
diff --git a/ENI2/DetailBaseControl.cs b/ENI2/DetailBaseControl.cs
index b1c00860..70ecc986 100644
--- a/ENI2/DetailBaseControl.cs
+++ b/ENI2/DetailBaseControl.cs
@@ -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;
+ }
}
}
diff --git a/ENI2/DetailRootControl.xaml.cs b/ENI2/DetailRootControl.xaml.cs
index ef0d533e..72deed89 100644
--- a/ENI2/DetailRootControl.xaml.cs
+++ b/ENI2/DetailRootControl.xaml.cs
@@ -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 = "";
diff --git a/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs b/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
index b3bc701a..9f1f7d34 100644
--- a/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
+++ b/ENI2/DetailViewControls/BorderPoliceDetailControl.xaml.cs
@@ -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;
diff --git a/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml b/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml
index 683af440..fe9d1837 100644
--- a/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml
+++ b/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml
@@ -63,13 +63,14 @@
-
+
-
+
+
diff --git a/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs b/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs
index 06fb8685..1c28b2cb 100644
--- a/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs
+++ b/ENI2/DetailViewControls/DangerousGoodsDetailControl.xaml.cs
@@ -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;
}
}
diff --git a/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs b/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
index 1bb1ba98..4a86d304 100644
--- a/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
+++ b/ENI2/DetailViewControls/OverViewDetailControl.xaml.cs
@@ -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;
diff --git a/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs b/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
index 605f2730..45787c79 100644
--- a/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
+++ b/ENI2/DetailViewControls/PortNotificationDetailControl.xaml.cs
@@ -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);
diff --git a/ENI2/DetailViewControls/TowageDetailControl.xaml.cs b/ENI2/DetailViewControls/TowageDetailControl.xaml.cs
index 6bfae9f9..2ad50d4f 100644
--- a/ENI2/DetailViewControls/TowageDetailControl.xaml.cs
+++ b/ENI2/DetailViewControls/TowageDetailControl.xaml.cs
@@ -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);
diff --git a/ENI2/DetailViewControls/WasteDetailControl.xaml.cs b/ENI2/DetailViewControls/WasteDetailControl.xaml.cs
index 2850e023..a5fb8751 100644
--- a/ENI2/DetailViewControls/WasteDetailControl.xaml.cs
+++ b/ENI2/DetailViewControls/WasteDetailControl.xaml.cs
@@ -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);
diff --git a/ENI2/ENI2.csproj b/ENI2/ENI2.csproj
index 7456d833..e3825e8f 100644
--- a/ENI2/ENI2.csproj
+++ b/ENI2/ENI2.csproj
@@ -36,8 +36,8 @@
5.4.0.0
true
publish.html
- 2
- 7.2.0.2
+ 3
+ 7.3.0.3
false
true
true
@@ -228,6 +228,9 @@
LocodeControl.xaml
+
+ CompareExcelDialog.xaml
+
EditWasteReceiptDialog.xaml
@@ -236,6 +239,7 @@
+
@@ -532,6 +536,10 @@
Designer
MSBuild:Compile
+
+ Designer
+ MSBuild:Compile
+
Designer
MSBuild:Compile
@@ -777,10 +785,10 @@
-
-
-
-
+
+
+
+
@@ -814,6 +822,8 @@
+
+
Always
diff --git a/ENI2/EditControls/CompareExcelDialog.xaml b/ENI2/EditControls/CompareExcelDialog.xaml
new file mode 100644
index 00000000..cf243be2
--- /dev/null
+++ b/ENI2/EditControls/CompareExcelDialog.xaml
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Drop your Excel file here
+
+
+
+
+
+
+
+
+
+
+
diff --git a/ENI2/EditControls/CompareExcelDialog.xaml.cs b/ENI2/EditControls/CompareExcelDialog.xaml.cs
new file mode 100644
index 00000000..f7cbc548
--- /dev/null
+++ b/ENI2/EditControls/CompareExcelDialog.xaml.cs
@@ -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
+{
+ ///
+ /// Interaction logic for CompareExcelDialog.xaml
+ ///
+ 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
+
+ }
+}
diff --git a/ENI2/Excel/DakosyUtil.cs b/ENI2/Excel/DakosyUtil.cs
index c4e84226..9346a2e7 100644
--- a/ENI2/Excel/DakosyUtil.cs
+++ b/ENI2/Excel/DakosyUtil.cs
@@ -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));
diff --git a/ENI2/Excel/ExcelBase.cs b/ENI2/Excel/ExcelBase.cs
index 34a2df7f..31eb1cd5 100644
--- a/ENI2/Excel/ExcelBase.cs
+++ b/ENI2/Excel/ExcelBase.cs
@@ -25,11 +25,11 @@ namespace ENI2.Excel
protected Dictionary _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 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
diff --git a/ENI2/Excel/ExcelComparer.cs b/ENI2/Excel/ExcelComparer.cs
new file mode 100644
index 00000000..99eea7e0
--- /dev/null
+++ b/ENI2/Excel/ExcelComparer.cs
@@ -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
+{
+
+ ///
+ /// 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
+ ///
+ 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;
+ }
+
+ }
+}
diff --git a/ENI2/Excel/ExcelManager.cs b/ENI2/Excel/ExcelManager.cs
index 14ae76b3..ee169071 100644
--- a/ENI2/Excel/ExcelManager.cs
+++ b/ENI2/Excel/ExcelManager.cs
@@ -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);
}
}
}
diff --git a/ENI2/Excel/ExcelReader.cs b/ENI2/Excel/ExcelReader.cs
index bd21b971..cb9444d2 100644
--- a/ENI2/Excel/ExcelReader.cs
+++ b/ENI2/Excel/ExcelReader.cs
@@ -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 ImportValues { get; } = new Dictionary();
- 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)
{
diff --git a/ENI2/Excel/ExcelUtil.cs b/ENI2/Excel/ExcelUtil.cs
index 7c6be159..0e30232a 100644
--- a/ENI2/Excel/ExcelUtil.cs
+++ b/ENI2/Excel/ExcelUtil.cs
@@ -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 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 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
{
diff --git a/ENI2/Excel/ExcelWriter.cs b/ENI2/Excel/ExcelWriter.cs
index 9a0c9098..6f06015e 100644
--- a/ENI2/Excel/ExcelWriter.cs
+++ b/ENI2/Excel/ExcelWriter.cs
@@ -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
diff --git a/ENI2/MainWindow.xaml b/ENI2/MainWindow.xaml
index a33af61f..37d9d068 100644
--- a/ENI2/MainWindow.xaml
+++ b/ENI2/MainWindow.xaml
@@ -72,6 +72,7 @@
+
@@ -84,7 +85,8 @@
-
+
+
diff --git a/ENI2/MainWindow.xaml.cs b/ENI2/MainWindow.xaml.cs
index ae7de548..483bc33a 100644
--- a/ENI2/MainWindow.xaml.cs
+++ b/ENI2/MainWindow.xaml.cs
@@ -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
-
+
}
}
diff --git a/ENI2/Properties/Resources.Designer.cs b/ENI2/Properties/Resources.Designer.cs
index d7b6c951..e0f5ccba 100644
--- a/ENI2/Properties/Resources.Designer.cs
+++ b/ENI2/Properties/Resources.Designer.cs
@@ -500,6 +500,26 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ public static System.Drawing.Bitmap import1 {
+ get {
+ object obj = ResourceManager.GetObject("import1", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// Looks up a localized resource of type System.Drawing.Bitmap.
+ ///
+ public static System.Drawing.Bitmap import2 {
+ get {
+ object obj = ResourceManager.GetObject("import2", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
@@ -1345,6 +1365,15 @@ namespace ENI2.Properties {
}
}
+ ///
+ /// Looks up a localized string similar to Compare excel sheets.
+ ///
+ public static string textCompareExcel {
+ get {
+ return ResourceManager.GetString("textCompareExcel", resourceCulture);
+ }
+ }
+
///
/// Looks up a localized string similar to Condition.
///
diff --git a/ENI2/Properties/Resources.resx b/ENI2/Properties/Resources.resx
index 214be32e..445b547c 100644
--- a/ENI2/Properties/Resources.resx
+++ b/ENI2/Properties/Resources.resx
@@ -1840,4 +1840,13 @@
Copy to {0}
+
+ Compare excel sheets
+
+
+ ..\Resources\import1.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Resources\import2.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
\ No newline at end of file
diff --git a/ENI2/Resources/import1.png b/ENI2/Resources/import1.png
new file mode 100644
index 00000000..ccde244d
Binary files /dev/null and b/ENI2/Resources/import1.png differ
diff --git a/ENI2/Resources/import2.png b/ENI2/Resources/import2.png
new file mode 100644
index 00000000..51e2c05d
Binary files /dev/null and b/ENI2/Resources/import2.png differ
diff --git a/bsmd.database/CREW.cs b/bsmd.database/CREW.cs
index 78041839..bbc1f5de 100644
--- a/bsmd.database/CREW.cs
+++ b/bsmd.database/CREW.cs
@@ -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; }
diff --git a/bsmd.database/Extensions.cs b/bsmd.database/Extensions.cs
index fe65bb6c..0e745fd5 100644
--- a/bsmd.database/Extensions.cs
+++ b/bsmd.database/Extensions.cs
@@ -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(this T[] array, T target)
+ {
+ return array.Contains(target);
+ }
}
}
diff --git a/bsmd.database/PAS.cs b/bsmd.database/PAS.cs
index f367423b..aeaaa61c 100644
--- a/bsmd.database/PAS.cs
+++ b/bsmd.database/PAS.cs
@@ -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; }
diff --git a/bsmd.database/Properties/AssemblyProductInfo.cs b/bsmd.database/Properties/AssemblyProductInfo.cs
index 35318206..ee133160 100644
--- a/bsmd.database/Properties/AssemblyProductInfo.cs
+++ b/bsmd.database/Properties/AssemblyProductInfo.cs
@@ -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("")]
\ No newline at end of file
diff --git a/bsmd.database/Properties/AssemblyProjectInfo.cs b/bsmd.database/Properties/AssemblyProjectInfo.cs
index 8111450c..1d4cc244 100644
--- a/bsmd.database/Properties/AssemblyProjectInfo.cs
+++ b/bsmd.database/Properties/AssemblyProjectInfo.cs
@@ -1,4 +1,4 @@
using System.Reflection;
-[assembly: AssemblyVersion("7.2.0.*")]
+[assembly: AssemblyVersion("7.3.0.*")]
diff --git a/bsmd.database/RuleEngine.cs b/bsmd.database/RuleEngine.cs
index 7cdea26d..d22adbf5 100644
--- a/bsmd.database/RuleEngine.cs
+++ b/bsmd.database/RuleEngine.cs
@@ -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(",")))
diff --git a/bsmd.database/ValidationAttribute.cs b/bsmd.database/ValidationAttribute.cs
index dabe029e..16fa8ff4 100644
--- a/bsmd.database/ValidationAttribute.cs
+++ b/bsmd.database/ValidationAttribute.cs
@@ -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,
diff --git a/bsmd.database/WAS.cs b/bsmd.database/WAS.cs
index 202b1e89..2debf224 100644
--- a/bsmd.database/WAS.cs
+++ b/bsmd.database/WAS.cs
@@ -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 };
+
///
/// NSW 7.0 Waste descriptions
///
diff --git a/bsmd.hisnord/Request.cs b/bsmd.hisnord/Request.cs
index 9bf1c726..8f2a0974 100644
--- a/bsmd.hisnord/Request.cs
+++ b/bsmd.hisnord/Request.cs
@@ -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(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);