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

            err = CheckSession();
            if (err.IsSuccess())
            {
                err = MonitorChannelBll.Instance().GetRefreshStatus(out refreshStatus);
            }
            else
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED;
            }
            if (err.IsSuccess())
            {
                logEx.Info("SMC GetRefreshStatus Success,Current SMC IP is : {0}, refreshStatus : {1}", CgwConst.SmcIp, refreshStatus.ErrNo);
            }
            else
            {
                logEx.Error("SMC GetRefreshStatus Failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 同步通道信息
        /// </summary>
        /// <param name="ChannelInfoList">通道列表</param>
        /// <returns></returns>
        public SmcErr SyncMonitorChannel(List <ChannelInfo> ChannelInfoList)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            err = CheckSession();
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                if (ChannelInfoList != null)
                {
                    err = MonitorChannelBll.Instance().SyncMonitorChannel(ChannelInfoList);
                }
                else
                {
                    err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_CHANNELLIST_NULL);
                }
            }
            if (err.IsSuccess())
            {
                logEx.Trace("SyncMonitorChannel Successful");
            }
            else
            {
                logEx.Error("SyncMonitorChannel failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取监控摄像头列表刷新状态,返回结果为0是表示刷新完毕,为1是刷新操作中。当查询刷新状态为0时,可调用获取监控摄像头列表接口,获取刷新后监控摄像头列表
        /// </summary>
        /// <param name="refreshStatus"></param>
        /// <returns></returns>
        public SmcErr GetRefreshStatus(out SmcErr refreshStatus)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            refreshStatus       = new SmcErr();
            refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;
            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().GetRefreshStatus(out refreshStatus);
            }
            else
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED;
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService GetRefreshStatus  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService GetRefreshStatus failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 刷新监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public SmcErr RefreshMonitorCamera()
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                Thread th = new Thread(new ThreadStart(() =>
                {
                    VideoMonitorManage.Instance().RefreshMonitorCamera();
                }));
                th.Start();
            }

            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService RefreshMonitorCamera  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService RefreshMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 获取摄像头列表及分组信息
        /// </summary>
        /// <param name="fromMonitorSys">如果该值为true,则实时从监控平台获取,否则从融合网关缓存获取</param>
        /// <param name="cameraList">摄像头列表</param>
        /// <param name="groupList">组信息</param>
        /// <param name="nodeRelationList">分组关系</param>
        /// <returns></returns>
        public SmcErr GetAllCameras(PlatformType platformType, PagesParam pageParam, out List <Camera> cameraList, out List <CameraGroup> groupList, out List <NodeRelation> nodeRelationList, out PageInfo pagesInfo, PlatformLicenseInfo licenseInfo = null)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            cameraList       = null;
            groupList        = null;
            nodeRelationList = null;
            pagesInfo        = null;

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().GetAllCameras(pageParam, out cameraList, out groupList, out nodeRelationList, out pagesInfo, licenseInfo);
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService QueryMonitorCamera  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService QueryMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 停止预览摄像头视频,并清理命名管道
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <returns></returns>
        public SmcErr StopReceiveVideoByPipe(string cameraNo)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().StopReceiveVideo(cameraNo);
                VideoPipe videoPipe = VideoPipeManage.Instance().DeleteVideoPipe(cameraNo);
                if (videoPipe == null)
                {
                    logEx.Error("MonitorManageService StopReceiveVideoByPipe failed,VideoPipe is null,cameraNo = {0}", cameraNo);
                    err.SetErrorNo(CgwError.STOP_RECEIVE_VIDEO_FAILED);
                }
                else
                {
                    videoPipe.Stop();
                }
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService StopReceiveVideoByPipe  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService StopReceiveVideoByPipe failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 7
0
        /// <summary>
        /// 分配监控通道
        /// </summary>
        public SmcErr UpdateMonitorChannel(List <ChannelInfo> channelInfoList)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            err = CheckSession();
            if (err.IsSuccess())
            {
                if (channelInfoList != null)
                {
                    err = MonitorChannelBll.Instance().AssignMonitorChannel(channelInfoList);
                }
                else
                {
                    err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_CHANNELLIST_NULL);
                }
            }
            if (err.IsSuccess())
            {
                logEx.Info("SMC AssignMonitorChannel  Successful,Current SMC IP is : {0}", CgwConst.SmcIp);
            }
            else
            {
                logEx.Error("SMC AssignMonitorChannel failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 8
0
        /// <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);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 检查Session
        /// </summary>
        /// <returns></returns>
        private SmcErr CheckSession()
        {
            NLogEx.LoggerEx logEx      = new NLogEx.LoggerEx(log);
            SmcErr          err        = new CgwError();
            CGWSession      CgwSession = null;

            if (OperationContext.Current != null)
            {
                string strSessionId = OperationContext.Current.SessionId;
                err = SessionManage.Instance().GetSessionsBySessionId(strSessionId, out CgwSession);

                if (err.IsSuccess() == false || CgwSession == null)
                {
                    err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_SESSION_NULL);
                }
                else
                {
                    //更新Session最后访问时间
                    CgwSession.LastVisitedTime = DateTime.Now;
                    logEx.Trace("Current SessionId is:{0}, LastVisitedTime is :{1}", strSessionId, CgwSession.LastVisitedTime.ToLongTimeString());
                }
            }
            else
            {
                err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_CURRENTSESSION_NULL);
            }

            return(err);
        }
Exemplo n.º 10
0
        /// <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);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 摄像头闭音(暂无)
        /// </summary>
        public SmcErr MuteCamera()
        {
            SmcErr err = new CgwError();

            err = CheckSession();
            if (err.IsSuccess())
            {
            }
            return(err);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 预览摄像头视频,使用命名管道方式接收数据
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <param name="pipeName"></param>
        /// <returns></returns>
        public SmcErr StartReceiveVideoByPipe(string cameraNo, out string pipeName)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            pipeName = string.Empty;
            err      = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().StartReceiveVideo(cameraNo);

                //开始监控平台成功、开始通过管道发送数据
                if (err.IsSuccess())
                {
                    VideoPipeManage.Instance().DeleteVideoPipe(cameraNo);
                    VideoPipe videoPipe = VideoPipeManage.Instance().AddVideoPipe(cameraNo);
                    if (videoPipe != null)
                    {
                        pipeName = videoPipe.PipeName;
                        videoPipe.Run();

                        logEx.Info("MonitorManageService StartReceiveVideoByPipe  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
                    }
                    else
                    {
                        logEx.Error("MonitorManageService AddVideoPipe failed.cameraNo = {0}", cameraNo);
                        err.SetErrorNo(CgwError.START_RECEIVE_VIDEO_FAILED);
                        StopReceiveVideoByPipe(cameraNo);
                    }
                }
                else
                {
                    logEx.Error("MonitorManageService StartReceiveVideoByPipe failed,ErrNo :{0}", err.ErrNo);
                }
            }
            else
            {
                logEx.Error("MonitorManageService StartReceiveVideoByPipe failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 开始PTZ操作
        /// </summary>
        /// <param name="cameraNo">摄像头NO</param>
        /// <param name="ptzCommand">操作类型</param>
        /// <param name="param">命令参数</param>
        /// <returns></returns>
        public SmcErr StartControlPtz(string cameraNo, PtzCommandType ptzCommand, int param)
        {
            SmcErr err = new CgwError();

            err = CheckSession();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            if (err.IsSuccess())
            {
                err = MonitorChannelBll.Instance().StartControlPtz(cameraNo, ptzCommand, param);
            }
            if (err.IsSuccess())
            {
                logEx.Trace("StartControlPtz Successful");
            }
            else
            {
                logEx.Error("StartControlPtz failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 关闭PTZ操作
        /// </summary>
        /// <param name="Camerano">摄像头</param>
        /// <returns></returns>
        public SmcErr StopControlPtz(string cameraNo, PtzCommandType ptzCommandType)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            err = CheckSession();
            if (err.IsSuccess())
            {
                err = MonitorChannelBll.Instance().StopControlPtz(cameraNo, ptzCommandType);
            }
            if (err.IsSuccess())
            {
                logEx.Info("SMC StopPTZ  Successful,Current SMC IP is : {0}", CgwConst.SmcIp);
            }
            else
            {
                logEx.Error("SMC StopPTZ failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 设置扬声器
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <param name="isOn"></param>
        /// <returns></returns>
        public SmcErr SetSpeaker(string channelLabel, string cameraNo, bool isOn)
        {
            SmcErr err = new CgwError();

            err = CheckSession();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            if (err.IsSuccess())
            {
                err = MonitorChannelBll.Instance().SetSpeaker(channelLabel, cameraNo, isOn);
            }
            if (err.IsSuccess())
            {
                logEx.Info("SMC StartControlPtz  Successful,Current SMC IP is : {0}", CgwConst.SmcIp);
            }
            else
            {
                logEx.Error("SMC StartControlPtz failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 关闭PTZ操作
        /// </summary>
        /// <param name="Camerano">摄像头</param>
        /// <returns></returns>
        public SmcErr StopPTZ(string Camerano)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            err = CheckSession();
            if (err.IsSuccess())
            {
                err = MonitorChannelBll.Instance().StopPTZ(Camerano);
            }
            if (err.IsSuccess())
            {
                logEx.Trace("StopPTZ Successful");
            }
            else
            {
                logEx.Error("StopPTZ failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 17
0
        /// <summary>
        /// 设置监控通道视频源
        /// </summary>
        /// <param name="channelLabel">通道label</param>
        /// <param name="cameraNo">摄像头NO</param>
        /// <returns></returns>
        public SmcErr SwitchChannelVideoSource(string channelLabel, string cameraNo)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            err = CheckSession();
            if (err.IsSuccess())
            {
                err = MonitorChannelBll.Instance().SwitchChannelVideoSource(channelLabel, cameraNo);
            }
            if (err.IsSuccess())
            {
                logEx.Trace("SwitchChannelVideoSource Successful");
            }
            else
            {
                logEx.Error("SwitchChannelVideoSource failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 18
0
        /// <summary>
        /// 导入网关license文件
        /// </summary>
        /// <param name="license"></param>
        /// <returns></returns>
        public SmcErr ImportCGWLicense(string license)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwService.ImportCGWLicense");
            SmcErr err = new CgwError();

            err = CheckSession();
            if (err.IsSuccess())
            {
                err = MonitorChannelBll.Instance().ImportCGWLicense(license);
            }
            if (err.IsSuccess())
            {
                logEx.Info("SMC ImportCGWLicense  Successful,Current SMC IP is : {0}", CgwConst.SmcIp);
            }
            else
            {
                logEx.Error("SMC ImportCGWLicense failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 停止云台控制,摄像头控制
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <param name="ptzCommandType">命令类型</param>
        /// <returns></returns>
        public SmcErr StopControlPtz(string cameraNo, PtzCommandType ptzCommandType)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().StopControlPtz(cameraNo, ptzCommandType);
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService StopControlPtz  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService StopControlPtz failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 20
0
        /// <summary>
        /// 设置摄像头麦克风状态
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <param name="isOn">麦克风是否开启</param>
        /// <returns></returns>
        public SmcErr SetMic(string cameraNo, bool isOn)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().SetMic(cameraNo, isOn);
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService SetMic  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService SetMic failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 21
0
        /// <summary>
        /// 刷新监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public SmcErr RefreshMonitorCamera()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: CgwService.RefreshMonitorCamera");

            SmcErr err = new CgwError();

            err = CheckSession();
            if (err.IsSuccess())
            {
                err = MonitorChannelBll.Instance().RefreshMonitorCamera();
            }
            if (err.IsSuccess())
            {
                logEx.Info("SMC RefreshMonitorCamera  Successful,Current SMC IP is : {0}", CgwConst.SmcIp);
            }
            else
            {
                logEx.Error("SMC RefreshMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }

            return(err);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 获取监控设备列表
        /// </summary>
        /// <param name="CameraInfoList">摄像头基本信息</param>
        /// <param name="CameraGroupList">组基本信息</param>
        /// <param name="nodeRelationList">所属分组关系信息</param>
        /// <returns></returns>
        public SmcErr QueryMonitorCamera(out List <Camera> CameraInfoList, out List <CameraGroup> CameraGroupList, out List <NodeRelation> nodeRelationList)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            CameraInfoList   = null;
            CameraGroupList  = null;
            nodeRelationList = null;
            err = CheckSession();
            if (err.IsSuccess())
            {
                err = MonitorChannelBll.Instance().QueryMonitorCamera(out CameraInfoList, out CameraGroupList, out nodeRelationList);
            }
            if (err.IsSuccess())
            {
                logEx.Trace("SyncMonitorChannel Successful");
            }
            else
            {
                logEx.Error("SyncMonitorChannel failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 23
0
        /// <summary>
        /// 获取监控设备列表
        /// </summary>
        /// <param name="CameraInfoList">摄像头基本信息</param>
        /// <param name="CameraGroupList">组基本信息</param>
        /// <param name="nodeRelationList">所属分组关系信息</param>
        /// <returns></returns>
        public SmcErr QueryMonitorCamera(PlatformType platformType, PageParam pageParam, out List <Camera> cameraInfoList, out List <CameraGroup> cameraGroupList, out List <NodeRelation> nodeRelationList, out PagesInfo pagesInfo)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            cameraInfoList   = null;
            cameraGroupList  = null;
            nodeRelationList = null;
            pagesInfo        = null;
            err = CheckSession();
            if (err.IsSuccess())
            {
                err = MonitorChannelBll.Instance().QueryMonitorCamera(platformType, pageParam, out cameraInfoList, out cameraGroupList, out nodeRelationList, out pagesInfo);
            }
            if (err.IsSuccess())
            {
                logEx.Info("SMC QueryMonitorCamera  Successful,Current SMC IP is : {0}", CgwConst.SmcIp);
            }
            else
            {
                logEx.Error("SMC QueryMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 24
0
        /// <summary>
        /// 保持连接
        /// </summary>]
        public SmcErr KeepAliver(string sessionID)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            err = CheckSession(sessionID);
            if (err.IsSuccess())
            {
                logEx.Trace("KeepAlive Successful");
            }
            else
            {
                logEx.Error("KeepAlive failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 软终端初始化
        /// </summary>
        /// <param name="addr"></param>
        /// <returns></returns>
        public SmcErr Init(InitSotParam param)
        {
            SmcErr err = new CgwError();

            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            try
            {
                SoftTerminalCallback handler = new SoftTerminalCallback();
                handler.NlogHandler      = new NLogCallback(this.WriteLog);
                handler.IFrameHandler    = this.makeIFrameCallback;
                handler.errReportHandler = this.errReportCallback;
                bool isSuccess = this.softTerminalAdapter.RegistSotCallback(handler);
                if (!isSuccess)
                {
                    logEx.Trace("Init Regist callback failed.");
                    err.SetErrorNo(CgwError.ERR_CGW_CHANNEL_SOT_REGIST_CALLBACK_FAIL);
                    return(err);
                }

                err = this.softTerminalAdapter.Init(param);
                if (!err.IsSuccess())
                {
                    logEx.Trace("Init failed.");
                    return(err);
                }
            }
            catch (System.Exception ex)
            {
                logEx.Error(ex, "Init Exception.");
            }


            logEx.Trace("Init successfully.");
            return(err);
        }
Exemplo n.º 26
0
        /// <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);
        }
Exemplo n.º 27
0
        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);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 刷新监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public SmcErr RefreshMonitorCamera()
        {
            SmcErr err = new CgwError();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                Thread th = new Thread(new ThreadStart(() =>
                {
                    VideoMonitorManage.Instance().RefreshMonitorCamera();
                }));
                th.Start();
            }

            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService RefreshMonitorCamera  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService RefreshMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }
            return err;
        }
Exemplo n.º 29
0
        /// <summary>
        /// 初始化监控平台
        /// </summary>
        /// <returns></returns>
        public SmcErr Load()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Info("Enter: VideoMonitorManage.Load()");
            SmcErr     err = new CgwError();
            XmlElement monitorsRootElement = ConfigSettings.MonitorSettings;

            if (monitorsRootElement == null)
            {
                err.SetErrorNo(CgwError.MONITOR_CONFIG_FILE_INVALID);
                logEx.Error("Monitor config file is invalid.Can not found monitorSettings node.");
                return(err);
            }

            foreach (XmlNode monitorNode in monitorsRootElement)
            {
                XmlElement monitorElement = monitorNode as XmlElement;

                if (monitorElement == null)
                {
                    continue;
                }
                else if (CgwConst.MONITOR_TAG.Equals(monitorElement.Name))
                {
                    //判断监控平台是否启用
                    string isEnable = monitorElement.GetAttribute(CgwConst.ENABLE_TAG).Trim();
                    if (!CgwConst.TRUE_TAG.Equals(isEnable.ToLower()))
                    {
                        logEx.Warn("This monitor is disable.");
                        continue;
                    }

                    string monitorId;
                    string className;
                    err = GetMonitorConfig(monitorElement, out monitorId, out className);

                    if (!err.IsSuccess())
                    {
                        return(err);
                    }

                    IVideoMonitor videoMonitor;
                    //加载监控平台
                    err = CreateMonitor(monitorId, className, out videoMonitor);
                    if (!err.IsSuccess())
                    {
                        logEx.Error("Create monitor failed.monitorId:{0}, className:{1}, Error code:{2}", monitorId, className, err.ErrNo);
                        return(err);
                    }

                    err = videoMonitor.Load(monitorElement);
                    if (err.IsSuccess())
                    {
                        if (this.monitorsOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                        {
                            try
                            {
                                monitorsDictionary.Add(monitorId, videoMonitor);
                            }
                            catch (Exception e)
                            {
                                logEx.Error("Load monitor failed.Execption message:{0}", e.Message);
                                return(err);
                            }
                            finally
                            {
                                this.monitorsOperateLock.ExitWriteLock();
                            }
                        }
                    }
                    else
                    {
                        logEx.Error("Load monitor failed.MonitorId:{0},Error code:{1}", monitorId, err.ErrNo);
                        return(err);
                    }
                }
            }

            logEx.Info("Load all monitors success.");
            return(err);
        }
Exemplo n.º 30
0
        /// <summary>
        /// 获取摄像头列表及分组信息
        /// </summary>
        /// <param name="fromMonitorSys">如果该值为true,则实时从监控平台获取,否则从融合网关缓存获取</param>
        /// <param name="cameraList">摄像头列表</param>
        /// <param name="groupList">组信息</param>
        /// <param name="nodeRelationList">分组关系</param>
        /// <returns></returns>
        public SmcErr GetAllCameras(PagesParam pageparam, out List <Camera> cameraList, out List <CameraGroup> groupList, out List <NodeRelation> nodeRelationList, out PageInfo pageinfo, PlatformLicenseInfo licenseInfo = null)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.GetAllCameras().");
            SmcErr err = new CgwError();

            cameraList       = new List <Camera>();
            groupList        = new List <CameraGroup>();
            nodeRelationList = new List <NodeRelation>();
            pageinfo         = new PageInfo();
            //copy 一份,防止长时间占用锁
            Dictionary <string, IVideoMonitor> monitorsDictionaryTemp = null;

            if (this.monitorsOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    monitorsDictionaryTemp = new Dictionary <string, IVideoMonitor>(monitorsDictionary);
                }
                catch (Exception e)
                {
                    logEx.Error("Get all cameras failed.Execption message:{0}", e.Message);
                }
                finally
                {
                    this.monitorsOperateLock.ExitReadLock();
                }
            }
            if (monitorsDictionaryTemp == null)
            {
                //记录日志,获取*监控平台的摄像头列表失败
                logEx.Error("Get all cameras from monitor failed.No any monitor.");
                err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
                return(err);
            }
            //循环已加载的所有的监控平台,将所有摄像头和分组组成一个list返回
            foreach (KeyValuePair <string, IVideoMonitor> monitor in monitorsDictionaryTemp)
            {
                //if ((monitor.Key == "ivs" || monitor.Key == "tiandy" || monitor.Key == "T28181IVS") && licenseInfo.IsMonitorPlatform == false)
                //{
                //    logEx.Warn("GetAllCameras.smc license no right:{0}", monitor.Key);
                //    continue;
                //}
                //if (monitor.Key == "eLTE" && licenseInfo.IsEltePlatform == false)
                //{
                //    logEx.Warn("GetAllCameras.smc license no right:{0}", monitor.Key);
                //    continue;
                //}
                IVideoMonitor videoMonitor = monitor.Value;

                List <Camera>       cameraListTemp;
                List <CameraGroup>  groupListTemp;
                List <NodeRelation> nodeRelationListTemp;

                err = videoMonitor.GetAllCameras(out cameraListTemp, out groupListTemp, out nodeRelationListTemp);

                if (err.IsSuccess())
                {
                    //摄像头编号加上监控平台唯一标识
                    foreach (Camera camera in cameraListTemp)
                    {
                        camera.No = EncodeNo(camera.No, monitor.Key);
                        cameraList.Add(camera);
                    }

                    //组编号加上监控平台唯一标识
                    foreach (CameraGroup cameraGroup in groupListTemp)
                    {
                        cameraGroup.No = EncodeNo(cameraGroup.No, monitor.Key);
                        groupList.Add(cameraGroup);
                    }

                    //节点关系编号加上监控平台唯一标识
                    foreach (NodeRelation nodeRelation in nodeRelationListTemp)
                    {
                        nodeRelation.No = EncodeNo(nodeRelation.No, monitor.Key);
                        List <string> pathListTemp = null;
                        if (null != nodeRelation.Path)
                        {
                            pathListTemp = new List <string>();
                            foreach (string path in nodeRelation.Path)
                            {
                                pathListTemp.Add(EncodeNo(path, monitor.Key));
                            }
                        }
                        nodeRelation.Path = pathListTemp;

                        nodeRelationList.Add(nodeRelation);
                    }
                }
                else
                {
                    //记录日志,获取*监控平台的摄像头列表失败
                    logEx.Error("Get all cameras from monitor failed.Monitor id:{0} ,Error code:{1}", monitor.Key, err.ErrNo);
                    err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
                    continue;
                }
            }

            //2015/2/26 打印日志
            logEx.Info("all List Counts.");
            logEx.Info("cameraList:" + cameraList.Count);
            logEx.Info("groupList:" + groupList.Count);
            logEx.Info("nodeRelationList:" + nodeRelationList.Count);

            #region 判断传递的pageParam信息的合法性
            //计算cameraList、groupList、nodeRelationList中数据最多的列表长度
            int maxNum = (cameraList.Count > groupList.Count) ? cameraList.Count : groupList.Count;
            maxNum = maxNum > nodeRelationList.Count ? maxNum : nodeRelationList.Count;

            pageinfo.TotalRecords = maxNum;
            logEx.Info("GetAllCameras.pageparam.CurrentPage ={0},pageparam.NumberPerPage ={1}", pageparam.CurrentPage, pageparam.NumberPerPage);
            if (pageparam.CurrentPage <= 0 || pageparam.NumberPerPage <= 0) //如果当前页数或者每页条数小于0,则提示错误
            {
                logEx.Error("The CurrentPage or NumberPerPage can not be smaller than zero ,the CurrentPage is {0},the NumberPerPage is {1}", pageparam.CurrentPage, pageparam.NumberPerPage);
                err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
                cameraList       = new List <Camera>();
                groupList        = new List <CameraGroup>();
                nodeRelationList = new List <NodeRelation>();
                pageinfo         = new PageInfo();
                return(err);
            }
            else if (maxNum == 0)
            {
                pageinfo = new PageInfo();
                return(err);
            }
            else if (maxNum % pageparam.NumberPerPage != 0)
            {
                if (pageparam.CurrentPage > (pageinfo.TotalRecords / pageparam.NumberPerPage + 1)) //如果当前页数大于记录总页数,则提示错误
                {
                    logEx.Error("The CurrentPage can not be more than The Total pageNum(odd),the CurrentPage is {0},the Total PageNum is {1}", pageparam.CurrentPage, pageinfo.TotalRecords / pageparam.NumberPerPage + 1);
                    err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
                    cameraList       = new List <Camera>();
                    groupList        = new List <CameraGroup>();
                    nodeRelationList = new List <NodeRelation>();
                    pageinfo         = new PageInfo();
                    return(err);
                }
            }
            else
            {
                if (pageparam.CurrentPage > (pageinfo.TotalRecords / pageparam.NumberPerPage)) //如果当前页数大于记录总页数,则提示错误
                {
                    logEx.Error("The CurrentPage can not be more than The Total pageNum(even),the CurrentPage is {0},the Total PageNum is {1}", pageparam.CurrentPage, pageinfo.TotalRecords / pageparam.NumberPerPage);
                    err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
                    cameraList       = new List <Camera>();
                    groupList        = new List <CameraGroup>();
                    nodeRelationList = new List <NodeRelation>();
                    pageinfo         = new PageInfo();
                    return(err);
                }
            }
            #endregion

            #region 设置返回项PageInfo的值
            pageinfo.TotalRecords = maxNum;
            pageinfo.CurrentPage  = pageparam.CurrentPage;
            if (pageinfo.TotalRecords % pageparam.NumberPerPage != 0)
            {
                pageinfo.TotalPages = pageinfo.TotalRecords / pageparam.NumberPerPage + 1;
            }
            else
            {
                pageinfo.TotalPages = pageinfo.TotalRecords / pageparam.NumberPerPage;
            }
            #endregion

            #region 分割数据列表
            List <Camera>       CameraListTemp             = new List <Camera>();;
            List <CameraGroup>  CameraGroupTemp            = new List <CameraGroup>();;
            List <NodeRelation> CamerNodeRelationaListTemp = new List <NodeRelation>();

            int BeforeCurrentPageNum = (pageparam.CurrentPage - 1) * pageparam.NumberPerPage;   //vsd传递的当前页(PageParam.CurrentPage)之前的数据总数
            //cameraList ↓↓
            if (null != cameraList && cameraList.Count > 0)
            {
                for (int i = BeforeCurrentPageNum; i < BeforeCurrentPageNum + pageparam.NumberPerPage; i++)  //i从0开始
                {
                    if (i > cameraList.Count - 1)
                    {
                        break;
                    }
                    CameraListTemp.Add(cameraList[i]);
                }
                cameraList = CameraListTemp;
            }
            //groupList↓↓
            if (null != groupList && groupList.Count > 0)
            {
                for (int i = BeforeCurrentPageNum; i < BeforeCurrentPageNum + pageparam.NumberPerPage; i++)   //将请求页中包含的数据读取出来,并赋值给groupList
                {
                    if (i > groupList.Count - 1)
                    {
                        break;
                    }
                    CameraGroupTemp.Add(groupList[i]);
                }
                groupList = CameraGroupTemp;
            }
            //nodeRelationList↓↓
            if (null != nodeRelationList && nodeRelationList.Count > 0)
            {
                for (int i = BeforeCurrentPageNum; i < BeforeCurrentPageNum + pageparam.NumberPerPage; i++)   //将请求页中包含的数据读取出来,并赋值给nodeRelationList
                {
                    if (i > nodeRelationList.Count - 1)
                    {
                        break;
                    }
                    CamerNodeRelationaListTemp.Add(nodeRelationList[i]);
                }
                nodeRelationList = CamerNodeRelationaListTemp;
            }
            #endregion

            logEx.Info("Get all cameras success.");
            //特殊处理,监控平台统一返回成功,做轮询处理
            err.SetErrorNo(SmcErr.SMC_ERR_SUCCESS);
            return(err);
        }
Exemplo n.º 31
0
        /// <summary>
        /// 获取摄像头列表及分组信息
        /// </summary>
        /// <param name="fromMonitorSys">如果该值为true,则实时从监控平台获取,否则从融合网关缓存获取</param>
        /// <param name="cameraList">摄像头列表</param>
        /// <param name="groupList">组信息</param>
        /// <param name="nodeRelationList">分组关系</param>
        /// <returns></returns>
        public SmcErr GetAllCameras(PagesParam pageparam, out List<Camera> cameraList, out List<CameraGroup> groupList, out List<NodeRelation> nodeRelationList, out PageInfo pageinfo, PlatformLicenseInfo licenseInfo = null)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.GetAllCameras().");
            SmcErr err = new CgwError();
            cameraList = new List<Camera>();
            groupList = new List<CameraGroup>();
            nodeRelationList = new List<NodeRelation>();
            pageinfo = new PageInfo();
            //copy 一份,防止长时间占用锁
            Dictionary<string, IVideoMonitor> monitorsDictionaryTemp = null;

            if (this.monitorsOperateLock.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    monitorsDictionaryTemp = new Dictionary<string, IVideoMonitor>(monitorsDictionary);
                }
                catch (Exception e)
                {
                    logEx.Error("Get all cameras failed.Execption message:{0}", e.Message);
                }
                finally
                {
                    this.monitorsOperateLock.ExitReadLock();
                }
            }
            if (monitorsDictionaryTemp == null)
            {
                //记录日志,获取*监控平台的摄像头列表失败
                logEx.Error("Get all cameras from monitor failed.No any monitor.");
                err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
                return err;
            }
            //循环已加载的所有的监控平台,将所有摄像头和分组组成一个list返回
            foreach (KeyValuePair<string, IVideoMonitor> monitor in monitorsDictionaryTemp)
            {
                //if ((monitor.Key == "ivs" || monitor.Key == "tiandy" || monitor.Key == "T28181IVS") && licenseInfo.IsMonitorPlatform == false)
                //{
                //    logEx.Warn("GetAllCameras.smc license no right:{0}", monitor.Key);
                //    continue;
                //}
                //if (monitor.Key == "eLTE" && licenseInfo.IsEltePlatform == false)
                //{
                //    logEx.Warn("GetAllCameras.smc license no right:{0}", monitor.Key);
                //    continue;
                //}
                IVideoMonitor videoMonitor = monitor.Value;

                List<Camera> cameraListTemp;
                List<CameraGroup> groupListTemp;
                List<NodeRelation> nodeRelationListTemp;

                err = videoMonitor.GetAllCameras(out cameraListTemp, out groupListTemp, out nodeRelationListTemp);

                if (err.IsSuccess())
                {
                    //摄像头编号加上监控平台唯一标识
                    foreach (Camera camera in cameraListTemp)
                    {
                        camera.No = EncodeNo(camera.No, monitor.Key);
                        cameraList.Add(camera);
                    }

                    //组编号加上监控平台唯一标识
                    foreach (CameraGroup cameraGroup in groupListTemp)
                    {
                        cameraGroup.No = EncodeNo(cameraGroup.No, monitor.Key);
                        groupList.Add(cameraGroup);
                    }

                    //节点关系编号加上监控平台唯一标识
                    foreach (NodeRelation nodeRelation in nodeRelationListTemp)
                    {
                        nodeRelation.No = EncodeNo(nodeRelation.No, monitor.Key);
                        List<string> pathListTemp = null;
                        if (null != nodeRelation.Path)
                        {
                            pathListTemp = new List<string>();
                            foreach (string path in nodeRelation.Path)
                            {
                                pathListTemp.Add(EncodeNo(path, monitor.Key));
                            }
                        }
                        nodeRelation.Path = pathListTemp;

                        nodeRelationList.Add(nodeRelation);
                    }

                }
                else
                {
                    //记录日志,获取*监控平台的摄像头列表失败
                    logEx.Error("Get all cameras from monitor failed.Monitor id:{0} ,Error code:{1}", monitor.Key, err.ErrNo);
                    err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
                    continue;
                }
            }

            //2015/2/26 打印日志
            logEx.Info("all List Counts.");
            logEx.Info("cameraList:" + cameraList.Count);
            logEx.Info("groupList:" + groupList.Count);
            logEx.Info("nodeRelationList:" + nodeRelationList.Count);

            #region 判断传递的pageParam信息的合法性
            //计算cameraList、groupList、nodeRelationList中数据最多的列表长度
            int maxNum = (cameraList.Count > groupList.Count) ? cameraList.Count : groupList.Count;
            maxNum = maxNum > nodeRelationList.Count ? maxNum : nodeRelationList.Count;

            pageinfo.TotalRecords = maxNum;
            logEx.Info("GetAllCameras.pageparam.CurrentPage ={0},pageparam.NumberPerPage ={1}", pageparam.CurrentPage, pageparam.NumberPerPage);
            if (pageparam.CurrentPage <= 0 || pageparam.NumberPerPage <= 0) //如果当前页数或者每页条数小于0,则提示错误
            {
                logEx.Error("The CurrentPage or NumberPerPage can not be smaller than zero ,the CurrentPage is {0},the NumberPerPage is {1}", pageparam.CurrentPage, pageparam.NumberPerPage);
                err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
                cameraList = new List<Camera>();
                groupList = new List<CameraGroup>();
                nodeRelationList = new List<NodeRelation>();
                pageinfo = new PageInfo();
                return err;
            }
            else if (maxNum == 0)
            {
                pageinfo = new PageInfo();
                return err;
            }
            else if (maxNum % pageparam.NumberPerPage != 0)
            {
                if (pageparam.CurrentPage > (pageinfo.TotalRecords / pageparam.NumberPerPage + 1)) //如果当前页数大于记录总页数,则提示错误
                {
                    logEx.Error("The CurrentPage can not be more than The Total pageNum(odd),the CurrentPage is {0},the Total PageNum is {1}", pageparam.CurrentPage, pageinfo.TotalRecords / pageparam.NumberPerPage + 1);
                    err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
                    cameraList = new List<Camera>();
                    groupList = new List<CameraGroup>();
                    nodeRelationList = new List<NodeRelation>();
                    pageinfo = new PageInfo();
                    return err;
                }
            }
            else
            {
                if (pageparam.CurrentPage > (pageinfo.TotalRecords / pageparam.NumberPerPage)) //如果当前页数大于记录总页数,则提示错误
                {
                    logEx.Error("The CurrentPage can not be more than The Total pageNum(even),the CurrentPage is {0},the Total PageNum is {1}", pageparam.CurrentPage, pageinfo.TotalRecords / pageparam.NumberPerPage);
                    err.SetErrorNo(CgwError.GET_ALL_CAMERAS_FAILED);
                    cameraList = new List<Camera>();
                    groupList = new List<CameraGroup>();
                    nodeRelationList = new List<NodeRelation>();
                    pageinfo = new PageInfo();
                    return err;
                }
            }
            #endregion

            #region 设置返回项PageInfo的值
            pageinfo.TotalRecords = maxNum;
            pageinfo.CurrentPage = pageparam.CurrentPage;
            if (pageinfo.TotalRecords % pageparam.NumberPerPage != 0)
            {
                pageinfo.TotalPages = pageinfo.TotalRecords / pageparam.NumberPerPage + 1;
            }
            else
            {
                pageinfo.TotalPages = pageinfo.TotalRecords / pageparam.NumberPerPage;

            }
            #endregion

            #region 分割数据列表
            List<Camera> CameraListTemp = new List<Camera>(); ;
            List<CameraGroup> CameraGroupTemp = new List<CameraGroup>(); ;
            List<NodeRelation> CamerNodeRelationaListTemp = new List<NodeRelation>();

            int BeforeCurrentPageNum = (pageparam.CurrentPage - 1) * pageparam.NumberPerPage;   //vsd传递的当前页(PageParam.CurrentPage)之前的数据总数
            //cameraList ↓↓
            if (null != cameraList && cameraList.Count > 0)
            {
                for (int i = BeforeCurrentPageNum; i < BeforeCurrentPageNum + pageparam.NumberPerPage; i++)  //i从0开始
                {
                    if (i > cameraList.Count - 1)
                    {
                        break;
                    }
                    CameraListTemp.Add(cameraList[i]);
                }
                cameraList = CameraListTemp;
            }
            //groupList↓↓
            if (null != groupList && groupList.Count > 0)
            {
                for (int i = BeforeCurrentPageNum; i < BeforeCurrentPageNum + pageparam.NumberPerPage; i++)   //将请求页中包含的数据读取出来,并赋值给groupList
                {
                    if (i > groupList.Count - 1)
                    {
                        break;
                    }
                    CameraGroupTemp.Add(groupList[i]);
                }
                groupList = CameraGroupTemp;
            }
            //nodeRelationList↓↓
            if (null != nodeRelationList && nodeRelationList.Count > 0)
            {
                for (int i = BeforeCurrentPageNum; i < BeforeCurrentPageNum + pageparam.NumberPerPage; i++)   //将请求页中包含的数据读取出来,并赋值给nodeRelationList
                {
                    if (i > nodeRelationList.Count - 1)
                    {
                        break;
                    }
                    CamerNodeRelationaListTemp.Add(nodeRelationList[i]);
                }
                nodeRelationList = CamerNodeRelationaListTemp;
            }
            #endregion

            logEx.Info("Get all cameras success.");
            //特殊处理,监控平台统一返回成功,做轮询处理
            err.SetErrorNo(SmcErr.SMC_ERR_SUCCESS);
            return err;
        }
Exemplo n.º 32
0
        /// <summary>
        /// 初始化监控平台
        /// </summary>
        /// <returns></returns>
        public SmcErr Load()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Info("Enter: VideoMonitorManage.Load()");
            SmcErr err = new CgwError();
            XmlElement monitorsRootElement = ConfigSettings.MonitorSettings;
            if (monitorsRootElement == null)
            {
                err.SetErrorNo(CgwError.MONITOR_CONFIG_FILE_INVALID);
                logEx.Error("Monitor config file is invalid.Can not found monitorSettings node.");
                return err;
            }

            foreach (XmlNode monitorNode in monitorsRootElement)
            {
                XmlElement monitorElement = monitorNode as XmlElement;

                if (monitorElement == null)
                {
                    continue;
                }
                else if (CgwConst.MONITOR_TAG.Equals(monitorElement.Name))
                {
                    //判断监控平台是否启用
                    string isEnable = monitorElement.GetAttribute(CgwConst.ENABLE_TAG).Trim();
                    if (!CgwConst.TRUE_TAG.Equals(isEnable.ToLower()))
                    {
                        logEx.Warn("This monitor is disable.");
                        continue;
                    }

                    string monitorId;
                    string className;
                    err = GetMonitorConfig(monitorElement, out monitorId, out className);

                    if (!err.IsSuccess())
                    {
                        return err;
                    }

                    IVideoMonitor videoMonitor;
                    //加载监控平台
                    err = CreateMonitor(monitorId, className, out videoMonitor);
                    if (!err.IsSuccess())
                    {
                        logEx.Error("Create monitor failed.monitorId:{0}, className:{1}, Error code:{2}", monitorId, className, err.ErrNo);
                        return err;
                    }

                    err = videoMonitor.Load(monitorElement);
                    if (err.IsSuccess())
                    {
                        if (this.monitorsOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
                        {
                            try
                            {
                                monitorsDictionary.Add(monitorId, videoMonitor);
                            }
                            catch (Exception e)
                            {
                                logEx.Error("Load monitor failed.Execption message:{0}", e.Message);
                                return err;
                            }
                            finally
                            {
                                this.monitorsOperateLock.ExitWriteLock();
                            }
                        }
                    }
                    else
                    {
                        logEx.Error("Load monitor failed.MonitorId:{0},Error code:{1}", monitorId, err.ErrNo);
                        return err;
                    }
                }
            }

            logEx.Info("Load all monitors success.");
            return err;
        }
Exemplo n.º 33
0
 /// <summary>
 /// 保持连接
 /// </summary>]
 public SmcErr KeepAliver(string sessionID)
 {
     SmcErr err = new CgwError();
     NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
     err = CheckSession(sessionID);
     if (err.IsSuccess())
     {
         logEx.Trace("KeepAlive Successful");
     }
     else
     {
         logEx.Error("KeepAlive failed,ErrNo :{0}", err.ErrNo);
     }
     return err;
 }
Exemplo n.º 34
0
        /// <summary>
        /// 获取摄像头列表及分组信息
        /// </summary>
        /// <param name="fromMonitorSys">如果该值为true,则实时从监控平台获取,否则从融合网关缓存获取</param>
        /// <param name="cameraList">摄像头列表</param>
        /// <param name="groupList">组信息</param>
        /// <param name="nodeRelationList">分组关系</param>
        /// <returns></returns>
        public SmcErr GetAllCameras(PlatformType platformType, PagesParam pageParam, out List<Camera> cameraList, out List<CameraGroup> groupList, out List<NodeRelation> nodeRelationList, out PageInfo pagesInfo, PlatformLicenseInfo licenseInfo = null)
        {
            SmcErr err = new CgwError();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            cameraList = null;
            groupList = null;
            nodeRelationList = null;
            pagesInfo = null;

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().GetAllCameras(pageParam, out cameraList, out groupList, out nodeRelationList, out pagesInfo, licenseInfo);
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService QueryMonitorCamera  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService QueryMonitorCamera failed,ErrNo :{0}", err.ErrNo);
            }
            return err;
        }
Exemplo n.º 35
0
        /// <summary>
        /// 停止云台控制,摄像头控制
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <param name="ptzCommandType">命令类型</param>
        /// <returns></returns>
        public SmcErr StopControlPtz(string cameraNo, PtzCommandType ptzCommandType)
        {
            SmcErr err = new CgwError();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().StopControlPtz(cameraNo, ptzCommandType);
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService StopControlPtz  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService StopControlPtz failed,ErrNo :{0}", err.ErrNo);
            }
            return err;
        }
Exemplo n.º 36
0
        /// <summary>
        /// 设置摄像头麦克风状态
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <param name="isOn">麦克风是否开启</param>
        /// <returns></returns>
        public SmcErr SetMic(string cameraNo, bool isOn)
        {
            SmcErr err = new CgwError();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().SetMic(cameraNo, isOn);
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService SetMic  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService SetMic failed,ErrNo :{0}", err.ErrNo);
            }
            return err;
        }
Exemplo n.º 37
0
 /// <summary>
 /// 获取监控摄像头列表刷新状态,返回结果为0是表示刷新完毕,为1是刷新操作中。当查询刷新状态为0时,可调用获取监控摄像头列表接口,获取刷新后监控摄像头列表
 /// </summary>
 /// <param name="refreshStatus"></param>
 /// <returns></returns>
 public SmcErr GetRefreshStatus(out SmcErr refreshStatus)
 {
     SmcErr err = new CgwError();
     NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
     refreshStatus = new SmcErr();
     refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;
     err = CheckSession(currentSessionID);
     //调任何接口前 需要判断监控平台是否加载成功
     if (err.IsSuccess())
     {
         err = VideoMonitorManage.Instance().GetRefreshStatus(out refreshStatus);
     }
     else
     {
         refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED;
     }
     if (err.IsSuccess())
     {
         logEx.Info("MonitorManageService GetRefreshStatus  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
     }
     else
     {
         logEx.Error("MonitorManageService GetRefreshStatus failed,ErrNo :{0}", err.ErrNo);
     }
     return err;
 }
Exemplo n.º 38
0
        /// <summary>
        /// 预览摄像头视频,使用命名管道方式接收数据
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <param name="pipeName"></param>
        /// <returns></returns>
        public SmcErr StartReceiveVideoByPipe(string cameraNo, out string pipeName)
        {
            SmcErr err = new CgwError();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            pipeName = string.Empty;
            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().StartReceiveVideo(cameraNo);

                //开始监控平台成功、开始通过管道发送数据
                if (err.IsSuccess())
                {
                    VideoPipeManage.Instance().DeleteVideoPipe(cameraNo);
                    VideoPipe videoPipe = VideoPipeManage.Instance().AddVideoPipe(cameraNo);
                    if (videoPipe != null)
                    {
                        pipeName = videoPipe.PipeName;
                        videoPipe.Run();

                        logEx.Info("MonitorManageService StartReceiveVideoByPipe  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
                    }
                    else
                    {
                        logEx.Error("MonitorManageService AddVideoPipe failed.cameraNo = {0}", cameraNo);
                        err.SetErrorNo(CgwError.START_RECEIVE_VIDEO_FAILED);
                        StopReceiveVideoByPipe(cameraNo);
                    }
                }
                else
                {
                    logEx.Error("MonitorManageService StartReceiveVideoByPipe failed,ErrNo :{0}", err.ErrNo);
                }
            }
            else
            {
                logEx.Error("MonitorManageService StartReceiveVideoByPipe failed,ErrNo :{0}", err.ErrNo);
            }
            return err;
        }
Exemplo n.º 39
0
        /// <summary>
        /// 停止预览摄像头视频,并清理命名管道
        /// </summary>
        /// <param name="cameraNo"></param>
        /// <returns></returns>
        public SmcErr StopReceiveVideoByPipe(string cameraNo)
        {
            SmcErr err = new CgwError();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);

            err = CheckSession(currentSessionID);
            //调任何接口前 需要判断监控平台是否加载成功
            if (err.IsSuccess())
            {
                err = VideoMonitorManage.Instance().StopReceiveVideo(cameraNo);
                VideoPipe videoPipe = VideoPipeManage.Instance().DeleteVideoPipe(cameraNo);
                if (videoPipe == null)
                {
                    logEx.Error("MonitorManageService StopReceiveVideoByPipe failed,VideoPipe is null,cameraNo = {0}", cameraNo);
                    err.SetErrorNo(CgwError.STOP_RECEIVE_VIDEO_FAILED);
                }
                else
                {
                    videoPipe.Stop();
                }
            }
            if (err.IsSuccess())
            {
                logEx.Info("MonitorManageService StopReceiveVideoByPipe  Successful,Current Cgw IP is : {0}", CgwConst.ClientIp);
            }
            else
            {
                logEx.Error("MonitorManageService StopReceiveVideoByPipe failed,ErrNo :{0}", err.ErrNo);
            }
            return err;
        }
Exemplo n.º 40
0
        /// <summary>
        /// 检查Session
        /// </summary>
        /// <returns></returns>
        private SmcErr CheckSession(string sessionID)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr err = new CgwError();
            CgwSession CgwSession = null;
            if (OperationContext.Current != null)
            {
                //string strSessionId = OperationContext.Current.SessionId;
                string strSessionId = sessionID;
                err = SessionManage.Instance().GetSessionsBySessionId(strSessionId, out CgwSession);

                if (err.IsSuccess() == false || CgwSession == null)
                {
                    err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_SESSION_NULL);
                }
                else
                {
                    if (CgwSession != null)
                    {
                        //更新Session最后访问时间
                        CgwSession.LastVisitedTime = DateTime.Now;
                        //logEx.Trace("Current SessionId is:{0}, LastVisitedTime is :{1}", strSessionId, CgwSession.LastVisitedTime.ToLongTimeString());
                        logEx.Trace("LastVisitedTime is :{0}", CgwSession.LastVisitedTime.ToLongTimeString());

                        if (isLoadSuccess == false)
                        {
                            err.SetErrorNo(CgwError.ERR_CGW_IS_LOADING);
                        }
                    }
                }
            }
            else
            {
                err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_CURRENTSESSION_NULL);
            }
            return err;
        }