12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Xml;
- using Aitex.Common.Util;
- using Aitex.Core.RT.Log;
- using Aitex.Core.Util;
- namespace Aitex.Triton160.UI.Config
- {
- class SystemConfigManager : Singleton<SystemConfigManager>
- {
- private XmlDocument _domLocal = new XmlDocument();
- private XmlDocument _domDefault = new XmlDocument();
- public void Initialize()
- {
- try
- {
- string fileNameLocal = PathManager.GetCfgDir() + "\\SystemConfig.xml";
- if (File.Exists(fileNameLocal))
- {
- _domLocal.Load(fileNameLocal);
- }
- string fileNameDefault = PathManager.GetCfgDir() + "\\SystemConfig.default.xml";
- if (File.Exists(fileNameDefault))
- {
- _domDefault.Load(fileNameDefault);
- }
- if (!File.Exists(fileNameDefault) && !File.Exists(fileNameLocal))
- throw new ApplicationException(string.Format("did not find the system config file {0} ", fileNameLocal));
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- throw;
- }
- }
- public string GetUiLayoutXmlFile()
- {
- return GetValue("/SystemConfig/uiLayoutXmlFile");
- }
- public string GetTopviewLogoFile()
- {
- return GetValue("/SystemConfig/topViewLogoFile");
- }
- string GetValue(string path)
- {
- XmlElement node =
- _domLocal.SelectSingleNode(path) as XmlElement;
- if (node == null)
- {
- node =
- _domDefault.SelectSingleNode(path) as XmlElement;
- }
- if (node == null)
- return null;
- return node.GetAttribute("value");
- }
-
- //dbName, displayName, cnName, isPressureAxis
- public List<Tuple<string, string, string, bool>> GetMonitorDataList()
- {
- List<Tuple<string, string, string, bool>> lstResult = new List<Tuple<string, string, string, bool>>();
- XmlNodeList nodeList = _domLocal.SelectNodes("/SystemConfig/DataElements/DataElement");
- if (nodeList == null || nodeList.Count==0)
- {
- nodeList = _domDefault.SelectNodes("/SystemConfig/DataElements/DataElement");
- }
- if (nodeList != null)
- {
- foreach (XmlElement dataXmlElement in nodeList)
- {
- lstResult.Add(Tuple.Create(dataXmlElement.GetAttribute("dbName"),
- dataXmlElement.GetAttribute("displayName"),
- dataXmlElement.GetAttribute("cn"),
- !string.IsNullOrEmpty(dataXmlElement.GetAttribute("isPressureAxis")) && bool.Parse(dataXmlElement.GetAttribute("isPressureAxis"))));
- }
- }
- return lstResult;
- }
- }
- }
|