using Mesnac.Action.ChemicalWeighing.FreeDb; using Mesnac.Action.ChemicalWeighing.LjMaterial; using Mesnac.Action.ChemicalWeighing.Report.Entity; 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.Report { /// /// 配料日志 /// public class LjLogControl { /// /// 通过内容查询日志 /// /// 查询关键字 public static DataTable ManualLogSelect(string txt) { string sql; if (!string.IsNullOrEmpty(txt)) { sql = BaseSelect($"where logtext like '%{txt}%'"); } else { sql = BaseSelect(""); } return DBHelp.GetTable(sql); } /// /// 通过内容和机台号查询日志 /// /// 查询关键字 public static DataTable ManualLogSelect(string txt, int deviceNo) { string sql; if (deviceNo == 0) { return ManualLogSelect(txt); } else { sql = BaseSelect($"where deviceNo = {deviceNo} and logtext like '%{txt}%'"); return DBHelp.GetTable(sql); } } /// /// 通过时间查询日志 /// /// 查询关键字 public static DataTable ManualLogSelect(string startTime, string endTime) { string sql = BaseSelect($"where logtime BETWEEN '{startTime}' AND '{endTime}'"); return DBHelp.GetTable(sql); } private static string BaseSelect(string sql) { string s = "select top 500 id, logtext, logtime, value, deviceno from Manual_Log " + sql + " order by id desc"; return s; } /// /// 完整手动日志插入 /// /// 日志内容 /// 值 /// 值类型 0无 1水称设定值 2水称称量值 3螺旋设定值 4螺旋称量值 /// 设备编号 /// 设备类型 0无 1水称 2螺旋 3糊化 public static void ManualLogControl(string logName, int value, int valuekind, int deviceno, int devicekind) { var Log = new LjLogEntity() { 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 LjLogEntity() { 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 LjLogEntity() { 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(); } } }