SystemConfigManager.cs 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. using System;
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Xml;
  8. using Aitex.Common.Util;
  9. using Aitex.Core.RT.Log;
  10. using Aitex.Core.Util;
  11. using MECF.Framework.Common.DataCenter;
  12. namespace EfemDualUI.Config
  13. {
  14. class SystemConfigManager : Singleton<SystemConfigManager>
  15. {
  16. public List<Tuple<string, string, string, bool>> PMAMonitorDataList = new List<Tuple<string, string, string, bool>>();
  17. public List<Tuple<string, string, string, bool>> PMBMonitorDataList = new List<Tuple<string, string, string, bool>>();
  18. private XmlDocument _domADefault = new XmlDocument();
  19. private XmlDocument _domBDefault = new XmlDocument();
  20. public void Initialize()
  21. {
  22. try
  23. {
  24. if (File.Exists(PathManager.GetCfgDir() + "\\SystemConfigA.default.xml"))
  25. {
  26. _domADefault.Load(PathManager.GetCfgDir() + "\\SystemConfigA.default.xml");
  27. }
  28. if (File.Exists(PathManager.GetCfgDir() + "\\SystemConfigB.default.xml"))
  29. {
  30. _domBDefault.Load(PathManager.GetCfgDir() + "\\SystemConfigB.default.xml");
  31. }
  32. GetMonitorDataList();
  33. }
  34. catch (Exception ex)
  35. {
  36. LOG.Write(ex);
  37. throw;
  38. }
  39. }
  40. //dbName, displayName, cnName, isPressureAxis
  41. public List<Tuple<string, string, string, bool>> GetMonitorDataList()
  42. {
  43. PMAMonitorDataList = new List<Tuple<string, string, string, bool>>();
  44. XmlNodeList nodeAList = _domADefault.SelectNodes("/SystemConfig/DataElements/DataElement");
  45. if (nodeAList != null)
  46. {
  47. foreach (XmlElement dataXmlElement in nodeAList)
  48. {
  49. PMAMonitorDataList.Add(Tuple.Create(dataXmlElement.GetAttribute("dbName"),
  50. dataXmlElement.GetAttribute("displayName"),
  51. dataXmlElement.GetAttribute("cn"),
  52. !string.IsNullOrEmpty(dataXmlElement.GetAttribute("isPressureAxis")) && bool.Parse(dataXmlElement.GetAttribute("isPressureAxis"))));
  53. }
  54. }
  55. PMBMonitorDataList = new List<Tuple<string, string, string, bool>>();
  56. XmlNodeList nodeBList = _domBDefault.SelectNodes("/SystemConfig/DataElements/DataElement");
  57. if (nodeBList != null)
  58. {
  59. foreach (XmlElement dataXmlElement in nodeBList)
  60. {
  61. PMBMonitorDataList.Add(Tuple.Create(dataXmlElement.GetAttribute("dbName"),
  62. dataXmlElement.GetAttribute("displayName"),
  63. dataXmlElement.GetAttribute("cn"),
  64. !string.IsNullOrEmpty(dataXmlElement.GetAttribute("isPressureAxis")) && bool.Parse(dataXmlElement.GetAttribute("isPressureAxis"))));
  65. }
  66. }
  67. return PMAMonitorDataList.Union(PMBMonitorDataList).ToList();
  68. }
  69. }
  70. }