using Autodesk.Revit.DB;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FWindSoft.Revit.Mep
{
/////
///// 连接生成器
/////
//public class JoinCreator
//{
// public JoinCreator(IMepCurveJoin curveJoin, IMepEquipmentJoin equipmentJoin)
// {
// CurveJoin = curveJoin;
// EequipmentJoin = equipmentJoin;
// }
// ///
// /// 管线连接
// ///
// public IMepCurveJoin CurveJoin { get; private set; }
// ///
// /// 末端连接
// ///
// public IMepEquipmentJoin EequipmentJoin { get; private set; }
// ///
// /// 创建连接
// ///
// ///
// ///
// ///
// public virtual bool CreateConnectors(ConnectorRvtElement cre, Dictionary idDict,Document doc)
// {
// /*
// * 记录未成功连接的数据
// */
// bool? result = false;
// var joinElements = cre.conduit_list;
// var joinElementRevitIds = joinElements.Select(global =>
// { idDict.TryGetValue(global, out string revitId);
// return revitId;
// }).OfType();
// var revitELements = joinElementRevitIds.Select(id => doc.GetElement(new ElementId(id.ToInt()))).ToList();
// JoinContext context = new JoinContext();//预留,附加信息可能会在这个类中进行扩展
// var elementWrappers = revitELements.Select(el => new JoinElementWraper(el)).ToList();//使用Wrapper代理,为了方便扩展一些自定义扩展数据
// try
// {
// switch (elementWrappers.Count())
// {
// case 2:
// {
// if (elementWrappers.Any(ew => ew.IsFamilyInstance))
// {
// result = EequipmentJoin?.JoinEquipment(elementWrappers, context);
// }
// else
// {
// result = CurveJoin?.Join2Curve(elementWrappers, context);
// }
// break;
// }
// case 3:
// {
// result = CurveJoin?.Join3Curve(elementWrappers, context);
// break;
// }
// case 4:
// {
// result = CurveJoin?.Join4Curve(elementWrappers, context);
// break;
// }
// }
// }
// catch (Exception ex)
// {
// //自动执行,暂时不抛出异常,
// result = false;
// //throw;
// }
// if(result != true)
// {
// List ids = elementWrappers.Select(ew => ew.AssociateElement?.Id.ToString()).ToList();
// var filePath = Path.Combine(AppBaseInfo.LogPath, "测试.txt");
// if(!Directory.GetParent(filePath).Exists)
// {
// Directory.GetParent(filePath).Create();
// }
// File.AppendAllLines(filePath, new List() {DateTime.Now.ToString("yyyyMMddHHmmss :") + string.Join(",", ids) });
// }
// return result == true;
// }
// #region 单例连接生成器
// private static JoinCreator m_ConduitJoinCreator;
// ///
// /// 线管连接器
// ///
// ///
// public static JoinCreator ConduitJoinCreator
// {
// get
// {
// if(m_ConduitJoinCreator == null)
// {
// m_ConduitJoinCreator= new JoinCreator(new ConduitJoin(), null);
// }
// return m_ConduitJoinCreator;
// }
// }
// private static JoinCreator m_PipeJoinCreator;
// ///
// /// 水管连接器
// ///
// ///
// public static JoinCreator PipeJoinCreator
// {
// get
// {
// if (m_PipeJoinCreator == null)
// {
// m_PipeJoinCreator = new JoinCreator(null, null);
// }
// return m_PipeJoinCreator;
// }
// }
// private static JoinCreator m_DuctJoinCreator;
// ///
// /// 风管连接器
// ///
// ///
// public static JoinCreator DuctJoinCreator
// {
// get
// {
// if (m_DuctJoinCreator == null)
// {
// m_DuctJoinCreator = new JoinCreator(null, null);
// }
// return m_DuctJoinCreator;
// }
// }
// private static JoinCreator m_CableTrayJoinCreator;
// ///
// /// 桥架连接器
// ///
// ///
// public static JoinCreator CableTrayJoinCreator
// {
// get
// {
// if (m_CableTrayJoinCreator == null)
// {
// m_CableTrayJoinCreator = new JoinCreator(null, null);
// }
// return m_CableTrayJoinCreator;
// }
// }
// #endregion
//}
}