From a5872f7ed264a634c809b026d4d181f99a78db1d Mon Sep 17 00:00:00 2001
From: lixiaojun <1287241240@qq.com>
Date: 星期二, 10 十二月 2024 16:48:54 +0800
Subject: [PATCH] ResetMonitorValue bug修复

---
 WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs |   95 ++++++++++++++++++++++++++++-------------------
 1 files changed, 57 insertions(+), 38 deletions(-)

diff --git a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
index 311d22c..a868760 100644
--- a/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
+++ b/WinFrmUI/HStation.WinFrmUI.Xhs.Core/03-simulation/06-simulation/XhsProjectSimulationCorePage.cs
@@ -1540,6 +1540,13 @@
             return _monitorHelper;
         }
 
+        //鑾峰彇鐩戞祴鐐瑰垪琛�
+        private async Task<List<HydroMonitorVmo>> GetMonitorList()
+        {
+            var helper = GetMonitorHelper();
+            return await helper.Get();
+        }
+
         //璁剧疆鐩戞祴鐐瑰垪琛�
         private async void SetMonitorList(HydroVisualInfo visual)
         {
@@ -1599,7 +1606,7 @@
         private void ResetMonitorValue()
         {
             var allWorkingList = GetWorkingList();
-            var working = allWorkingList?.Last(x => !string.IsNullOrEmpty(x.MonitorInfo));
+            var working = allWorkingList?.LastOrDefault(x => !string.IsNullOrEmpty(x.MonitorInfo));
             if (working != null)
             {
                 var helper = GetMonitorValueHelper();
@@ -2197,6 +2204,7 @@
                         ShowCalcuWarningCtrl(calcuResult);
                     }
                     this.barBtnAddWorking.Enabled = true;
+                    this.barBtnExportWord.Enabled = true;
                     TipFormHelper.ShowSucceed("璁$畻鎴愬姛锛�");
                 }
                 else
@@ -2248,6 +2256,21 @@
         private void barBtnCalcu_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
             Calcu();
+        }
+
+        #endregion
+
+        #region 瀵煎嚭鎶ュ憡
+
+        private void barBtnExportWord_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        {
+            var fileName = FileDialogHelper.SaveWordDoc("瀵煎嚭Word鎶ュ憡");
+            if (string.IsNullOrEmpty(fileName))
+            {
+                return;
+            }
+            SimulationWordReport word = new SimulationWordReport();
+            //word.Create(fileName);
         }
 
         #endregion
@@ -2367,6 +2390,27 @@
 
         #region 宸ュ喌鍒嗘瀽
 
+        //閫夋嫨杩涘彛姘存簮
+        private void SelectInputSource()
+        {
+            var sources = GetSourceList();
+            if (sources != null)
+            {
+                if (sources.Count == 1)
+                {
+                    SelectVisual(sources[0], eVisualSource.None);
+                }
+                else
+                {
+                    var source = sources.FirstOrDefault(x => x.Flags.Contains(HStation.Xhs.Flags.杩涘彛));
+                    if (source != null)
+                    {
+                        SelectVisual(source, eVisualSource.None);
+                    }
+                }
+            }
+        }
+
         //绮惧害璇勪及
         private async void barBtnWorkingEvaluation_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
@@ -2421,8 +2465,9 @@
         }
 
         //鑳芥晥鍒嗘瀽
-        private void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
+        private async void barBtnWorkingPower_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
         {
+            var allMonitorList = await GetMonitorList();
             var workingCheckedListHelper = GetWorkingCheckedListHelper();
             var allCheckedWorkingList = workingCheckedListHelper.GetCheckedWorkingList();
             if (allCheckedWorkingList == null || allCheckedWorkingList.Count < 1)
@@ -2434,14 +2479,14 @@
                     return;
                 }
                 var dlg = new SimulationSingleWorkingEnergyDlg();
-                dlg.SetBindingData(workingHelper.Working, workingHelper.HydroInfo, workingHelper.CalcuResult);
+                dlg.SetBindingData(workingHelper.Working, workingHelper.HydroInfo, allMonitorList, workingHelper.CalcuResult);
                 dlg.ShowDialog();
             }
             else
             {
 
                 var dlg = new SimulationMultiWorkingEnergyDlg();
-                dlg.SetBindingData(_hydroInfo, allCheckedWorkingList);
+                dlg.SetBindingData(_hydroInfo, allMonitorList, allCheckedWorkingList);
                 dlg.ShowDialog();
             }
         }
@@ -2451,22 +2496,7 @@
         {
             if (_visual == null)
             {
-                var sources = GetSourceList();
-                if (sources != null)
-                {
-                    if (sources.Count == 1)
-                    {
-                        SelectVisual(sources[0], eVisualSource.None);
-                    }
-                    else
-                    {
-                        var source = sources.FirstOrDefault(x => x.Flags.Contains(HStation.Xhs.Flags.杩涘彛));
-                        if (source != null)
-                        {
-                            SelectVisual(source, eVisualSource.None);
-                        }
-                    }
-                }
+                SelectInputSource();
                 if (_visual == null)
                 {
                     TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒");
@@ -2540,26 +2570,14 @@
         {
             if (_visual == null)
             {
-                var sources = GetSourceList();
-                if (sources != null)
-                {
-                    if (sources.Count == 1)
-                    {
-                        SelectVisual(sources[0], eVisualSource.None);
-                    }
-                    else
-                    {
-                        var source = sources.FirstOrDefault(x => x.Flags.Contains(HStation.Xhs.Flags.杩涘彛));
-                        if (source != null)
-                        {
-                            SelectVisual(source, eVisualSource.None);
-                        }
-                    }
-                }
                 if (_visual == null)
                 {
-                    TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒");
-                    return;
+                    SelectInputSource();
+                    if (_visual == null)
+                    {
+                        TipFormHelper.ShowWarn("璇烽�夋嫨鏋勪欢鍚庨噸璇曪紒");
+                        return;
+                    }
                 }
             }
             HydroVisualInfo visual = _visual;
@@ -2602,5 +2620,6 @@
 
 
 
+
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3