LeakCheckDataRecorder.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Data;
  4. using Aitex.Core.RT.DBCore;
  5. using CyberX8_Core;
  6. namespace MECF.Framework.Common.DBCore
  7. {
  8. public class LeakCheckDataRecorder
  9. {
  10. public static void Add(int leakCheckTime, double beginPressure, double endPressure, double leakRate, string status, string mode,string moduleName,string gaslines="")
  11. {
  12. string sql = string.Format(
  13. "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}' );",
  14. Guid.NewGuid(),
  15. DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff"),
  16. status,
  17. leakRate,
  18. beginPressure,
  19. endPressure,
  20. mode,
  21. leakCheckTime,
  22. moduleName,
  23. gaslines);
  24. DB.Insert(sql);
  25. }
  26. public static List<PMLeakCheckResult> GetAllLeakCheckData(string moduleName)
  27. {
  28. List<PMLeakCheckResult> result = new List<PMLeakCheckResult>();
  29. string sql = $"SELECT * FROM \"leak_check_data\" where \"module_name\"='{moduleName}' order by operate_time desc LIMIT 15";
  30. DataSet ds = DB.ExecuteDataset(sql);
  31. if (ds == null)
  32. return result;
  33. if (ds.Tables.Count==0)
  34. return result;
  35. for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
  36. {
  37. PMLeakCheckResult checkresult = new PMLeakCheckResult();
  38. checkresult.CheckDate= ds.Tables[0].Rows[i]["operate_time"].ToString();
  39. checkresult.StartPressure =Convert.ToDouble( ds.Tables[0].Rows[i]["start_pressure"].ToString());
  40. checkresult.EndPressure = Convert.ToDouble(ds.Tables[0].Rows[i]["stop_pressure"].ToString());
  41. checkresult.LeakCheckTime = Convert.ToInt32(ds.Tables[0].Rows[i]["leak_check_time"].ToString());
  42. checkresult.LeakRate = Convert.ToDouble(ds.Tables[0].Rows[i]["leak_rate"].ToString());
  43. checkresult.CheckMode = ds.Tables[0].Rows[i]["mode"].ToString();
  44. checkresult.GasLines = ds.Tables[0].Rows[i]["gasline_selection"].ToString();
  45. checkresult.Result = ds.Tables[0].Rows[i]["status"].ToString();
  46. result.Add(checkresult);
  47. }
  48. ds.Clear();
  49. return result;
  50. }
  51. }
  52. }