/// <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; }
/// <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; }