VpwMainItemManager.cs 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. using Aitex.Core.RT.DataCenter;
  2. using Aitex.Core.Util;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Xml;
  9. namespace MECF.Framework.Common.ToolLayout
  10. {
  11. public class VpwMainItemManager : Singleton<VpwMainItemManager>
  12. {
  13. #region 常量
  14. /// <summary>
  15. /// 前缀
  16. /// </summary>
  17. private const string PREFIX = "VPWMain";
  18. #endregion
  19. #region 内部变量
  20. /// <summary>
  21. /// 字典
  22. /// </summary>
  23. private Dictionary<string,VpwMainItem> _vpwMainItemDictionary=new Dictionary<string, VpwMainItem>();
  24. #endregion
  25. #region 属性
  26. /// <summary>
  27. /// 已经安装模块
  28. /// </summary>
  29. public List<string> InstalledModules { get; private set; } = new List<string>();
  30. #endregion
  31. /// <summary>
  32. /// VpwMain
  33. /// </summary>
  34. /// <param name="rinservoirElement"></param>
  35. public void InitializeVpwMainItem(XmlElement mainElement)
  36. {
  37. VpwMainItem vpwMainItem = new VpwMainItem();
  38. vpwMainItem.Installed = bool.Parse(mainElement.SelectSingleNode("Installed").InnerText);
  39. vpwMainItem.VpwMainID = int.Parse(mainElement.SelectSingleNode("VpwMainID").InnerText);
  40. vpwMainItem.SubType = mainElement.SelectSingleNode("SubType").InnerText;
  41. string key = $"{PREFIX}{vpwMainItem.VpwMainID}";
  42. vpwMainItem.VpwCells = new List<VpwCellItem>();
  43. XmlNodeList itemsNode = mainElement.SelectNodes("Cells/Item");
  44. List<string> metals = new List<string>();
  45. foreach (var item in itemsNode)
  46. {
  47. XmlElement element = item as XmlElement;
  48. VpwCellItem metalItem = VpwCellItemManager.Instance.InitializeVpwCellItem(element);
  49. VpwCellItemManager.Instance.AddCellItem(metalItem);
  50. vpwMainItem.VpwCells.Add(metalItem);
  51. }
  52. if (vpwMainItem.Installed && !InstalledModules.Contains(key))
  53. {
  54. InstalledModules.Add(key);
  55. }
  56. _vpwMainItemDictionary[key] = vpwMainItem;
  57. }
  58. /// <summary>
  59. /// 获取对象
  60. /// </summary>
  61. /// <param name="moduleName"></param>
  62. /// <returns></returns>
  63. public VpwMainItem GetItem(string moduleName)
  64. {
  65. return _vpwMainItemDictionary.ContainsKey(moduleName) ? _vpwMainItemDictionary[moduleName] : null;
  66. }
  67. }
  68. }