GplotCommand.cs 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. 
  2. using System.Collections.Generic;
  3. using System.IO;
  4. using System.Linq;
  5. using Autodesk.Revit.Attributes;
  6. using Autodesk.Revit.DB;
  7. using Autodesk.Revit.UI;
  8. using SAGA.DotNetUtils.Others;
  9. using SAGA.GplotDrawData;
  10. using SAGA.GplotDrawData.View;
  11. using SAGA.GplotManage.RelationManager;
  12. using SAGA.GplotRelationComputerManage;
  13. using SAGA.Models;
  14. using SAGA.RevitUtils.Extends;
  15. namespace SAGA.GplotManage
  16. {
  17. /// <summary>
  18. /// 空间计算--平面
  19. /// </summary>
  20. [Transaction(TransactionMode.Manual)]
  21. [Regeneration(RegenerationOption.Manual)]
  22. public class SpaceComputerGraph : ExternalCommand
  23. {
  24. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  25. {
  26. //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
  27. //{
  28. // return Result.Succeeded;
  29. //}
  30. /*
  31. * 交互逻辑:
  32. * 1、缓存结果不存在,直接计算
  33. * 2、缓存结果存在,且没有过期,直接显示
  34. * 3、缓存结果存在,且数据过去,弹出提示框,用户选择是否重新计算
  35. */
  36. var state = SpaceComputerDataUtil.ComputeFileState();
  37. if (state==CacheFileState.Miss)
  38. {
  39. SpaceComputerHandler.ComputerAllRelations();
  40. }
  41. else if(state == CacheFileState.Expire)
  42. {
  43. if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
  44. {
  45. SpaceComputerHandler.ComputerAllRelations();
  46. }
  47. }
  48. var win = new WinDrawSpace_Web(GplotShowType.ViewPlan);//
  49. win.Show();
  50. return Result.Succeeded;
  51. }
  52. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  53. {
  54. return true;
  55. }
  56. }
  57. /// <summary>
  58. /// 空间计算--立面
  59. /// </summary>
  60. [Transaction(TransactionMode.Manual)]
  61. [Regeneration(RegenerationOption.Manual)]
  62. public class SpaceComputerVGraph : ExternalCommand
  63. {
  64. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  65. {
  66. //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
  67. //{
  68. // return Result.Succeeded;
  69. //}
  70. var state = SpaceComputerDataUtil.ComputeFileState();
  71. if (state == CacheFileState.Miss)
  72. {
  73. SpaceComputerHandler.ComputerAllRelations();
  74. }
  75. else if (state == CacheFileState.Expire)
  76. {
  77. if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
  78. {
  79. SpaceComputerHandler.ComputerAllRelations();
  80. }
  81. }
  82. var win = new WinDrawSpace_Web(GplotShowType.VerticalPlan);
  83. win.Show();
  84. return Result.Succeeded;
  85. }
  86. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  87. {
  88. return true;
  89. }
  90. }
  91. /// <summary>
  92. /// 水系统
  93. /// </summary>
  94. [Transaction(TransactionMode.Manual)]
  95. [Regeneration(RegenerationOption.Manual)]
  96. public class ChillWaterLoopComputerSupplyGraph : ExternalCommand
  97. {
  98. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  99. {
  100. //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
  101. //{
  102. // return Result.Succeeded;
  103. //}
  104. var state = SystemComputerHandler.ComputeFileState();
  105. if (state == CacheFileState.Miss)
  106. {
  107. SystemComputerHandler.ComputerAllRelations();
  108. }
  109. else if (state == CacheFileState.Expire)
  110. {
  111. if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
  112. {
  113. SystemComputerHandler.ComputerAllRelations();
  114. }
  115. }
  116. WinSystem floorWin = new WinSystem(GplotShowType.ViewPlan);
  117. floorWin.Show();
  118. return Result.Succeeded;
  119. }
  120. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  121. {
  122. return true;
  123. }
  124. }
  125. /// <summary>
  126. /// 系统平面信息
  127. /// </summary>
  128. [Transaction(TransactionMode.Manual)]
  129. [Regeneration(RegenerationOption.Manual)]
  130. public class ChillWaterLoopComputerBackGraph : ExternalCommand
  131. {
  132. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  133. {
  134. //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
  135. //{
  136. // return Result.Succeeded;
  137. //}
  138. var state = SystemComputerHandler.ComputeFileState();
  139. if (state == CacheFileState.Miss)
  140. {
  141. SystemComputerHandler.ComputerAllRelations();
  142. }
  143. else if (state == CacheFileState.Expire)
  144. {
  145. if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
  146. {
  147. SystemComputerHandler.ComputerAllRelations();
  148. }
  149. }
  150. WinSystem floorWin = new WinSystem(GplotShowType.ViewPlan);
  151. floorWin.Show();
  152. return Result.Succeeded;
  153. }
  154. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  155. {
  156. return true;
  157. }
  158. }
  159. /// <summary>
  160. /// 系统立面信息
  161. /// </summary>
  162. [Transaction(TransactionMode.Manual)]
  163. [Regeneration(RegenerationOption.Manual)]
  164. public class ChillWaterLoopComputerVGraph : ExternalCommand
  165. {
  166. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  167. {
  168. //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
  169. //{
  170. // return Result.Succeeded;
  171. //}
  172. var state = SystemComputerHandler.ComputeFileState();
  173. if (state == CacheFileState.Miss)
  174. {
  175. SystemComputerHandler.ComputerAllRelations();
  176. }
  177. else if (state == CacheFileState.Expire)
  178. {
  179. if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
  180. {
  181. SystemComputerHandler.ComputerAllRelations();
  182. }
  183. }
  184. WinSystem verticalWin = new WinSystem(GplotShowType.VerticalPlan);
  185. verticalWin.Show();
  186. return Result.Succeeded;
  187. }
  188. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  189. {
  190. return true;
  191. }
  192. }
  193. /// <summary>
  194. /// 机房信息
  195. /// </summary>
  196. [Transaction(TransactionMode.Manual)]
  197. [Regeneration(RegenerationOption.Manual)]
  198. public class ChillWaterLoopRoom : ExternalCommand
  199. {
  200. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  201. {
  202. //if (!MessageShowBase.Confirm("确定要执行拓扑计算命令吗"))
  203. //{
  204. // return Result.Succeeded;
  205. //}
  206. var state = SystemComputerHandler.ComputeFileState();
  207. if (state == CacheFileState.Miss)
  208. {
  209. SystemComputerHandler.ComputerAllRelations();
  210. }
  211. else if (state == CacheFileState.Expire)
  212. {
  213. if (MessageShowBase.ConfirmYesNo("您是否要重新计算?"))
  214. {
  215. SystemComputerHandler.ComputerAllRelations();
  216. }
  217. }
  218. WinMachineRoom room = new WinMachineRoom();
  219. room.Show();
  220. return Result.Succeeded;
  221. }
  222. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  223. {
  224. return true;
  225. }
  226. }
  227. /// <summary>
  228. /// 拓扑图上传测试
  229. /// </summary>
  230. [Transaction(TransactionMode.Manual)]
  231. [Regeneration(RegenerationOption.Manual)]
  232. public class GraphUploadTest : ExternalCommand
  233. {
  234. public override Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
  235. {
  236. WinComputeRelations win = new WinComputeRelations();
  237. win.ShowDialog();
  238. return Result.Succeeded;
  239. }
  240. public override bool IsCommandAvailable(UIApplication applicationData, CategorySet selectedCategories)
  241. {
  242. return true;
  243. }
  244. }
  245. }