105040 Update 窗口打开时重新加载缓存数据

This commit is contained in:
lihanbo 2024-11-08 17:10:10 +08:00
parent 7bc9c84af3
commit 82a9f67d8c
2 changed files with 7 additions and 2 deletions

View File

@ -139,8 +139,13 @@ public partial class MainWindow : Window
{ {
try try
{ {
LoadingMask.Visibility = Visibility.Visible; LoadingMask.Visibility = Visibility.Visible;
this.Dispatcher.BeginInvoke(async delegate ()
{
ExcelHelper.CheckAndGetCache(true);
await LoadDataAsync(datas, reportColumns); await LoadDataAsync(datas, reportColumns);
});
} }
catch (System.Exception ex) catch (System.Exception ex)
{ {

View File

@ -26,11 +26,11 @@ namespace Sinvo.EplanHpD.Plugin.WPFUI.Utils
CheckAndGetCache(); CheckAndGetCache();
return _terminalMappingCache.Where(item => item.WireModelSpecification == wireModel && (item.Prefix == prefix || item.Prefix == null)); return _terminalMappingCache.Where(item => item.WireModelSpecification == wireModel && (item.Prefix == prefix || item.Prefix == null));
} }
private static void CheckAndGetCache() public static void CheckAndGetCache(bool isForceReload = false)
{ {
lock (_terminalMappingCache) lock (_terminalMappingCache)
{ {
if (_terminalMappingCache == null || !_terminalMappingCache.Any()) if ((_terminalMappingCache == null || !_terminalMappingCache.Any()) || isForceReload)
{ {
GetAllWireTerminalMappingTable(); GetAllWireTerminalMappingTable();
} }