1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- using Aitex.Core.Util;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Xml;
- namespace MECF.Framework.Common.ToolLayout
- {
- public class BarcodeReaderItemManager : Singleton<BarcodeReaderItemManager>
- {
- #region 常量
- /// <summary>
- /// 前缀
- /// </summary>
- private const string PREFIX = "BR";
- #endregion
- #region 内部变量
- /// <summary>
- /// 字典
- /// </summary>
- private Dictionary<string, BarcodeReaderItem> _moduleItemDictionary = new Dictionary<string, BarcodeReaderItem>();
- #endregion
- #region 属性
- /// <summary>
- /// 已经安装模块
- /// </summary>
- public List<string> InstalledModules { get; private set; } = new List<string>();
- #endregion
- /// <summary>
- /// 初始化
- /// </summary>
- /// <param name="xmlElement"></param>
- public void InitializeItem(XmlElement xmlElement)
- {
- BarcodeReaderItem rpItem = new BarcodeReaderItem();
- rpItem.Installed = bool.Parse(xmlElement.SelectSingleNode("Installed").InnerText);
- rpItem.BarcodeReaderID = int.Parse(xmlElement.SelectSingleNode("BarcodeReaderID").InnerText);
- rpItem.Count = int.Parse(xmlElement.SelectSingleNode("Count").InnerText);
- string key = $"{PREFIX}{rpItem.BarcodeReaderID}";
- if (rpItem.Installed && !InstalledModules.Contains(key))
- {
- InstalledModules.Add(key);
- }
- _moduleItemDictionary[key] = rpItem;
- }
- /// <summary>
- /// 获取BarcodeReader项
- /// </summary>
- /// <returns></returns>
- public BarcodeReaderItem GetBarcodeReaderItem(string moduleName)
- {
- return _moduleItemDictionary.ContainsKey(moduleName) ? _moduleItemDictionary[moduleName] : null;
- }
- }
- }
|