From 9be9ba4e159969fb5e32648c2c34e912ccc3ae6d Mon Sep 17 00:00:00 2001
From: duheng <2286773002@qq.com>
Date: 星期五, 28 三月 2025 14:22:42 +0800
Subject: [PATCH] 优化细节问题

---
 WinFrmUI/IBox.WinFrmUI/Form/IBoxFormLog.cs |   74 +++++++++++++++++++++++++++++++-----
 1 files changed, 63 insertions(+), 11 deletions(-)

diff --git a/WinFrmUI/IBox.WinFrmUI/Form/IBoxFormLog.cs b/WinFrmUI/IBox.WinFrmUI/Form/IBoxFormLog.cs
index 8bff9c6..9284079 100644
--- a/WinFrmUI/IBox.WinFrmUI/Form/IBoxFormLog.cs
+++ b/WinFrmUI/IBox.WinFrmUI/Form/IBoxFormLog.cs
@@ -3,13 +3,10 @@
 using Yw;
 using Yw.WinFrmUI;
 
-
 namespace IBox.WinFrmUI
 {
     public partial class IBoxFormLog : DocumentPage
     {
-
-        
         public IBoxFormLog()
         {
             this.PageTitle.Caption = "鏃ュ織绠$悊";
@@ -19,7 +16,8 @@
         public void HideButton()
         {
             //simpleButton1.Visible = simpleButton2.Visible =  false;
-            layoutControlItem2.Visibility = layoutControlItem3.Visibility  = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
+            /*layoutControlItem2.Visibility =*/
+            layoutControlItem3.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
         }
 
         private void EboxFormLog_Load(object sender, EventArgs e)
@@ -55,17 +53,59 @@
 
             imageComboBoxEdit1.SelectedIndex = 0;
             imageComboBoxEdit2.SelectedIndex = 0;
-
         }
 
         public event EventHandler<string> SendData;
+
         private void SendText(string content)
         {
-            //BluetoothHelper.GetInstance().SendData(content);
-            SendData?.Invoke(null, content);
+            if (SendData != null)
+            {
+                SendData?.Invoke(null, content);
+            }
+            else
+            {
+                if (IBoxHelper.Ping())
+                {
+                    var smsg = content.Split(new string[] { IBoxHelper.paramCode, IBoxHelper.startCode }, StringSplitOptions.RemoveEmptyEntries);
+                    if (smsg.Length < 2)
+                    {
+                        return;
+                    }
+                    switch (smsg[0].Trim())
+                    {
+                        case IBoxHelper.getlogCode:
+                            {
+                                var order = IBoxHelper.HttpGet(content);
+                                var result = IBoxHelper.GetContent(order);
+                                if (!string.IsNullOrEmpty(result))
+                                {
+                                    var model = JsonHelper.Json2Object<List<IBoxLogViewModel>>(result);
+                                    BindData(model, false);
+                                }
+                                break;
+                            }
+                        default:
+                            IBoxHelper.HttpGet(content);
+                            break;
+                    }
+                }
+                else
+                {
+                    MessageBoxHelper.ShowWarning("缃戠粶杩炴帴澶辫触锛岃妫�鏌ョ綉缁�");
+                }
+            }
         }
 
         private void simpleButton1_Click(object sender, EventArgs e)
+        {
+            Search();
+        }
+
+        /// <summary>
+        /// 鏌ヨ
+        /// </summary>
+        public void Search()
         {
             //鏌ヨ
             var m = new GetCalcValueModel()
@@ -81,6 +121,14 @@
 
         private void simpleButton2_Click(object sender, EventArgs e)
         {
+            Clear();
+        }
+
+        /// <summary>
+        /// 娓呯┖
+        /// </summary>
+        public void Clear()
+        {
             //娓呯┖
             this.Invoke(new Action(() =>
             {
@@ -92,7 +140,6 @@
 
         private void gridView1_CustomDrawCell(object sender, DevExpress.XtraGrid.Views.Base.RowCellCustomDrawEventArgs e)
         {
-
             if (e.Column.FieldName == "LogResult")
             {
                 var celValue = e.CellValue.ToString();
@@ -103,14 +150,17 @@
                         celNewValue = "鎻愮ず";
                         e.Appearance.ForeColor = Color.Blue;
                         break;
+
                     case "fail":
                         celNewValue = "澶辫触";
                         e.Appearance.ForeColor = Color.Coral;
                         break;
+
                     case "error":
                         celNewValue = "寮傚父";
                         e.Appearance.ForeColor = Color.Red;
                         break;
+
                     default:
                         celNewValue = "鎴愬姛";
                         e.Appearance.ForeColor = Color.Green;
@@ -122,7 +172,6 @@
 
         private Dictionary<string, string> GetDic()
         {
-
             return new Dictionary<string, string>
                             {
                                 { "controll", "鏅鸿兘鎺у埗" },
@@ -131,6 +180,7 @@
                                 { "datadocking", "鏁版嵁閲囬泦" },
                             };
         }
+
         private void gridView1_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
         {
             if (e.Column.FieldName == "LogEvent")
@@ -158,19 +208,21 @@
                     case "info":
                         celNewValue = "鎻愮ず";
                         break;
+
                     case "fail":
                         celNewValue = "澶辫触";
                         break;
+
                     case "error":
                         celNewValue = "寮傚父";
                         break;
+
                     default:
                         celNewValue = "鎴愬姛";
                         break;
                 }
                 e.DisplayText = celNewValue;
             }
-
         }
 
         /// <summary>
@@ -195,4 +247,4 @@
             }
         }
     }
-}
+}
\ No newline at end of file

--
Gitblit v1.9.3