Example #1
0
 /// <summary>
 /// Fatal类(致命)日志输出。
 /// </summary>
 /// <param name="err">错误码,即信息</param>
 /// <param name="message">message</param>
 /// <param name="args">args</param>
 public void Fatal(SmcErr err, string message, params object[] args)
 {
     if (this.Log.IsFatalEnabled)
     {
         this.WriteToLog(LogLevel.Fatal, err, null, message, args);
     }
 }
Example #2
0
        /// <summary>
        /// 删除会话
        /// </summary>
        /// <param name="sessionGuid">会话Guid</param>
        /// <returns></returns>
        public SmcErr RemoveSession(Guid sessionGuid)
        {
            SmcErr err = new SmcErr();

            if (rwl.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    CgwSession session;
                    if (sessionDict.TryGetValue(sessionGuid, out session))
                    {
                        if (session != null)
                        {
                            sessionDict.Remove(sessionGuid);
                            session = null;
                        }
                    }
                }
                finally
                {
                    rwl.ExitWriteLock();
                }
            }
            return(err);
        }
Example #3
0
        /// <summary>
        /// 线程加载监控平台
        /// </summary>
        private static void LoadMonitorTimer_Elapsed()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            System.Threading.Thread.Sleep(1000);
            SmcErr smcErr = new SmcErr();

            try
            {
                smcErr = CgwService.Instance().Load();
                if (false == smcErr.IsSuccess())
                {
                    logEx.Error("CGW service Start failed! Errno :{0}", smcErr.ErrNo);
                    NLog.LogManager.Flush();
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
                }
                else
                {
                    logEx.Info("CGW service Start Success");
                }
            }
            catch (Exception ex)
            {
                logEx.Fatal(ex, "CGW service LoadMonitor Failed!");
                NLog.LogManager.Flush();
            }
        }
Example #4
0
 /// <summary>
 /// Error类日志输出。
 /// </summary>
 /// <param name="err">错误码,即信息</param>
 /// <param name="args">args</param>
 public void Error(SmcErr err, params object[] args)
 {
     if (this.Log.IsErrorEnabled)
     {
         this.WriteToLog(LogLevel.Error, err, null, String.Empty, args);
     }
 }
Example #5
0
 /// <summary>
 /// 带异常信息的Error类日志输出。
 /// </summary>
 /// <param name="err">错误码,即信息</param>
 /// <param name="e">e</param>
 /// <param name="message">message</param>
 /// <param name="args">args</param>
 public void Error(SmcErr err, Exception e, string message, params object[] args)
 {
     if (this.Log.IsErrorEnabled)
     {
         this.WriteToLog(LogLevel.Error, err, e, message, args);
     }
 }
Example #6
0
 /// <summary>
 /// Warn类日志输出。
 /// </summary>
 /// <param name="err">错误码,即信息</param>
 /// <param name="message">message</param>
 /// <param name="args">args</param>
 public void Warn(SmcErr err, string message, params object[] args)
 {
     if (this.Log.IsWarnEnabled)
     {
         this.WriteToLog(LogLevel.Warn, err, null, message, args);
     }
 }
Example #7
0
 /// <summary>
 /// Error类日志输出。
 /// </summary>
 /// <param name="err">错误码,即信息</param>
 /// <param name="message">message</param>
 /// <param name="args">args</param>
 public void Error(SmcErr err)
 {
     if (this.Log.IsErrorEnabled)
     {
         this.WriteToLog(LogLevel.Error, err, null, String.Empty, null);
     }
 }
Example #8
0
 /// <summary>
 /// Info类日志输出。
 /// </summary>
 /// <param name="err">错误码,即信息</param>
 /// <param name="message">message</param>
 /// <param name="args">args</param>
 public void Info(SmcErr err, string message, params object[] args)
 {
     if (this.Log.IsInfoEnabled)
     {
         this.WriteToLog(LogLevel.Info, err, null, message, args);
     }
 }
Example #9
0
 /// <summary>
 /// Warn类日志输出。
 /// </summary>
 /// <param name="err">错误码</param>
 /// <param name="args">参数</param>
 public void Warn(SmcErr err, params object[] args)
 {
     if (this.Log.IsWarnEnabled)
     {
         this.WriteToLog(LogLevel.Warn, err, null, String.Empty, args);
     }
 }
Example #10
0
 /// <summary>
 /// Info类日志输出。
 /// </summary>
 /// <param name="err">错误码</param>
 /// <param name="args">参数</param>
 public void Info(SmcErr err, params object[] args)
 {
     if (this.Log.IsInfoEnabled)
     {
         this.WriteToLog(LogLevel.Info, err, null, String.Empty, args);
     }
 }
Example #11
0
 /// <summary>
 /// Info类日志输出。
 /// </summary>
 /// <param name="err">错误码,即信息</param>
 /// <param name="message">message</param>
 /// <param name="args">args</param>
 public void Info(SmcErr err)
 {
     if (this.Log.IsInfoEnabled)
     {
         this.WriteToLog(LogLevel.Info, err, null, String.Empty, null);
     }
 }
Example #12
0
 /// <summary>
 /// Debug类日志输出。
 /// </summary>
 /// <param name="err">错误码,即信息</param>
 /// <param name="message">message</param>
 /// <param name="args">args</param>
 public void Debug(SmcErr err, string message, params object[] args)
 {
     if (this.Log.IsDebugEnabled)
     {
         this.WriteToLog(LogLevel.Debug, err, null, message, args);
     }
 }
Example #13
0
 /// <summary>
 /// Fatal类(致命)日志输出。
 /// </summary>
 /// <param name="err">错误码,即信息</param>
 /// <param name="args">args</param>
 public void Fatal(SmcErr err, params object[] args)
 {
     if (this.Log.IsFatalEnabled)
     {
         this.WriteToLog(LogLevel.Fatal, err, null, String.Empty, args);
     }
 }
Example #14
0
        /// <summary>
        /// 根据sessionId获取session
        /// </summary>
        /// <param name="sessionId">sessionId</param>
        /// <param name="sessions">session</param>
        /// <returns></returns>
        public SmcErr GetSessionsBySessionId(string sessionId, out CgwSession sessions)
        {
            SmcErr err = new SmcErr();

            sessions = null;

            if (rwl.TryEnterReadLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                try
                {
                    foreach (CgwSession cgwSession in sessionDict.Values)
                    {
                        if (cgwSession.SessionId == sessionId)
                        {
                            sessions = cgwSession;
                            break;
                        }
                    }
                }
                finally
                {
                    rwl.ExitReadLock();
                }
            }

            return(err);
        }
Example #15
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);
        }
Example #16
0
        /// <summary>
        /// 设置摄像头麦克风状态
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <param name="isOn">麦克风是否开启</param>
        /// <returns></returns>
        public SmcErr SetMic(string cameraNo, bool isOn)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.SetMic({0},{1}).", cameraNo, isOn);
            IVideoMonitor videoMonitor;
            string        decodedCameraNo;

            SmcErr err = DecoderCameraNo(cameraNo, out decodedCameraNo, out videoMonitor);

            if (err.IsSuccess())
            {
                err = videoMonitor.SetMic(decodedCameraNo, isOn);
                if (err.IsSuccess())
                {
                    logEx.Info("Set camera Mic status success.Camera no:{0}, isOn:{1}.", cameraNo, isOn);
                }
                else
                {
                    logEx.Error("Set camera Mic status failed. Camera no:{0}, isOn:{1}, Error Code:{2} ", cameraNo, isOn, err.ErrNo);
                }
            }
            else
            {
                logEx.Error("Set camera Mic status failed.Camera no is not found.Camera no:{0}, isOn:{1}.", cameraNo, isOn);
            }

            return(err);
        }
Example #17
0
        /// <summary>
        /// 停止云台控制,摄像头控制
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <param name="ptzCommandType">命令类型</param>
        /// <returns></returns>
        public SmcErr StopControlPtz(string cameraNo, PtzCommandType ptzCommandType)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.StopControlPtz({0}).", cameraNo);
            IVideoMonitor videoMonitor;
            string        decodedCameraNo;

            SmcErr err = DecoderCameraNo(cameraNo, out decodedCameraNo, out videoMonitor);

            if (err.IsSuccess())
            {
                err = videoMonitor.StopControlPtz(decodedCameraNo, ptzCommandType);
                if (err.IsSuccess())
                {
                    logEx.Info("Stop control ptz success.Camera no:{0},ptzCommandType:{1}.", cameraNo, ptzCommandType);
                }
                else
                {
                    logEx.Error("Stop control ptz failed.Camera no:{0},ptzCommandType:{1},Error Code:{1} ", cameraNo, ptzCommandType, err.ErrNo);
                }
            }
            else
            {
                logEx.Error("Stop control ptz failed. Camera no is not found.Camera no:{0}.", cameraNo);
            }
            return(err);
        }
Example #18
0
        /// <summary>
        /// 重发关键帧
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <returns></returns>
        public SmcErr MakeIFrame(string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.MakeIFrame({0}).", cameraNo);
            IVideoMonitor videoMonitor;
            string        decodedCameraNo;

            SmcErr err = DecoderCameraNo(cameraNo, out decodedCameraNo, out videoMonitor);

            if (err.IsSuccess())
            {
                err = videoMonitor.MakeIFrame(decodedCameraNo);
                if (err.IsSuccess())
                {
                    logEx.Info("Make I Frame success.Camera no:{0}.", cameraNo);
                }
                else
                {
                    logEx.Error("Make I Frame failed.Camera no:{0},Error Code:{1}.", cameraNo, err.ErrNo);
                }
            }
            else
            {
                logEx.Error("Make I Frame failed. Camera no is not found.Camera no:{0}.", cameraNo);
            }

            return(err);
        }
Example #19
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: IvsVideoMonitor.GetRefreshStatus");
            SmcErr err = new CgwError();

            refreshStatus       = new SmcErr();
            refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;

            if (refreshMonitorCameraOperateLock.TryEnterWriteLock(CgwConst.EFRESH_MONITOR_CAMERA_WAIT_TIME))
            {
                try
                {
                    if (loadResult)
                    {
                        refreshStatus.ErrNo = isRefreshSucess ? CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END : CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED;
                    }
                    else
                    {
                        refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING;
                    }
                }
                finally
                {
                    refreshMonitorCameraOperateLock.ExitWriteLock();
                }
            }
            else
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING;
            }
            logEx.Info("GetRefreshStatus success.");
            return(err);
        }
Example #20
0
        /// <summary>
        /// 停止预览
        /// </summary>
        /// <param name="cameraNo">摄像头编号</param>
        /// <returns>返回错误码</returns>
        public SmcErr StopReceiveVideo(string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.StopReceiveVideo({0}).", cameraNo);
            IVideoMonitor videoMonitor;
            string        decodedCameraNo;

            SmcErr err = DecoderCameraNo(cameraNo, out decodedCameraNo, out videoMonitor);

            if (err.IsSuccess())
            {
                err = videoMonitor.StopReceiveVideo(decodedCameraNo);
                if (err.IsSuccess())
                {
                    logEx.Info("Stop receive camera video data success.Camera no:{0}.", cameraNo);
                }
                else
                {
                    logEx.Error("Stop receive camera video data failed.Camera no:{0},Error Code:{1} ", cameraNo, err.ErrNo);
                }
            }
            else
            {
                logEx.Error("Stop receive camera video data failed.Camera no is not found.Camera no:{0}.", cameraNo);
            }
            return(err);
        }
Example #21
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);
        }
Example #22
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);
        }
Example #23
0
        /// <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);
        }
Example #24
0
        /// <summary>
        /// 设置监控通道视频源
        /// </summary>
        /// <param name="channelLabel">通道label</param>
        /// <param name="cameraNo">摄像头NO</param>
        /// <returns></returns>
        public SmcErr SwitchChannelVideoSource(string channelLabel, string cameraNo)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            if (serviceControl.MonitorServiceRun())
            {
                if (!string.IsNullOrEmpty(channelLabel))
                {
                    //切换通道关联
                    err = manageChannel.SwitchChannelRelation(channelLabel, cameraNo);
                }
                else
                {
                    //监控通道号不能为空
                    err.SetErrorNo(CgwError.ERR_CGW_BUSINESS_CHANNELNO_NULL);
                }
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }

            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("SwitchChannelVideoSource Successful");
            }
            else
            {
                logEx.Error("SwitchChannelVideoSource failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Example #25
0
        /// <summary>
        /// 分配监控通道
        /// </summary>
        /// <param name="ChannelInfoList"></param>
        /// <returns></returns>
        public SmcErr AssignMonitorChannel(List <Common.ChannelInfo> ChannelInfoList)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            if (serviceControl.MonitorServiceRun())
            {
                err = manageChannel.AssignChannel(ChannelInfoList);
            }
            else
            {
                err.SetErrorNo(Cgw.SmcError.CgwError.ERR_MONITOR_MANAGE_SERVICE_RESTARTING);
            }

            //日志记录
            if (err.IsSuccess())
            {
                logEx.Trace("AssignMonitorChannel Successful");
            }
            else
            {
                logEx.Error("AssignMonitorChannel failed,ErrNo :{0}", err.ErrNo);
            }
            return(err);
        }
Example #26
0
 /// <summary>
 /// 带异常信息的Trace类日志输出。
 /// </summary>
 /// <param name="err">错误码,即信息</param>
 /// <param name="e">e</param>
 /// <param name="message">message</param>
 /// <param name="args">args</param>
 public void Trace(SmcErr err, string message, params object[] args)
 {
     if (this.Log.IsTraceEnabled)
     {
         this.WriteToLog(LogLevel.Trace, err, null, message, args);
     }
 }
Example #27
0
        /// <summary>
        /// 停止管道中所有的流
        /// </summary>
        /// <returns></returns>
        public SmcErr StopAllStream()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            SmcErr          err   = new SmcErr();

            logEx.Info("Enter:CgwService UnLoad:");
            manageChannel.StopChannelData();
            return(err);
        }
Example #28
0
        /// <summary>
        /// 初始化融合网管服务
        /// </summary>
        public SmcErr InitService()
        {
            SmcErr err = new SmcErr();

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

            //strPwd = ConfigSettings.ConnectPassword;
            return(err);
        }
Example #29
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void fileWatcher_Changed(object sender, FileSystemEventArgs e)
        {
            if (this.licenseFileOperateLock.TryEnterWriteLock(CgwConst.ENTER_LOCK_WAIT_TIME))
            {
                LoggerEx logEx = new LoggerEx(log);
                try
                {
                    fileWatcher.EnableRaisingEvents = false;
                    try
                    {
                        if (e.ChangeType == WatcherChangeTypes.Changed)
                        {
                            uint resultErr = 0;

                            byte[] bteLic;
                            if (File.Exists(strPathLic))
                            {
                                Thread.Sleep(1000);
                                FileStream files = File.Open(strPathLic, FileMode.Open, FileAccess.Read, FileShare.Read);
                                if (files.Length != 0)
                                {
                                    byte[] btemp = new byte[files.Length];
                                    files.Read(btemp, 0, btemp.Length);
                                    bteLic = btemp;
                                }
                                else
                                {
                                    bteLic = new byte[0];
                                }
                                files.Close();
                            }
                            else
                            {
                                byte[] b = new byte[0];
                                bteLic = b;
                            }
                            CLicenseManagedAdapter licMan = new CLicenseManagedAdapter();
                            SmcErr smcErr = Convert2ErrNo(licMan.ActivateLicenseKey(bteLic, ref resultErr));
                        }
                        GetControlLicItem(null);
                    }
                    catch (System.Exception ex)
                    {
                        logEx.Error("fileWatcher_Changed Exception:{0}", ex.ToString());
                    }
                    finally
                    {
                        fileWatcher.EnableRaisingEvents = true;
                    }
                }
                finally
                {
                    this.licenseFileOperateLock.ExitWriteLock();
                }
            }
        }
Example #30
0
 /// <summary>
 /// 记录操作日志
 /// </summary>
 /// <param name="operateName">操作名称</param>
 /// <param name="err">错误码</param>
 public void RecordOperateLog(string operateName, SmcErr err)
 {
     if (err.IsSuccess())
     {
         this.Info("{0} Succeed", operateName);
     }
     else
     {
         this.Error("{0} Failed,ErrNo:{1}", operateName, err.ErrNo);
     }
 }