STAT PortOfRegistry: hier sind alle Locodes, nicht nur Häfen erlaubt
This commit is contained in:
parent
9cb40ad699
commit
151f351ac2
@ -36,8 +36,8 @@
|
|||||||
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
|
<MinimumRequiredVersion>5.4.0.0</MinimumRequiredVersion>
|
||||||
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
<CreateWebPageOnPublish>true</CreateWebPageOnPublish>
|
||||||
<WebPage>publish.html</WebPage>
|
<WebPage>publish.html</WebPage>
|
||||||
<ApplicationRevision>1</ApplicationRevision>
|
<ApplicationRevision>2</ApplicationRevision>
|
||||||
<ApplicationVersion>7.2.0.1</ApplicationVersion>
|
<ApplicationVersion>7.2.0.2</ApplicationVersion>
|
||||||
<UseApplicationTrust>false</UseApplicationTrust>
|
<UseApplicationTrust>false</UseApplicationTrust>
|
||||||
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
<CreateDesktopShortcut>true</CreateDesktopShortcut>
|
||||||
<PublishWizardCompleted>true</PublishWizardCompleted>
|
<PublishWizardCompleted>true</PublishWizardCompleted>
|
||||||
|
|||||||
@ -90,13 +90,14 @@ namespace ENI2.Excel
|
|||||||
return new string(val.Where(c => !Char.IsWhiteSpace(c)).ToArray());
|
return new string(val.Where(c => !Char.IsWhiteSpace(c)).ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
internal string ReadLoCode(string lookup)
|
internal string ReadLoCode(string lookup, bool justPorts = true)
|
||||||
{
|
{
|
||||||
string val = this.ReadText(lookup);
|
string val = this.ReadText(lookup);
|
||||||
if (!val.IsNullOrEmpty())
|
if (!val.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
val = val.ToUpper();
|
val = val.ToUpper();
|
||||||
string portName = LocodeDB.PortNameFromLocode(val);
|
string portName = LocodeDB.PortNameFromLocode(val);
|
||||||
|
if (!justPorts) portName = LocodeDB.NameFromLocode(val);
|
||||||
if (portName.IsNullOrEmpty())
|
if (portName.IsNullOrEmpty())
|
||||||
{
|
{
|
||||||
_log.WarnFormat("unknown Locode {0}", val);
|
_log.WarnFormat("unknown Locode {0}", val);
|
||||||
|
|||||||
@ -978,7 +978,7 @@ namespace ENI2.Excel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stat.PortOfRegistry = reader.ReadLoCode("STAT.PortOfRegistry");
|
stat.PortOfRegistry = reader.ReadLoCode("STAT.PortOfRegistry", false);
|
||||||
if (stat.PortOfRegistry.Length == 5)
|
if (stat.PortOfRegistry.Length == 5)
|
||||||
stat.Flag = stat.PortOfRegistry.Substring(0, 2);
|
stat.Flag = stat.PortOfRegistry.Substring(0, 2);
|
||||||
stat.MMSINumber = reader.ReadTextNoWhitespace("STAT.MMSINumber");
|
stat.MMSINumber = reader.ReadTextNoWhitespace("STAT.MMSINumber");
|
||||||
|
|||||||
@ -146,6 +146,38 @@ namespace ENI2.Locode
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get Name from LOCODE (any! type of locode, not just ports)
|
||||||
|
/// </summary>
|
||||||
|
public static string NameFromLocode(string locode)
|
||||||
|
{
|
||||||
|
if (locode.IsNullOrEmpty()) return null;
|
||||||
|
if (locode.Length != 5) return null;
|
||||||
|
|
||||||
|
string result = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string locodeUpper = locode.ToUpper();
|
||||||
|
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}'",
|
||||||
|
locodeUpper.Substring(2), locodeUpper.Substring(0, 2));
|
||||||
|
SQLiteCommand cmd = new SQLiteCommand(query, _con);
|
||||||
|
IDataReader reader = cmd.ExecuteReader();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
if (!reader.IsDBNull(0))
|
||||||
|
result = reader.GetString(0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
reader.Close();
|
||||||
|
cmd.Dispose();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_log.WarnFormat("Error on locode lookup: {0}", ex.Message);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get Portname from LOCODE
|
/// Get Portname from LOCODE
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user