/* ============================================================================== * 功能描述:SagaCheck * 创 建 者:Garrett * 创建日期:2019/6/11 16:09:09 * ==============================================================================*/ using System; using System.Collections.Generic; using System.Linq; using Autodesk.Revit.DB; using SAGA.RevitUtils.Extends; using ServiceRevitLib.Common; using ServiceRevitLib.Extend; using ServiceRevitLib.Mode; namespace ServiceRevitLib.DataCheck.Mode { /// /// SagaCheck /// class ParameterIntegrityCheck : CheckBase { public override void Check() { try { base.Check(); #region var doc = m_Doc; var instances = doc.GetEqEcElements(); var familyGroups = instances.GroupBy(t => t.GetFamilyName()); foreach (IGrouping 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 } catch (Exception e) { Result = ResultState.Failure; ResultMsg = $"{e.Message}\r\n{e.StackTrace}"; } } /// /// 获取检测结果 /// /// /// private ParameterIntegrityCheckResult GetCheckResult(Element fi) { //检查项 var checkParamNames = new List() { MBIConst.EquipLocalName, MBIConst.EquipLocalID }; var result = new ParameterIntegrityCheckResult(); List list = new List(); 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; } } }