From b9c79f595e5ad4684d731f968bf120ff8c52dbd8 Mon Sep 17 00:00:00 2001 From: lixiaojun <1287241240@qq.com> Date: 星期一, 23 十二月 2024 00:42:25 +0800 Subject: [PATCH] 解决重复HydroInfo获取问题 --- WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs | 32 +++++++++++++++++++++++++++++++- 1 files changed, 31 insertions(+), 1 deletions(-) diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs index 82cb9c5..0adeba7 100644 --- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs +++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs @@ -3,6 +3,7 @@ using DevExpress.Utils.Extensions; using DevExpress.Utils.Svg; using DevExpress.XtraCharts; +using System.Collections.Concurrent; using Yw.DAL.Basic; using Yw.Vmo; @@ -67,7 +68,7 @@ private Dictionary<HydroWorkingVmo, bool> _allWorkingCheckedListDict = null;//鎵�鏈夊伐鍐甸�夋嫨鍒楄〃瀛楀吀 private Dictionary<XhsSchemeVmo, Yw.Model.HydroModelInfo> _allSchemeHydroInfoDict = null;//鎵�鏈夋柟妗堟按鍔涗俊鎭垪琛� private Dictionary<XhsSchemeVmo, Dictionary<HydroWorkingVmo, bool>> _allSchemeWorkingCheckedListDict = null;//鎵�鏈夋柟妗堝伐鍐甸�夋嫨鍒楄〃瀛楀吀 - private readonly object _locker = new();//閿佸畾瀵硅薄 + private ConcurrentDictionary<string, bool> _gettingHydroInfoDict = new ConcurrentDictionary<string, bool>();//鑾峰彇姘村姏淇℃伅瀛楀吀 /// <summary> /// 缁戝畾鏁版嵁 @@ -209,6 +210,10 @@ if (_hydroInfo == null) { hydroInfo = await GetHydroInfo(null); + if (hydroInfo == null) + { + return default; + } if (_hydroInfo == null) { _hydroInfo = hydroInfo; @@ -230,6 +235,10 @@ if (!_allSchemeHydroInfoDict.ContainsKey(scheme)) { hydroInfo = await GetHydroInfo(scheme); + if (hydroInfo == null) + { + return default; + } if (!_allSchemeHydroInfoDict.ContainsKey(scheme)) { _allSchemeHydroInfoDict.Add(scheme, hydroInfo); @@ -261,6 +270,18 @@ { return default; } + string key = $"{_project.ID}-{_projectSite.ID}-{scheme?.ID}"; + if (_gettingHydroInfoDict.TryGetValue(key, out bool getting)) + { + if (getting) + { + return default; + } + } + if (!_gettingHydroInfoDict.TryAdd(key, true)) + { + _gettingHydroInfoDict[key] = true; + } HydroModelRelationVmo relation = null; if (scheme == null) @@ -278,6 +299,7 @@ return default; } var hydroInfo = await BLLFactory<Yw.BLL.HydroModelInfo>.Instance.GetByID(relation.ModelID); + _gettingHydroInfoDict[key] = false; return hydroInfo; } @@ -500,6 +522,10 @@ elementWorking.Click += async (sender, e) => { var hydroInfo = await GetHydroInfo(null, true); + if (hydroInfo == null) + { + return; + } this.ShowProjectSiteWorkingEvent?.Invoke(_project, _projectSite, null, hydroInfo, working, this.svgImg32[4]); }; this.elementProjectSiteSimulation.Elements.Add(elementWorking); @@ -550,6 +576,10 @@ elementWorking.Click += async (sender, e) => { var hydroInfo = await GetHydroInfo(scheme, true); + if (hydroInfo == null) + { + return; + } this.ShowProjectSiteWorkingEvent?.Invoke(_project, _projectSite, scheme, hydroInfo, working, this.svgImg32[4]); }; elementScheme.Elements.Add(elementWorking); -- Gitblit v1.9.3