123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- using Aitex.Common.Util;
- using Aitex.Core.RT.DataCenter;
- using Aitex.Core.RT.Log;
- using Aitex.Core.RT.OperationCenter;
- using Aitex.Core.Util;
- using Aitex.Core.WCF;
- using MECF.Framework.Common.Account;
- using MECF.Framework.Common.Event;
- using MECF.Framework.Common.FAServices;
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.ServiceModel;
- using System.Xml;
- namespace Aitex.Core.RT.Event
- {
- public class DisplayManager : Singleton<DisplayManager>
- {
- public Dictionary<string, string> DisplayDict { get; set; } = new Dictionary<string, string>();
- public Dictionary<string, string> ProcessDetailDisplayDict { get; set; } = new Dictionary<string, string>();
- private string _displayReplaceFile = PathManager.GetCfgDir() + "DisplayReplace.xml";
- private object _displayDicLocker = new object();
- public DisplayManager()
- {
- }
- public void Initialize()
- {
- Initialize(_displayReplaceFile);
- DATA.Subscribe($"System.Display", () => DisplayDict);
- DATA.Subscribe($"System.ProcessDetailDisplay", () => ProcessDetailDisplayDict);
- }
- public void Initialize(string ListXmlFile)
- {
- try
- {
- if (!string.IsNullOrEmpty(ListXmlFile))
- {
- lock (_displayDicLocker)
- {
- BuildItems(ListXmlFile);
- }
- }
- }
- catch (Exception ex)
- {
- throw new ApplicationException("DisplayReplace," + ListXmlFile + ",\r\n" + ex.Message);
- }
- }
- private void BuildItems(string xmlFile)
- {
- Dictionary<string, string> values = new Dictionary<string, string>();
- try
- {
- if (File.Exists(xmlFile))
- {
- XmlDocument xml = new XmlDocument();
- xml.Load(xmlFile);
- XmlNodeList node = xml.SelectNodes("Displays/HistoryGroup");
- foreach (XmlElement AlarmTable in node)
- {
- XmlNodeList nodeList = AlarmTable.SelectNodes("Display");
- foreach (XmlElement nodeCategory in nodeList)
- {
- string name = nodeCategory.GetAttribute("Name");
- if (DisplayDict.ContainsKey(name))
- {
- DisplayDict[name] = nodeCategory.GetAttribute("DisplayName");
- }
- else
- {
- DisplayDict.Add(name, nodeCategory.GetAttribute("DisplayName"));
- }
- }
- }
- node = xml.SelectNodes("Displays/DetailGroup");
- foreach (XmlElement AlarmTable in node)
- {
- XmlNodeList nodeList = AlarmTable.SelectNodes("Display");
- foreach (XmlElement nodeCategory in nodeList)
- {
- string name = nodeCategory.GetAttribute("Name");
- if (ProcessDetailDisplayDict.ContainsKey(name))
- {
- ProcessDetailDisplayDict[name] = nodeCategory.GetAttribute("DisplayName");
- }
- else
- {
- ProcessDetailDisplayDict.Add(name, nodeCategory.GetAttribute("DisplayName"));
- }
- }
- }
- }
- }
- catch (Exception ex)
- {
- LOG.Write(ex);
- }
- }
- }
- }
|