コード例 #1
0
 private static void BindBoundWithPoint(List <Point> points, List <Bound> bounds)
 {
     foreach (Point point in points)
     {
         Bound bound = bounds.Find(i => i.Id == point.BoundId);
         if (bound != null)
         {
             bound.AddPoint(point);
         }
     }
 }
コード例 #2
0
        /// <summary>
        /// 获取物理逻辑拓扑
        /// </summary>
        /// <returns></returns>
        public static PhysicalTopology GetPhysicalTopologyTree()
        {
            try
            {
                using (LocationBll db = new LocationBll(false, false, false))
                {
                    Log.InfoStart("GetPhysicalTopologyTree");


                    //LocationBll dbEx = new LocationBll(false, true, false);
                    //List<PhysicalTopology> list = dbEx.PhysicalTopologys.ToList();
                    //PhysicalTopology root = list[0];
                    //return root;

                    List <PhysicalTopology> list = db.PhysicalTopologys.ToList();

                    List <TransformM> transformMs = db.TransformMs.ToList();
                    foreach (PhysicalTopology p in list)
                    {
                        p.Transfrom = transformMs.Find((item) => item.Id == p.TransfromId);
                    }

                    List <NodeKKS> kksList = db.NodeKKSs.ToList();
                    foreach (PhysicalTopology p in list)
                    {
                        p.Nodekks = kksList.Find((item) => item.Id == p.NodekksId);
                    }

                    List <Bound> bounds = db.Bounds.ToList();
                    List <Point> points = db.Points.ToList();
                    foreach (Point point in points)
                    {
                        Bound bound = bounds.Find(i => i.Id == point.BoundId);
                        if (bound != null)
                        {
                            bound.AddPoint(point);
                        }
                    }

                    foreach (PhysicalTopology p in list)
                    {
                        p.InitBound = bounds.Find((item) => item.Id == p.InitBoundId);
                        p.EditBound = bounds.Find((item) => item.Id == p.EditBoundId);
                    }

                    List <DevInfo>          leafNodes = db.DevInfos.ToList();
                    List <PhysicalTopology> roots     = TreeHelper.CreateTree(list, leafNodes);

                    Log.InfoEnd("GetPhysicalTopologyTree");

                    if (roots.Count > 0)
                    {
                        return(roots[0]);
                    }
                    else
                    {
                        return(null);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("GetPhysicalTopologyTree", ex);
                return(null);
            }
        }