SystemComputerHandler.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*-------------------------------------------------------------------------
  2. * 功能描述:SystemComputerHandler
  3. * 作者:xulisong
  4. * 创建时间: 2019/1/17 9:42:03
  5. * 版本号:v1.0
  6. * -------------------------------------------------------------------------*/
  7. using System;
  8. using System.Collections.Generic;
  9. using System.IO;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading.Tasks;
  13. using SAGA.MBI.Tools;
  14. namespace SAGA.GplotRelationComputerManage
  15. {
  16. public class SystemComputerHandler
  17. {
  18. /// <summary>
  19. /// 根据上下文计算系统数据
  20. /// </summary>
  21. /// <param name="context"></param>
  22. public void Computer(SystemComputerContext context)
  23. {
  24. List<string> testFiles = new List<string>();
  25. #if DEBUG
  26. testFiles.Add("Fl420105000119b7c08edcee11e8a553abe8a598be93.rvt");
  27. testFiles.Add("Fl420105000110be38e9dcf511e8a5532b791a1ee2c4.rvt");
  28. #endif
  29. var fileInfos = RevitModelPath.GetAllRevitFiles();
  30. foreach (var fileInfo in fileInfos)
  31. {
  32. if (File.Exists(fileInfo))
  33. {
  34. #if DEBUG
  35. //if (testFiles.All(f => !fileInfo.Contains(f)))
  36. //{
  37. // continue;
  38. //}
  39. #endif
  40. FloorSystemItem floorItems = context.FloorItems.GetItem(fileInfo);
  41. //FloorSystemItemTest floorItems = context.TestFloorItems.GetItem(fileInfo);
  42. floorItems.Parse(context);
  43. floorItems.Document.CloseDocSimple();
  44. }
  45. }
  46. context.SaveComputerData();
  47. }
  48. /// <summary>
  49. /// 根据输入系统类型计算系统数据
  50. /// </summary>
  51. /// <param name="relationTypes"></param>
  52. public void Computer(List<string> relationTypes)
  53. {
  54. if (relationTypes == null || !relationTypes.Any())
  55. {
  56. return;
  57. }
  58. SystemComputerContext context = new SystemComputerContext();
  59. context.Relations.AddRange(relationTypes);
  60. Computer(context);
  61. }
  62. /// <summary>
  63. /// 计算没有被缓存或者缓存过期的数据
  64. /// </summary>
  65. /// <param name="relationTypes"></param>
  66. public void ComputerWidthCache(List<string> relationTypes)
  67. {
  68. if (relationTypes == null || !relationTypes.Any())
  69. return;
  70. var useRelationTypes = RelationTypeUtil.NeedResetRelationTypes(relationTypes);
  71. if(!useRelationTypes.Any())
  72. {
  73. return;
  74. }
  75. Computer(useRelationTypes);
  76. }
  77. /// <summary>
  78. /// 计算所有关系信息
  79. /// </summary>
  80. public static void ComputerAllRelations()
  81. {
  82. // List<string> useRelations = new List<string>() { "ChillWaterLoop" };
  83. List<string> useRelations = RelationTypeManager.GetSystemRelationTypeNames();
  84. SystemComputerHandler handler1 = new SystemComputerHandler();
  85. handler1.ComputerWidthCache(useRelations);
  86. }
  87. }
  88. }