Пример #1
0
        /// <summary>
        /// 通过文件导入设备信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="devBll"></param>
        /// <returns></returns>
        public static bool ImportFireFightDevInfoFromFile(string filePath, Bll bll)
        {
            if (!File.Exists(filePath) || bll == null)
            {
                Log.Error("文件不存在:" + filePath);
                return(false);
            }
            var initInfo = XmlSerializeHelper.LoadFromFile <FireFightDevInfoBackupList>(filePath);

            if (initInfo == null || initInfo.DevList == null || initInfo.DevList.Count == 0)
            {
                return(false);
            }
            var areas = bll.Areas.ToList();

            foreach (var devInfo in initInfo.DevList)
            {
                if (devInfo.ParentName == "")
                {
                    continue;
                }

                int?parentID = GetAreaIdByPath2(devInfo.ParentName, areas);
                if (parentID != null)
                {
                    devInfo.ParentId = Convert.ToString(parentID);
                    AddFireFightDevInfo(devInfo, bll);
                }
            }


            return(true);
        }
Пример #2
0
        private void LoadData()
        {
            fileArchorList        = ArchorHelper.LoadArchoDevInfo().ArchorList;
            Group1.Header        += " " + fileArchorList.Count;
            DataGrid1.ItemsSource = fileArchorList;

            BLL.Bll bll = new BLL.Bll();

            dbArchorList           = bll.Archors.ToList();
            DataGridDb.ItemsSource = dbArchorList;

            string path = AppDomain.CurrentDomain.BaseDirectory + "\\Data\\基站信息\\UDPArchorList.xml";

            udpArchorList         = XmlSerializeHelper.LoadFromFile <UDPArchorList>(path);
            Group2.Header        += " " + udpArchorList.Count;
            DataGrid2.ItemsSource = udpArchorList;

            var switchAreas = bll.bus_anchor_switch_area.ToList();

            var list4 = bll.bus_anchors.ToList();

            if (list4 != null)
            {
                Group4.Header        += " " + list4.Count;
                DataGrid4.ItemsSource = list4;
            }

            areas = bll.Areas.ToList();

            Check();
        }
        private void InitAuthorizationFromFile(string path)
        {
            var aaList  = new List <AreaAuthorization>();
            var aarList = new List <AreaAuthorizationRecord>();
            var tree    = XmlSerializeHelper.LoadFromFile <AuthorizationArea>(path);
            var list    = tree.GetAllChildren(null);

            foreach (var area in list)
            {
                if (area.Items != null)
                {
                    foreach (var aa in area.Items)
                    {
                        aa.CreateTime = DateTime.Now;
                        aa.ModifyTime = DateTime.Now;
                        aaList.Add(aa);
                    }
                }
            }
            bool r1 = AreaAuthorizations.AddRange(aaList);

            foreach (var area in list)
            {
                if (area.Records != null)
                {
                    foreach (var ar in area.Records)
                    {
                        ar.CreateTime = DateTime.Now;
                        ar.ModifyTime = DateTime.Now;
                        aarList.Add(ar);
                    }
                }
            }
            AreaAuthorizationRecords.AddRange(aarList);
        }
Пример #4
0
        /// <summary>
        /// 通过文件导入设备信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="devBll"></param>
        /// <returns></returns>
        public static bool ImportDevInfoFromFile(string filePath, Bll bll)
        {
            if (!File.Exists(filePath) || bll == null)
            {
                Log.Error("文件不存在:" + filePath);
                return(false);
            }
            var initInfo = XmlSerializeHelper.LoadFromFile <DevInfoBackupList>(filePath);

            if (initInfo == null || initInfo.DevList == null || initInfo.DevList.Count == 0)
            {
                return(false);
            }
            var areas = bll.Areas.ToList();

            //var devs = bll.DevInfos.Where(i => i.Local_TypeCode != TypeCodes.Archor);
            //bll.DevInfos.RemoveList(devs);//先清空所有设备
            foreach (var devInfo in initInfo.DevList)
            {
                if (devInfo.TypeCode == TypeCodes.Archor + "")
                {
                    continue;
                }
                int?parentID = GetAreaIdByPath(devInfo.ParentName, areas);
                if (parentID != null)
                {
                    devInfo.ParentId = (int)parentID;
                    AddDevInfo(devInfo, bll.DevInfos);
                }
            }
            return(true);
        }
Пример #5
0
        /// <summary>
        /// 通过文件导入人员信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="devBll"></param>
        /// <returns></returns>
        public static bool ImportPersonInfoFromFile(string filePath, Bll bll)
        {
            if (!File.Exists(filePath) || bll == null)
            {
                Log.Error("文件不存在:" + filePath);
                return(false);
            }
            var initInfo = XmlSerializeHelper.LoadFromFile <PersonnelInfoBackupList>(filePath);

            if (initInfo == null || initInfo.PerList == null || initInfo.PerList.Count == 0)
            {
                return(false);
            }
            var areas = bll.Areas.ToList();
            var deps  = bll.Departments.ToList();

            foreach (var Per in initInfo.PerList)
            {
                var dep = deps.Find(i => i.Id == Per.ParentId);
                if (dep == null)
                {
                    dep          = deps[Per.ParentId];
                    Per.ParentId = dep.Id;
                }
                else
                {
                }
                AddPersonInfo(Per, bll);
            }
            return(true);
        }
Пример #6
0
        /// <summary>
        /// 通过文件导入设备信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="devBll"></param>
        /// <returns></returns>
        public static bool ImportDoorAccessInfoFromFile(string filePath, Bll bll)
        {
            if (!File.Exists(filePath) || bll == null)
            {
                Log.Error("文件不存在:" + filePath);
                return(false);
            }
            var initInfo = XmlSerializeHelper.LoadFromFile <DoorAccessList>(filePath);

            if (initInfo == null || initInfo.DevList == null || initInfo.DevList.Count == 0)
            {
                return(false);
            }
            var areas = bll.Areas.ToList();

            foreach (var devInfo in initInfo.DevList)
            {
                int?parentId = GetAreaIdByPath(devInfo.ParentName, areas);
                if (parentId != null)
                {
                    devInfo.ParentId = (int)parentId;
                    AddDoorAccessInfo(devInfo, bll);
                }
            }
            return(true);
        }
Пример #7
0
        public UnitySetting GetUnitySetting()
        {
            string       path    = AppDomain.CurrentDomain.BaseDirectory + "\\UnitySetting.xml";
            UnitySetting setting = XmlSerializeHelper.LoadFromFile <UnitySetting>(path);

            return(setting);
        }
Пример #8
0
        public static UDPArchorList LoadArchorListResult()
        {
            if (savedList == null)
            {
                string   path = AppDomain.CurrentDomain.BaseDirectory + "\\Data\\基站信息\\UDPArchorList.xml";
                FileInfo fi   = new FileInfo(path);
                savedList = XmlSerializeHelper.LoadFromFile <UDPArchorList>(path);
            }

            return(savedList);
        }
Пример #9
0
        internal void LoadArchorList(string path)
        {
            archorList = XmlSerializeHelper.LoadFromFile <UDPArchorList>(path);

            resultList = new CommandResultManager();
            foreach (var item in archorList)
            {
                var group = resultList.Add(item);
            }

            OnArchorListChanged(archorList, null);
        }
Пример #10
0
        public static ArchorDevList LoadArchoDevInfo()
        {
            string basePath = AppDomain.CurrentDomain.BaseDirectory;
            string filePath = basePath + "Data\\基站信息\\ArchorFiles.xml";
            var    initInfo = XmlSerializeHelper.LoadFromFile <ArchorDevList>(filePath);

            if (initInfo != null)
            {
                ArchorList = initInfo;
            }
            return(initInfo);
        }
Пример #11
0
        private void DecreasePosYCamera()
        {
            Log.Info(LogTags.DbInit, "导入摄像头信息");
            string cameraFilePath = GetBasicDevBackupDir() + "CameraInfoBackup.xml";
            var    initInfo       = XmlSerializeHelper.LoadFromFile <Assets.z_Test.BackUpDevInfo.CameraInfoBackUpList>(cameraFilePath);

            foreach (var item in initInfo.DevList)
            {
                float y = float.Parse(item.YPos);
                item.YPos = (y - 400).ToString("f2");
            }
            XmlSerializeHelper.Save(initInfo, cameraFilePath);
            //Log.Info(LogTags.DbInit, string.Format("导入摄像头信息结果:{0}", valueCamera));
        }
Пример #12
0
        public static void RemoveArchorDev()
        {
            string basePath = AppDomain.CurrentDomain.BaseDirectory;
            string filePath = basePath + "Data\\设备信息\\DevInfoBackup.xml";
            var    initInfo = XmlSerializeHelper.LoadFromFile <DevInfoBackupList>(filePath);

            for (int i = 0; i < initInfo.DevList.Count; i++)
            {
                if (initInfo.DevList[i].TypeCode == TypeCodes.Archor + "")
                {
                    initInfo.DevList.RemoveAt(i);
                    i--;
                }
            }
            initInfo.DevList.Sort();
            XmlSerializeHelper.Save(initInfo, filePath);
        }
Пример #13
0
        /// <summary>
        /// 通过文件导入设备信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="devBll"></param>
        /// <returns></returns>
        public static bool ImportDevInfoFromFile(string filePath, DevInfoBll devBll)
        {
            if (!File.Exists(filePath) || devBll == null)
            {
                return(false);
            }
            DevInfoBackupList initInfo = XmlSerializeHelper.LoadFromFile <DevInfoBackupList>(filePath);

            foreach (var devInfo in initInfo.DevList)
            {
                if (devInfo.TypeCode == LocationDeviceHelper.LocationDevTypeCode)
                {
                    continue;
                }
                AddDevInfo(devInfo, devBll);
            }
            return(true);
        }
Пример #14
0
        /// <summary>
        /// 通过文件导入基站信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="devBlls"></param>
        /// <param name="topoTree"></param>
        /// <returns></returns>
        public static bool ImportLocationDeviceFromFile(string filePath, ArchorBll archorBll, PhysicalTopologyBll topoTree)
        {
            if (!File.Exists(filePath) || archorBll == null || topoTree == null)
            {
                return(false);
            }
            LocationDeviceList initInfo = XmlSerializeHelper.LoadFromFile <LocationDeviceList>(filePath);

            foreach (var devArea in initInfo.DepList)
            {
                PhysicalTopology topo = topoTree.FindByName(devArea.Name);
                if (topo == null)
                {
                    continue;
                }
                AddLocationDev(devArea.DevList, archorBll, topo.Id);
            }
            return(true);
        }
Пример #15
0
        /// <summary>
        /// 记录删除的设备(如果有设备被删除,备份时会被记录下来,TypeCode="DeleteDev",还原时这些设备不会被还原)
        /// 作用(当出现错误删除时,可以利用这些删除记录还原)
        /// </summary>
        /// <param name="devInfoList"></param>
        /// <returns></returns>
        private List <DevInfoBackup> AddDeleteDev(List <Location.TModel.Location.AreaAndDev.DevInfo> devInfoList)
        {
            //1.加载上一次的设备备份信息
            string filePath = GetSaveDevDirectory() + "DevInfoBackup.xml";
            var    initInfo = XmlSerializeHelper.LoadFromFile <DevInfoBackupList>(filePath);
            List <DevInfoBackup>        devInfos    = initInfo.DevList;
            List <DevInfoBackup>        deleteInfos = new List <DevInfoBackup>();
            Dictionary <string, string> devDic      = TryGetDevDic(devInfoList);

            if (devInfos != null)
            {
                foreach (var item in devInfos)
                {
                    if (item.TypeCode == DeleteTypeCode)
                    {
                        continue;
                    }
                    //2.如果上一次备份的设备,在现在的数据库找不到。说明被删除了,记录下来。
                    if (!string.IsNullOrEmpty(item.DevId) && !devDic.ContainsKey(item.DevId))
                    {
                        deleteInfos.Add(item);
                    }
                }
            }
            string deleteInfoPath = GetSaveDevDirectory() + "DeleteInfoBackup.xml";

            if (deleteInfos.Count != 0)
            {
                var deleteBackup = XmlSerializeHelper.LoadFromFile <DevInfoBackupList>(filePath);
                if (deleteBackup == null)
                {
                    deleteBackup         = new DevInfoBackupList();
                    deleteBackup.DevList = new List <DevInfoBackup>();
                }
                deleteBackup.DevList.AddRange(deleteInfos);
                XmlSerializeHelper.Save(deleteBackup, deleteInfoPath, Encoding.UTF8);
                foreach (var item in deleteInfos)
                {
                    item.TypeCode = DeleteTypeCode;
                }
            }
            return(deleteInfos);
        }
Пример #16
0
        public Dev_Monitor GetDevMonitor(string KKS, bool isShowAll)
        {
            Dev_Monitor monitor = new Dev_Monitor();

            DbModel.Location.AreaAndDev.KKSCode kksCode = KKSCodes.FirstOrDefault(p => p.Code == KKS);
            if (kksCode == null)
            {
                string dirPath = AppDomain.CurrentDomain.BaseDirectory + "Data\\DeviceData\\" + KKS + ".xml";
                if (File.Exists(dirPath))
                {
                    var list = XmlSerializeHelper.LoadFromFile <TModel.Location.AreaAndDev.DevMonitorNodeList>(dirPath);
                    monitor.Name            = KKS;
                    monitor.KKSCode         = KKS;
                    monitor.MonitorNodeList = list;
                }
                else
                {
                    monitor = null;
                }
            }
            else
            {
                monitor.Name    = kksCode.Name;
                monitor.KKSCode = kksCode.Code;
                var monitorNodeList = GetDevMonitorNodeListByKKS(kksCode.Code);
                monitor.MonitorNodeList = monitorNodeList;
                monitor.ChildrenList    = GetChildMonitorDev(kksCode);
                if (isShowAll == false)
                {
                    monitor.RemoveEmpty();
                }
                monitor.AddChildrenMonitorNodes();
            }

            if (monitor != null)
            {
                monitor.SetEmpty();
            }

            return(monitor);
        }
        /// <summary>
        /// 通过文件导入门禁卡信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="devBll"></param>
        /// <returns></returns>
        public static bool ImportEntranceGuardCardInfoFromFile(string filePath, Bll bll)
        {
            if (!File.Exists(filePath) || bll == null)
            {
                Log.Error("文件不存在:" + filePath);
                return(false);
            }
            var initInfo = XmlSerializeHelper.LoadFromFile <EntranceGuardCardInfoBackupList>(filePath);

            if (initInfo == null || initInfo.EcList == null || initInfo.EcList.Count == 0)
            {
                return(false);
            }
            var areas = bll.Areas.ToList();

            foreach (var ec in initInfo.EcList)
            {
                AddEntranceGuardCardInfo(ec, bll);
            }
            return(true);
        }
Пример #18
0
        /// <summary>
        /// 通过文件导入部门信息
        /// </summary>
        /// <param name="filePath"></param>
        /// <param name="devBll"></param>
        /// <returns></returns>
        public static bool ImportDepartmentInfoFromFile(string filePath, Bll bll)
        {
            if (!File.Exists(filePath) || bll == null)
            {
                Log.Error("文件不存在:" + filePath);
                return(false);
            }
            var initInfo = XmlSerializeHelper.LoadFromFile <DepartmentInfoBackupList>(filePath);

            if (initInfo == null || initInfo.DepList == null || initInfo.DepList.Count == 0)
            {
                return(false);
            }
            var areas = bll.Areas.ToList();

            foreach (var Dep in initInfo.DepList)
            {
                AddDepartmentInfo(Dep, bll);
            }
            return(true);
        }
 public bool InitTopoFromXml()
 {
     Log.InfoStart("InitTopoFromXml");
     try
     {
         string initFile = AppDomain.CurrentDomain.BaseDirectory + "Data\\InitInfo.xml";
         if (!File.Exists(initFile))
         {
             return(false);
         }
         InitInfo initInfo = XmlSerializeHelper.LoadFromFile <InitInfo>(initFile);
         TopoInfo topoInfo = initInfo.TopoInfo;
         InitTopo(topoInfo);
         Log.InfoEnd("InitTopoFromXml");
         return(true);
     }
     catch (Exception ex)
     {
         Log.Error("InitTopoFromXml", ex);
         Log.InfoEnd("InitTopoFromXml");
         return(false);
     }
 }
        private void Worker2_DoWork(object sender, DoWorkEventArgs e)
        {
            BackgroundWorker worker1  = sender as BackgroundWorker;
            string           basePath = AppDomain.CurrentDomain.BaseDirectory;
            string           filePath = basePath + "Data\\CADAreaInfo.xml";

            CADAreaList list = XmlSerializeHelper.LoadFromFile <CADAreaList>(filePath);

            list.LineToBlock();

            Bll          bll       = new Bll();
            var          areas     = bll.Areas.ToList(false);
            List <Point> newPoints = new List <Point>();
            List <Area>  newBounds = new List <Area>();
            List <Area>  newAreas  = new List <Area>();
            int          count     = 0;

            for (int i1 = 0; i1 < list.Count; i1++)
            {
                CADArea item = list[i1];
                var     area = areas.Find(i => i.Name == item.Name);
                if (area != null)
                {
                    count += item.Shapes.Count;
                }
            }



            int index = 0;

            for (int i1 = 0; i1 < list.Count; i1++)
            {
                CADArea item = list[i1];
                var     area = areas.Find(i => i.Name == item.Name);
                if (area != null)
                {
                    for (int i = 0; i < item.Shapes.Count; i++)
                    {
                        index++;
                        CADShape sp    = item.Shapes[i];
                        Bound    bound = new Bound();
                        bool     r1    = bll.Bounds.Add(bound);
                        if (r1)
                        {
                            Area newArea = new Area();
                            newArea.Name      = sp.Name;
                            newArea.Type      = AreaTypes.CAD;
                            newArea.ParentId  = area.Id;
                            newArea.InitBound = bound;
                            var r2 = bll.Areas.Add(newArea);
                            if (r2)
                            {
                                var pointList = new List <Point>();
                                foreach (var pt in sp.Points)
                                {
                                    var point = new Point();
                                    point.X       = (float)pt.X / 1000 - 0.1f;
                                    point.Y       = (float)pt.Y / 1000 - 0.1f;
                                    point.BoundId = bound.Id;
                                    var r3 = bll.Points.Add(point);
                                    pointList.Add(point);
                                }
                                bound.Shape      = 0;
                                bound.IsRelative = true;
                                bound.SetInitBound(pointList.ToArray(), area.InitBound.MinZ, (float)area.InitBound.GetHeight());

                                bool r4 = bll.Bounds.Edit(bound);
                                newArea.SetBound(bound);
                                bll.Areas.Edit(newArea);
                            }
                        }

                        int percent = (int)((index + 0.0) / count * 100);
                        worker1.ReportProgress(percent);
                    }
                }
            }

            //bll.Areas.AddRange(newAreas);
        }
Пример #21
0
        private Rectangle AddDevRect(DevEntity dev, double scale, double size, bool showDevName)
        {
            if (DevDict.ContainsKey(dev.Id))
            {
                DevDict[dev.Id].Remove();
            }

            AreaEntity parent = dev.Parent;

            double roomOffX = 0;
            double roomOffY = 0;

            if (DrawMode == 1)//大图模式
            {
                if (parent != null)
                {
                    if (parent.Type == AreaTypes.楼层 && parent.Parent != null)
                    {
                        roomOffX = parent.InitBound.MinX + parent.Parent.InitBound.MinX;
                        roomOffY = parent.InitBound.MinY + parent.Parent.InitBound.MinY;
                    }
                    else if (parent.Type == AreaTypes.机房 && parent.Parent != null)
                    {
                        roomOffX = parent.Parent.Parent.InitBound.MinX + parent.Parent.InitBound.MinX;
                        roomOffY = parent.Parent.Parent.InitBound.MinY + parent.Parent.InitBound.MinY;
                    }
                }
            }
            else //小图模式
            {
                if (parent != null)
                {
                    if (parent.Type == AreaTypes.楼层)
                    {
                        roomOffX = parent.InitBound.MinX;
                        roomOffY = parent.InitBound.MinY;
                    }
                    else if (parent.Type == AreaTypes.机房)
                    {
                        roomOffX = parent.Parent.InitBound.MinX;
                        roomOffY = parent.Parent.InitBound.MinY;
                    }
                }
            }

            double ax = dev.Pos.PosX + roomOffX;
            double ay = dev.Pos.PosZ + roomOffY;

            if (DrawMode == 1 && GetSettingFunc != null)//大图模式
            {
                ArchorSetting setting = GetSettingFunc(dev);
                if (setting != null)
                {
                    setting.CalAbsolute();//检测配置的数据是否正确
                    ax = setting.AbsoluteX.ToDouble();
                    ay = setting.AbsoluteY.ToDouble();
                }
            }


            double x = (ax - OffsetX) * scale - size * scale / 2;
            double y = (ay - OffsetY) * scale - size * scale / 2;

            DevShape devShape = new DevShape(Canvas1);

            if (showDevName)
            {
                if (udpArchorList == null)
                {
                    string path = AppDomain.CurrentDomain.BaseDirectory + "\\Data\\基站信息\\UDPArchorList.xml";
                    udpArchorList = XmlSerializeHelper.LoadFromFile <UDPArchorList>(path);
                }
                Label lb = new Label();
                lb.Content = GetDevName(dev);
                Canvas.SetLeft(lb, x + size * scale);
                Canvas.SetTop(lb, y);
                Canvas1.Children.Add(lb);
                lb.LayoutTransform = ScaleTransform1;

                var udpArchor = udpArchorList.Find(i => i.Id == GetArchorCode(dev));
                if (udpArchor != null)
                {
                    lb.Foreground = Brushes.Blue;
                }

                devShape.Label = lb;
            }


            //if (ViewMode == 0)
            //    y = Canvas1.Height - size * scale - y; //上下颠倒一下,不然就不是CAD上的上北下南的状况了
            Rectangle devRect = new Rectangle()
            {
                //Margin = new Thickness(x, y, 0, 0),
                Width           = size * scale,
                Height          = size * scale,
                Fill            = GetDevRectFillColor(dev),
                Stroke          = Brushes.Black,
                StrokeThickness = 1,
                Tag             = dev,
                ToolTip         = GetDevNameEx(dev)
            };

            devShape.Rect = devRect;
            devShape.Id   = dev.Id;

            devRect.ContextMenu = DevContextMenu;

            Canvas.SetLeft(devRect, x);
            Canvas.SetTop(devRect, y);

            DevDict[dev.Id]     = devShape;
            devRect.MouseDown  += DevRect_MouseDown;
            devRect.MouseEnter += DevRect_MouseEnter;
            devRect.MouseLeave += DevRect_MouseLeave;
            Canvas1.Children.Add(devRect);

            return(devRect);
        }
Пример #22
0
        public Dev_Monitor GetDevMonitorInfoByKKS(string KKS, bool bFlag)
        {
            DateTime    start   = DateTime.Now;
            Dev_Monitor monitor = new Dev_Monitor();

            //Log.Info(LogTags.KKS, string.Format("[{2}]KKS:{0},测点:{1}", KKS, tags, time));

            if (DbModel.AppSetting.ParkName == "四会热电厂")
            {
                monitor = GetDevMonitor(KKS, bFlag);
                if (monitor == null)
                {
                    return(null);
                }
                var             tags        = monitor.GetAllTagList();
                TimeSpan        time        = DateTime.Now - start;
                BaseDataService baseservice = new BaseDataService();
                List <TModel.Location.AreaAndDev.DevMonitorNode> dataList = baseservice.GetSomesisList(tags);//到基础平台获取数据
                //Log.Info(LogTags.KKS, string.Format("获取sis数据"));
                monitor = InsertDataToEveryDev(monitor, dataList);
            }
            else if (DbModel.AppSetting.ParkName == "中山嘉明电厂")
            {
                //Todo:根据Tags,获取所有监控点信息,并填入monitor中,发给客户端
                //SetParentMonitorNodes(tags, monitor);
                //先从该名字下xml获取测点,再从数据库中查询
                string        dirPath     = AppDomain.CurrentDomain.BaseDirectory + "Data\\DeviceData\\中山嘉明电厂\\" + KKS + ".xml";
                List <string> tagNameList = new List <string>();
                if (File.Exists(dirPath))
                {
                    TModel.Location.AreaAndDev.DevMonitorNodeList list = XmlSerializeHelper.LoadFromFile <TModel.Location.AreaAndDev.DevMonitorNodeList>(dirPath);
                    foreach (TModel.Location.AreaAndDev.DevMonitorNode node in list)
                    {
                        tagNameList.Add(node.TagName);
                    }
                }
                string tagnames = "";
                foreach (string tagname in tagNameList)
                {
                    tagnames += "'" + tagname + "',";
                }
                string sqlwhere = "";
                if (tagnames != "")
                {
                    tagnames = tagnames.Substring(0, tagnames.Length - 1);
                    sqlwhere = " and  TagName  in (" + tagnames + ")";
                    string strsql = string.Format(@"select * from devmonitornodes where 1=1 " + sqlwhere);
                    List <DbModel.Location.AreaAndDev.DevMonitorNode> nodesList = db.DevMonitorNodes.GetListBySql <DbModel.Location.AreaAndDev.DevMonitorNode>(strsql);
                    if (nodesList != null && nodesList.Count > 0)
                    {
                        monitor.MonitorNodeList = new List <TModel.Location.AreaAndDev.DevMonitorNode>();
                        monitor.MonitorNodeList.AddRange(nodesList.ToTModel());
                    }
                }
                else
                {
                    monitor.MonitorNodeList = null;
                }
            }
            return(monitor);
        }
Пример #23
0
        public bool InitTopoFromXml()
        {
            Log.InfoStart(LogTags.DbInit, "InitTopoFromXml");
            try
            {
                string initFile = InitPaths.GetInitInfo();

                if (!File.Exists(initFile))
                {
                    Log.Error("InitTopoFromXml找不到文件:" + initFile);
                    return(false);
                }
                InitInfo initInfo = XmlSerializeHelper.LoadFromFile <InitInfo>(initFile);
                if (initInfo == null)
                {
                    Log.Error("解析失败:" + XmlSerializeHelper.ExceptionText);
                }
                TopoInfo topoInfo = initInfo.TopoInfo;

                //if(!string.IsNullOrEmpty(parkName))
                //    for (int i = 0; i < topoInfo.Children.Count; i++)
                //    {
                //        var child = topoInfo.Children[i];
                //        if (child.Name != parkName)
                //        {
                //            topoInfo.Children.RemoveAt(i);
                //            i--;
                //        }
                //    }

                var nodes = topoInfo.GetAllTopos();
                foreach (TopoInfo node in nodes)
                {
                    if (node.Type != AreaTypes.园区)
                    {
                        if (node.BoundInfo != null)
                        {
                            if (node.BoundInfo.Points != null)
                            {
                                foreach (PointInfo point in node.BoundInfo.Points)
                                {
                                    LocationContext.Transform(point);//设置位置偏移
                                }
                            }
                        }
                    }
                }

                foreach (TopoInfo node in nodes)
                {
                    if (node.Type == AreaTypes.大楼)
                    {
                        if (node.IsCommon == true)
                        {
                            var floor1 = node.Children[0];
                            if (floor1.IsCommon == true)
                            {
                                List <TopoInfo> commonList = floor1.Children.FindAll(i => i.IsCommon);
                                for (int i = 1; i < node.Children.Count; i++)//拷贝第一层的柱子给下面所有层
                                {
                                    var floor = node.Children[i];
                                    IList <TopoInfo> cloneList = ConvertHelper.CloneObjectList(commonList);
                                    foreach (TopoInfo item in cloneList)
                                    {
                                        floor.Children.Add(item);
                                    }
                                }
                            }
                        }
                    }
                }

                InitTopo(topoInfo);
                Log.InfoEnd("InitTopoFromXml");
                return(true);
            }
            catch (Exception ex)
            {
                Log.Error(LogTags.DbInit, "InitTopoFromXml:" + ex);
                Log.InfoEnd("InitTopoFromXml");
                return(false);
            }
        }