/// <summary>
        /// 获取监控摄像头列表刷新状态,返回结果为0是表示刷新完毕,为1是刷新操作中。当查询刷新状态为0时,可调用获取监控摄像头列表接口,获取刷新后监控摄像头列表
        /// </summary>
        /// <param name="refreshStatus"></param>
        /// <returns></returns>
        public SmcErr GetRefreshStatus(out SmcErr refreshStatus)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new CgwError();

            refreshStatus       = new SmcErr();
            refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;
            if (serviceControl.MonitorServiceRun())
            {
                err = CgwMonitorManageAdapter.Instance().GetRefreshStatus(out refreshStatus);
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }
            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("GetRefreshStatus Successful");
            }
            else
            {
                logEx.Error("GetRefreshStatus failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
        /// <summary>
        /// 开启PTZ控制
        /// </summary>
        /// <param name="cameraNo">摄像头NO</param>
        /// <param name="ptzCommand">操作类型</param>
        /// <param name="param">命令参数</param>
        /// <returns></returns>
        public SmcErr StartControlPtz(string cameraNo, Common.PtzCommandType ptzCommand, int param)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new CgwError();

            if (serviceControl.MonitorServiceRun())
            {
                err = CgwMonitorManageAdapter.Instance().StartControlPtz(cameraNo, ptzCommand, param);
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }


            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("StartControlPtz Successful");
            }
            else
            {
                logEx.Error("StartControlPtz failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
        /// <summary>
        /// 获取监控设备列表,返回摄像头基本信息,组基本信息,所属分组关系信息
        /// </summary>
        public SmcErr QueryMonitorCamera(Cgw.Common.PlatformType platformType, Cgw.Common.PageParam pageParam, out List <Common.Camera> CameraInfoList, out List <Common.CameraGroup> CameraGroupList, out List <Common.NodeRelation> nodeRelationList, out Cgw.Common.PagesInfo pagesInfo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            CameraInfoList   = null;
            CameraGroupList  = null;
            nodeRelationList = null;
            pagesInfo        = null;
            if (serviceControl.MonitorServiceRun())
            {
                try
                {
                    err = CgwMonitorManageAdapter.Instance().GetAllCameras(platformType, pageParam, out CameraInfoList, out CameraGroupList, out nodeRelationList, out pagesInfo, licenseInfo);
                }
                catch (Exception ex)
                {
                    logEx.Trace("QueryMonitorCamera.Exception = {0}", ex.ToString());
                }
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }
            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("QueryMonitorCamera Successful");
            }
            else
            {
                logEx.Error("QueryMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
        /// <summary>
        /// 连接监控通道
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void ConnectMonitorManageServiceTimer()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            while (true)
            {
                try
                {
                    if (isNeedConnect)
                    {
                        //err = CgwMonitorManageAdapter.Instance().Connect(CommonFunction.SHA256Encrypt(ConfigSettings.ConnectMonitorManagePassword));
                        err = CgwMonitorManageAdapter.Instance().Connect(null);

                        if (err.IsSuccess())
                        {
                            logEx.Info("Load MonitorManageService Successful !");
                            isNeedConnect    = false;
                            isNeedKeepAliver = true;

                            Thread th = new Thread(new ThreadStart(() =>
                            {
                                while (true)
                                {
                                    //建立连接后,需要查看监控通道关系中是否存在开启的视频,如果存在,需要重新打开视频
                                    SmcErr refreshStatus = new SmcErr();
                                    GetRefreshStatus(out refreshStatus);

                                    if (refreshStatus.ErrNo == Cgw.SmcError.CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END)
                                    {
                                        Thread.Sleep(1500);
                                        manageChannel.ReChannelVideo();
                                        break;
                                    }
                                    Thread.Sleep(1000);
                                }
                            }));
                            th.Start();
                        }
                    }
                }
                catch (System.Exception ex)
                {
                    logEx.Error("Load MonitorManageService.Exception = {0}", ex.ToString());
                }
                finally
                {
                    Thread.Sleep(CgwConst.CONNECT_MONITOR_MANAGE_WAIT_TIME);
                }
            }
        }
        /// <summary>
        /// Disconnect monitorPlat
        /// </summary>
        /// <returns></returns>
        public Cgw.SmcError.SmcErr Disconnect()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            //2015/2/13  停止服务,将状态重新赋值
            isNeedKeepAliver = false;
            isNeedConnect    = false;
            logEx.Info("Bll.Disconnect set isNeedKeepAliver=false,isNeedConnect=false.");

            err = CgwMonitorManageAdapter.Instance().Disconnect();
            if (err.IsSuccess())
            {
                logEx.Info("Bll.Disconnect Successful !");
            }

            return(err);
        }
        /// <summary>
        /// 保活监控平台服务
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void MonitorManageServiceKeepLiveTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            try
            {
                if (isNeedKeepAliver)
                {
                    //Connect Monitor
                    if (!serviceControl.MonitorServiceRun())
                    {
                        isNeedConnect = true;

                        //2015/2/13 Monitor服务不在线,将KeepAliver置为false,避免线程不断保活,待测试
                        isNeedKeepAliver = false;
                        err.SetErrorNo(CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
                    }
                    else
                    {
                        err = CgwMonitorManageAdapter.Instance().KeepAliver();
                    }
                    if (err.IsSuccess())
                    {
                        logEx.Trace("MonitorManageServiceKeepLive Successful !");
                    }
                    else
                    {
                        isNeedConnect    = true;
                        isNeedKeepAliver = false;
                        logEx.Warn("MonitorManageServiceKeepLive Failed !");
                    }
                }
            }
            catch (System.Exception ex)
            {
                isNeedConnect    = true;
                isNeedKeepAliver = false;
                logEx.Error("MonitorManageServiceKeepLive.Exception is {0}", ex.ToString());
            }
        }
        /// <summary>
        /// 刷新监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public SmcErr RefreshMonitorCamera()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new CgwError();

            if (serviceControl.MonitorServiceRun())
            {
                err = CgwMonitorManageAdapter.Instance().RefreshMonitorCamera();
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }
            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("RefreshMonitorCamera Successful");
            }
            else
            {
                logEx.Error("RefreshMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
        public SmcErr SetSpeaker(string channelLabel, string cameraNo, bool isOn)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new CgwError();

            if (serviceControl.MonitorServiceRun())
            {
                err = CgwMonitorManageAdapter.Instance().SetSpeaker(cameraNo, isOn);
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }
            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("SetMic Successful");
            }
            else
            {
                logEx.Error("SetMic failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }