diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/LjManualLog.cs b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/LjManualLog.cs new file mode 100644 index 0000000..30b30dc --- /dev/null +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/LjManualLog.cs @@ -0,0 +1,101 @@ +using Mesnac.Action.ChemicalWeighing.FreeDb; +using Mesnac.Action.ChemicalWeighing.LjMaterial; +using Mesnac.Basic; +using System; +using System.Collections.Generic; +using System.Data; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Mesnac.Action.ChemicalWeighing.ManualControl +{ + public class LjManualLog + { + /// + /// 日志查询 内容 时间 值 + /// + /// 查询关键字 + public static DataTable ManualLogSelect(string txt) + { + string sql = "select top 500 id, logtext, logtime, value from Manual_Log "; + + if (!string.IsNullOrEmpty(txt)) + { + sql += $" where logtext like '%{txt}%'"; + } + sql += " order by id desc"; + + return DBHelp.GetTable(sql); + } + + /// + /// 完整手动日志插入 + /// + /// 日志内容 + /// 值 + /// 值类型 0无 1水称设定值 2水称称量值 3螺旋设定值 4螺旋称量值 + /// 设备编号 + /// 设备类型 0无 1水称 2螺旋 + public static void ManualLogControl(string logName, int value, int valuekind, int deviceno, int devicekind) + { + var Log = new ManualLogEntity() + { + logtext = logName, + logtime = DateTime.Now, + userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName, + value = value, + deviceno = deviceno, + devicekind = devicekind, + valuekind = valuekind, + createdate = DateTime.Now.ToString("yyyyMMdd") + }; + + FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity(); + } + + /// + /// 无数值 有设备 日志记录 + /// + /// 日志内容 + /// 设备编号 + /// 设备类型 + public static void ManualLogControl(string logName, int deviceno, int devicekind) + { + var Log = new ManualLogEntity() + { + logtext = logName, + logtime = DateTime.Now, + userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName, + value = 0, + deviceno = deviceno, + devicekind = devicekind, + valuekind = 0, + createdate = DateTime.Now.ToString("yyyyMMdd") + }; + + FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity(); + } + + /// + /// 无数值 无设备 日志记录 + /// + /// + public static void ManualLogControl(string logName) + { + var Log = new ManualLogEntity() + { + logtext = logName, + logtime = DateTime.Now, + userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName, + value = 0, + deviceno = 0, + devicekind = 0, + valuekind = 0, + createdate = DateTime.Now.ToString("yyyyMMdd") + }; + + 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 189c59c..174f210 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/ManualControl/ManualControlAction.cs @@ -150,7 +150,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl base.RunIni(runtime); //必须要调用 materialGridControl = this.GetDbMCControlByKey(Mesnac.Basic.DataSourceFactory.MCDbType.Local, "ManualLogGridView").FirstOrDefault(); - ManualLogSelect(""); + LogSelect(""); ControlImport(); SingleSelect(); @@ -394,7 +394,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.20.0", value); PlcControl("DB2119.28.0", true); MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始称量" + value); - ManualLogControl("冷水称A开始称量", value, 1, 3, 1); + LjManualLog.ManualLogControl("冷水称A开始称量", value, 1, 3, 1); + LogSelect(""); } else { @@ -408,8 +409,9 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl { PlcControl("DB2119.28.1", true); MesnacServiceManager.Instance.LoggingService.Info("冷水称A称量已手动停止"); - ManualLogControl("冷水称A称量已手动停止", 3, 1); + LjManualLog.ManualLogControl("冷水称A称量已手动停止", 3, 1); MessageBox.Show("冷水称A称量已停止!"); + LogSelect(""); } if (StartMetage2 == runtime.Sender) @@ -429,8 +431,9 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.0.0", value); PlcControl("DB2119.8.0", true); MesnacServiceManager.Instance.LoggingService.Info("热水称A开始称量" + value); - ManualLogControl("热水称A开始称量", value, 1, 1, 1); + LjManualLog.ManualLogControl("热水称A开始称量", value, 1, 1, 1); PlcControl("DB2119.0.0", value); + LogSelect(""); } else { @@ -444,8 +447,9 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl { PlcControl("DB2119.8.1", true); MesnacServiceManager.Instance.LoggingService.Info("热水称A称量已手动停止"); - ManualLogControl("热水称A称量已手动停止", 1, 1); + LjManualLog.ManualLogControl("热水称A称量已手动停止", 1, 1); MessageBox.Show("热水称A称量已停止!"); + LogSelect(""); } if (StartMetage3 == runtime.Sender) @@ -463,9 +467,10 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl return; } MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始称量" + value); - ManualLogControl("冷水称B开始称量", value, 1, 4, 1); + LjManualLog.ManualLogControl("冷水称B开始称量", value, 1, 4, 1); PlcControl("DB2119.30.0", value); PlcControl("DB2119.38.0", true); + LogSelect(""); } else { @@ -479,8 +484,9 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl { PlcControl("DB2119.38.1", true); MesnacServiceManager.Instance.LoggingService.Info("冷水称B称量已手动停止"); - ManualLogControl("冷水称B称量已手动停止", 4, 1); + LjManualLog.ManualLogControl("冷水称B称量已手动停止", 4, 1); MessageBox.Show("冷水称B称量已停止!"); + LogSelect(""); } if (StartMetage4 == runtime.Sender) @@ -498,9 +504,10 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl return; } MesnacServiceManager.Instance.LoggingService.Info("热水称B开始称量" + value); - ManualLogControl("热水称B开始称量", value, 1, 2, 1); + LjManualLog.ManualLogControl("热水称B开始称量", value, 1, 2, 1); PlcControl("DB2119.10.0", value); PlcControl("DB2119.18.0", true); + LogSelect(""); } else { @@ -514,8 +521,9 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl { PlcControl("DB2119.18.1", true); MesnacServiceManager.Instance.LoggingService.Info("热水称B称量已手动停止"); - ManualLogControl("热水称B称量已手动停止", 2, 1); + LjManualLog.ManualLogControl("热水称B称量已手动停止", 2, 1); MessageBox.Show("热水称B称量已停止!"); + LogSelect(""); } #endregion @@ -550,7 +558,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.28.4", true); MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅1排水"); AdddWaterLogControl(1, 2); - ManualLogControl("冷水称A开始向糊化锅1排水"); + LjManualLog.ManualLogControl("冷水称A开始向糊化锅1排水"); + LogSelect(""); break; case 2: if (SelectAddWaterControl(2) == 2) @@ -564,7 +573,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.28.4", true); MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅2排水"); AdddWaterLogControl(2, 2); - ManualLogControl("冷水称A开始向糊化锅2排水"); + LjManualLog.ManualLogControl("冷水称A开始向糊化锅2排水"); + LogSelect(""); break; case 3: if (SelectAddWaterControl(3) == 2) @@ -578,7 +588,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.28.4", true); MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅3排水"); AdddWaterLogControl(3, 2); - ManualLogControl("冷水称A开始向糊化锅3排水"); + LjManualLog.ManualLogControl("冷水称A开始向糊化锅3排水"); + LogSelect(""); break; case 4: if (SelectAddWaterControl(4) == 2) @@ -592,7 +603,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.28.4", true); MesnacServiceManager.Instance.LoggingService.Info("冷水称A开始向糊化锅4排水"); AdddWaterLogControl(4, 2); - ManualLogControl("冷水称A开始向糊化锅4排水"); + LjManualLog.ManualLogControl("冷水称A开始向糊化锅4排水"); + LogSelect(""); break; default: MessageBox.Show("请选择一个糊化锅!"); @@ -628,7 +640,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.8.4", true); MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅1排水"); AdddWaterLogControl(1, 1); - ManualLogControl("热水称A开始向糊化锅1排水"); + LjManualLog.ManualLogControl("热水称A开始向糊化锅1排水"); + LogSelect(""); break; case 2: if (SelectAddWaterControl(2) == 0 || SelectAddWaterControl(2) == 1) @@ -642,7 +655,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.8.4", true); MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅2排水"); AdddWaterLogControl(2, 1); - ManualLogControl("热水称A开始向糊化锅2排水"); + LjManualLog.ManualLogControl("热水称A开始向糊化锅2排水"); + LogSelect(""); break; case 3: if (SelectAddWaterControl(3) == 0 || SelectAddWaterControl(3) == 1) @@ -656,7 +670,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.8.4", true); MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅3排水"); AdddWaterLogControl(3, 1); - ManualLogControl("热水称A开始向糊化锅3排水"); + LjManualLog.ManualLogControl("热水称A开始向糊化锅3排水"); + LogSelect(""); break; case 4: if (SelectAddWaterControl(4) == 0 || SelectAddWaterControl(4) == 1) @@ -670,7 +685,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.8.4", true); MesnacServiceManager.Instance.LoggingService.Info("热水称A开始向糊化锅4排水"); AdddWaterLogControl(4, 1); - ManualLogControl("热水称A开始向糊化锅4排水"); + LjManualLog.ManualLogControl("热水称A开始向糊化锅4排水"); + LogSelect(""); break; default: MessageBox.Show("请选择一个糊化锅!"); @@ -706,7 +722,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.38.4", true); MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅5排水"); AdddWaterLogControl(5, 2); - ManualLogControl("冷水称B开始向糊化锅5排水"); + LjManualLog.ManualLogControl("冷水称B开始向糊化锅5排水"); + LogSelect(""); break; case 6: if (SelectAddWaterControl(6) == 2) @@ -720,7 +737,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.38.4", true); MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅6排水"); AdddWaterLogControl(6, 2); - ManualLogControl("冷水称B开始向糊化锅6排水"); + LjManualLog.ManualLogControl("冷水称B开始向糊化锅6排水"); + LogSelect(""); break; case 7: if (SelectAddWaterControl(7) == 2) @@ -734,7 +752,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.38.4", true); MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅7排水"); AdddWaterLogControl(7, 2); - ManualLogControl("冷水称B开始向糊化锅7排水"); + LjManualLog.ManualLogControl("冷水称B开始向糊化锅7排水"); + LogSelect(""); break; case 8: if (SelectAddWaterControl(8) == 2) @@ -748,7 +767,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.38.4", true); MesnacServiceManager.Instance.LoggingService.Info("冷水称B开始向糊化锅8排水"); AdddWaterLogControl(8, 2); - ManualLogControl("冷水称B开始向糊化锅8排水"); + LjManualLog.ManualLogControl("冷水称B开始向糊化锅8排水"); + LogSelect(""); break; default: MessageBox.Show("请选择一个糊化锅!"); @@ -784,7 +804,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.18.4", true); MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅5排水"); AdddWaterLogControl(5, 1); - ManualLogControl("热水称B开始向糊化锅5排水"); + LjManualLog.ManualLogControl("热水称B开始向糊化锅5排水"); + LogSelect(""); break; case 6: if (SelectAddWaterControl(6) == 0 || SelectAddWaterControl(6) == 1) @@ -798,7 +819,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.18.4", true); MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅6排水"); AdddWaterLogControl(6, 1); - ManualLogControl("热水称B开始向糊化锅6排水"); + LjManualLog.ManualLogControl("热水称B开始向糊化锅6排水"); + LogSelect(""); break; case 7: if (SelectAddWaterControl(7) == 0 || SelectAddWaterControl(7) == 1) @@ -812,7 +834,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.18.4", true); MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅7排水"); AdddWaterLogControl(7, 1); - ManualLogControl("热水称B开始向糊化锅7排水"); + LjManualLog.ManualLogControl("热水称B开始向糊化锅7排水"); + LogSelect(""); break; case 8: if (SelectAddWaterControl(8) == 0 || SelectAddWaterControl(8) == 1) @@ -826,7 +849,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.18.4", true); MesnacServiceManager.Instance.LoggingService.Info("热水称B开始向糊化锅8排水"); AdddWaterLogControl(8, 1); - ManualLogControl("热水称B开始向糊化锅8排水"); + LjManualLog.ManualLogControl("热水称B开始向糊化锅8排水"); + LogSelect(""); break; default: MessageBox.Show("请选择一个糊化锅!"); @@ -863,7 +887,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl WaterStopAction("DB2119.28.5", WaterStop1, "冷", "A"); //MessageBox.Show("冷水称A已停止排水"); - //ManualLogControl("冷水称A停止排水"); + //LjManualLog.ManualLogControl("冷水称A停止排水"); //MesnacServiceManager.Instance.LoggingService.Info("冷水称A停止排水"); } @@ -895,7 +919,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl WaterStopAction("DB2119.8.5", WaterStop2, "热", "A"); //MessageBox.Show("热水称A已停止排水"); - //ManualLogControl("热水称A停止排水"); + //LjManualLog.ManualLogControl("热水称A停止排水"); //MesnacServiceManager.Instance.LoggingService.Info("热水称A停止排水"); } @@ -928,7 +952,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl //MessageBox.Show("冷水称B已停止排水"); - //ManualLogControl("冷水称B停止排水"); + //LjManualLog.ManualLogControl("冷水称B停止排水"); //MesnacServiceManager.Instance.LoggingService.Info("冷水称B停止排水"); } @@ -960,7 +984,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl WaterStopAction("DB2119.18.5", WaterStop4, "热", "B"); //MessageBox.Show("热水称B已停止排水"); - //ManualLogControl("热水称B停止排水"); + //LjManualLog.ManualLogControl("热水称B停止排水"); //MesnacServiceManager.Instance.LoggingService.Info("热水称B停止排水"); } @@ -1031,7 +1055,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.58.0", 1); PlcControl("DB2119.60.0", true); MesnacServiceManager.Instance.LoggingService.Info("螺旋1启动向湿混机1 " + valueSet); - ManualLogControl("螺旋1启动向湿混机1", valueSet, 3, 1, 2); + LjManualLog.ManualLogControl("螺旋1启动向湿混机1", valueSet, 3, 1, 2); + LogSelect(""); break; case 2: if (valueSet > 350) @@ -1058,7 +1083,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.58.0", 2); PlcControl("DB2119.60.0", true); MesnacServiceManager.Instance.LoggingService.Info("螺旋1启动向湿混机2 " + valueSet); - ManualLogControl("螺旋1启动向湿混机2", valueSet, 3, 2, 2); + LjManualLog.ManualLogControl("螺旋1启动向湿混机2", valueSet, 3, 2, 2); + LogSelect(""); break; default: MessageBox.Show("请选择一个湿混机!"); @@ -1131,7 +1157,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.80.0", 1); PlcControl("DB2119.82.0", true); MesnacServiceManager.Instance.LoggingService.Info("螺旋2启动向湿混机3 " + valueSet); - ManualLogControl("螺旋2启动向湿混机3", valueSet, 3, 3, 2); + LjManualLog.ManualLogControl("螺旋2启动向湿混机3", valueSet, 3, 3, 2); + LogSelect(""); break; case 4: if (valueSet > 350) @@ -1158,7 +1185,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.80.0", 2); PlcControl("DB2119.82.0", true); MesnacServiceManager.Instance.LoggingService.Info("螺旋2启动向湿混机4 " + valueSet); - ManualLogControl("螺旋2启动向湿混机4", valueSet, 3, 4, 2); + LjManualLog.ManualLogControl("螺旋2启动向湿混机4", valueSet, 3, 4, 2); + LogSelect(""); break; default: MessageBox.Show("请选择一个湿混机!"); @@ -1231,7 +1259,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.102.0", 1); PlcControl("DB2119.104.0", true); MesnacServiceManager.Instance.LoggingService.Info("螺旋3启动向湿混机5 " + valueSet); - ManualLogControl("螺旋3启动向湿混机5", valueSet, 3, 5, 2); + LjManualLog.ManualLogControl("螺旋3启动向湿混机5", valueSet, 3, 5, 2); + LogSelect(""); break; case 6: if (valueSet > 350) @@ -1258,7 +1287,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl PlcControl("DB2119.102.0", 2); PlcControl("DB2119.104.0", true); MesnacServiceManager.Instance.LoggingService.Info("螺旋3启动向湿混机6 " + valueSet); - ManualLogControl("螺旋3启动向湿混机6", valueSet, 3, 6, 2); + LjManualLog.ManualLogControl("螺旋3启动向湿混机6", valueSet, 3, 6, 2); + LogSelect(""); break; default: MessageBox.Show("请选择一个湿混机!"); @@ -1325,7 +1355,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl { PlcControl("DB2119.60.1", true); MesnacServiceManager.Instance.LoggingService.Info("螺旋1已手动停止"); - ManualLogControl("螺旋1已手动停止"); + LjManualLog.ManualLogControl("螺旋1已手动停止"); + LogSelect(""); MessageBox.Show("螺旋1已停止!"); } @@ -1333,7 +1364,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl { PlcControl("DB2119.82.1", true); MesnacServiceManager.Instance.LoggingService.Info("螺旋2已手动停止"); - ManualLogControl("螺旋2已手动停止"); + LjManualLog.ManualLogControl("螺旋2已手动停止"); + LogSelect(""); MessageBox.Show("螺旋2已停止!"); } @@ -1341,7 +1373,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl { PlcControl("DB2119.104.1", true); MesnacServiceManager.Instance.LoggingService.Info("螺旋3已手动停止"); - ManualLogControl("螺旋3已手动停止"); + LjManualLog.ManualLogControl("螺旋3已手动停止"); + LogSelect(""); MessageBox.Show("螺旋3已停止!"); } @@ -1361,7 +1394,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl if (WetRequest1 == runtime.Sender) { string key = keywords.MCValue.ToString(); - ManualLogSelect(key); + LogSelect(key); } @@ -1426,7 +1459,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl //Setting.Default.SetSpiralValue3 = value7; //Setting.Default.SetSpiralValue4 = value8; MesnacServiceManager.Instance.LoggingService.Info("配置已保存"); - ManualLogControl("配置已保存 " + value1 + value2 + value3 + value4 + value5 + value6 + value7 + value8); + LjManualLog.ManualLogControl("配置已保存 " + value1 + value2 + value3 + value4 + value5 + value6 + value7 + value8); + LogSelect(""); } } @@ -1448,7 +1482,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl SetSpiralValue3.MCValue = table.Where(x => x.SettingName == "SpiralValue3").LastOrDefault().Value; SetSpiralValue4.MCValue = table.Where(x => x.SettingName == "SpiralValue4").LastOrDefault().Value; MesnacServiceManager.Instance.LoggingService.Info("配置已加载"); - ManualLogControl("配置已加载 "); + LjManualLog.ManualLogControl("配置已加载 "); + LogSelect(""); } #endregion @@ -1543,7 +1578,8 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl } MessageBox.Show(txt); - ManualLogControl(txt); + LjManualLog.ManualLogControl(txt); + LogSelect(""); MesnacServiceManager.Instance.LoggingService.Info(txt); } @@ -1564,13 +1600,16 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl Thread.Sleep(100); if (PlcConnect.Instance.Write(address, binNo).IsSuccess) { - ManualLogControl("第 " + (i + 1) + " 次重发测试成功"); + LjManualLog.ManualLogControl("第 " + (i + 1) + " 次重发测试成功"); + LogSelect(""); return; } - ManualLogControl("第 " + (i + 1) + " 次重发测试失败"); + LjManualLog.ManualLogControl("第 " + (i + 1) + " 次重发测试失败"); + LogSelect(""); } MessageBox.Show(address + "写入失败!"); - ManualLogControl("PLC写入失败!"); + LjManualLog.ManualLogControl("PLC写入失败!"); + LogSelect(""); } } private void PlcControl(string address, bool state) @@ -1586,13 +1625,16 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl Thread.Sleep(100); if (PlcConnect.Instance.Write(address, state).IsSuccess) { - ManualLogControl("第 " + (i + 1) + " 次重发测试成功"); + LjManualLog.ManualLogControl("第 " + (i + 1) + " 次重发测试成功"); + LogSelect(""); return; } - ManualLogControl("第 " + (i + 1) + " 次重发测试失败"); + LjManualLog.ManualLogControl("第 " + (i + 1) + " 次重发测试失败"); + LogSelect(""); } MessageBox.Show(address + "写入失败!"); - ManualLogControl("PLC写入失败!"); + LjManualLog.ManualLogControl("PLC写入失败!"); + LogSelect(""); } } @@ -1617,17 +1659,9 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl /// 日志查询 /// /// 查询关键字 - private void ManualLogSelect(string txt) + private void LogSelect(string txt) { - string sql = "select top 500 id, logtext, logtime, value from Manual_Log "; - - if (!string.IsNullOrEmpty(txt)) - { - sql += $" where logtext like '%{txt}%'"; - } - - sql += " order by id desc"; - DataTable table = DBHelp.GetTable(sql); + DataTable table = LjManualLog.ManualLogSelect(txt); if (this.materialGridControl != null && this.materialGridControl.BaseControl != null) { @@ -1641,72 +1675,7 @@ namespace Mesnac.Action.ChemicalWeighing.ManualControl } /// - /// 日志插入 - /// - /// 日志内容 - /// 值 - /// 值类型 0无 1水称设定值 2水称称量值 3螺旋设定值 4螺旋称量值 - /// 设备编号 - /// 设备类型 0无 1水称 2螺旋 - private void ManualLogControl(string logName, int value, int valuekind, int deviceno, int devicekind) - { - var Log = new ManualLogEntity() - { - logtext = logName, - logtime = DateTime.Now, - userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName, - value = value, - deviceno = deviceno, - devicekind = devicekind, - valuekind = valuekind, - createdate = DateTime.Now.ToString("yyyyMMdd") - }; - - FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity(); - - ManualLogSelect(""); - } - - private void ManualLogControl(string logName, int deviceno, int devicekind) - { - var Log = new ManualLogEntity() - { - logtext = logName, - logtime = DateTime.Now, - userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName, - value = 0, - deviceno = deviceno, - devicekind = devicekind, - valuekind = 0, - createdate = DateTime.Now.ToString("yyyyMMdd") - }; - - FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity(); - - ManualLogSelect(""); - } - - private void ManualLogControl(string logName) - { - var Log = new ManualLogEntity() - { - logtext = logName, - logtime = DateTime.Now, - userid = string.IsNullOrWhiteSpace(UserInfo.Instance.UserName) ? "Edit" : UserInfo.Instance.UserName, - value = 0, - deviceno = 0, - devicekind = 0, - valuekind = 0, - createdate = DateTime.Now.ToString("yyyyMMdd") - }; - - FreeSqlUnit.Instance.Insert(Log).ExecuteIdentity(); - - ManualLogSelect(""); - } - - /// - /// + /// 冷热水交替记录 /// /// /// 1是热水 2是冷水 0为空 diff --git a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj index 908cbb8..e21bb17 100644 --- a/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj +++ b/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Mesnac.Action.ChemicalWeighing.csproj @@ -556,6 +556,7 @@ + True