Korrekturen Excel einlesen Locode und Datum korrekt schreiben (Localtime)

This commit is contained in:
Daniel Schick 2022-04-03 11:11:24 +02:00
parent 811d8c1eb4
commit 176602c184
4 changed files with 48 additions and 29 deletions

View File

@ -37,7 +37,7 @@
<CreateWebPageOnPublish>true</CreateWebPageOnPublish> <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
<WebPage>publish.html</WebPage> <WebPage>publish.html</WebPage>
<ApplicationRevision>0</ApplicationRevision> <ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>7.0.1.0</ApplicationVersion> <ApplicationVersion>7.0.2.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut> <CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted> <PublishWizardCompleted>true</PublishWizardCompleted>

View File

@ -78,7 +78,10 @@ namespace ENI2.Excel
val = val.ToUpper(); val = val.ToUpper();
string portName = LocodeDB.PortNameFromLocode(val); string portName = LocodeDB.PortNameFromLocode(val);
if (portName.IsNullOrEmpty()) if (portName.IsNullOrEmpty())
{
_log.WarnFormat("unknown Locode {0}", val); _log.WarnFormat("unknown Locode {0}", val);
val = "";
}
} }
return val; return val;
} }

View File

@ -1379,7 +1379,7 @@ namespace ENI2.Excel
{ {
if(v != null) if(v != null)
{ {
_nameDict[lookupName].RefersToRange.Value = ((DateTime) v).ToOADate(); // Test this I dont believe it _nameDict[lookupName].RefersToRange.Value = ((DateTime) v).ToLocalTime().ToOADate();
} }
} }

View File

@ -186,6 +186,9 @@ namespace ENI2.Locode
if (locode.IsNullOrEmpty()) return null; if (locode.IsNullOrEmpty()) return null;
if (locode.Length != 5) return null; if (locode.Length != 5) return null;
try
{
string result = null; string result = null;
string query = string.Format("SELECT LocationName FROM SSN_LOCODES WHERE LocationCode = '{0}'", locode); string query = string.Format("SELECT LocationName FROM SSN_LOCODES WHERE LocationCode = '{0}'", locode);
@ -201,6 +204,12 @@ namespace ENI2.Locode
cmd.Dispose(); cmd.Dispose();
return result; return result;
} }
catch (Exception ex)
{
_log.WarnFormat("error reading SSN location from locode: {0}", ex.ToString());
return null;
}
}
/// <summary> /// <summary>
@ -212,7 +221,8 @@ namespace ENI2.Locode
{ {
if (locode.IsNullOrEmpty()) return null; if (locode.IsNullOrEmpty()) return null;
if (locode.Length != 5) return null; if (locode.Length != 5) return null;
try
{
string result = null; string result = null;
string query = string.Format("SELECT locodes.name_wo_diacritics FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE locodes.city_code = '{0}' AND countries.code = '{1}'", string query = string.Format("SELECT locodes.name_wo_diacritics FROM locodes JOIN countries ON locodes.country_id = countries.ID WHERE locodes.city_code = '{0}' AND countries.code = '{1}'",
locode.Substring(2), locode.Substring(0, 2)); locode.Substring(2), locode.Substring(0, 2));
@ -228,6 +238,12 @@ namespace ENI2.Locode
cmd.Dispose(); cmd.Dispose();
return result; return result;
} }
catch(Exception ex)
{
_log.WarnFormat("error reading location from locode: {0}", ex.ToString());
return null;
}
}
public static void CloseDB() public static void CloseDB()
{ {