ClientCache.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using GDNXFD.Data;
  4. namespace IntelligentControlForsx
  5. {
  6. public class ClientCache
  7. {
  8. private AlertServiceClient asc = null;
  9. public IList<AlertSnap> AlertSnaps { get; set; }
  10. public Dictionary<string, AlarmGroupModel> AlarmGroups { get; set; }
  11. public IList<ShutdownEvent> ShutdownEvents { get; set; }
  12. //光字牌分组统计,key: 光字牌ID
  13. public Dictionary<string, LightPlateModel> LPModels { get; set; }
  14. #region 单例模式
  15. private ClientCache()
  16. {
  17. }
  18. public static ClientCache Instance
  19. {
  20. get { return SingletonCreator.instance; }
  21. }
  22. class SingletonCreator
  23. {
  24. internal static readonly ClientCache instance = new ClientCache();
  25. }
  26. #endregion
  27. #region 数据字典
  28. public IList<DictItem> DataDict { get; set; }
  29. public IList<DictItem> GetDataDictByCategory(string category)
  30. {
  31. if (DataDict != null)
  32. {
  33. var tmp = DataDict.Where(c => c.Category == category && c.Enabled);
  34. if (tmp != null)
  35. return tmp.OrderBy(c => c.OrderNo).ToList();
  36. }
  37. return null;
  38. }
  39. #endregion
  40. #region 风机数据
  41. private IList<WindTurbine> wtList;
  42. private IList<WindPowerStation> stList;
  43. private IList<Project> prjList;
  44. private IList<Line> lnList;
  45. public IList<WindTurbine> WindturbineList
  46. {
  47. get
  48. {
  49. if (wtList == null)
  50. {
  51. if (asc == null)
  52. asc = AlertServiceClientFactory.CreateAlertServiceClient();
  53. wtList = asc.GetFDCWindturbinies();
  54. }
  55. return wtList;
  56. }
  57. set
  58. {
  59. wtList = value;
  60. }
  61. }
  62. public IList<WindPowerStation> StationList
  63. {
  64. get
  65. {
  66. if (stList == null)
  67. {
  68. if (asc == null)
  69. asc = AlertServiceClientFactory.CreateAlertServiceClient();
  70. stList = asc.GetWindPowerStations();
  71. }
  72. return stList;
  73. }
  74. set
  75. {
  76. stList = value;
  77. }
  78. }
  79. public IList<Project> ProjectList
  80. {
  81. get
  82. {
  83. if (prjList == null)
  84. {
  85. if (asc == null)
  86. asc = AlertServiceClientFactory.CreateAlertServiceClient();
  87. prjList = asc.GetProjects();
  88. }
  89. return prjList;
  90. }
  91. set
  92. {
  93. prjList = value;
  94. }
  95. }
  96. public IList<Line> LineList
  97. {
  98. get
  99. {
  100. if (lnList == null)
  101. {
  102. if (asc == null)
  103. asc = AlertServiceClientFactory.CreateAlertServiceClient();
  104. lnList = asc.GetLines();
  105. }
  106. return lnList;
  107. }
  108. set
  109. {
  110. lnList = value;
  111. }
  112. }
  113. #endregion
  114. }
  115. }