From dc63fbdaf4464fc0e5392c21b82869324cfc83e1 Mon Sep 17 00:00:00 2001 From: wangsr Date: Mon, 9 Oct 2023 09:07:17 +0800 Subject: [PATCH] =?UTF-8?q?change=20-=20=E5=8A=A0=E8=BD=BD=E6=97=B6?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E9=85=8D=E7=BD=AE=EF=BC=8C=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ManualControl/InitAction.cs | 48 +++++++++++++++++++ .../ManualControl/ManualControlAction.cs | 16 ++----- Main/MCEdit/Data/MCProject/nodeDevice.xml | 8 ++-- 3 files changed, 56 insertions(+), 16 deletions(-) diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs index d49faa7..6d8a016 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/InitAction.cs @@ -27,6 +27,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl DB2103Helper DB2103; List McControllist; + List _McControllist; OperateResult Read; @@ -63,6 +64,15 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl IBaseControl SpiralState3; IBaseControl SpiralState4; + IBaseControl SetWaterValue1; + IBaseControl SetWaterValue2; + IBaseControl SetWaterValue3; + IBaseControl SetWaterValue4; + IBaseControl SetSpiralValue1; + IBaseControl SetSpiralValue2; + IBaseControl SetSpiralValue3; + IBaseControl SetSpiralValue4; + bool State1; bool State2; byte Byt; @@ -76,6 +86,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl base.RunIni(runtime); //必须要调用的 McControllist = GetAllDbMCControlsByOption(DbOptionTypes.InitData); + _McControllist = GetAllDbMCControlsByOption(DbOptionTypes.Modify); WaterActualValue1 = GetBaseControl("WaterActualValue1"); WaterActualValue2 = GetBaseControl("WaterActualValue2"); @@ -102,10 +113,30 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl SpiralState3 = GetBaseControl("SpiralState3"); SpiralState4 = GetBaseControl("SpiralState4"); + SetWaterValue1 = _GetBaseControl("SetWaterValue1"); + SetWaterValue2 = _GetBaseControl("SetWaterValue2"); + SetWaterValue3 = _GetBaseControl("SetWaterValue3"); + SetWaterValue4 = _GetBaseControl("SetWaterValue4"); + SetSpiralValue1 = _GetBaseControl("SetSpiralValue1"); + SetSpiralValue2 = _GetBaseControl("SetSpiralValue2"); + SetSpiralValue3 = _GetBaseControl("SetSpiralValue3"); + SetSpiralValue4 = _GetBaseControl("SetSpiralValue4"); + materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ManualLogGridView").FirstOrDefault(); LogInsertToDatabase(); + SetWaterValue1.MCValue = Setting.Default.SetWaterValue1; + SetWaterValue2.MCValue = Setting.Default.SetWaterValue2; + SetWaterValue3.MCValue = Setting.Default.SetWaterValue3; + SetWaterValue4.MCValue = Setting.Default.SetWaterValue4; + SetSpiralValue1.MCValue = Setting.Default.SetSpiralValue1; + SetSpiralValue2.MCValue = Setting.Default.SetSpiralValue2; + SetSpiralValue3.MCValue = Setting.Default.SetSpiralValue3; + SetSpiralValue4.MCValue = Setting.Default.SetSpiralValue4; + MesnacServiceManager.Instance.LoggingService.Info("配置已加载"); + ManualLogControl("配置已加载 "); + timer = new Timer(); timer.Interval = 1000; timer.Enabled = true; @@ -356,6 +387,11 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl return McControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == name).FirstOrDefault().BaseControl; } + private IBaseControl _GetBaseControl(string name) + { + return _McControllist.Where(t => t.BaseControl.MCKey != null && t.BaseControl.MCKey == name).FirstOrDefault().BaseControl; + } + private void LogInsertToDatabase() { DataTable table = DBHelp.GetTable(@"select top 100 id, logtext, logtime from Manual_Log order by id desc"); @@ -370,5 +406,17 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl ICSharpCode.Core.LoggingService.Warn("手动操作日志信息控件为Null..."); } } + + private void ManualLogControl(string logName) + { + var Log = new ManualLogEntity() + { + logtext = logName, + logtime = DateTime.Now, + userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName + }; + + FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity(); + } } } diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs index 027a00f..10145df 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs @@ -139,14 +139,6 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl BottomSelect(runtime); - SetWaterValue1.MCValue = Setting.Default.SetWaterValue1; - SetWaterValue2.MCValue = Setting.Default.SetWaterValue2; - SetWaterValue3.MCValue = Setting.Default.SetWaterValue3; - SetWaterValue4.MCValue = Setting.Default.SetWaterValue4; - SetSpiralValue1.MCValue = Setting.Default.SetSpiralValue1; - SetSpiralValue2.MCValue = Setting.Default.SetSpiralValue2; - SetSpiralValue3.MCValue = Setting.Default.SetSpiralValue3; - SetSpiralValue4.MCValue = Setting.Default.SetSpiralValue4; } /// @@ -1204,10 +1196,10 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl Setting.Default.SetWaterValue2 = value2; Setting.Default.SetWaterValue3 = value3; Setting.Default.SetWaterValue4 = value4; - Setting.Default.SetSpiralValue1 = value1; - Setting.Default.SetSpiralValue2 = value2; - Setting.Default.SetSpiralValue3 = value3; - Setting.Default.SetSpiralValue4 = value4; + Setting.Default.SetSpiralValue1 = value5; + Setting.Default.SetSpiralValue2 = value6; + Setting.Default.SetSpiralValue3 = value7; + Setting.Default.SetSpiralValue4 = value8; MesnacServiceManager.Instance.LoggingService.Info("配置已保存"); ManualLogControl("配置已保存 " + value1 + value2 + value3 + value4 + value5 + value6 + value7 + value8); } diff --git a/Main/MCEdit/Data/MCProject/nodeDevice.xml b/Main/MCEdit/Data/MCProject/nodeDevice.xml index 0b6144f..38fa499 100644 --- a/Main/MCEdit/Data/MCProject/nodeDevice.xml +++ b/Main/MCEdit/Data/MCProject/nodeDevice.xml @@ -13,7 +13,7 @@ - + @@ -2810,7 +2810,7 @@ - + @@ -3958,7 +3958,7 @@ - + @@ -5395,7 +5395,7 @@ - +