3.4.8: Korrekturen und weiteren Kleinkruscht

This commit is contained in:
Daniel Schick 2017-03-25 18:09:52 +00:00
parent 240dc42f1f
commit 5d58beea00
13 changed files with 114 additions and 31 deletions

View File

@ -58,6 +58,9 @@
<PropertyGroup>
<AssemblyOriginatorKeyFile>bsmdKey.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Resources\containership.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>

View File

@ -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">
<Grid>
<!--Label x:Name="label" Content="Platzhalter für Suche " HorizontalAlignment="Left" Margin="48,128,0,0" VerticalAlignment="Top"/-->

Binary file not shown.

View File

@ -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<string, List<Name>> 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<string> SaveConfirmationSheets(string receivedFileName)
{

View File

@ -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;
}

View File

@ -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
/// </summary>
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));

View File

@ -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)
{

View File

@ -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;
}
}

View File

@ -153,6 +153,8 @@ namespace bsmd.database
break;
}
query += " ORDER BY CAST(Identifier AS INT)";
cmd.CommandText = query;
}

View File

@ -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;
}
}

View File

@ -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("")]

View File

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

View File

@ -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";