public void Timer1CallBack(object sender, ElapsedEventArgs e) { try { if (faceCompareInfoList != null && faceCompareInfoList.Count > 0) { FaceCompareInfo faceCompareInfo = faceCompareInfoList.FirstOrDefault(x => !x.isShow); if (faceCompareInfo != null && !string.IsNullOrWhiteSpace(faceCompareInfo.CompareImage)) { if (!string.IsNullOrWhiteSpace(faceCompareInfo.CompareImage)) { bool result = onProcessEvent(faceCompareInfo.CompareImage, faceCompareInfo.PersonName, faceCompareInfo.Sex == "男" ? "先生" : (faceCompareInfo.Sex == "女" ? "女士" : "")); faceCompareInfo.isShow = result; if (result) { ToolHelper.RecordSystemInfoLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, string.Format("{0}显示成功", faceCompareInfo.PersonName)); } else { ToolHelper.RecordSystemErrorLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, string.Format("{0}显示失败", faceCompareInfo.PersonName), JsonConvert.SerializeObject(faceCompareInfo)); } } } else { if (timer1.Enabled) { timer1.Enabled = false; } ToolHelper.RecordSystemInfoLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, JsonConvert.SerializeObject(faceCompareInfo)); } } else { if (timer1.Enabled) { timer1.Enabled = false; } ToolHelper.RecordSystemInfoLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, "faceCompareInfoList.Count为0"); } } catch (Exception ex) { ToolHelper.RecordSystemErrorLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, ex.Message, ex.StackTrace); } }
/// <summary> /// 报警上传回调函数 /// </summary> /// <param name="lCommand"></param> /// <param name="pAlarmer"></param> /// <param name="pAlarmInfo"></param> /// <param name="dwBufLen"></param> /// <param name="pUser"></param> /// <returns></returns> public bool MsgCallback_V31(int lCommand, ref CHCNetSDK.NET_DVR_ALARMER pAlarmer, IntPtr pAlarmInfo, uint dwBufLen, IntPtr pUser) { try { string strIP = pAlarmer.sDeviceIP; string infoStr = string.Format("{0}上传{1}类型报警", strIP, lCommand); ToolHelper.RecordSystemInfoLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, infoStr); //通过lCommand来判断接收到的报警信息类型,不同的lCommand对应不同的pAlarmInfo内容 switch (lCommand) { case CHCNetSDK.COMM_SNAP_MATCH_ALARM: //人脸比对结果信息 ToolHelper.RecordSystemInfoLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, "MsgCallback_V31"); ProcessCommAlarm_FaceMatch(pAlarmer, pAlarmInfo, dwBufLen, pUser); break; } } catch (Exception ex) { ToolHelper.RecordSystemErrorLog(this.GetType().ToString(), MethodBase.GetCurrentMethod().Name, ex.Message, ex.StackTrace); } return(true); //回调函数需要有返回,表示正常接收到数据 }