IsSuccess() public method

当前是否成功状态
public IsSuccess ( ) : bool
return bool
Esempio n. 1
0
        /// <summary>
        /// 线程加载监控平台
        /// </summary>
        private static void LoadMonitorTimer_Elapsed()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            System.Threading.Thread.Sleep(CgwConst.Thread_Sleep_Time);
            SmcErr smcErr = new SmcErr();
            try
            {

                smcErr = MonitorManageService.Instance().Load();
                if (false == smcErr.IsSuccess())
                {
                    logEx.Error("MonitorManageService Start failed! Errno :{0}", smcErr.ErrNo);
                    NLog.LogManager.Flush();
                    System.Diagnostics.Process.GetCurrentProcess().Kill();
                }
            }
            catch (Exception ex)
            {
                logEx.Fatal(ex, "MonitorManageService LoadMonitor Failed!");
                NLog.LogManager.Flush();
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 线程加载cgw
        /// </summary>
        /// <returns></returns>
        public SmcErr Load()
        {
            SmcErr err = new SmcErr();
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            //初始化监控平台
            err = VideoMonitorManage.Instance().Load();
            VideoMonitorManage.Instance().SetDataCallBackFunc(DataCallBackFunc);
            if (err.IsSuccess())
            {
                logEx.Trace("Load CgwMonitorManage Successful !");
                isLoadSuccess = true;

            }
            else
            {
                logEx.Fatal("Load CgwMonitorManage Failed, ErrNo : {0}!", err.ErrNo);
            }

            return err;
        }
Esempio n. 3
0
        /// <summary>
        /// 刷新监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public SmcErr RefreshMonitorCamera()
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.RefreshMonitorCamera.");
            SmcErr err = new SmcErr();

            //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("RefreshMonitorCamera failed.Execption message:{0}", e.Message);
                }
                finally
                {
                    this.monitorsOperateLock.ExitReadLock();
                }
            }
            if (monitorsDictionaryTemp == null)
            {
                //记录日志,获取*监控平台的摄像头列表失败
                logEx.Error("RefreshMonitorCamera from monitor failed.No any monitor.");
                err.SetErrorNo(CgwError.ERR_REFRESH_MONITOR_CAMERA_FAIL);
                return err;
            }

            //循环已加载的所有的监控平台,将所有摄像头和分组组成一个list返回
            foreach (KeyValuePair<string, IVideoMonitor> monitor in monitorsDictionaryTemp)
            {
                IVideoMonitor videoMonitor = monitor.Value;
                err = videoMonitor.RefreshMonitorCamera();

                if (err.IsSuccess())
                {
                    logEx.Info("RefreshMonitorCamera success.");
                }
                else
                {
                    logEx.Error("RefreshMonitorCamera failed.");
                    err.SetErrorNo(CgwError.ERR_REFRESH_MONITOR_CAMERA_FAIL);
                    break;
                }
            }
            return err;
        }
Esempio n. 4
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);
     }
 }
Esempio n. 5
0
        /// <summary>
        /// 获取监控摄像头列表刷新状态,返回结果为0是表示刷新完毕,为1是刷新操作中。当查询刷新状态为0时,可调用获取监控摄像头列表接口,获取刷新后监控摄像头列表
        /// </summary>
        /// <returns></returns>
        public SmcErr GetRefreshStatus(out SmcErr refreshStatus)
        {
            NLogEx.LoggerEx logEx = new NLogEx.LoggerEx(log);
            logEx.Trace("Enter: VideoMonitorManage.GetRefreshStatus.");

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

            //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("GetRefreshStatus failed.Execption message:{0}", e.Message);
                }
                finally
                {
                    this.monitorsOperateLock.ExitReadLock();
                }
            }
            if (monitorsDictionaryTemp == null)
            {
                //记录日志,获取*监控平台的摄像头列表失败
                logEx.Error("GetRefreshStatus from monitor failed.No any monitor.");
                err.SetErrorNo(CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED);
                return err;
            }
            //循环已加载的所有的监控平台,将所有摄像头和分组组成一个list返回

            SmcErr tempMonitor = new SmcErr();
            tempMonitor.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;
            SmcErr tempLTE = new SmcErr();
            tempLTE.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;

            foreach (KeyValuePair<string, IVideoMonitor> monitor in monitorsDictionaryTemp)
            {
                IVideoMonitor videoMonitor = monitor.Value;

                if (monitor.Key != "eLTE")
                {
                    if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END)
                    {
                        err = videoMonitor.GetRefreshStatus(out tempMonitor);
                    }
                }
                else
                {
                    err = videoMonitor.GetRefreshStatus(out tempLTE);
                }

                if (!err.IsSuccess())
                {
                    logEx.Error("GetRefreshStatus failed.");
                    err.SetErrorNo(CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED);
                    refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED;
                    return err;
                }
            }

            //监控和elte都刷新完毕
            if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END;
            }
            //监控和elte都刷新执行中
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING;
            }
            //监控和elte都刷新失败
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED;
            }
            //监控成功、elte失败
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_SUCCESS_ELTE_FAIL;
            }
            //监控成功、elte执行中
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_SUCCESS_ELTE_EXECUTING;
            }
            //监控执行中、elte成功
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_EXECUTING_ELTE_SUCCESS;
            }
            //监控执行中、elte失败
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_EXECUTING_ELTE_FAIL;
            }
            //监控失败、elte成功
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_END)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_FAIL_ELTE_SUCCESS;
            }
            //监控失败、elte执行中
            else if (tempMonitor.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_FAILED && tempLTE.ErrNo == CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_EXECUTING)
            {
                refreshStatus.ErrNo = CgwError.ERR_DEVICE_LIST_REFRESH_STATUS_MONITOR_FAIL_ELTE_EXECUTING;
            }
            return err;
        }