using System; using System.Collections.Generic; using System.Data; using Aitex.Core.RT.DBCore; using CyberX8_Core; namespace MECF.Framework.Common.DBCore { public class LeakCheckDataRecorder { public static void Add(int leakCheckTime, double beginPressure, double endPressure, double leakRate, string status, string mode,string moduleName,string gaslines="") { string sql = string.Format( "INSERT INTO \"leak_check_data\"(\"guid\", \"operate_time\", \"status\" , \"leak_rate\", \"start_pressure\", \"stop_pressure\", \"mode\", \"leak_check_time\" , \"module_name\", \"gasline_selection\")VALUES ('{0}', '{1}', '{2}', '{3}', '{4}', '{5}', '{6}', '{7}','{8}','{9}' );", Guid.NewGuid(), DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"), status, leakRate, beginPressure, endPressure, mode, leakCheckTime, moduleName, gaslines); DB.Insert(sql); } public static List GetAllLeakCheckData(string moduleName) { List result = new List(); string sql = $"SELECT * FROM \"leak_check_data\" where \"module_name\"='{moduleName}' order by operate_time desc LIMIT 15"; DataSet ds = DB.ExecuteDataset(sql); if (ds == null) return result; if (ds.Tables.Count==0) return result; for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { PMLeakCheckResult checkresult = new PMLeakCheckResult(); checkresult.CheckDate= ds.Tables[0].Rows[i]["operate_time"].ToString(); checkresult.StartPressure =Convert.ToDouble( ds.Tables[0].Rows[i]["start_pressure"].ToString()); checkresult.EndPressure = Convert.ToDouble(ds.Tables[0].Rows[i]["stop_pressure"].ToString()); checkresult.LeakCheckTime = Convert.ToInt32(ds.Tables[0].Rows[i]["leak_check_time"].ToString()); checkresult.LeakRate = Convert.ToDouble(ds.Tables[0].Rows[i]["leak_rate"].ToString()); checkresult.CheckMode = ds.Tables[0].Rows[i]["mode"].ToString(); checkresult.GasLines = ds.Tables[0].Rows[i]["gasline_selection"].ToString(); checkresult.Result = ds.Tables[0].Rows[i]["status"].ToString(); result.Add(checkresult); } ds.Clear(); return result; } } }