Пример #1
0
        /// <summary>
        /// 获取监控设备列表
        /// </summary>
        /// <param name="CameraInfoList">摄像头基本信息</param>
        /// <param name="CameraGroupList">组基本信息</param>
        /// <param name="nodeRelationList">所属分组关系信息</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr GetAllCameras(Cgw.Common.PlatformType platformType, Common.PageParam pageParam, out List <Cgw.Common.Camera> cameraList, out List <Cgw.Common.CameraGroup> groupList, out List <Cgw.Common.NodeRelation> nodeRelationList, out PagesInfo pageInfo, Cgw.Common.PlatformLicenseInfo licenseInfo = null)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.GetAllCameras");

            cameraList       = new List <Cgw.Common.Camera>();
            groupList        = new List <Common.CameraGroup>();
            nodeRelationList = new List <Common.NodeRelation>();
            pageInfo         = new PagesInfo();

            CgwMonitorManageServiceReference.Camera[]       cameraListTemp       = null;
            CgwMonitorManageServiceReference.CameraGroup[]  groupListTemp        = null;
            CgwMonitorManageServiceReference.NodeRelation[] nodeRelationListTemp = null;
            CgwMonitorManageServiceReference.PageInfo       pagesInfoTemp        = null;

            CgwMonitorManageServiceReference.PlatformLicenseInfo info = new CgwMonitorManageServiceReference.PlatformLicenseInfo();
            if (licenseInfo != null)
            {
                info.IsEltePlatform    = licenseInfo.IsEltePlatform;
                info.IsMonitorPlatform = licenseInfo.IsMonitorPlatform;
            }

            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (client.State == CommunicationState.Opened)
                if (serviceControl.MonitorServiceRun())
                {
                    CgwMonitorManageServiceReference.PlatformType platformTypeTemp = (CgwMonitorManageServiceReference.PlatformType)platformType;
                    CgwMonitorManageServiceReference.PagesParam   pageParamTemp    = new CgwMonitorManageServiceReference.PagesParam();
                    pageParamTemp.CurrentPage   = pageParam.CurrentPage;
                    pageParamTemp.NumberPerPage = pageParam.NumberPerPage;

                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.GetAllCameras(out cameraListTemp, out groupListTemp, out nodeRelationListTemp, out pagesInfoTemp, platformTypeTemp, pageParamTemp, info);
                    client.Close();

                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.GetAllCameras failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        if (pagesInfoTemp != null)
                        {
                            pageInfo.CurrentPage  = pagesInfoTemp.CurrentPage;
                            pageInfo.TotalPages   = pagesInfoTemp.TotalPages;
                            pageInfo.TotalRecords = pagesInfoTemp.TotalRecords;
                        }

                        if (cameraListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.Camera ca in cameraListTemp)
                            {
                                Common.Camera temp = new Common.Camera(ca.No, ca.Name, (Common.CameraStatus)ca.Status);
                                cameraList.Add(temp);
                            }
                        }

                        if (groupListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.CameraGroup cg in groupListTemp)
                            {
                                Common.CameraGroup temp = new Common.CameraGroup(cg.No, cg.Name);
                                groupList.Add(temp);
                            }
                        }

                        if (nodeRelationList != null && nodeRelationListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.NodeRelation no in nodeRelationListTemp)
                            {
                                Common.NodeRelation temp = new Common.NodeRelation(no.No, new List <String>(no.Path), (Common.NodeType)no.Type);
                                nodeRelationList.Add(temp);
                            }
                        }

                        //增加顶层分组
                        if (string.IsNullOrEmpty(monitorPlatformCameraGroupName))
                        {
                            monitorPlatformCameraGroupName = "MonitorPlatform";
                        }
                        if (string.IsNullOrEmpty(eLTEPlatformCameraGroupName))
                        {
                            eLTEPlatformCameraGroupName = "eLTEPlatform";
                        }

                        //查询第一页数据时增加顶层分组信息
                        if (pageParam.CurrentPage == 1)
                        {
                            //if (licenseInfo != null && licenseInfo.IsEltePlatform)
                            if (licenseInfo != null)
                            {
                                groupList.Add(new Common.CameraGroup(eLTEPlatformCameraGroupName, eLTEPlatformCameraGroupName));
                            }
                            //if (licenseInfo != null && licenseInfo.IsMonitorPlatform)
                            if (licenseInfo != null)
                            {
                                groupList.Add(new Common.CameraGroup(monitorPlatformCameraGroupName, monitorPlatformCameraGroupName));
                            }
                        }

                        if (nodeRelationList.Count > 0)
                        {
                            List <Common.NodeRelation> nodeRelationTemp = new List <Common.NodeRelation>(nodeRelationList);
                            nodeRelationList.Clear();

                            foreach (Common.NodeRelation no in nodeRelationTemp)
                            {
                                List <String> path = new List <String>(no.Path);
                                if (path.Count > 1)
                                {
                                    //按照从底到顶排序
                                    path.Reverse();
                                }
                                if (no.No.IndexOf("eLTE") > -1)
                                {
                                    path.Add(eLTEPlatformCameraGroupName);
                                }
                                else
                                {
                                    path.Add(monitorPlatformCameraGroupName);
                                }

                                if (path.Count > 1)
                                {
                                    //按照从顶到底排序
                                    path.Reverse();
                                }
                                Common.NodeRelation temp = new Common.NodeRelation(no.No, path, (Common.NodeType)no.Type);
                                nodeRelationList.Add(temp);
                            }
                        }

                        if (pageParam.CurrentPage == 1)
                        {
                            //if (licenseInfo != null && licenseInfo.IsEltePlatform)
                            if (licenseInfo != null)
                            {
                                Common.NodeRelation tempELTE = new Common.NodeRelation(eLTEPlatformCameraGroupName, new List <String>(), Common.NodeType.GROUP);
                                nodeRelationList.Add(tempELTE);
                            }
                            //if (licenseInfo != null && licenseInfo.IsMonitorPlatform)
                            if (licenseInfo != null)
                            {
                                Common.NodeRelation tempMonitor = new Common.NodeRelation(monitorPlatformCameraGroupName, new List <String>(), Common.NodeType.GROUP);
                                nodeRelationList.Add(tempMonitor);
                            }
                        }
                    }
                }
                else
                {
                    err.ErrNo = Cgw.SmcError.CgwError.GET_ALL_CAMERAS_FAILED;
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.GetAllCameras failed. Exception is {0} ", ex.ToString());
            }
            return(err);
        }
Пример #2
0
        /// <summary>
        /// 获取监控设备列表
        /// </summary>
        /// <param name="CameraInfoList">摄像头基本信息</param>
        /// <param name="CameraGroupList">组基本信息</param>
        /// <param name="nodeRelationList">所属分组关系信息</param>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr GetAllCameras(Cgw.Common.PlatformType platformType, Common.PageParam pageParam, out List<Cgw.Common.Camera> cameraList, out List<Cgw.Common.CameraGroup> groupList, out List<Cgw.Common.NodeRelation> nodeRelationList, out PagesInfo pageInfo, Cgw.Common.PlatformLicenseInfo licenseInfo = null)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwMonitorManageAdapter.GetAllCameras");

            cameraList = new List<Cgw.Common.Camera>();
            groupList = new List<Common.CameraGroup>();
            nodeRelationList = new List<Common.NodeRelation>();
            pageInfo = new PagesInfo();

            CgwMonitorManageServiceReference.Camera[] cameraListTemp = null;
            CgwMonitorManageServiceReference.CameraGroup[] groupListTemp = null;
            CgwMonitorManageServiceReference.NodeRelation[] nodeRelationListTemp = null;
            CgwMonitorManageServiceReference.PageInfo pagesInfoTemp = null;

            CgwMonitorManageServiceReference.PlatformLicenseInfo info = new CgwMonitorManageServiceReference.PlatformLicenseInfo();
            if (licenseInfo != null)
            {
                info.IsEltePlatform = licenseInfo.IsEltePlatform;
                info.IsMonitorPlatform = licenseInfo.IsMonitorPlatform;
            }

            Cgw.SmcError.SmcErr err = new Cgw.SmcError.SmcErr();

            try
            {
                //if (client.State == CommunicationState.Opened)
                if(serviceControl.MonitorServiceRun())
                {
                    CgwMonitorManageServiceReference.PlatformType platformTypeTemp = (CgwMonitorManageServiceReference.PlatformType)platformType;
                    CgwMonitorManageServiceReference.PagesParam pageParamTemp = new CgwMonitorManageServiceReference.PagesParam();
                    pageParamTemp.CurrentPage = pageParam.CurrentPage;
                    pageParamTemp.NumberPerPage = pageParam.NumberPerPage;

                    client = new MonitorManageServiceClient();
                    CgwMonitorManageServiceReference.SmcErr serviceErr = client.GetAllCameras(out cameraListTemp, out groupListTemp, out nodeRelationListTemp, out pagesInfoTemp, platformTypeTemp, pageParamTemp, info);
                    client.Close();

                    if (serviceErr.ErrNo != Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_SUCCESS)
                    {
                        logEx.Error("CgwMonitorManageAdapter.GetAllCameras failed. ErrNo = {0} ", serviceErr.ErrNo);
                        err = SetCgwErrNo(serviceErr);
                    }
                    else
                    {
                        if (pagesInfoTemp != null)
                        {
                            pageInfo.CurrentPage = pagesInfoTemp.CurrentPage;
                            pageInfo.TotalPages = pagesInfoTemp.TotalPages;
                            pageInfo.TotalRecords = pagesInfoTemp.TotalRecords;
                        }

                        if (cameraListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.Camera ca in cameraListTemp)
                            {
                                Common.Camera temp = new Common.Camera(ca.No, ca.Name, (Common.CameraStatus)ca.Status);
                                cameraList.Add(temp);
                            }
                        }

                        if (groupListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.CameraGroup cg in groupListTemp)
                            {
                                Common.CameraGroup temp = new Common.CameraGroup(cg.No, cg.Name);
                                groupList.Add(temp);
                            }
                        }

                        if (nodeRelationList != null && nodeRelationListTemp != null)
                        {
                            foreach (CgwMonitorManageServiceReference.NodeRelation no in nodeRelationListTemp)
                            {
                                Common.NodeRelation temp = new Common.NodeRelation(no.No, new List<String>(no.Path), (Common.NodeType)no.Type);
                                nodeRelationList.Add(temp);
                            }
                        }

                        //增加顶层分组
                        if (string.IsNullOrEmpty(monitorPlatformCameraGroupName))
                        {
                            monitorPlatformCameraGroupName = "MonitorPlatform";
                        }
                        if (string.IsNullOrEmpty(eLTEPlatformCameraGroupName))
                        {
                            eLTEPlatformCameraGroupName = "eLTEPlatform";
                        }

                        //查询第一页数据时增加顶层分组信息
                        if (pageParam.CurrentPage == 1)
                        {
                            //if (licenseInfo != null && licenseInfo.IsEltePlatform)
                            if(licenseInfo!=null)
                            {
                                groupList.Add(new Common.CameraGroup(eLTEPlatformCameraGroupName, eLTEPlatformCameraGroupName));
                            }
                            //if (licenseInfo != null && licenseInfo.IsMonitorPlatform)
                            if(licenseInfo!=null)
                            {
                                groupList.Add(new Common.CameraGroup(monitorPlatformCameraGroupName, monitorPlatformCameraGroupName));
                            }
                        }

                        if (nodeRelationList.Count > 0)
                        {
                            List<Common.NodeRelation> nodeRelationTemp = new List<Common.NodeRelation>(nodeRelationList);
                            nodeRelationList.Clear();

                            foreach (Common.NodeRelation no in nodeRelationTemp)
                            {
                                List<String> path = new List<String>(no.Path);
                                if (path.Count > 1)
                                {
                                    //按照从底到顶排序
                                    path.Reverse();
                                }
                                if (no.No.IndexOf("eLTE") > -1)
                                {
                                    path.Add(eLTEPlatformCameraGroupName);
                                }
                                else
                                {
                                    path.Add(monitorPlatformCameraGroupName);
                                }

                                if (path.Count > 1)
                                {
                                    //按照从顶到底排序
                                    path.Reverse();
                                }
                                Common.NodeRelation temp = new Common.NodeRelation(no.No, path, (Common.NodeType)no.Type);
                                nodeRelationList.Add(temp);
                            }

                        }

                        if (pageParam.CurrentPage == 1)
                        {
                            //if (licenseInfo != null && licenseInfo.IsEltePlatform)
                            if(licenseInfo!=null)
                            {
                                Common.NodeRelation tempELTE = new Common.NodeRelation(eLTEPlatformCameraGroupName, new List<String>(), Common.NodeType.GROUP);
                                nodeRelationList.Add(tempELTE);
                            }
                            //if (licenseInfo != null && licenseInfo.IsMonitorPlatform)
                            if(licenseInfo !=null)
                            {
                                Common.NodeRelation tempMonitor = new Common.NodeRelation(monitorPlatformCameraGroupName, new List<String>(), Common.NodeType.GROUP);
                                nodeRelationList.Add(tempMonitor);
                            }
                        }
                    }
                }
                else
                {
                    err.ErrNo = Cgw.SmcError.CgwError.GET_ALL_CAMERAS_FAILED;
                }
            }
            catch (System.Exception ex)
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                logEx.Error("CgwMonitorManageServiceReference.GetAllCameras failed. Exception is {0} ", ex.ToString());
            }
            return err;
        }