111,119
社区成员
发帖
与我相关
我的任务
分享//{{AFX_INCLUDES()
#include "doronuruactivex.h"
//}}AFX_INCLUDES
#if !defined(AFX_FINGERPRINTAUTHENDLG_H__57AE9845_17DD_4DCA_A50A_68E222256922__INCLUDED_)
#define AFX_FINGERPRINTAUTHENDLG_H__57AE9845_17DD_4DCA_A50A_68E222256922__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// FingerprintAuthenDlg.h : header file
//
#include "tcmfpctl.h"
#include "doronuruactivex.h"
/////////////////////////////////////////////////////////////////////////////
// CFingerprintAuthenDlg dialog
class CFingerprintAuthenDlg : public CDialog
{
// Construction
public:
CFingerprintAuthenDlg(CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CFingerprintAuthenDlg)
enum { IDD = IDD_FINGERPRINTAUTHENDLG_DIALOG };
CString m_sPIdNo;
CString m_sName;
CString m_sExamIdNo;
CString m_sExamAutoType;
CString m_sVerificationStatus;
//}}AFX_DATA
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CFingerprintAuthenDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
char m_sFingerprint1[FINGERPRINT_LEN];
char m_sFingerprint2[FINGERPRINT_LEN];
CString m_sPhotoFileName;
bool m_bIsSnapped;
bool m_bIsAuthenticated;
CTCMFPCtl *m_pCTCMFPCtrl;
CDoronUruActiveX *m_pCDoronUruActiveXCtrl;
// Generated message map functions
//{{AFX_MSG(CFingerprintAuthenDlg)
virtual BOOL OnInitDialog();
afx_msg void OnButtonSnap();
virtual void OnOK();
virtual void OnCancel();
afx_msg void OnNotifyDoronuruactivexctrlFp(short SensorNo, short NotifyCode);
afx_msg void OnPaint();
DECLARE_EVENTSINK_MAP()
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_FINGERPRINTAUTHENDLG_H__57AE9845_17DD_4DCA_A50A_68E222256922__INCLUDED_)
// FingerprintAuthenDlg.cpp : implementation file
//
#include "stdafx.h"
#include "garage.h"
#include "GarageDlg.h"
#include "FingerprintAuthenDlg.h"
#include "mmsystem.h"
#include "CImage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern char gFingerprintAuthenAudioPrompt[INI_KEY_LEN];
extern int gFingerprintDevice;
/////////////////////////////////////////////////////////////////////////////
// CFingerprintAuthenDlg dialog
CFingerprintAuthenDlg::CFingerprintAuthenDlg(CWnd* pParent /*=NULL*/)
: CDialog(CFingerprintAuthenDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CFingerprintAuthenDlg)
m_sPIdNo = _T("");
m_sName = _T("");
m_sExamIdNo = _T("");
m_sExamAutoType = _T("");
m_sVerificationStatus = _T("");
//}}AFX_DATA_INIT
CGarageDlg *pDlg = NULL;
if(pParent)
pDlg = (CGarageDlg*) pParent;
if(!pDlg)
return;
m_sExamAutoType = pDlg->m_sExamAutoType;
m_sExamIdNo = pDlg->m_sExamIdNo;
m_sName = pDlg->m_sName;
m_sPIdNo = pDlg->m_sPIdNo;
m_sPhotoFileName = pDlg->m_sPhotoFileName;
strncpy(m_sFingerprint1, pDlg->m_Exam.m_Examinee.GetFingerprint1(), FINGERPRINT_LEN);
strncpy(m_sFingerprint2, pDlg->m_Exam.m_Examinee.GetFingerprint2(), FINGERPRINT_LEN);
m_bIsSnapped = false;
m_bIsAuthenticated = false;
m_pCTCMFPCtrl = NULL;
m_pCDoronUruActiveXCtrl = NULL;
}
void CFingerprintAuthenDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFingerprintAuthenDlg)
DDX_Text(pDX, IDC_EDIT_PID_NO, m_sPIdNo);
DDX_Text(pDX, IDC_EDIT_NAME, m_sName);
DDX_Text(pDX, IDC_EDIT_EXAMID_NO, m_sExamIdNo);
DDX_Text(pDX, IDC_EDIT_EXAM_AUTO_TYPE, m_sExamAutoType);
DDX_Text(pDX, IDC_EDIT_VERIFICATION_STATUS, m_sVerificationStatus);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFingerprintAuthenDlg, CDialog)
//{{AFX_MSG_MAP(CFingerprintAuthenDlg)
ON_BN_CLICKED(IDC_BUTTON_SNAP, OnButtonSnap)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFingerprintAuthenDlg message handlers
BOOL CFingerprintAuthenDlg::OnInitDialog()
{
CDialog::OnInitDialog();
if(!strcmp(m_sFingerprint1, "") && !strcmp(m_sFingerprint2, ""))
m_sVerificationStatus = "数据库中没有该考生的指纹数据!";
if(gFingerprintDevice == 0)
{
m_pCTCMFPCtrl = (CTCMFPCtl*)GetDlgItem(IDC_TCMFPCTLCTRL_FP);
if(m_pCTCMFPCtrl)
if(m_pCTCMFPCtrl->Connect() != 1)
m_sVerificationStatus = "连接指纹仪失败!";
else
{
//PlaySound(gFingerprintAuthenAudioPrompt, NULL, SND_ASYNC);
m_pCTCMFPCtrl->ShowWindow(true);
}
}
else
{
m_pCDoronUruActiveXCtrl = (CDoronUruActiveX*)GetDlgItem(IDC_DORONURUACTIVEXCTRL_FP);
if(m_pCDoronUruActiveXCtrl)
{
m_pCDoronUruActiveXCtrl->Init(0.001, 1000, false);
m_pCDoronUruActiveXCtrl->ShowWindow(true);
}
else
m_sVerificationStatus = "初始化指纹仪失败!";
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BEGIN_EVENTSINK_MAP(CFingerprintAuthenDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CFingerprintAuthenDlg)
ON_EVENT(CFingerprintAuthenDlg, IDC_DORONURUACTIVEXCTRL_FP, 1 /* Notify */, OnNotifyDoronuruactivexctrlFp, VTS_I2 VTS_I2)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CFingerprintAuthenDlg::OnNotifyDoronuruactivexctrlFp(short SensorNo, short NotifyCode)
{
m_pCDoronUruActiveXCtrl->Invalidate();
switch(NotifyCode)
{
case 1:
m_sVerificationStatus = "连接指纹仪成功!";
break;
case -1:
m_sVerificationStatus = "连接指纹仪失败!";
break;
case 3:
m_sVerificationStatus = "指纹核对成功!请按确认考生身份按钮,准备开始考试。";
m_bIsAuthenticated = true;
m_bIsSnapped = true;
break;
case -3:
m_sVerificationStatus = "指纹不匹配!请重试。";
m_pCDoronUruActiveXCtrl->Verify("", false);
m_bIsAuthenticated = false;
m_bIsSnapped = true;
break;
case 6:
m_pCDoronUruActiveXCtrl->Invalidate();
break;
case -10:
m_sVerificationStatus = "无效的指纹仪设备!";
break;
}
UpdateData(FALSE);
m_pCDoronUruActiveXCtrl->Invalidate();
}
void CFingerprintAuthenDlg::OnButtonSnap()
{
if(gFingerprintDevice == 0)
{
if(m_pCTCMFPCtrl)
{
if(m_pCTCMFPCtrl->Snap() != 1)
{
m_bIsSnapped = false;
m_sVerificationStatus = "没有取到指纹!请重试。";
UpdateData(FALSE);
return;
}
m_bIsSnapped = true;
char sEnrollTemplate[FINGERPRINT_LEN] = "\0";
for(int i = 0; i < 2; i++)
{
m_sVerificationStatus = "请考生将手指放到指纹仪上。";
if(i == 0)
{
if(strcmp(m_sFingerprint1, ""))
strncpy(sEnrollTemplate, m_sFingerprint1, FINGERPRINT_LEN);
else
continue;
}
if(i == 1)
{
if(strcmp(m_sFingerprint2, ""))
strncpy(sEnrollTemplate, m_sFingerprint2, FINGERPRINT_LEN);
else
{
if(!strcmp(m_sFingerprint1, ""))
{
AfxMessageBox("数据库中没有该考生的指纹数据!考生身份无法验证。");
return;
}
continue;
}
}
// Set EnrollTemplate.
m_pCTCMFPCtrl->SetEnrollTemplate(sEnrollTemplate);
// Set the verify security to be the lowest 4 : 1/1000.
m_pCTCMFPCtrl->SetVerifySecurity(4);
if(m_pCTCMFPCtrl->Verify() == 1)
{
m_sVerificationStatus = "指纹核对成功!请稍候 ...";
UpdateData(FALSE);
m_bIsAuthenticated = true;
Sleep(3000);
m_pCTCMFPCtrl->Disconnect();
CDialog::OnOK();
return;
}
else
m_bIsAuthenticated = false;
}
if(!m_bIsAuthenticated)
m_sVerificationStatus = "指纹不匹配!";
UpdateData(FALSE);
}
}
else
{
if(m_pCDoronUruActiveXCtrl)
{
m_sVerificationStatus = "请考生将手指放到指纹仪上进行指纹比对。";
//PlaySound(gFingerprintAuthenAudioPrompt, NULL, SND_ASYNC);
if(m_bIsSnapped)
{
m_pCDoronUruActiveXCtrl->Terminate();
m_pCDoronUruActiveXCtrl->Init(0.001, 1000, false);
}
char sFingerprint1[1001] = "\0";
char sFingerprint2[1001] = "\0";
strncpy(sFingerprint1, m_sFingerprint1, 1000);
strncpy(sFingerprint2, m_sFingerprint2, 1000);
m_pCDoronUruActiveXCtrl->Clear();
m_pCDoronUruActiveXCtrl->PutBase64Feature("", "", sFingerprint1);
m_pCDoronUruActiveXCtrl->PutBase64Feature("", "", sFingerprint2);
m_pCDoronUruActiveXCtrl->Verify("", false);
}
}
}
void CFingerprintAuthenDlg::OnCancel()
{
if(m_bIsAuthenticated)
{
int nResponseCode = AfxMessageBox("考生指纹核对已经成功,是否终止考试?", MB_OKCANCEL);
if(nResponseCode == IDCANCEL)
return;
}
if(gFingerprintDevice == 0)
m_pCTCMFPCtrl->Disconnect();
else
m_pCDoronUruActiveXCtrl->Terminate();
CDialog::OnCancel();
}
void CFingerprintAuthenDlg::OnOK()
{
if(!m_bIsAuthenticated)
{
int nResponseCode = AfxMessageBox("考生指纹核对尚未成功,是否继续进行考试?", MB_OKCANCEL);
if(nResponseCode == IDCANCEL)
return;
}
if(gFingerprintDevice == 0)
m_pCTCMFPCtrl->Disconnect();
else
m_pCDoronUruActiveXCtrl->Terminate();
CDialog::OnOK();
}
void CFingerprintAuthenDlg::OnPaint()
{
if(m_sPhotoFileName.Find(".jpg") != -1)
{
CPaintDC dc(this); // device context for painting
CImage imgObj(m_sPhotoFileName);
CPalette *hOldPal = NULL;
if(imgObj.GetPalette())
{
hOldPal = dc.SelectPalette((CPalette*)imgObj.GetPalette(), TRUE);
dc.RealizePalette();
}
//int rc = imgObj.Draw(&dc, 30, 30);
imgObj.Stretch(&dc, 30, 30, 240, 360);
if(hOldPal)
dc.SelectPalette(hOldPal, TRUE);
}
// Do not call CDialog::OnPaint() for painting messages
}