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 { 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> GetMonitorDataList() { List> lstResult = new List>(); 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; } } }