private void btnTestAuth_Click(object sender, RoutedEventArgs e) { try { EnableFingerPrintComponent(false); if (fingerSensor.CmdCmosLed(true) == 0) { UpdateCompLogMsg("Input your finger on sensor."); if (fingerSensor.CmdCaptureFinger() == 0) { UpdateCompLogMsg("Exporting deleted fingerprint data"); if (fingerSensor.CmdGetRawImage() == 0) { UpdateCompLogMsg("Succeed export fingerprint data."); Bitmap receivedImage = BBDataConverter.GrayRawToBitmap(fingerSensor.getRawImage(), FingerSensorPacket.SIZE_FP_WIDTH, FingerSensorPacket.SIZE_FP_HEIGHT); UpdateReceivedImage(receivedImage); UserManager fpm = new UserManager(); MyPerson guest = fpm.Enroll(BBDataConverter.ImageToByte(receivedImage), "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 { UpdateCompLogMsg("Failed export fingerparint data."); } } else { UpdateCompLogMsg("Time out or can not delected fingerprint."); } } } catch (Exception ex) { Console.WriteLine(ex.Message); UpdateCompLogMsg("Failed export fingerparint data."); } finally { fingerSensor.CmdCmosLed(false); EnableFingerPrintComponent(true); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (tbName.Text == "" || tbName == null) { MessageBox.Show("이름을 입력하세요.", "알림", MessageBoxButton.OK); return; } else if (tbIdNum.Text == "" || tbIdNum == null) { MessageBox.Show("주민번호를 입력하세요.", "알림", MessageBoxButton.OK); return; } else if (tbPhone.Text == "" || tbPhone == null) { MessageBox.Show("연락처를 입력하세요.", "알림", MessageBoxButton.OK); return; } else if (pbFingerPrint.Source == null) { MessageBox.Show("지문을 입력하세요.", "알림", MessageBoxButton.OK); return; } if (MessageBox.Show("저장하시겠습니까?", "알림", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { int executeCnt = 0; byte[] fpBytes = BBDataConverter.ImageToByte(fp.AsBitmap); m_user = userManager.Enroll(fpBytes, UserId, tbName.Text, tbIdNum.Text, tbPhone.Text, tbEmail.Text); executeCnt = userManager.SaveUser(m_user); if (executeCnt > 0) { MessageBox.Show("사용자(" + m_user.Name + ") 정보가 저장되었습니다.", "알림", MessageBoxButton.OK); this.DialogResult = true; this.Close(); } else { MessageBox.Show("사용자(" + m_user.Name + ") 정보가 저장되지 않았습니다.", "알림", MessageBoxButton.OK); } } }
public static byte[] StructToByte(Packet pkt) { MemoryStream ms = new MemoryStream(); BinaryWriter bw = new BinaryWriter(ms); bw.Write((int)pkt.type); bw.Write(pkt.userId); try { byte[] carId = new byte[16]; Encoding.UTF8.GetBytes(pkt.carId, 0, pkt.carId.Length, carId, 0); bw.Write(carId); } catch (Exception ex) { Console.WriteLine("Error : {0}", ex.Message.ToString()); } bw.Write((int)0); byte[] guid; switch (pkt.type) { case PktType.AUTH: if (pkt.fingerPrint != null) { byte[] fp = BBDataConverter.ImageToByte(pkt.fingerPrint); bw.Write(fp.Length); bw.Write(fp); } else { bw.Write(0); } break; case PktType.PASSENGER: guid = BBDataConverter.StringToByte(pkt.guid); byte[] psgCnt = BBDataConverter.Int32ToByte(pkt.psgCnt); bw.Write(guid.Length + psgCnt.Length); bw.Write(guid); bw.Write(psgCnt); break; case PktType.ORDER: guid = BBDataConverter.StringToByte(pkt.guid); byte[] accessId = BBDataConverter.Int32ToByte(pkt.accessId); bw.Write(guid.Length + accessId.Length); bw.Write(guid); bw.Write(accessId); break; case PktType.ONCE: byte[] psgCnt1 = BBDataConverter.Int32ToByte(pkt.psgCnt); bw.Write(psgCnt1.Length + pkt.data.Length); bw.Write(psgCnt1); bw.Write(pkt.data); break; } bw.Close(); byte[] buffer = ms.ToArray(); ms.Dispose(); return(buffer); }