/// <summary> /// 扫码进入闸机流程 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void EntryByCodeProcess(object sender, TX400Scanner.QRcodeScannerEventArgs e) { //scanner is trigged, lock the system 3s if (sysIsLock == false) { //lock the scanner in case this process is interrupted scanner.Lock(); logger.Info("Recieved code=" + e.Code); logger.Trace("Lock QR code scanner started " + DateTime.Now.ToString()); char[] trimchars = new char[2] { '\0', ' ' }; string trimcode = e.Code.Trim(trimchars); APIClient.Code code = new APIClient.Code() { code = trimcode }; APIClient.UserInfo userinfo = client.EntryByCode(code); if (userinfo.nickName != string.Empty) { SetTileButton(tileBtn, userinfo); SetTileButtonVisable(tileBtn, true); SetPictureBox(pictureBoxCenter, new Bitmap("success.gif")); SetPictureBoxVisibility(loadBox_small, false); SetMessageLabel(bunifuCustomLabel1, code_identify_success_str); OpenGate(); PlayWelcomSound(userinfo.nickName); APIClient.Log log = new APIClient.Log() { who = userinfo.id, where = shopid }; client.VistLogToSystem(log); //success code will lock the system for 3s LockSystem(); //clear textbox SetDataText(richTextBox1, string.Empty); } else { //服务器没有返回用户信息 //todo:提示QRcode错误 logger.Error("Server return unvalid user info, QR code Error"); scanner.Unlock(); } } else { //skip this scan result if system is lockeds } }
/// <summary> /// tilebutton委托赋值函数 /// </summary> /// <param name="tileButton"></param> /// <param name="userInfo"></param> private void SetTileButton(Bunifu.Framework.UI.BunifuTileButton tileButton, APIClient.UserInfo userInfo) { if (tileButton.InvokeRequired) { setTileButton setThis = new setTileButton(SetTileButton); tileButton.Invoke(setThis, tileButton, userInfo); } else { tileButton.Image = APIClient.LoadPicture(userInfo.avatarUrl); tileButton.LabelText = userInfo.nickName; } }
/// <summary> /// 刷脸进门流程处理,直接调用aip节省阿里云流量费用 /// </summary> /// <param name="bmap"></param> /// <returns></returns> private bool faceIdentify_usingAIP(Bitmap bmap) { bool ret = false; var result = CVclient.face_search_using_aip(bmap); logger.Info("Get Face search return message : " + result.ToString()); if (result.GetValue("error_code").ToString() != "0") { ret = false; } else { var score = result["result"]["user_list"][0]["score"]; double valid = Convert.ToDouble(score.ToString()); if (valid >= 90) { var id = result["result"]["user_list"][0]["user_id"]; APIClient.ID uid = new APIClient.ID() { id = id.ToString() }; APIClient.UserInfo userinfo = client.GetUserInfo(uid); if (userinfo.nickName != string.Empty) { SetTileButton(tileBtn, userinfo); SetTileButtonVisable(tileBtn, true); OpenGate(); //PlayWelcomSound(userinfo.nickName); APIClient.Log log = new APIClient.Log() { who = userinfo.id, where = shopid }; client.VistLogToSystem(log); ret = true; } } } return(ret); }
/// <summary> /// 刷脸进门流程处理, Not Used /// </summary> /// <param name="bmap"></param> private bool faceIdentify(Bitmap bmap) { bool ret = false; try { //random file name, solving conflict problem string filepath = rand_filename.Next().ToString() + ".jpg"; if (File.Exists(filepath)) { File.Delete(filepath); } bmap.Save(filepath, System.Drawing.Imaging.ImageFormat.Jpeg); APIClient.UserInfo userinfo = client.EntryByFace(filepath); if (userinfo.nickName != string.Empty) { SetTileButton(tileBtn, userinfo); SetTileButtonVisable(tileBtn, true); OpenGate(); //PlayWelcomSound(userinfo.nickName); APIClient.Log log = new APIClient.Log() { who = userinfo.id, where = shopid }; client.VistLogToSystem(log); ret = true; } File.Delete(filepath); } catch (Exception ex) { logger.Error("Camera Event search faces failed, exception: " + ex.ToString()); } return(ret); }