|
@@ -1665,7 +1665,6 @@ ErrorCodeEnum CCustMngrAuthFSM::SaveFingerPrint(SpReqAnsContext<CustMngrAuthServ
|
|
|
fd->FingerIDArray[i] = ctx->Req.FPFeatureList[i];
|
|
|
fd->FingerIDLenArray[i] = fd->FingerIDArray[i].GetLength();
|
|
|
}
|
|
|
-
|
|
|
if (m_featureData.find(ctx->Req.CustomerID) == m_featureData.end())
|
|
|
{
|
|
|
//not exist, insert directly
|
|
@@ -1913,4 +1912,141 @@ ErrorCodeEnum CCustMngrAuthFSM::AnalyzeMatchResult(MatchParams* matchParam, bool
|
|
|
return Error_Unexpect;
|
|
|
}
|
|
|
|
|
|
+ErrorCodeEnum CCustMngrAuthFSM::MatchFingerPrintEx(SpReqAnsContext<CustMngrAuthService_QueryAuthorInfo_Req, CustMngrAuthService_QueryAuthorInfo_Ans>::Pointer ctx, bool& bStopAuthorize, DWORD& dwUserErrCode)
|
|
|
+{
|
|
|
+ LOG_FUNCTION();
|
|
|
+ ErrorCodeEnum errCode;
|
|
|
+ m_pFingerPrint = new FingerPrintService_ClientBase(m_pEntity);
|
|
|
+ errCode = m_pFingerPrint->Connect();
|
|
|
+ if (errCode != Error_Succeed)
|
|
|
+ {
|
|
|
+ Dbg("ERROR: connect to fingerprint entity failed while match");
|
|
|
+ m_pFingerPrint->SafeDelete();
|
|
|
+ m_pFingerPrint = NULL;
|
|
|
+ return Error_Hardware; //TODO::give one other errCode
|
|
|
+ }
|
|
|
+
|
|
|
+ CSimpleStringA depPath(true);
|
|
|
+ m_pEntity->GetFunction()->GetPath("Dep", depPath);
|
|
|
+
|
|
|
+ FingerPrintService_GetFingerPrint_Req GetFingerReq;
|
|
|
+ FingerPrintService_GetFingerPrint_Ans GetFingerAns;
|
|
|
+ GetFingerReq.times = 10;
|
|
|
+
|
|
|
+ if (m_pFingerPrint == NULL || m_pFingerPrint->QuerySessionClosed())
|
|
|
+ {
|
|
|
+ Dbg("m_pFingerPrint is NULL or connection closed.");
|
|
|
+ return Error_Hardware;
|
|
|
+ }
|
|
|
+
|
|
|
+ errCode = m_pFingerPrint->GetFingerPrint(GetFingerReq, GetFingerAns, 30000, dwUserErrCode);
|
|
|
+
|
|
|
+ if (errCode == Error_NotInit)
|
|
|
+ {
|
|
|
+ Dbg("FingerPrintEntity not ready or failed.");
|
|
|
+ return Error_Hardware;
|
|
|
+ }
|
|
|
+
|
|
|
+ bStopAuthorize = true;
|
|
|
+ if (m_bCancelAuthorize || GetFingerAns.reserved1[0] == 3) {
|
|
|
+ Dbg("GetFingerPrint is canceled while match.");
|
|
|
+ m_bCancelAuthorize = false;
|
|
|
+ if (m_bAuthorizeTimeout) {
|
|
|
+ m_bAuthorizeTimeout = false;
|
|
|
+ return Error_TimeOut;
|
|
|
+ }
|
|
|
+ return Error_Cancel;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (errCode == Error_Succeed)
|
|
|
+ {
|
|
|
+ switch (GetFingerAns.reserved1[0])
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ errCode = Error_Succeed;
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ errCode = Error_TimeOut;
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ errCode = Error_Cancel;
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ errCode = Error_Unexpect;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (errCode == Error_Succeed)
|
|
|
+ {
|
|
|
+ m_authCtx.eAuthByWhich = AuthByFngPrnt;
|
|
|
+ ctx->Ans.Feature = GetFingerAns.feature;
|
|
|
+
|
|
|
+ CBlob data;
|
|
|
+ CSimpleStringA imgFullPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", depPath.GetData(), GetFingerAns.imageName.GetData());
|
|
|
+ ErrorCodeEnum imgErrCode = GetImgBlob(data, imgFullPath);
|
|
|
+ if (imgErrCode != Error_Succeed)
|
|
|
+ {
|
|
|
+ Dbg("Failed to load image(%s)", imgFullPath.GetData());
|
|
|
+ return Error_Unexpect;
|
|
|
+ }
|
|
|
+ ctx->Ans.FingerImg = data;
|
|
|
+ m_authCtx.Feature = ctx->Ans.Feature;
|
|
|
+ m_authCtx.FingerImg = ctx->Ans.FingerImg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ errCode = Error_Unexpect;
|
|
|
+
|
|
|
+ DeleteBmp(BmpImage);
|
|
|
+ return errCode;
|
|
|
+}
|
|
|
+
|
|
|
+void CCustMngrAuthFSM::DeleteBmp(int type)
|
|
|
+{
|
|
|
+ if ((type & BmpImage) == BmpImage)
|
|
|
+ {
|
|
|
+ Dbg("to delete fingerprint images...");
|
|
|
+ CSimpleStringA imageName;
|
|
|
+ DeleteFileIfExisted("finger.bmp");
|
|
|
+ for (int i = 1; i <= 10; ++i) {
|
|
|
+ imageName = CSimpleString::Format("finger%d.bmp", i);
|
|
|
+ DeleteFileIfExisted(imageName.GetData());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if ((type & TestImage) == TestImage)
|
|
|
+ {
|
|
|
+ DeleteFileIfExisted("testFinger.bmp");
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+ErrorCodeEnum CCustMngrAuthFSM::DeleteFileIfExisted(const char* fileName)
|
|
|
+{
|
|
|
+ if (strlen(fileName) == 0 || strchr(fileName, (int)'*') != NULL)
|
|
|
+ {
|
|
|
+ Dbg("Invalid or empty filename(%s)", fileName);
|
|
|
+ return Error_Param;
|
|
|
+ }
|
|
|
+ CSimpleStringA strPath, strObjPath;
|
|
|
+ ErrorCodeEnum errCode = m_pEntity->GetFunction()->GetPath("Dep", strPath);
|
|
|
+ strObjPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s"
|
|
|
+ , strPath.GetData(), fileName);
|
|
|
+
|
|
|
+ if (ExistsFileA(strObjPath))
|
|
|
+ {
|
|
|
+ if (RemoveFileA(strObjPath))
|
|
|
+ {
|
|
|
+ Dbg("DeleteFile(%s) success.", strObjPath.GetData());
|
|
|
+ return Error_Succeed;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Dbg("DeleteFile(%s) failed LastError(%s).", strObjPath.GetData(), GetLastError());
|
|
|
+ return Error_Unexpect;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ Dbg("file %s not exist.", fileName);
|
|
|
+ return Error_Succeed;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
#pragma endregion
|