Adjusted usage of NST2007 lookup in LADG dialog
This commit is contained in:
parent
acc4fde897
commit
a1eb65c834
@ -38,7 +38,7 @@ namespace ENI2.EditControls
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Loaded += EditLADGDialog_Loaded;
|
Loaded += EditLADGDialog_Loaded;
|
||||||
if (_nstList == null)
|
if (_nstList == null)
|
||||||
_nstList = LocalizedLookup.GetNST2007List();
|
_nstList = LADG_NST2007.GetNST2007List();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LADG LADG { get; set; }
|
public LADG LADG { get; set; }
|
||||||
|
|||||||
@ -232,26 +232,6 @@ namespace ENI2
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<KeyValuePair<string, string>> GetNST2007List()
|
|
||||||
{
|
|
||||||
List<KeyValuePair<string, string>> result = new List<KeyValuePair<string, string>>();
|
|
||||||
|
|
||||||
string query = string.Format("SELECT Description, NST2007 FROM LADG_NST2007 ORDER BY Description");
|
|
||||||
SQLiteCommand cmd = new SQLiteCommand(query, _con);
|
|
||||||
IDataReader reader = cmd.ExecuteReader();
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
if (reader.IsDBNull(0)) continue;
|
|
||||||
string desc = reader.GetString(0);
|
|
||||||
string code = reader.GetString(1);
|
|
||||||
KeyValuePair<string, string> kvp = new KeyValuePair<string, string>(desc, code);
|
|
||||||
result.Add(kvp);
|
|
||||||
}
|
|
||||||
|
|
||||||
reader.Close();
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<string> getMVSHLocodes()
|
public static List<string> getMVSHLocodes()
|
||||||
{
|
{
|
||||||
List<string> result = new List<string>();
|
List<string> result = new List<string>();
|
||||||
|
|||||||
@ -115,7 +115,7 @@
|
|||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem x:Name="menuItemLADGNST2007" Header="LADG NST2007" Click="radioButton_Click">
|
<MenuItem x:Name="menuItemLADGNST2007" Header="LADG NST2007" Click="radioButton_Click">
|
||||||
<MenuItem.Icon>
|
<MenuItem.Icon>
|
||||||
<Image Source="Resources/nav_refresh_blue.png" />
|
<Image Source="Resources/containership.png" />
|
||||||
</MenuItem.Icon>
|
</MenuItem.Icon>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
|||||||
@ -21,7 +21,7 @@ namespace bsmd.database
|
|||||||
private static List<PortArea> _allPortAreaRows;
|
private static List<PortArea> _allPortAreaRows;
|
||||||
private static Dictionary<string, PortArea> _allPortAreasByCode;
|
private static Dictionary<string, PortArea> _allPortAreasByCode;
|
||||||
private static List<LADG_NST2007> _allLADGNST2007Rows;
|
private static List<LADG_NST2007> _allLADGNST2007Rows;
|
||||||
private static Dictionary<string, LADG_NST2007> _allLADGNST2007ByCode;
|
private static Dictionary<string, LADG_NST2007> _allLADGNST2007ByDescription;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@ -168,7 +168,7 @@ namespace bsmd.database
|
|||||||
public static async Task<Dictionary<string, LADG_NST2007>> GetLADGNST2007DictAsync(bool forceReload = false)
|
public static async Task<Dictionary<string, LADG_NST2007>> GetLADGNST2007DictAsync(bool forceReload = false)
|
||||||
{
|
{
|
||||||
await EnsureLADGNST2007LoadedAsync(forceReload);
|
await EnsureLADGNST2007LoadedAsync(forceReload);
|
||||||
return _allLADGNST2007ByCode;
|
return _allLADGNST2007ByDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<string, LADG_NST2007> GetLADGNST2007Dict(bool forceReload = false)
|
public static Dictionary<string, LADG_NST2007> GetLADGNST2007Dict(bool forceReload = false)
|
||||||
@ -179,7 +179,7 @@ namespace bsmd.database
|
|||||||
public static void InvalidateLADGNST2007Cache()
|
public static void InvalidateLADGNST2007Cache()
|
||||||
{
|
{
|
||||||
_allLADGNST2007Rows = null;
|
_allLADGNST2007Rows = null;
|
||||||
_allLADGNST2007ByCode = null;
|
_allLADGNST2007ByDescription = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<List<AGNT_Template>> GetAGNTTemplatesAsync()
|
public static async Task<List<AGNT_Template>> GetAGNTTemplatesAsync()
|
||||||
@ -266,13 +266,13 @@ namespace bsmd.database
|
|||||||
if (forceReload)
|
if (forceReload)
|
||||||
InvalidateLADGNST2007Cache();
|
InvalidateLADGNST2007Cache();
|
||||||
|
|
||||||
if ((_allLADGNST2007Rows != null) && (_allLADGNST2007ByCode != null))
|
if ((_allLADGNST2007Rows != null) && (_allLADGNST2007ByDescription != null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
await _ladgNst2007LoadLock.WaitAsync();
|
await _ladgNst2007LoadLock.WaitAsync();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if ((_allLADGNST2007Rows != null) && (_allLADGNST2007ByCode != null))
|
if ((_allLADGNST2007Rows != null) && (_allLADGNST2007ByDescription != null))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SqlCommand cmd = new SqlCommand();
|
SqlCommand cmd = new SqlCommand();
|
||||||
@ -290,15 +290,15 @@ namespace bsmd.database
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Dictionary<string, LADG_NST2007> byCode = new Dictionary<string, LADG_NST2007>(StringComparer.OrdinalIgnoreCase);
|
Dictionary<string, LADG_NST2007> byDescription = new Dictionary<string, LADG_NST2007>(StringComparer.OrdinalIgnoreCase);
|
||||||
foreach (LADG_NST2007 nst in rows)
|
foreach (LADG_NST2007 nst in rows)
|
||||||
{
|
{
|
||||||
if (!nst.NST2007.IsNullOrEmpty())
|
if (!nst.Description.IsNullOrEmpty())
|
||||||
byCode[nst.NST2007] = nst;
|
byDescription[nst.Description] = nst;
|
||||||
}
|
}
|
||||||
|
|
||||||
_allLADGNST2007Rows = rows;
|
_allLADGNST2007Rows = rows;
|
||||||
_allLADGNST2007ByCode = byCode;
|
_allLADGNST2007ByDescription = byDescription;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
|
|||||||
@ -28,23 +28,14 @@ namespace bsmd.database
|
|||||||
|
|
||||||
#region public static methods
|
#region public static methods
|
||||||
|
|
||||||
public static bool NST2007Exists(string nst2007)
|
public static List<KeyValuePair<string, string>> GetNST2007List()
|
||||||
{
|
{
|
||||||
if (nst2007.IsNullOrEmpty())
|
List<KeyValuePair<string, string>> result = new List<KeyValuePair<string, string>>();
|
||||||
return false;
|
foreach (LADG_NST2007 item in DBManagerAsync.GetLADGNST2007Dict().Values)
|
||||||
|
{
|
||||||
return DBManagerAsync.GetLADGNST2007Dict().ContainsKey(nst2007);
|
result.Add(new KeyValuePair<string, string>(item.Description, item.NST2007));
|
||||||
}
|
}
|
||||||
|
return result;
|
||||||
public static string GetDescription(string nst2007)
|
|
||||||
{
|
|
||||||
if (nst2007.IsNullOrEmpty())
|
|
||||||
return null;
|
|
||||||
|
|
||||||
if (DBManagerAsync.GetLADGNST2007Dict().TryGetValue(nst2007, out LADG_NST2007 value))
|
|
||||||
return value.Description;
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user