RelationComputerData.cs 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. using SAGA.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace SAGA.GplotRelationComputerManage
  8. {
  9. /*
  10. * 为了控制属性的安全想,想计算数据分为保存数据,和加载数据
  11. */
  12. /// <summary>
  13. /// 关系计算数据
  14. /// </summary>
  15. public class RelationComputerData
  16. {
  17. public RelationComputerData(string relationType)
  18. {
  19. this.RelationType = relationType;
  20. }
  21. /// <summary>
  22. /// 关系类型
  23. /// </summary>
  24. public string RelationType { get; protected set; }
  25. /// <summary>
  26. /// 获取当前关系类型的通用键值
  27. /// </summary>
  28. /// <param name="commonKey"></param>
  29. /// <returns></returns>
  30. public string RealKey(string commonKey)
  31. {
  32. return ComputerFileSetting.GetRealKey(RelationType, commonKey);
  33. }
  34. }
  35. /// <summary>
  36. /// 保存的计算数据类型
  37. /// </summary>
  38. public class SaveComputerData : RelationComputerData
  39. {
  40. public SaveComputerData(string relationType) : base(relationType)
  41. {
  42. Init();
  43. }
  44. /// <summary>
  45. /// 初始化集合字段
  46. /// </summary>
  47. private void Init()
  48. {
  49. VerticalPipes = new List<VerticalPipe>();
  50. Levels = new List<LevelData>();
  51. FloorDrawRecords = new List<FloorDrawRecord>();
  52. FloorRelationRecords = new List<FloorRelationRecord>();
  53. MachineRoomDrawRecords = new List<MachineRoomDrawRecord>();
  54. MachineRoomRelationRecords = new List<MachineRoomRelationRecord>();
  55. }
  56. #region 存储数据
  57. public List<VerticalPipe> VerticalPipes { get; private set; }
  58. public List<LevelData> Levels { get; private set; }
  59. public List<FloorDrawRecord> FloorDrawRecords { get; protected set; }
  60. public List<FloorRelationRecord> FloorRelationRecords { get; protected set; }
  61. public List<MachineRoomDrawRecord> MachineRoomDrawRecords { get; protected set; }
  62. public List<MachineRoomRelationRecord> MachineRoomRelationRecords { get; protected set; }
  63. #endregion
  64. /// <summary>
  65. /// 保存立面数据
  66. /// </summary>
  67. public void SaveData()
  68. {
  69. DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.FloorDraw), FloorDrawRecords);
  70. DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.FloorRelation), FloorRelationRecords);
  71. DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.MachineRoomDraw), MachineRoomDrawRecords);
  72. DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.MachineRoomRelation), MachineRoomRelationRecords);
  73. var result = SystemParseManager.ComputerVerticalData(VerticalPipes, Levels);
  74. DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.VerticalDraw), result.DrawData);
  75. DataServerUtil.Current.SaveData(RealKey(ComputerFileSetting.VerticalRelation), result.RelationData);
  76. }
  77. }
  78. /// <summary>
  79. /// 加载的关系数据
  80. /// </summary>
  81. public class LoadRelationData : RelationComputerData
  82. {
  83. public LoadRelationData(string relationType) : base(relationType)
  84. {
  85. FloorRelationRecords = new List<FloorRelationRecord>();
  86. VerticalRelationRecords = new List<VerticalRelationRecord>();
  87. MachineRoomRelationRecords = new List<MachineRoomRelationRecord>();
  88. }
  89. #region 存储数据
  90. public List<FloorRelationRecord> FloorRelationRecords { get; protected set; }
  91. public List<MachineRoomRelationRecord> MachineRoomRelationRecords { get; protected set; }
  92. public List<VerticalRelationRecord> VerticalRelationRecords { get; private set; }
  93. #endregion
  94. #region 数据的保存加载
  95. /// <summary>
  96. /// 加载计算数据
  97. /// </summary>
  98. public void LoadData()
  99. {
  100. FloorRelationRecords = DataServerUtil.Current.LoadData<List<FloorRelationRecord>>(RealKey(ComputerFileSetting.FloorRelation));
  101. MachineRoomRelationRecords = DataServerUtil.Current.LoadData<List<MachineRoomRelationRecord>>(RealKey(ComputerFileSetting.MachineRoomRelation));
  102. VerticalRelationRecords = DataServerUtil.Current.LoadData<List<VerticalRelationRecord>>(RealKey(ComputerFileSetting.VerticalRelation));
  103. }
  104. #endregion
  105. }
  106. /// <summary>
  107. /// 加载平面展示数据
  108. /// </summary>
  109. public class LoadFloorDrawData : RelationComputerData
  110. {
  111. public LoadFloorDrawData(string relationType) : base(relationType)
  112. {
  113. FloorDrawRecords = new List<FloorDrawRecord>();
  114. }
  115. #region 存储数据
  116. public List<FloorDrawRecord> FloorDrawRecords { get; protected set; }
  117. #endregion
  118. #region 数据的保存加载
  119. /// <summary>
  120. /// 加载计算数据
  121. /// </summary>
  122. public void LoadData()
  123. {
  124. FloorDrawRecords = DataServerUtil.Current.LoadData<List<FloorDrawRecord>>(RealKey(ComputerFileSetting.FloorDraw));
  125. }
  126. #endregion
  127. }
  128. /// <summary>
  129. /// 加载机房展示数据
  130. /// </summary>
  131. public class LoadMachineRoomDrawData : RelationComputerData
  132. {
  133. public LoadMachineRoomDrawData(string relationType) : base(relationType)
  134. {
  135. MachineRoomDrawRecords = new List<MachineRoomDrawRecord>();
  136. }
  137. public List<MachineRoomDrawRecord> MachineRoomDrawRecords { get; protected set; }
  138. #region 数据的保存加载
  139. /// <summary>
  140. /// 加载计算数据
  141. /// </summary>
  142. public void LoadData()
  143. {
  144. MachineRoomDrawRecords = DataServerUtil.Current.LoadData<List<MachineRoomDrawRecord>>(RealKey(ComputerFileSetting.MachineRoomDraw));
  145. }
  146. #endregion
  147. }
  148. /// <summary>
  149. /// 加载立面展示
  150. /// </summary>
  151. public class LoadVerticalDrawData : RelationComputerData
  152. {
  153. public LoadVerticalDrawData(string relationType) : base(relationType)
  154. {
  155. VerticalDrawData = new VerticalDrawData();
  156. }
  157. #region 存储数据
  158. public VerticalDrawData VerticalDrawData { get; protected set; }
  159. #endregion
  160. /// <summary>
  161. /// 加载计算数据
  162. /// </summary>
  163. public void LoadData()
  164. {
  165. VerticalDrawData = DataServerUtil.Current.LoadData<VerticalDrawData>(RealKey(ComputerFileSetting.VerticalDraw));
  166. }
  167. }
  168. }