public void Execute() { while (!this._IsStop) { this._autoResetEvent.WaitOne(); if (!this._IsStop) { try { ResultInfo recognition = this._recognition; string channel = this._channel; byte[] faceImage = this._FaceImage; this._faceCompareLog = new FaceCompareLog { FaceDetcetDate = DateTime.Now.ToString(), FaceDetcetImage = Convert.ToBase64String(faceImage), FaceTempateImage = recognition.FaceTemplate.ImageLocation, PersonID = (long)Convert.ToInt16(recognition.FaceTemplate.PersonId), PersonName = recognition.FaceTemplate.PersonName, PersonNumber = recognition.FaceTemplate.PersonNumber, Similarity = recognition.Score.ToString("P"), tmp1 = channel, tmp2 = (recognition.FaceTemplate.PersonType == PersonType.Black) ? "黑名单" : "白名单" }; this._faceCompareLogService.Add(this._faceCompareLog); } catch (Exception message) { SaveFaceCompareThred._log.Error(message); } } } }
public int Add(FaceCompareLog faceCompareLog) { int result; using (this._mcFace = new McFaceContext()) { this._mcFace.FaceCompareLogs.Add(faceCompareLog); this._mcFace.SaveChanges(); result = (int)Convert.ToInt16(faceCompareLog.ID); } return(result); }
public static void AddFaceCompare(ResultInfo recognition, string channel, byte[] faceImage, string cameraIP) { FaceCompareLogService faceCompareLogService = new FaceCompareLogService(); string tmp = "VIP"; switch (recognition.FaceTemplate.PersonType) { case PersonType.Black: tmp = "黑名单"; break; case PersonType.White: tmp = "白名单"; break; case PersonType.VIP: tmp = "VIP"; break; } try { FaceCompareLog faceCompareLog = new FaceCompareLog { FaceDetcetDate = DateTime.Now.ToString("yyyy\\/M\\/d HH:mm:ss"), FaceDetcetImage = Convert.ToBase64String(faceImage), FaceTempateImage = recognition.FaceTemplate.ImageLocation, PersonID = (long)Convert.ToInt16(recognition.FaceTemplate.PersonId), PersonName = recognition.FaceTemplate.PersonName, PersonNumber = recognition.FaceTemplate.PersonNumber, Similarity = recognition.Score.ToString("P"), tmp1 = channel, tmp2 = tmp, tmp3 = cameraIP }; object obj = SaveFaceCompareThred._obj; lock (obj) { faceCompareLogService.Add(faceCompareLog); } UnitHelper.PostUrl2(recognition.FaceTemplate.PersonName); } catch (Exception message) { SaveFaceCompareThred._log.Error(message); } }