123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- /* ==============================================================================
- * 功能描述:SagaCheck
- * 创 建 者:Garrett
- * 创建日期:2019/6/11 16:09:09
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text.RegularExpressions;
- using Autodesk.Revit.DB;
- using SAGA.DotNetUtils.Extend;
- using ServiceRevitLib.Common;
- using SAGA.RevitUtils.Extends;
- using ServiceRevitLib.Extend;
- namespace ServiceRevitLib.Mode
- {
- /// <summary>
- /// SagaCheck
- /// </summary>
- class ParameterIntegrityCheck : CheckBase
- {
- public override void Check()
- {
- base.Check();
- #region
- var doc = m_Doc;
- var instances = doc.GetEqEcElements();
- var familyGroups = instances.GroupBy(t => t.GetFamilyName());
- foreach (IGrouping<string, Element> familyGroup in familyGroups)
- {
- Element fi = familyGroup.FirstOrDefault();
- if (fi == null) continue;
- var result = GetCheckResult(fi);
- if (result == null) continue;
- result.FamilyName = familyGroup.Key;
- Content.Add(result);
- }
- #endregion
- }
- /// <summary>
- /// 获取检测结果
- /// </summary>
- /// <param name="fi"></param>
- /// <returns></returns>
- private ParameterIntegrityCheckResult GetCheckResult(Element fi)
- {
- //检查项
- var checkParamNames = new List<string>() { MBIConst.EquipLocalName, MBIConst.EquipLocalID };
- var result = new ParameterIntegrityCheckResult();
- List<string> list = new List<string>();
- foreach (var paramName in checkParamNames)
- {
- var parameter = fi.GetParameter(paramName);
- if (parameter == null)
- list.Add(paramName);
- }
- if (list.Any())
- {
- result.Result = ResultState.Failure;
- result.ResultMsg = $"缺失的参数为:{string.Join("、", list)}";
- }
- else
- {
- result.Result = ResultState.Success;
- }
- return result;
- }
- }
- }
|