Example #1
0
 private List <DbModel.Location.AreaAndDev.DevInfo> GetLeafNodes(DbEntity area)
 {
     if (area != null)
     {
         var list = db.DevInfos.GetListByPid(area.Id);
         area.LeafNodes = list;
         return(list);
     }
     else
     {
         return(new List <DbModel.Location.AreaAndDev.DevInfo>());
     }
 }
Example #2
0
 private List <DbEntity> GetChildren(DbEntity item)
 {
     if (item != null)
     {
         var list = dbSet.FindListByPid(item.Id);
         item.Children = list;
         return(list);
     }
     else
     {
         return(new List <DbEntity>());
     }
 }
Example #3
0
        private void GetChildrenTree(DbEntity entity)
        {
            if (entity == null)
            {
                return;
            }
            var list = GetChildren(entity);

            if (list != null)
            {
                foreach (var item in list)
                {
                    GetChildrenTree(item);
                }
            }
        }
Example #4
0
 private List <DbEntity> GetChildren(DbEntity item)
 {
     try
     {
         if (item != null)
         {
             var list = dbSet.FindListByPid(item.Id);
             item.Children = list;
             return(list);
         }
         else
         {
             return(new List <DbEntity>());
         }
     }
     catch (System.Exception ex)
     {
         Log.Error(tag, "GetChildren", ex.ToString());
         return(null);
     }
 }
Example #5
0
 private void GetChildrenTree(DbEntity entity)
 {
     try
     {
         if (entity == null)
         {
             return;
         }
         var list = GetChildren(entity);
         if (list != null)
         {
             foreach (var item in list)
             {
                 GetChildrenTree(item);
             }
         }
     }
     catch (System.Exception ex)
     {
         Log.Error(tag, "GetChildrenTree", ex.ToString());
     }
 }
        private static bool IsPictureExist(DbAreaEntity a)
        {
            var roomPath = a.GetPath(AreaTypes.楼层, "_");
            var dirPath  = AppDomain.CurrentDomain.BaseDirectory + "\\RoomPictures\\" + roomPath;

            if (Directory.Exists(dirPath))
            {
                var files = Directory.GetFiles(dirPath);
                if (files.Length > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
                //return true;
            }
            else
            {
                return(false);
            }
        }
Example #7
0
 private List <DbModel.Location.AreaAndDev.DevInfo> GetLeafNodes(DbEntity area)
 {
     try
     {
         if (area != null)
         {
             var list = db.DevInfos.GetListByPid(new List <int>()
             {
                 area.Id
             });
             area.LeafNodes = list;
             return(list);
         }
         else
         {
             return(new List <DbModel.Location.AreaAndDev.DevInfo>());
         }
     }
     catch (System.Exception ex)
     {
         Log.Error(tag, "GetLeafNodes", ex.ToString());
         return(null);
     }
 }
        private void LoadAreaTree()
        {
            DbAreaEntity tree1 = null;

            if (FilterAreaTree == null)
            {
                tree1 = bll.GetAreaTree(true, null, true);
            }
            else
            {
                tree1 = bll.GetAreaTreeEx(false, null, FilterAreaTree);
            }


            var tree = tree1.ToTModel();

            if (tree == null)
            {
                return;
            }
            var devList    = tree.GetAllDev();
            var archorList = archorService.GetList();

            foreach (var dev in devList)
            {
                if (archorList != null)
                {
                    dev.DevDetail = archorList.FirstOrDefault(i => i.DevInfoId == dev.Id);
                }
            }
            var topoTree = ResourceTreeView1.TopoTree;
            var iId      = topoTree.SelectedObject as IId;

            InitTopoTreeAreaMenu(topoTree);
            InitTopoTreeDevMenu(topoTree);
            topoTree.LoadDataEx <AreaEntity, DevEntity>(tree);
            topoTree.Tree.SelectedItemChanged += Tree_SelectedItemChanged;
            topoTree.ExpandLevel(2);

            if (_archors != null)
            {
                List <int> ids = new List <int>();
                foreach (var archor in _archors)
                {
                    topoTree.SelectNode(typeof(AreaEntity), (int)archor.ParentId, archor.DevInfoId);
                    ids.Add(archor.DevInfoId);
                }
                AreaCanvas1.SelectDevsById(ids);//
                //AreaCanvas1.SelectDevsByIdEx(ids);//把其他的都删除了
            }
            else
            {
                if (iId == null)
                {
                    topoTree.SelectFirst();
                }
                else
                {
                    topoTree.SelectNodeById(iId);
                }
            }
        }
Example #9
0
        public string GetAreaSvgXml(int Id)
        {
            int    Scale       = 0;
            int    Margin      = 0;
            double DevSize     = 0;
            double OffsetX     = 0;
            double OffsetY     = 0;
            double CanvaWidth  = 0;
            double CanvaHeight = 0;
            string strReturn   = "";
            string strXml      = "";
            string strWidth    = "";
            string strHeight   = "";

            DbEntity area = dbSet.Find(Id);

            if (area == null)
            {
                return(strReturn);
            }

            int?     ParentId = area.ParentId;
            DbEntity Parent   = dbSet.Find(ParentId);

            if (Parent == null)
            {
                return(strReturn);
            }

            DbModel.Location.AreaAndDev.Bound bound = db.Bounds.Find(area.InitBoundId);
            if (bound == null)
            {
                return(strReturn);
            }



            List <DbModel.Location.AreaAndDev.Point> pointlist = db.Points.ToList();

            if (Parent.Name == "根节点") //电厂
            {
                Scale       = 3;
                DevSize     = 3;
                Margin      = 20;
                OffsetX     = bound.MinX - Margin;
                OffsetY     = bound.MinY - Margin;
                CanvaWidth  = (bound.MaxX - OffsetX + Margin) * Scale;
                CanvaHeight = (bound.MaxY - OffsetY + Margin) * Scale;
                strWidth    = Convert.ToString(CanvaWidth);
                strHeight   = Convert.ToString(CanvaHeight);

                strReturn = area.GetSvgXml(bound, pointlist, Scale, OffsetX, OffsetY, CanvaHeight);
                var lst1 = dbSet.DbSet.Where(p => p.ParentId == Id).ToList();
                if (lst1 != null)
                {
                    foreach (var item1 in lst1)
                    {
                        DbModel.Location.AreaAndDev.Bound bound1 = db.Bounds.Find(item1.InitBoundId);
                        //if (bound1 == null)
                        //{
                        //    continue;
                        //}

                        strReturn += item1.GetSvgXml(bound1, pointlist, Scale, OffsetX, OffsetY, CanvaHeight);
                        var lst2 = dbSet.DbSet.Where(p => p.ParentId == item1.Id).ToList();
                        if (lst2 != null)
                        {
                            foreach (var item2 in lst2)
                            {
                                DbModel.Location.AreaAndDev.Bound bound2 = db.Bounds.Find(item2.InitBoundId);
                                //if (bound2 == null)
                                //{
                                //    continue;
                                //}
                                strReturn += item2.GetSvgXml(bound2, pointlist, Scale, OffsetX, OffsetY, CanvaHeight);
                            }
                        }
                    }
                }
            }
            else if (area.Type == AreaTypes.楼层)
            {
                Scale       = 20;
                DevSize     = 0.3;
                Margin      = 10;
                OffsetX     = -Margin / 2;
                OffsetY     = -Margin / 2;
                CanvaWidth  = (bound.MaxX - OffsetX + Margin) * Scale;
                CanvaHeight = (bound.MaxY - OffsetY + Margin) * Scale;
                strWidth    = Convert.ToString(CanvaWidth);
                strHeight   = Convert.ToString(CanvaHeight);

                strReturn = area.GetSvgXml(bound, pointlist, Scale, OffsetX, OffsetY, CanvaHeight);
                var lst1 = dbSet.DbSet.Where(p => p.ParentId == Id).ToList();
                if (lst1 != null)
                {
                    foreach (var item1 in lst1)
                    {
                        DbModel.Location.AreaAndDev.Bound bound1 = db.Bounds.Find(item1.InitBoundId);
                        //if (bound1 == null)
                        //{
                        //    continue;
                        //}

                        strReturn += item1.GetSvgXml(bound1, pointlist, Scale, OffsetX, OffsetY, CanvaHeight);
                    }
                }
            }

            var devList = db.DevInfos.DbSet.Where(p => p.ParentId == Id).ToList();

            if (devList != null)
            {
                foreach (var item3 in devList)
                {
                    strReturn += item3.GetSvgXml(Scale, DevSize, OffsetX, OffsetY, CanvaHeight);
                }
            }

            strXml  = "<svg id=\"厂区\" width=\"" + strWidth + "\" height=\"" + strHeight + "\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" > ";
            strXml += "<defs><style>.cls-1{fill:none;stroke:#4d9fb5;}</style></defs>";
            strXml += strReturn;
            strXml += "</svg>";
            return(strXml);
        }
Example #10
0
        public bool EditArchor(TModel.Location.AreaAndDev.Archor Archor, int ParentId)
        {
            bool bReturn = false;

            DbModel.Location.AreaAndDev.Archor Archor2;
            Archor2 = db.Archors.FirstOrDefault(p => p.Code == Archor.Code);
            if (Archor2 == null)
            {
                Archor2 = db.Archors.FirstOrDefault(p => p.DevInfoId == Archor.DevInfoId);
            }
            if (Archor2 == null)
            {
                LocationService service = new LocationService();
                DbModel.Location.AreaAndDev.Area area = service.GetAreaById(ParentId);
                Archor2 = Archor.ToDbModel();

                DbModel.Location.AreaAndDev.DevInfo dev = new DbModel.Location.AreaAndDev.DevInfo();
                dev.Local_DevID = Guid.NewGuid().ToString();
                dev.IP          = "";
                dev.KKS         = "";
                dev.Name        = Archor2.Name;
                if (area != null)
                {
                    dev.ModelName = area.Name == DepNames.FactoryName ? TypeNames.ArchorOutdoor : TypeNames.Archor;//室外基站||室内基站
                }
                else
                {
                    dev.ModelName = TypeNames.Archor;
                }
                dev.Status         = 0;
                dev.ParentId       = ParentId;
                dev.Local_TypeCode = TypeCodes.Archor;
                dev.UserName       = "******";
                Archor2.DevInfo    = dev;
                Archor2.ParentId   = ParentId;

                bReturn = db.Archors.Add(Archor2);
            }
            else
            {
                Archor2.Name       = Archor.Name;
                Archor2.X          = Archor.X;
                Archor2.Y          = Archor.Y;
                Archor2.Z          = Archor.Z;
                Archor2.Type       = Archor.Type;
                Archor2.IsAutoIp   = Archor.IsAutoIp;
                Archor2.Ip         = Archor.Ip;
                Archor2.ServerIp   = Archor.ServerIp;
                Archor2.ServerPort = Archor.ServerPort;
                Archor2.Power      = Archor.Power;
                Archor2.AliveTime  = Archor.AliveTime;
                Archor2.Enable     = Archor.Enable;
                if (!string.IsNullOrEmpty(Archor.Code))
                {
                    Archor2.Code = Archor.Code;
                }
                bReturn = db.Archors.Edit(Archor2);
            }
            EditBusAnchor(Archor, ParentId);
            return(bReturn);
        }