/// <summary> /// 设置报警上传回调 /// </summary> /// <param name="deviceInfo"></param> public void SetDVRMessageCallBack(DeviceInfo deviceInfo, CHCNetSDK.MSGCallBack_V31 msgCallback) { try { BaseHelper hikVisionHelper = new HikVisionHelper(); if (!FaceRecognizeSignForm.isInit) { FaceRecognizeSignForm.isInit = hikVisionHelper.Init(); } if (FaceRecognizeSignForm.isInit) { bool isSuccess = hikVisionHelper.SetDVRMessageCallBack(msgCallback); if (!isSuccess) { RecordErrorCode(string.Format("{0} 设置报警上传回调函数失败", deviceInfo.deviceIp)); } } else { RecordErrorCode("初始化失败"); } } catch (Exception ex) { ToolHelper.RecordSystemErrorLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, ex.Message, ex.StackTrace); } }
/// <summary> /// 记录错误码 /// </summary> public void RecordErrorCode(string str) { try { BaseHelper hikVisionHelper = new HikVisionHelper(); uint errorCode = hikVisionHelper.GetLastError(); string fileName = string.Format("{0}_{1}.txt", DateTime.Now.ToString("yyyy-MM-dd"), MethodBase.GetCurrentMethod().Name); string content = string.Format("{0} {1}.{2} {3}:{4}", DateTime.Now, this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, str, errorCode); ToolHelper.RecordLog(fileName, content); } catch (Exception ex) { ToolHelper.RecordSystemErrorLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, ex.Message, ex.StackTrace); } }
/// <summary> /// 释放资源 /// </summary> /// <returns></returns> public void Cleanup() { try { BaseHelper hikVisionHelper = new HikVisionHelper(); bool result = hikVisionHelper.Cleanup(); if (!result) { RecordErrorCode("释放资源失败"); } } catch (Exception ex) { ToolHelper.RecordSystemErrorLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, ex.Message, ex.StackTrace); } }
/// <summary> /// 注销用户 /// </summary> /// <param name="deviceInfo"></param> public void LogOut(DeviceInfo deviceInfo) { try { if (deviceInfo.loginId > -1) { BaseHelper hikVisionHelper = new HikVisionHelper(); bool isSuccess = hikVisionHelper.LogOut(deviceInfo); if (!isSuccess) { RecordErrorCode(string.Format("{0} 注销失败", deviceInfo.deviceIp)); } } } catch (Exception ex) { ToolHelper.RecordSystemErrorLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, ex.Message, ex.StackTrace); } }
/// <summary> /// 预览 /// </summary> /// <param name="deviceInfo"></param> public void Prievew(DeviceInfo deviceInfo) { try { BaseHelper hikVisionHelper = new HikVisionHelper(); if (!FaceRecognizeSignForm.isInit) { FaceRecognizeSignForm.isInit = hikVisionHelper.Init(); } if (FaceRecognizeSignForm.isInit) { if (deviceInfo.loginId < 0) { hikVisionHelper.Login(deviceInfo); } if (deviceInfo.loginId > -1) { hikVisionHelper.Preview(deviceInfo, null); if (deviceInfo.realHandle < 0) { RecordErrorCode(string.Format("{0} 预览失败", deviceInfo.deviceIp)); } } else { RecordErrorCode(string.Format("{0} 登录失败", deviceInfo.deviceIp)); } } else { RecordErrorCode("初始化失败"); } } catch (Exception ex) { ToolHelper.RecordSystemErrorLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, ex.Message, ex.StackTrace); } }