private void btnSave_Click(object sender, EventArgs e) { if (tbName.Text == "" || tbName == null) { MessageBox.Show("이름을 입력하세요.", "알림", MessageBoxButtons.OK); return; } else if (tbIdnum.Text == "" || tbIdnum == null) { MessageBox.Show("주민번호를 입력하세요.", "알림", MessageBoxButtons.OK); return; } else if (tbPhone.Text == "" || tbPhone == null) { MessageBox.Show("연락처를 입력하세요.", "알림", MessageBoxButtons.OK); return; } else if (pbFingerPrint.Image == null) { MessageBox.Show("지문을 입력하세요.", "알림", MessageBoxButtons.OK); return; } if (MessageBox.Show("저장하시겠습니까?", "알림", MessageBoxButtons.YesNo) == DialogResult.Yes) { int rtn = 0; byte[] iBytes = BBDataConverter.ImageToByte(BBDataConverter.GrayRawToBitmap(fingerSensor.getRawImage(), FingerSensorPacket.SIZE_FP_WIDTH, FingerSensorPacket.SIZE_FP_HEIGHT)); m_user = userManager.Enroll(iBytes, tbName.Text, tbIdnum.Text, tbPhone.Text, tbEmail.Text); switch (mode) { case MODE.SAVE: rtn = userManager.InsertUser(m_user); break; case MODE.MODIFY: m_user.Id = Int32.Parse(tbId.Text.ToString()); rtn = userManager.UpdateUser(m_user); break; } if (rtn > 0) { StatusMessage("사용자(" + m_user.Name + ") 정보가 저장되었습니다."); this.DialogResult = DialogResult.OK; this.Close(); } else { StatusMessage("사용자(" + m_user.Name + ") 정보가 저장되지 않았습니다."); } } }
private void btnConfirm_Click(object sender, EventArgs e) { try { EnableFingerPrintComponent(false); if (fingerSensor.CmdCmosLed(true) == 0) { UpdateStatusMessage("Input your finger on sensor."); if (fingerSensor.CmdCaptureFinger() == 0) { UpdateStatusMessage("Exporting deleted fingerprint data"); if (fingerSensor.CmdGetRawImage() == 0) { UpdateStatusMessage("Succeed export fingerprint data."); pbImage.Image = BBDataConverter.GrayRawToBitmap(fingerSensor.getRawImage(), FingerSensorPacket.SIZE_FP_WIDTH, FingerSensorPacket.SIZE_FP_HEIGHT); UserManager fpm = new UserManager(); MyPerson guest = fpm.Enroll(BBDataConverter.ImageToByte(pbImage.Image), "guest"); MyPerson match = fpm.recognition(guest); if (match != null) { UpdateCompLogMsg("Matched person(" + match.Name + "): " + VerifyUserMatchRate(guest, match)); } else { UpdateCompLogMsg("No matching person found."); } UpdateCompMatchedUser(match); } else { UpdateStatusMessage("Failed export fingerparint data."); } } else { UpdateStatusMessage("Time out or can not delected fingerprint."); } } } catch (Exception ex) { Console.WriteLine(ex.Message); UpdateStatusMessage("Failed export fingerparint data."); } finally { fingerSensor.CmdCmosLed(false); EnableFingerPrintComponent(true); } }
public MyPerson RunAuth(Packet pkt) { UserManager fpm = new UserManager(); MyPerson match = null; Code code; try { MyPerson guest = fpm.Enroll(BBDataConverter.ImageToByte(pkt.fingerPrint), "guest"); match = fpm.recognition(guest); if (match != null) { Console.WriteLine("Found matched fingerprint."); bool isMatch = CheckLoginUser(match.Id, pkt.userId); if (isMatch) { SetLoginUser(match); UpdateLogMsgWithName("Matched person(" + match.Name.ToString() + ")"); //UpdateMatchedUser(match); pkt.guid = GetLoginUser().Guid; code = Code.SUCCESS_AUTH; } else { UpdateLogMsgWithName("Not Matched person"); code = Code.NOT_MATCH_LOGIN_FP; } } else { Console.WriteLine("Not found matched fingerprint."); UpdateLogMsgWithName("Not found matched fingerprint"); code = Code.NOT_FND_FINGERPRINT; } } catch (Exception e) { code = Code.ERROR; pkt.errMsg = e.Message; } SendResponse(pkt, code); return(match); }
public MyPerson RunAtOnce(Packet pkt) { UserManager fpm = new UserManager(); MyPerson match = null; Code code; try { MyPerson guest = fpm.Enroll(BBDataConverter.ImageToByte(pkt.fingerPrint), "guest"); match = fpm.recognition(guest); if (match != null) { bool isMatch = CheckLoginUser(match.Id, pkt.userId); if (isMatch) { SetLoginUser(match); UpdateLogMsgWithName("Step1: Check fingerprint(" + "Matched person(" + match.Name.ToString() + ")" + ")"); code = Code.SUCCESS_AUTH; AccessInfo access = new AccessInfoDB().SelectNowAccessibleInfo(GetLoginUser().Guid, pkt.carId); if (access != null) { if (access.access_dt == default(DateTime)) { if (pkt.psgCnt == access.psgCnt) { UpdateLogMsgWithName("Step2: Check passenger count(" + access.psgCnt + ")"); code = Code.SUCCESS_PASSENGER; pkt.accessId = access.seq; OrderInfo order = new OrderInfoManager().FindOrderInfoByAccessId(access.seq); if (order != null) { UpdateLogMsgWithName("Step3: Find Order Info(" + order.orderId + ")"); pkt.order = order; code = Code.SUCCESS_ORDER; } else { code = Code.NOT_FND_ORDER_INFO; } } else { code = Code.NOT_MATCH_PASSENGER_CNT; } } else { code = Code.ALREADY_ACCESS; } } else { code = Code.NOT_FND_ACCESS_INFO; } } else { code = Code.NOT_MATCH_LOGIN_FP; } } else { Console.WriteLine("Not found matched fingerprint."); code = Code.NOT_FND_FINGERPRINT; } } catch (Exception e) { code = Code.ERROR; pkt.errMsg = e.Message; } if (code == Code.SUCCESS_AUTH || code == Code.SUCCESS_ORDER || code == Code.SUCCESS_PASSENGER) { UpdateLogMsgWithName("Success authentication."); // if code is SUCCESS, Open gate and update access date new AccessInfoDB().UpdateAccessDate(pkt.accessId); } else { UpdateLogMsgWithName("Failed authentication.(" + GetMessage(code.ToString()) + ")"); } SendResponse(pkt, code); return(match); }