SystemComputerContext.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:SystemComputerContext
  3. * 作者:xulisong
  4. * 创建时间: 2019/1/4 17:52:22
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using Autodesk.Revit.DB.Mechanical;
  10. using SAGA.DotNetUtils.Cache;
  11. using SAGA.Models;
  12. using SAGA.RevitUtils;
  13. using MBIEquipItem = SAGA.Models.EquipmentItem;
  14. namespace SAGA.GplotRelationComputerManage
  15. {
  16. public class SystemComputerContext
  17. {
  18. public SystemComputerContext()
  19. {
  20. #region 初始化
  21. FloorItems = SystemCalcUtil.CreateFloorItems();
  22. Rooms = SystemCalcUtil.CreateRoomItems();
  23. RelationShells = SystemCalcUtil.CreateRelationShellItems();
  24. EquipmentItems = SystemCalcUtil.CreateEquipmentItems();
  25. VerticalPipes = new List<VerticalPipe>();
  26. Levels = new List<LevelData>();
  27. Relations = new List<string>();
  28. FloorDrawRecords = new List<FloorDrawRecord>();
  29. FloorRelationRecords = new List<FloorRelationRecord>();
  30. MachineRoomDrawRecords = new List<MachineRoomDrawRecord>();
  31. MachineRoomRelationRecords = new List<MachineRoomRelationRecord>();
  32. #endregion
  33. }
  34. #region 计算缓存对象
  35. /// <summary>
  36. /// 缓存空间对象
  37. /// </summary>
  38. public CacheItems<string, RoomItem> Rooms { get; private set; }
  39. /// <summary>
  40. /// 楼层系统数据缓存
  41. /// </summary>
  42. public CacheItems<string, FloorSystemItem> FloorItems { get; private set; }
  43. public CacheItems<string, MBIEquipItem> EquipmentItems { get; private set; }
  44. #endregion
  45. #region 一些上下文相关的方法
  46. private const string UnKnowSpace = "未知空间:BIMID编码";
  47. private const string SiSpace = "空间本地名称:BIMID编码";
  48. private const string ModelSpace = "空间模型名称:BIMID编码";
  49. /// <summary>
  50. /// 获取空间描述信息,立管使用
  51. /// </summary>
  52. /// <param name="space"></param>
  53. /// <param name="tip"></param>
  54. /// <returns></returns>
  55. public string GetSpaceDisplay(Space space, out string tip)
  56. {
  57. tip = string.Empty;
  58. if (space == null)
  59. {
  60. tip = UnKnowSpace;
  61. return "未知";
  62. }
  63. string bimId = space.GetBimId();
  64. var room = Rooms.GetItem(bimId);
  65. string useName = space.Name;
  66. tip = ModelSpace;
  67. if (room != null && !string.IsNullOrWhiteSpace(room.LocalName))
  68. {
  69. tip = SiSpace;
  70. useName = room.LocalName;
  71. }
  72. return useName;
  73. }
  74. #endregion
  75. #region 计算结果存储类
  76. /*
  77. *计算数据存储在Context中,FloorSystemItem尽量只跟解析算法相关
  78. */
  79. public List<VerticalPipe> VerticalPipes { get; private set; }
  80. public List<LevelData> Levels { get; private set; }
  81. public List<FloorDrawRecord> FloorDrawRecords { get; private set; }
  82. public List<FloorRelationRecord> FloorRelationRecords { get; private set; }
  83. public List<MachineRoomDrawRecord> MachineRoomDrawRecords { get; private set; }
  84. public List<MachineRoomRelationRecord> MachineRoomRelationRecords { get; private set; }
  85. #endregion
  86. #region 需要计算的系统相关
  87. /// <summary>
  88. /// 缓存关系计算壳对象
  89. /// </summary>
  90. public CacheItems<string, RelationTypeShell> RelationShells { get; private set; }
  91. /// <summary>
  92. /// 需要计算的关系类型
  93. /// </summary>
  94. public List<string> Relations { get;private set; }
  95. #endregion
  96. #region 保存计算结果
  97. /// <summary>
  98. /// 保存立面数据
  99. /// </summary>
  100. public void SaveComputerData()
  101. {
  102. DataServerUtil.Current.SaveData(ComputerFileSetting.FloorDraw, FloorDrawRecords);
  103. DataServerUtil.Current.SaveData(ComputerFileSetting.FloorRelation, FloorRelationRecords);
  104. DataServerUtil.Current.SaveData(ComputerFileSetting.MachineRoomDraw, MachineRoomDrawRecords);
  105. DataServerUtil.Current.SaveData(ComputerFileSetting.MachineRoomRelation, MachineRoomRelationRecords);
  106. var result = SystemParseManager.ComputerVerticalData(VerticalPipes, Levels);
  107. DataServerUtil.Current.SaveData(ComputerFileSetting.VerticalDraw, result.DrawData);
  108. DataServerUtil.Current.SaveData(ComputerFileSetting.VerticalRelation, result.RelationData);
  109. }
  110. #endregion
  111. }
  112. }