/* ==============================================================================
 * 功能描述：SagaCheck  
 * 创 建 者：Garrett
 * 创建日期：2019/6/11 16:09:09
 * ==============================================================================*/

using System;
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 EquipPartLocationCheck : CheckBase
    {
        public override void Check()
        {
            base.Check();

            #region
            
            var document = m_Doc;
            var elements = document.GetEqEcElements();
            var parts = elements.Where(t => t.IsEquipmentPart());
            foreach (Element fi in parts)
            {
                var result = new EquipPartLocationCheckResult();
                result.PartFamilyName = fi.GetFamilyName();
                result.PartId = fi.Id.ToString();
                var partParent = fi.GetPartParent();
                if (partParent == null)
                {
                    result.Result = ResultState.Failure;
                    result.ResultMsg = "未与设备相交，请检查";
                }
                else
                {
                    result.RefId = partParent.Id.ToString();
                    result.Result = ResultState.Success;
                }
                Content.Add(result);
            }

            #endregion

        }
    }
}
