diff --git a/ENI-2/ENI2/ENI2/ENI2.csproj b/ENI-2/ENI2/ENI2/ENI2.csproj index 827f77e8..7516ec77 100644 --- a/ENI-2/ENI2/ENI2/ENI2.csproj +++ b/ENI-2/ENI2/ENI2/ENI2.csproj @@ -58,6 +58,9 @@ bsmdKey.snk + + Resources\containership.ico + packages\log4net.2.0.8\lib\net45-full\log4net.dll diff --git a/ENI-2/ENI2/ENI2/SucheControl.xaml b/ENI-2/ENI2/ENI2/SucheControl.xaml index 8cead552..146979c5 100644 --- a/ENI-2/ENI2/ENI2/SucheControl.xaml +++ b/ENI-2/ENI2/ENI2/SucheControl.xaml @@ -6,7 +6,7 @@ xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:local="clr-namespace:ENI2" mc:Ignorable="d" - d:DesignHeight="300" d:DesignWidth="300"> + d:DesignHeight="600" d:DesignWidth="800"> diff --git a/Stundensheet.xlsx b/Stundensheet.xlsx index 36db0cd0..f463b495 100644 Binary files a/Stundensheet.xlsx and b/Stundensheet.xlsx differ diff --git a/nsw/Source/bsmd.ExcelReadService/Confirmation.cs b/nsw/Source/bsmd.ExcelReadService/Confirmation.cs index 5d8f6358..f0fb58b3 100644 --- a/nsw/Source/bsmd.ExcelReadService/Confirmation.cs +++ b/nsw/Source/bsmd.ExcelReadService/Confirmation.cs @@ -114,6 +114,35 @@ namespace bsmd.ExcelReadService this.ConfirmValue(lookup, value, state); } + public void HighlightCellWithState(string lookup, ExcelReader.ReadState state) + { + for (int i = 0; i < this.workbooks.Count; i++) + { + Workbook workbook = this.workbooks[i]; + Dictionary> nameDict = this.nameDicts[i]; + + if (nameDict.ContainsKey(lookup)) + { + try + { + foreach (Name someName in nameDict[lookup]) + { + Range range = someName.RefersToRange; + if (range != null) + { + range.Interior.Color = this.ColorForState(state); + } + Marshal.ReleaseComObject(range); + } + } + catch (Exception ex) + { + _log.WarnFormat("cannot set highlight {0} for lookup {1}: {2}", state, lookup, ex.Message); + } + } + } + } + public List SaveConfirmationSheets(string receivedFileName) { diff --git a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs index 22997597..6cd1766c 100644 --- a/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs +++ b/nsw/Source/bsmd.ExcelReadService/ExcelReader.cs @@ -365,7 +365,7 @@ namespace bsmd.ExcelReadService return result; } - internal DateTime? ReadDate(string lookup) + internal DateTime? ReadDate(string lookup, bool noHighlight = false) { try { @@ -376,7 +376,7 @@ namespace bsmd.ExcelReadService var val = _nameDict[lookup].RefersToRange.Value; if (val is DateTime) { - this.Conf.ConfirmDate(lookup, val, ReadState.OK); + this.Conf.ConfirmDate(lookup, val, noHighlight ? ReadState.NONE : ReadState.OK); return val; } if (val is double) @@ -410,16 +410,16 @@ namespace bsmd.ExcelReadService if ((date.Value < new DateTime(1900, 1, 1)) || (date.Value > new DateTime(2030, 1, 1))) { date = null; - this.Conf.ConfirmDate(lookup, date, ReadState.WARN); + this.Conf.ConfirmDate(lookup, date, noHighlight ? ReadState.NONE : ReadState.WARN); } else { - this.Conf.ConfirmDate(lookup, date, ReadState.OK); + this.Conf.ConfirmDate(lookup, date, noHighlight? ReadState.NONE : ReadState.OK); } } else { - this.Conf.ConfirmDate(lookup, null, ReadState.FAIL); + this.Conf.ConfirmDate(lookup, null, noHighlight ? ReadState.NONE : ReadState.FAIL); } } @@ -427,17 +427,17 @@ namespace bsmd.ExcelReadService } catch (Exception) { - this.Conf.ConfirmDate(lookup, null, ReadState.FAIL); + this.Conf.ConfirmDate(lookup, null, noHighlight ? ReadState.NONE : ReadState.FAIL); _log.WarnFormat("error parsing datetime for lookup {0}", lookup); return null; } } - internal DateTime? ReadDateTime(string dateField, string timeField) + internal DateTime? ReadDateTime(string dateField, string timeField, bool noHighlight = false) { DateTime? result = null; - DateTime? etaDate = this.ReadDate(dateField); - DateTime? etaTime = this.ReadTime(timeField); + DateTime? etaDate = this.ReadDate(dateField, noHighlight); + DateTime? etaTime = this.ReadTime(timeField, noHighlight); if (etaDate != null) { result = new DateTime(etaDate.Value.Year, etaDate.Value.Month, etaDate.Value.Day); @@ -454,7 +454,7 @@ namespace bsmd.ExcelReadService return result; } - internal DateTime? ReadTime(string lookup) + internal DateTime? ReadTime(string lookup, bool noHighlight = false) { DateTime? result = null; @@ -518,17 +518,17 @@ namespace bsmd.ExcelReadService if (result != null) { - this.Conf.ConfirmTime(lookup, result, ReadState.OK); + this.Conf.ConfirmTime(lookup, result, noHighlight ? ReadState.NONE : ReadState.OK); } else { - this.Conf.ConfirmTime(lookup, result, ReadState.WARN); + this.Conf.ConfirmTime(lookup, result, noHighlight ? ReadState.NONE : ReadState.WARN); } } } catch (Exception) { - this.Conf.ConfirmTime(lookup, null, ReadState.FAIL); + this.Conf.ConfirmTime(lookup, null, noHighlight ? ReadState.NONE : ReadState.FAIL); _log.WarnFormat("error reading time for lookup {0}", lookup); } @@ -601,12 +601,12 @@ namespace bsmd.ExcelReadService return result.Value; } - internal bool? ReadBoolean(string lookup) + internal bool? ReadBoolean(string lookup, bool noHighlight = false) { string val = this.ReadText(lookup); if (val == null) { - this.Conf.ConfirmText(lookup, val, ReadState.FAIL); + this.Conf.ConfirmText(lookup, val, noHighlight ? ReadState.NONE : ReadState.FAIL); return null; } diff --git a/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs b/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs index c2a98299..765b804c 100644 --- a/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs +++ b/nsw/Source/bsmd.ExcelReadService/LocodeDB.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.Data; using System.Data.SQLite; +using bsmd.database; namespace bsmd.ExcelReadService { @@ -103,6 +104,9 @@ namespace bsmd.ExcelReadService /// public static string PortNameFromLocode(string locode) { + if (locode.IsNullOrEmpty()) return null; + if (locode.Length != 5) return null; + string result = null; string query = string.Format("SELECT locodes.name FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE locodes.port='t' AND locodes.city_code = '{0}' AND countries.code = '{1}'", locode.Substring(2), locode.Substring(0,2)); diff --git a/nsw/Source/bsmd.ExcelReadService/Util.cs b/nsw/Source/bsmd.ExcelReadService/Util.cs index d0e52ade..ce305cd0 100644 --- a/nsw/Source/bsmd.ExcelReadService/Util.cs +++ b/nsw/Source/bsmd.ExcelReadService/Util.cs @@ -1155,8 +1155,8 @@ namespace bsmd.ExcelReadService noa_nod.ETDFromLastPort = reader.ReadDateTime("NOA_NOD.ETDDateFromLastPort", "NOA_NOD.ETDTimeFromLastPort"); noa_nod.ETAToNextPort = reader.ReadDateTime("NOA_NOD.ETADateToNextPort", "NOA_NOD.ETATimeToNextPort"); - // DK - noa_nod.IsAnchored = reader.ReadBoolean("NOA_NOD.IsAnchored"); + // DK + noa_nod.IsAnchored = reader.ReadBoolean("NOA_NOD.IsAnchored", (reader.Mode == ExcelReader.CountryMode.DE)); } @@ -1244,10 +1244,12 @@ namespace bsmd.ExcelReadService waste.WasteType = (int?) reader.ReadNumber(wasteCode); + if (waste.WasteType.HasValue && (waste.WasteType == 2313)) + waste.WasteType = 2600; + + if (reader.Mode == ExcelReader.CountryMode.DE) - { - // waste.WasteType = i; // remove for V4 - // change for V4 + { reader.Conf.ConfirmText(wastetype, waste.WasteTypeDisplay, ExcelReader.ReadState.OK); reader.Conf.ConfirmNumber(wasteCode, waste.WasteType, ExcelReader.ReadState.OK); } @@ -1288,9 +1290,21 @@ namespace bsmd.ExcelReadService waste.WasteCapacity_MTQ = reader.ReadNumberDefaultZero(wasteCapacity); waste.WasteAmountRetained_MTQ = reader.ReadNumberDefaultZero(wasteRetained); - waste.WasteDisposalPort = reader.ReadText(wastePort); // TODO: check for LOCODE? - if (waste.WasteDisposalPort.IsNullOrEmpty()) waste.WasteDisposalPort = "ZZUKN"; - reader.Conf.ConfirmText(wastePort, waste.WasteDisposalPort, waste.WasteDisposalPort.Equals("ZZUKN") ? ExcelReader.ReadState.WARN : ExcelReader.ReadState.OK); + waste.WasteDisposalPort = reader.ReadText(wastePort); + bool isLocode; + ExcelReader.ReadState rs; + if (waste.WasteDisposalPort.IsNullOrEmpty()) + { + waste.WasteDisposalPort = "ZZUKN"; + rs = ExcelReader.ReadState.WARN; + } + else + { + isLocode = (LocodeDB.PortNameFromLocode(waste.WasteDisposalPort) != null); + rs = isLocode ? ExcelReader.ReadState.OK : ExcelReader.ReadState.FAIL; + } + reader.Conf.ConfirmText(wastePort, waste.WasteDisposalPort, rs); + waste.WasteAmountGeneratedTillNextPort_MTQ = reader.ReadNumberDefaultZero(amountGen); waste.WasteDisposedAtLastPort_MTQ = reader.ReadNumberDefaultZero(wasteDis); @@ -1313,10 +1327,32 @@ namespace bsmd.ExcelReadService ((waste.WasteDisposalAmount_MTQ ?? 0) == 0) && (((waste.WasteType ?? 0) == 1300) || !waste.WasteType.HasValue)) was.Waste.Remove(waste); + + // 24.3.: - Für Waste-Type 15: Wenn in dieser Zeile andere Werte enthalten, als die nachfolgenden, ist die ganze Zeile rot zu markieren. + bool highlightRow15 = !(waste.WasteType == null); + highlightRow15 &= (waste.WasteDisposalAmount_MTQ > 0); + highlightRow15 &= (waste.WasteCapacity_MTQ > 0); + highlightRow15 &= (waste.WasteAmountRetained_MTQ > 0); + highlightRow15 &= (waste.WasteDisposalPort != "ZZUKN"); + highlightRow15 &= (waste.WasteAmountGeneratedTillNextPort_MTQ > 0); + highlightRow15 &= (waste.WasteDisposedAtLastPort_MTQ > 0); + + if(highlightRow15) + { + reader.Conf.HighlightCellWithState(wastetype, ExcelReader.ReadState.FAIL); + reader.Conf.HighlightCellWithState(wasteCode, ExcelReader.ReadState.FAIL); + reader.Conf.HighlightCellWithState(wasteDescription, ExcelReader.ReadState.FAIL); + reader.Conf.HighlightCellWithState(wasteAmount, ExcelReader.ReadState.FAIL); + reader.Conf.HighlightCellWithState(wasteCapacity, ExcelReader.ReadState.FAIL); + reader.Conf.HighlightCellWithState(wasteRetained, ExcelReader.ReadState.FAIL); + reader.Conf.HighlightCellWithState(wastePort, ExcelReader.ReadState.FAIL); + reader.Conf.HighlightCellWithState(amountGen, ExcelReader.ReadState.FAIL); + reader.Conf.HighlightCellWithState(wasteDis, ExcelReader.ReadState.FAIL); + } } - } + } /* try { @@ -1635,8 +1671,8 @@ namespace bsmd.ExcelReadService bool? secKielDeparture = reader.ReadBoolean("SEC.KielCanalPassagePlanned_Departure"); sec.KielCanalPassagePlanned = (secKielArrival ?? false) || (secKielDeparture ?? false); - sec.KielCanalPassagePlannedIncomming = reader.ReadDateTime("SEC.ETADateKielCanalPassagePlannedIncomming", "SEC.ETATimeKielCanalPassagePlannedIncomming"); - sec.KielCanalPassagePlannedOutgoing = reader.ReadDateTime("SEC.ETADateKielCanalPassagePlannedOutgoing", "SEC.ETATimeKielCanalPassagePlannedOutgoing"); + sec.KielCanalPassagePlannedIncomming = reader.ReadDateTime("SEC.ETADateKielCanalPassagePlannedIncomming", "SEC.ETATimeKielCanalPassagePlannedIncomming", !(secKielArrival ?? false)); + sec.KielCanalPassagePlannedOutgoing = reader.ReadDateTime("SEC.ETADateKielCanalPassagePlannedOutgoing", "SEC.ETATimeKielCanalPassagePlannedOutgoing", !(secKielDeparture ?? false)); // Last10PortFacilitesCalled @@ -2577,7 +2613,8 @@ namespace bsmd.ExcelReadService } } - reader.Conf.ConfirmText("ID", visitTransitId, ExcelReader.ReadState.OK); + bool isValidId = bsmd.database.Util.IsVisitId(visitTransitId) ||bsmd.database.Util.IsTransitId(visitTransitId); + reader.Conf.ConfirmText("ID", visitTransitId, isValidId ? ExcelReader.ReadState.OK : ExcelReader.ReadState.FAIL); if (result == null) { diff --git a/nsw/Source/bsmd.database/CREW.cs b/nsw/Source/bsmd.database/CREW.cs index 7a0c3dcb..fb195ea8 100644 --- a/nsw/Source/bsmd.database/CREW.cs +++ b/nsw/Source/bsmd.database/CREW.cs @@ -164,6 +164,8 @@ namespace bsmd.database break; } + query += " ORDER BY Identifier"; + cmd.CommandText = query; } @@ -223,6 +225,8 @@ namespace bsmd.database break; } + query += " ORDER BY CAST(Identifier AS INT)"; + cmd.CommandText = query; } } diff --git a/nsw/Source/bsmd.database/LADG.cs b/nsw/Source/bsmd.database/LADG.cs index 9b954ca8..45f7f2ee 100644 --- a/nsw/Source/bsmd.database/LADG.cs +++ b/nsw/Source/bsmd.database/LADG.cs @@ -153,6 +153,8 @@ namespace bsmd.database break; } + query += " ORDER BY CAST(Identifier AS INT)"; + cmd.CommandText = query; } diff --git a/nsw/Source/bsmd.database/PAS.cs b/nsw/Source/bsmd.database/PAS.cs index 65634a77..ddaeea95 100644 --- a/nsw/Source/bsmd.database/PAS.cs +++ b/nsw/Source/bsmd.database/PAS.cs @@ -180,6 +180,8 @@ namespace bsmd.database break; } + query += " ORDER BY Identifier"; + cmd.CommandText = query; } @@ -252,6 +254,8 @@ namespace bsmd.database break; } + query += " ORDER BY CAST(Identifier AS INT)"; + cmd.CommandText = query; } } diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs index 874beaa8..ab391b04 100644 --- a/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs +++ b/nsw/Source/bsmd.database/Properties/AssemblyProductInfo.cs @@ -2,6 +2,6 @@ [assembly: AssemblyCompany("Informatikbüro Daniel Schick")] [assembly: AssemblyProduct("BSMD NSW interface")] -[assembly: AssemblyInformationalVersion("3.4.7")] +[assembly: AssemblyInformationalVersion("3.4.8")] [assembly: AssemblyCopyright("Copyright © 2014-2017 Informatikbüro Daniel Schick. All rights reserved.")] [assembly: AssemblyTrademark("")] \ No newline at end of file diff --git a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs index 52942cfd..b52622db 100644 --- a/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs +++ b/nsw/Source/bsmd.database/Properties/AssemblyProjectInfo.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("3.4.7.*")] +[assembly: AssemblyVersion("3.4.8.*")] diff --git a/nsw/Source/bsmd.database/Waste.cs b/nsw/Source/bsmd.database/Waste.cs index ad4e3caa..4090bbcc 100644 --- a/nsw/Source/bsmd.database/Waste.cs +++ b/nsw/Source/bsmd.database/Waste.cs @@ -64,7 +64,7 @@ namespace bsmd.database case 2300: return "Domestic wastes"; case 2311: return "Cooking oil"; case 2308: return "Incinerator ashes"; - case 2313: return "Operational wastes"; + case 2600: return "Operational wastes"; case 2309: return "Animal carcass(es)"; case 3000: return "Sewage"; case 5100: return "Cargo residues - Marpol Annex I";