/* ==============================================================================
* 功能描述: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
{
///
/// SagaCheck
///
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 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
}
///
/// 获取检测结果
///
///
///
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;
}
}
}