From d7837329e5d2ca8938f4939fa58db2295c7ed88c Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期二, 10 十二月 2024 23:02:20 +0800
Subject: [PATCH] 优化解析

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/05-function/SimulationFunctionCtrl.cs        |  271 +++++++++++++++++++++++++++++++++-----------
 Service/HStation.Service.Revit.Core/04-service/01-json/02-helper/RevitConnectListExtensions.cs |    6 
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs               |   55 +++++++++
 Desktop/HStation.Desktop.Xhs.Core/Program.cs                                                   |    6 
 Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs                |    4 
 5 files changed, 265 insertions(+), 77 deletions(-)

diff --git a/Desktop/HStation.Desktop.Xhs.Core/Program.cs b/Desktop/HStation.Desktop.Xhs.Core/Program.cs
index 7c75e0d..5400635 100644
--- a/Desktop/HStation.Desktop.Xhs.Core/Program.cs
+++ b/Desktop/HStation.Desktop.Xhs.Core/Program.cs
@@ -29,11 +29,11 @@
                 System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("zh-Hans");
 
                 //处理未捕获的异常
-                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
+                //Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                 //处理UI线程异常
-                Application.ThreadException += Application_ThreadException;
+                //Application.ThreadException += Application_ThreadException;
                 //处理非UI线程异常
-                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
+                //AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
 
                 Application.EnableVisualStyles();
                 Application.SetCompatibleTextRenderingDefault(false);
diff --git a/Service/HStation.Service.Revit.Core/04-service/01-json/02-helper/RevitConnectListExtensions.cs b/Service/HStation.Service.Revit.Core/04-service/01-json/02-helper/RevitConnectListExtensions.cs
index ef8fac1..2b06795 100644
--- a/Service/HStation.Service.Revit.Core/04-service/01-json/02-helper/RevitConnectListExtensions.cs
+++ b/Service/HStation.Service.Revit.Core/04-service/01-json/02-helper/RevitConnectListExtensions.cs
@@ -59,7 +59,7 @@
         {
             if (list == null || list.Count < 1)
             {
-                return default;
+                return new List<Model.RevitConnect>();
             }
             var starts = list.Where(x => x.Direction == Direction.Inlet).ToList();
             return starts;
@@ -72,7 +72,7 @@
         {
             if (list == null || list.Count < 1)
             {
-                return default;
+                return new List<Model.RevitConnect>();
             }
             var ends = list.Where(x => x.Direction == Direction.Outlet).ToList();
             return ends;
@@ -85,7 +85,7 @@
         {
             if (list == null || list.Count < 1)
             {
-                return default;
+                return new List<Model.RevitConnect>();
             }
             var nones = list.Where(x => x.Direction == Direction.None).ToList();
             return nones;
diff --git a/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs b/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs
index 04f52ce..c7e71b6 100644
--- a/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs
+++ b/Service/HStation.Service.Revit.Core/04-service/02-correct/RevitCorrectHelper.cs
@@ -726,7 +726,7 @@
                 var startLinkParter = allParterList.Find(x => x.Id == link.StartCode);
                 if (startLinkParter == null)
                 {
-                    msgList.Add($"绠℃:[{link.Id}]涓婃父鑺傜偣閿欒");
+                    msgList.Add($"绠℃:[{link.Id}]涓婃父鑺傜偣[{link.StartCode}]閿欒");
                     result = false;
                 }
                 else
@@ -737,7 +737,7 @@
                 var endLinkParter = allParterList.Find(x => x.Id == link.EndCode);
                 if (endLinkParter == null)
                 {
-                    msgList.Add($"绠℃:[{link.Id}]涓嬫父鑺傜偣閿欒");
+                    msgList.Add($"绠℃:[{link.Id}]涓嬫父鑺傜偣[{link.EndCode}]閿欒");
                     result = false;
                 }
                 else
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 47901f0..522751c 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
@@ -31,6 +31,10 @@
         /// </summary>
         public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo, HydroWorkingVmo, bool> ProjectSiteWorkingCheckedEvent;
         /// <summary>
+        /// 椤圭洰绔欏伐鍐靛鍔犱簨浠�
+        /// </summary>
+        public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo, HydroWorkingVmo> ProjectSiteWorkingAppendEvent;
+        /// <summary>
         /// 椤圭洰绔欏伐鍐垫洿鏂颁簨浠�
         /// </summary>
         public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo, HydroWorkingVmo> ProjectSiteWorkingUpdateEvent;
@@ -42,6 +46,18 @@
         /// 鍒涘缓椤圭洰绔欐柟妗堜簨浠�
         /// </summary>
         public event Action<XhsProjectVmo, XhsProjectSiteVmo, Yw.Model.HydroModelInfo, SvgImage> CreateProjectSiteSchemeEvent;
+        /// <summary>
+        /// 椤圭洰绔欐柟妗堝鍔犱簨浠�
+        /// </summary>
+        public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo> ProjectSiteSchemeAppendEvent;
+        /// <summary>
+        /// 椤圭洰绔欐柟妗堟洿鏂颁簨浠�
+        /// </summary>
+        public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo> ProjectSiteSchemeUpdateEvent;
+        /// <summary>
+        /// 椤圭洰绔欐柟妗堢Щ闄や簨浠�
+        /// </summary>
+        public event Action<XhsProjectVmo, XhsProjectSiteVmo, XhsSchemeVmo> ProjectSiteSchemeRemoveEvent;
 
         private XhsProjectVmo _project = null;//椤圭洰
         private XhsProjectSiteVmo _projectSite = null;//椤圭洰绔�
@@ -90,6 +106,73 @@
             });
             await ShowInfo();
             overlay.Close();
+        }
+
+        //椤圭洰绔欐鍐�
+        private async void elementProjectSiteInfo_Click(object sender, EventArgs e)
+        {
+            await ShowInfo();
+        }
+
+        //椤圭洰绔欐按鍔涙ā鎷�
+        private async void elementProjectSiteSimulation_Click(object sender, EventArgs e)
+        {
+            if (_project == null)
+            {
+                return;
+            }
+            if (_projectSite == null)
+            {
+                return;
+            }
+            var hydroInfo = await GetHydroInfo(null, true);
+            if (hydroInfo == null)
+            {
+                return;
+            }
+            this.ShowProjectSiteSimulationEvent?.Invoke(_project, _projectSite, null, hydroInfo, _allWorkingCheckedListDict, this.svgImg32[1]);
+        }
+
+        //鍒涘缓椤圭洰绔欐柟妗�
+        private async void accordionControl1_ContextButtonClick(object sender, DevExpress.Utils.ContextItemClickEventArgs e)
+        {
+            if (_project == null)
+            {
+                return;
+            }
+            if (_projectSite == null)
+            {
+                return;
+            }
+            var element = e.DataItem as DevExpress.XtraBars.Navigation.AccordionControlElement;
+            if (element != this.elementProjectSiteSchemeList)
+            {
+                return;
+            }
+            var hydroInfo = await GetHydroInfo(null, true);
+            if (hydroInfo == null)
+            {
+                return;
+            }
+            this.CreateProjectSiteSchemeEvent?.Invoke(_project, _projectSite, hydroInfo, this.svgImg32[3]);
+        }
+
+        private void accordionControl1_MouseClick(object sender, MouseEventArgs e)
+        {
+            if (e.Button == MouseButtons.Right)
+            {
+                this.popupMenu1.ShowPopup(MousePosition);
+            }
+        }
+
+        private void barBtnCollpseAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            this.accordionControl1.CollapseAll();
+        }
+
+        private void barBtnExpandAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            this.accordionControl1.ExpandAll();
         }
 
         #region 閫氱敤鏂规硶
@@ -184,6 +267,7 @@
 
         /// <summary>
         /// 娣诲姞鏂规
+        /// 瑙﹀彂椤圭洰绔欐柟妗堝鍔犱簨浠�
         /// </summary>
         public void AppendScheme(XhsSchemeVmo scheme)
         {
@@ -237,11 +321,127 @@
             {
                 _allSchemeWorkingCheckedListDict.Add(scheme, new Dictionary<HydroWorkingVmo, bool>());
             }
+            this.ProjectSiteSchemeAppendEvent?.Invoke(_project, _projectSite, scheme);
+        }
+
+        /// <summary>
+        /// 鏇存柊鏂规
+        /// 瑙﹀彂椤圭洰绔欐柟妗堟洿鏂颁簨浠�
+        /// </summary>
+        public void UpdateScheme(XhsSchemeVmo scheme)
+        {
+            if (_project == null)
+            {
+                return;
+            }
+            if (_projectSite == null)
+            {
+                return;
+            }
+            if (scheme == null)
+            {
+                return;
+            }
+
+            var elementScheme = this.elementProjectSiteSchemeList.Elements
+                   .FirstOrDefault(x => (x.Tag is XhsSchemeVmo) && (x.Tag as XhsSchemeVmo).ID == scheme.ID);
+            if (elementScheme == null)
+            {
+                return;
+            }
+            elementScheme.Text = scheme.Name;
+            elementScheme.Hint = scheme.Description;
+            elementScheme.Tag = scheme;
+            if (_allSchemeHydroInfoDict != null && _allSchemeHydroInfoDict.Count > 0)
+            {
+                var schemeKey = _allSchemeHydroInfoDict.Keys.FirstOrDefault(x => x.ID == scheme.ID);
+                if (schemeKey != null)
+                {
+                    var hydroInfoValue = _allSchemeHydroInfoDict[schemeKey];
+                    _allSchemeHydroInfoDict.Remove(schemeKey);
+                    _allSchemeHydroInfoDict.Add(scheme, hydroInfoValue);
+                }
+            }
+            if (_allSchemeWorkingCheckedListDict != null && _allSchemeWorkingCheckedListDict.Count > 0)
+            {
+                var schemeKey = _allSchemeWorkingCheckedListDict.Keys.FirstOrDefault(x => x.ID == scheme.ID);
+                if (schemeKey != null)
+                {
+                    var workingCheckedValue = _allSchemeWorkingCheckedListDict[schemeKey];
+                    _allSchemeWorkingCheckedListDict.Remove(schemeKey);
+                    _allSchemeWorkingCheckedListDict.Add(scheme, workingCheckedValue);
+                }
+            }
+
+            this.ProjectSiteSchemeUpdateEvent?.Invoke(_project, _projectSite, scheme);
+        }
+
+        /// <summary>
+        /// 绉婚櫎鏂规
+        /// </summary>
+        public void RemoveScheme(XhsSchemeVmo scheme)
+        {
+            if (_project == null)
+            {
+                return;
+            }
+            if (_projectSite == null)
+            {
+                return;
+            }
+            if (scheme == null)
+            {
+                return;
+            }
+
+            var elementScheme = this.elementProjectSiteSchemeList.Elements
+                   .FirstOrDefault(x => (x.Tag is XhsSchemeVmo) && (x.Tag as XhsSchemeVmo).ID == scheme.ID);
+            if (elementScheme == null)
+            {
+                return;
+            }
+            if (elementScheme.Elements != null && elementScheme.Elements.Count > 0)
+            {
+                var workingElementList = elementScheme.Elements.ToList();
+                foreach (var workingElement in workingElementList)
+                {
+                    if (workingElement.HeaderControl != null)
+                    {
+                        this.accordionControl1.Controls.Remove(workingElement.HeaderControl);
+                    }
+                    elementScheme.Elements.Remove(workingElement);
+                }
+            }
+            this.elementProjectSiteSchemeList.Elements.Remove(elementScheme);
+
+            if (this.elementProjectSiteSchemeList.Elements.Count < 1)
+            {
+                this.elementProjectSiteSchemeList.Style = DevExpress.XtraBars.Navigation.ElementStyle.Item;
+            }
+
+            if (_allSchemeHydroInfoDict != null && _allSchemeHydroInfoDict.Count > 0)
+            {
+                var schemeKey = _allSchemeHydroInfoDict.Keys.FirstOrDefault(x => x.ID == scheme.ID);
+                if (schemeKey != null)
+                {
+                    _allSchemeHydroInfoDict.Remove(schemeKey);
+                }
+            }
+            if (_allSchemeWorkingCheckedListDict != null && _allSchemeWorkingCheckedListDict.Count > 0)
+            {
+                var schemeKey = _allSchemeWorkingCheckedListDict.Keys.FirstOrDefault(x => x.ID == scheme.ID);
+                if (schemeKey != null)
+                {
+                    _allSchemeWorkingCheckedListDict.Remove(schemeKey);
+                }
+            }
+
+            this.ProjectSiteSchemeRemoveEvent?.Invoke(_project, _projectSite, scheme);
         }
 
         /// <summary>
         /// 娣诲姞宸ュ喌
-        /// 绾坊鍔狅紝涓嶄細瑙﹀彂浜嬩欢
+        /// 瑙﹀彂椤圭洰绔欏伐鍐靛鍔犱簨浠�
         /// </summary>
         public void AppendWorking(XhsSchemeVmo scheme, Yw.Vmo.HydroWorkingVmo working)
         {
@@ -354,6 +554,8 @@
                     }
                 }
             }
+
+            this.ProjectSiteWorkingAppendEvent?.Invoke(_project, _projectSite, scheme, working);
         }
 
         /// <summary>
@@ -586,72 +788,5 @@
         }
 
         #endregion
-
-        //椤圭洰绔欐鍐�
-        private async void elementProjectSiteInfo_Click(object sender, EventArgs e)
-        {
-            await ShowInfo();
-        }
-
-        //椤圭洰绔欐按鍔涙ā鎷�
-        private async void elementProjectSiteSimulation_Click(object sender, EventArgs e)
-        {
-            if (_project == null)
-            {
-                return;
-            }
-            if (_projectSite == null)
-            {
-                return;
-            }
-            var hydroInfo = await GetHydroInfo(null, true);
-            if (hydroInfo == null)
-            {
-                return;
-            }
-            this.ShowProjectSiteSimulationEvent?.Invoke(_project, _projectSite, null, hydroInfo, _allWorkingCheckedListDict, this.svgImg32[1]);
-        }
-
-        //鍒涘缓椤圭洰绔欐柟妗�
-        private async void accordionControl1_ContextButtonClick(object sender, DevExpress.Utils.ContextItemClickEventArgs e)
-        {
-            if (_project == null)
-            {
-                return;
-            }
-            if (_projectSite == null)
-            {
-                return;
-            }
-            var element = e.DataItem as DevExpress.XtraBars.Navigation.AccordionControlElement;
-            if (element != this.elementProjectSiteSchemeList)
-            {
-                return;
-            }
-            var hydroInfo = await GetHydroInfo(null, true);
-            if (hydroInfo == null)
-            {
-                return;
-            }
-            this.CreateProjectSiteSchemeEvent?.Invoke(_project, _projectSite, hydroInfo, this.svgImg32[3]);
-        }
-
-        private void accordionControl1_MouseClick(object sender, MouseEventArgs e)
-        {
-            if (e.Button == MouseButtons.Right)
-            {
-                this.popupMenu1.ShowPopup(MousePosition);
-            }
-        }
-
-        private void barBtnCollpseAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
-        {
-            this.accordionControl1.CollapseAll();
-        }
-
-        private void barBtnExpandAll_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
-        {
-            this.accordionControl1.ExpandAll();
-        }
     }
 }
diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs
index e77c2e4..bafabbf 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/XhsProjectSimulationMgrPage.cs
@@ -18,14 +18,18 @@
             this.simulationFunctionMgrCtrl1.ShowProjectSiteInfoEvent += SimulationFunctionMgrCtrl1_ShowProjectSiteInfoEvent;
             this.simulationFunctionMgrCtrl1.ShowProjectSiteSimulationEvent += SimulationFunctionMgrCtrl1_ShowProjectSiteSimulationEvent;
             this.simulationFunctionMgrCtrl1.ShowProjectSiteWorkingEvent += SimulationFunctionMgrCtrl1_ShowProjectSiteWorkingEvent;
+            this.simulationFunctionMgrCtrl1.ProjectSiteWorkingAppendEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingAppendEvent;
             this.simulationFunctionMgrCtrl1.ProjectSiteWorkingUpdateEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingUpdateEvent;
             this.simulationFunctionMgrCtrl1.ProjectSiteWorkingRemoveEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingRemoveEvent;
             this.simulationFunctionMgrCtrl1.ProjectSiteWorkingCheckedEvent += SimulationFunctionMgrCtrl1_ProjectSiteWorkingCheckedEvent;
             this.simulationFunctionMgrCtrl1.CreateProjectSiteSchemeEvent += SimulationFunctionMgrCtrl1_CreateProjectSiteSchemeEvent;
+            this.simulationFunctionMgrCtrl1.ProjectSiteSchemeAppendEvent += SimulationFunctionMgrCtrl1_ProjectSiteSchemeAppendEvent;
+            this.simulationFunctionMgrCtrl1.ProjectSiteSchemeUpdateEvent += SimulationFunctionMgrCtrl1_ProjectSiteSchemeUpdateEvent;
+            this.simulationFunctionMgrCtrl1.ProjectSiteSchemeRemoveEvent += SimulationFunctionMgrCtrl1_ProjectSiteSchemeRemoveEvent;
         }
 
         private XhsProjectVmo _project = null;//椤圭洰
-        private object _locker = new object();//閿佸畾瀵硅薄
+        private object _locker = new();//閿佸畾瀵硅薄
 
         /// <summary>
         /// 鍒濆鍖栨暟鎹簮
@@ -134,10 +138,12 @@
                     page.UpdateSchemeEvent += (rhs) =>
                     {
                         //鏇存柊鏂规浜嬩欢
+                        this.simulationFunctionMgrCtrl1.UpdateScheme(rhs);
                     };
                     page.RemoveSchemeEvent += (rhs) =>
                     {
                         //绉婚櫎鏂规浜嬩欢
+                        this.simulationFunctionMgrCtrl1.RemoveScheme(rhs);
                     };
                     page.SetBindingData(project, projectSite, scheme, hydroInfo, allWorkingCheckedListDict);
                     CreatePage(page, guid);
@@ -181,6 +187,20 @@
                     CreatePage(page, guid);
                 }
             }
+        }
+
+        /// <summary>
+        /// 椤圭洰绔欏伐鍐靛鍔犱簨浠�
+        /// </summary>
+        private void SimulationFunctionMgrCtrl1_ProjectSiteWorkingAppendEvent
+            (
+                XhsProjectVmo project,
+                XhsProjectSiteVmo projectSite,
+                XhsSchemeVmo scheme,
+                HydroWorkingVmo working
+            )
+        {
+            //鐩墠澧炲姞宸ュ喌閮芥槸閫氳繃妯℃嫙鐣岄潰澧炲姞鐨勶紝鍔熻兘绠$悊鎺т欢灞炰簬琚�氱煡鐨勶紝鍏朵粬鍦版柟鏆傛椂涓嶅叧蹇冨伐鍐靛鍔�
         }
 
         //椤圭洰绔欏伐鍐垫洿鏂颁簨浠�
@@ -291,6 +311,39 @@
             dlg.ShowDialog();
         }
 
+        //椤圭洰绔欐柟妗堝鍔犱簨浠�
+        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeAppendEvent
+            (
+                XhsProjectVmo project,
+                XhsProjectSiteVmo projectSite,
+                XhsSchemeVmo scheme
+            )
+        {
+            //琚姩
+        }
+
+        //椤圭洰绔欐柟妗堟洿鏂颁簨浠�
+        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeUpdateEvent
+            (
+                XhsProjectVmo project,
+                XhsProjectSiteVmo projectSite,
+                XhsSchemeVmo scheme
+            )
+        {
+            //琚姩
+        }
+
+        //椤圭洰绔欐柟妗堢Щ闄や簨浠�
+        private void SimulationFunctionMgrCtrl1_ProjectSiteSchemeRemoveEvent
+            (
+                XhsProjectVmo project,
+                XhsProjectSiteVmo projectSite,
+                XhsSchemeVmo scheme
+            )
+        {
+            //琚姩
+        }
+
         #endregion
 
         #region TabbedView 鐩稿叧浜嬩欢澶勭悊绋嬪簭

--
Gitblit v1.9.3