12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- /*-------------------------------------------------------------------------
- * 功能描述:SystemComputerHandler
- * 作者:xulisong
- * 创建时间: 2019/1/17 9:42:03
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using SAGA.MBI.Tools;
- namespace SAGA.GplotRelationComputerManage
- {
- public class SystemComputerHandler
- {
- /// <summary>
- /// 根据上下文计算系统数据
- /// </summary>
- /// <param name="context"></param>
- public void Computer(SystemComputerContext context)
- {
- List<string> testFiles = new List<string>();
- #if DEBUG
- testFiles.Add("Fl420105000119b7c08edcee11e8a553abe8a598be93.rvt");
- testFiles.Add("Fl420105000110be38e9dcf511e8a5532b791a1ee2c4.rvt");
- #endif
- var fileInfos = RevitModelPath.GetAllRevitFiles();
- foreach (var fileInfo in fileInfos)
- {
- if (File.Exists(fileInfo))
- {
- #if DEBUG
- //if (testFiles.All(f => !fileInfo.Contains(f)))
- //{
- // continue;
- //}
- #endif
- FloorSystemItem floorItems = context.FloorItems.GetItem(fileInfo);
- //FloorSystemItemTest floorItems = context.TestFloorItems.GetItem(fileInfo);
- floorItems.Parse(context);
- floorItems.Document.CloseDocSimple();
- }
- }
- context.SaveComputerData();
- }
-
- /// <summary>
- /// 根据输入系统类型计算系统数据
- /// </summary>
- /// <param name="relationTypes"></param>
- public void Computer(List<string> relationTypes)
- {
- if (relationTypes == null || !relationTypes.Any())
- {
- return;
- }
- SystemComputerContext context = new SystemComputerContext();
- context.Relations.AddRange(relationTypes);
- Computer(context);
- }
- /// <summary>
- /// 计算没有被缓存或者缓存过期的数据
- /// </summary>
- /// <param name="relationTypes"></param>
- public void ComputerWidthCache(List<string> relationTypes)
- {
- if (relationTypes == null || !relationTypes.Any())
- return;
- var useRelationTypes = RelationTypeUtil.NeedResetRelationTypes(relationTypes);
- if(!useRelationTypes.Any())
- {
- return;
- }
- Computer(useRelationTypes);
- }
- /// <summary>
- /// 计算所有关系信息
- /// </summary>
- public static void ComputerAllRelations()
- {
- // List<string> useRelations = new List<string>() { "ChillWaterLoop" };
- List<string> useRelations = RelationTypeManager.GetSystemRelationTypeNames();
- SystemComputerHandler handler1 = new SystemComputerHandler();
- handler1.ComputerWidthCache(useRelations);
- }
- }
- }
|