From afbafeecc1325bff849a17fb63b9b2b65b48ddf1 Mon Sep 17 00:00:00 2001 From: ningshuxia <ningshuxia0927@outlook.com> Date: 星期四, 27 三月 2025 17:35:09 +0800 Subject: [PATCH] 模拟调度 --- WinFrmUI/IBox.WinFrmUI/Form/IBoxFormSystemInfo.cs | 79 +++++++++++++++++++++++++++++++-------- 1 files changed, 63 insertions(+), 16 deletions(-) diff --git a/WinFrmUI/IBox.WinFrmUI/Form/IBoxFormSystemInfo.cs b/WinFrmUI/IBox.WinFrmUI/Form/IBoxFormSystemInfo.cs index ddc214d..54c5625 100644 --- a/WinFrmUI/IBox.WinFrmUI/Form/IBoxFormSystemInfo.cs +++ b/WinFrmUI/IBox.WinFrmUI/Form/IBoxFormSystemInfo.cs @@ -1,14 +1,12 @@ 锘縰sing System.Data; using Yw.WinFrmUI; +using Yw; namespace IBox.WinFrmUI { public partial class IBoxFormSystemInfo : DocumentPage { - private string startCode = "[&start&]"; - private string endCode = "[&end&]"; - private string paramCode = "[¶m&]"; - private string getstoreCode = "getstore"; + public IBoxFormSystemInfo() { this.PageTitle.Caption = "璁惧淇℃伅"; @@ -18,35 +16,84 @@ private void EboxFormSystemInfo_Load(object sender, EventArgs e) { Thread.Sleep(500); - SendText(startCode + getstoreCode + paramCode + endCode); + SendText(IBoxHelper.startCode + IBoxHelper.getstoreCode + IBoxHelper.paramCode + IBoxHelper.endCode); } 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.getstoreCode: + { + var order = IBoxHelper.HttpGet(content); + var result = IBoxHelper.GetContent(order); + if (!string.IsNullOrEmpty(result)) + { + var model = JsonHelper.Json2Object<SystemInfoViewModel>(result); + BindData(model, false); + } + break; + } + default: + IBoxHelper.HttpGet(content); + break; + } + } + else + { + MessageBoxHelper.ShowWarning("缃戠粶杩炴帴澶辫触锛岃妫�鏌ョ綉缁�"); + } + } } + /// <summary> + /// 缁戝畾鏁版嵁 + /// </summary> + /// <param name="model"></param> + /// <param name="isBlue"></param> public void BindData(SystemInfoViewModel model, bool isBlue) { textEdit1.Text = model.Lan0IpAddress.Replace("\n", ""); textEdit2.Text = model.Wlan0IpAddress.Replace("\n", ""); textEdit3.Text = model.SystemVersion; textEdit4.Text = model.TotalRunTime; - textEdit10.Text = model.CurrentTime.Replace(";",""); - var dic = GetDuDic(model.Du); - textEdit5.Text = GetDuString(dic, "/usr/ebox"); - textEdit6.Text = GetDuString(dic, "/usr/ebox/Data"); - textEdit7.Text = GetDuString(dic, "/usr/ebox/DataDockingConsole"); - textEdit8.Text = GetDuString(dic, "/usr/ebox/PostDataConsole"); - textEdit9.Text = GetDuString(dic, "/usr/ebox/WebServer"); + try + { + textEdit10.Text = model.CurrentTime?.Replace(";", ""); + var dic = GetDuDic(model.Du); + if (dic != null) + { + textEdit5.Text = GetDuString(dic, "/usr/ebox"); + textEdit6.Text = GetDuString(dic, "/usr/ebox/Data"); + textEdit7.Text = GetDuString(dic, "/usr/ebox/DataDockingConsole"); + textEdit8.Text = GetDuString(dic, "/usr/ebox/PostDataConsole"); + textEdit9.Text = GetDuString(dic, "/usr/ebox/WebServer"); + } + } + catch (Exception ex) + { + } textEdit11.Text = model.MemUse; } private Dictionary<string, string> GetDuDic(string du) { - //8.2M:/usr/ebox/Data; 鐢熸垚Dictionary<string,string> - return du.Substring(0,du.Length - 1).Split(';').Select(c => c.Split(':')).ToDictionary(b => b[1], b => b[0]); + if (string.IsNullOrEmpty(du)) return null; + return du.Substring(0, du.Length - 1).Split(';').Select(c => c.Split(':')).ToDictionary(b => b[1], b => b[0]); } private string GetDuString(Dictionary<string, string> du, string type) -- Gitblit v1.9.3