Pārlūkot izejas kodu

Z991239-4900 #comment 同步授权实体代码,去除无用的方法,无效的请求直接拒绝

Signed-Off-By: commit-hook
刘文涛80174520 2 gadi atpakaļ
vecāks
revīzija
b20349b102

+ 69 - 493
Module/mod_CustMngrAuth/CustMngrAuthFSM.cpp

@@ -1,10 +1,22 @@
-
+#include "stdafx.h"
+#include "SpBase.h"
 #include "SpHelper.h"
 #include "CustMngrAuth_UserErrorCode.h"
 #include "CustMngrAuthFSM.h"
+#include "CommEntityUtil.hpp"
 
 #include <fstream>
 #include <map>
+#ifdef RVC_OS_WIN
+
+#include <iostream>
+#include <iomanip>
+#include <random>
+#include <stdint.h> 
+#include <sstream>
+
+using namespace std;
+#else
 #include "fileutil.h"
 #include <memory>
 #include <thread>
@@ -14,16 +26,17 @@
 #include <cstring>
 
 using std::string;
+#endif
 
-const int UPDATE_INTERNAL = 10 * 60 * 1000;	//query data from branch server internal, 10min
-const int CONNECT_INTERNAL = 10 * 60 * 1000;		//connect branch server internal, 10min
-const int FINGER_NUM = 8;					//suuport max register finger num
+//const int UPDATE_INTERNAL = 10 * 60 * 1000;	//query data from branch server internal, 10min
+//const int CONNECT_INTERNAL = 10 * 60 * 1000;		//connect branch server internal, 10min
+//const int FINGER_NUM = 8;					//suuport max register finger num
 #define IMAGE_NUM 3
-const int COLLECT_TIMES = 3;				//press finger times
+//const int COLLECT_TIMES = 3;				//press finger times
 
 class CCustMngrAuthEntity;
 
-#pragma region event response
+
 
 //Init
 void CCustMngrAuthFSM::s0_on_entry()
@@ -94,7 +107,7 @@ void CCustMngrAuthFSM::s2_on_exit()
 unsigned int CCustMngrAuthFSM::s2_on_event(FSMEvent* pEvt)
 {
 	LOG_FUNCTION();
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("s2 evt(%d)", pEvt->iEvt);
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("s2 evt(%d, %d)", pEvt->iEvt, pEvt->param1);
 
 	switch (pEvt->iEvt)
 	{
@@ -136,7 +149,7 @@ unsigned int CCustMngrAuthFSM::s2_on_event(FSMEvent* pEvt)
 				this->PostEventFIFO(e);
 				break;
 			}
-			m_TimeLimit = (queryEvt->ctx->Req.TimeLimit - 2) * 1000;
+			m_TimeLimit = (queryEvt->ctx->Req.TimeLimit - 3) * 1000;
 
 			ErrorCodeEnum eErr;
 			m_bCancelAuthorize = false;
@@ -287,7 +300,7 @@ unsigned int CCustMngrAuthFSM::s3_on_event(FSMEvent* pEvt)
 
 			if (m_pFingerPrint != NULL && !m_pFingerPrint->QuerySessionClosed())
 			{
-				//m_bCancelAuthorize = true; //已结束授权,无用?
+				m_bCancelAuthorize = true;
 				m_pFingerPrint->GetFunction()->CloseSession();
 				m_pFingerPrint = NULL;
 				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("M_pFingerPrint disconnected.");
@@ -435,7 +448,6 @@ unsigned int CCustMngrAuthFSM::s5_on_event(FSMEvent* pEvt)
 	return 0;
 }
 
-#pragma endregion
 
 #pragma region entity init
 
@@ -525,9 +537,9 @@ ErrorCodeEnum CCustMngrAuthFSM::CollectFingerPrintInfo(SpReqAnsContext<CustMngrA
 	}
 
 	ULLINT l_beginTime, l_endTime;
-	l_beginTime = RVCGetTickCount();
+	l_beginTime = SP::Module::Comm::RVCGetTickCount();
 	errCode = m_pFingerPrint->GetFingerPrint(GetFingerReq, GetFingerAns, 30000, dwUserErrCode);
-	l_endTime = RVCGetTickCount();
+	l_endTime = SP::Module::Comm::RVCGetTickCount();
 	//DbgInfo("GetFingerPrint", l_beginTime, l_endTime, errCode, CSimpleStringA::Format("reserved1[0]:%d", GetFingerAns.reserved1[0]));
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetFingerPrint").setBeginTime(l_beginTime).setEndTime(l_endTime)("CollectFingerPrintInfo invoke GetFingerPrint return %s", SpStrError(errCode));
 
@@ -621,9 +633,9 @@ ErrorCodeEnum CCustMngrAuthFSM::GenerateTemplate(SpReqAnsContext<CustMngrAuthSer
 	}
 
 	ULLINT l_beginTime, l_endTime;
-	l_beginTime = RVCGetTickCount();
+	l_beginTime = SP::Module::Comm::RVCGetTickCount();
 	errCode = (*m_pFingerPrint)(EntityResource::getLink().upgradeLink())->GenerateTemplate(generateReq, generateAns, 20000, dwUserErrCode);
-	l_endTime = RVCGetTickCount();
+	l_endTime = SP::Module::Comm::RVCGetTickCount();
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GenerateTemplate").setBeginTime(l_beginTime).setEndTime(l_endTime)("GenerateTemplate invoke GenerateTemplate return %s", SpStrError(errCode));
 
 	if (errCode == Error_NotInit)
@@ -649,7 +661,7 @@ void CCustMngrAuthFSM::BroadcastPressFinger(int times, bool bPressFinger)
 {
 	if (bPressFinger) {
 		PressFinger pfEvt;//
-		pfEvt.FingerNo = 1;//maybe no usecontrol by @zhuyi
+		pfEvt.FingerNo = 1;//maybe no use,control by @zhuyi
 		pfEvt.Times = times;
 		SpSendBroadcast(m_pEntity->GetFunction(), SP_MSG_OF(PressFinger), SP_MSG_SIG_OF(PressFinger), pfEvt);
 	}
@@ -683,282 +695,12 @@ ErrorCodeEnum CCustMngrAuthFSM::GetImgBlob(CBlob& data, CSimpleStringA imgPath)
 	return eErr;
 }
 
-ErrorCodeEnum CCustMngrAuthFSM::CollectFingerPrint(SpReqAnsContext<CustMngrAuthService_CollectFingerPrint_Req, CustMngrAuthService_CollectFingerPrint_Ans>::Pointer ctx, DWORD& dwUserErrCode)
-{
-	LOG_FUNCTION();
-	LogWarn(Severity_Low, Error_Unexpect, LOG_ERR_CUSTMNGRAUTH_INVOKE_GETIMAGE, "web invoke CollectFingerPrint");
-
-	ErrorCodeEnum errCode = ConnectFingerPrintEntity();
-	if (errCode != Error_Succeed)
-		return errCode;
-
-	errCode = CollectProcess(ctx, dwUserErrCode);
-
-	if (errCode == Error_Succeed)
-	{
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Register FingerPrint successfully.");
-		return Error_Succeed;
-	}
-	else {
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Register FingerPrint failed! %s", SpStrError(errCode));
-		return errCode;
-	}
-}
-
-ErrorCodeEnum CCustMngrAuthFSM::CollectProcess(SpReqAnsContext<CustMngrAuthService_CollectFingerPrint_Req, CustMngrAuthService_CollectFingerPrint_Ans>::Pointer& ctx, DWORD& dwUserErrCode)
-{
-	ErrorCodeEnum errCode = Error_Succeed;
-
-	vector<CSimpleStringA> imgPaths;
-	CSimpleStringA depPath(true);
-	m_pEntity->GetFunction()->GetPath("Dep", depPath);
-	ctx->Ans.FingerImgs.Init(COLLECT_TIMES);
-
-	for (int i = 0; i < COLLECT_TIMES; ++i)
-	{
-		if (i) SLEEP(2000);
-
-		if (m_pFingerPrint == NULL || m_pFingerPrint->QuerySessionClosed())
-		{
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("m_pFingerPrint is NULL or connection closed.");
-			return Error_NoTarget;
-		}
-
-		BroadcastPressFinger(i + 1, true);//press finger
-
-		FingerPrintService_GetImageAndFeature_Req collecetReq;
-		FingerPrintService_GetImageAndFeature_Ans collecetAns;
-		collecetReq.times = i + 1;//the num from 1 start , 1/2/3
-		errCode = (*m_pFingerPrint)(EntityResource::getLink().upgradeLink())->GetImageAndFeature(collecetReq, collecetAns, 16000, dwUserErrCode);//fingerprint entity loop duration is 15s
-		if (errCode == Error_Succeed)
-		{
-			BroadcastPressFinger(i + 1, false);//lift finger
-
-			CBlob data;
-			CSimpleStringA imgFullPath(true);
-			imgFullPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s"
-				, depPath.GetData(), collecetAns.imageName.GetData());
-			errCode = GetImgBlob(data, imgFullPath);
-			imgPaths.push_back(imgFullPath);
-
-			if (errCode != Error_Succeed)
-			{
-				DbgWithLink(LOG_LEVEL_ERROR, LOG_TYPE_USER)("Failed to load finger image, %s", imgFullPath.GetData());
-				errCode = Error_Unexpect;
-				break;
-			}
-			switch (i)
-			{
-			case 0:
-				ctx->Ans.FingerImg1 = data;
-				break;
-			case 1:
-				ctx->Ans.FingerImg2 = data;
-				break;
-			case 2:
-				ctx->Ans.FingerImg3 = data;
-				break;
-			}
-			ctx->Ans.FingerImgs[i] = data;
-
-			if (i == (COLLECT_TIMES - 1)) {
-				ctx->Ans.feature = collecetAns.feature;
-				DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("feature = %s", ctx->Ans.feature.GetData());
-			}
-		}
-		else {
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("invoke GetImageAndFeature failed in %dth time, errCode(%s)", i + 1, SpStrError(errCode));
-			break;
-		}
-	}
-	for (size_t i = 0; i < imgPaths.size(); ++i)
-	{
-		if (ExistsFileA(imgPaths[i]))
-			RemoveFileA(imgPaths[i]);
-	}
-
-	return errCode;
-}
-
-ErrorCodeEnum CCustMngrAuthFSM::CollectFingerPrintEx(SpReqAnsContext<CustMngrAuthService_CollectFingerPrintEx_Req, CustMngrAuthService_CollectFingerPrintEx_Ans>::Pointer ctx, DWORD& dwUserErrCode)
-{
-	LOG_FUNCTION();
-	LogWarn(Severity_Low, Error_Unexpect, LOG_ERR_CUSTMNGRAUTH_INVOKE_GETIMAGEEx, "web invoke CollectFingerPrintEx");
-
-	ErrorCodeEnum errCode = ConnectFingerPrintEntity();
-	if (errCode != Error_Succeed)
-		return errCode;
 
-	errCode = CollectProcessEx(ctx, dwUserErrCode);
-
-	if (errCode == Error_Succeed)
-	{
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Register FingerPrint successfully.");
-		return Error_Succeed;
-	}
-	else {
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Register FingerPrint failed: %s !", SpStrError(errCode));
-		return errCode;
-	}
-}
-
-ErrorCodeEnum CCustMngrAuthFSM::CollectProcessEx(SpReqAnsContext<CustMngrAuthService_CollectFingerPrintEx_Req, CustMngrAuthService_CollectFingerPrintEx_Ans>::Pointer& ctx, DWORD& dwUserErrCode)
-{
-	ErrorCodeEnum errCode = Error_Succeed;
-
-	CSimpleStringA depPath(true);
-	m_pEntity->GetFunction()->GetPath("Dep", depPath);
-	ctx->Ans.FingerImgs.Init(COLLECT_TIMES);
-
-	FingerPrintService_GetImageAndFeatureEx_Req collectExReq;
-	FingerPrintService_GetImageAndFeatureEx_Ans collectExAns;
-	collectExReq.times = ctx->Req.FingerId;
-
-	if (m_pFingerPrint == NULL || m_pFingerPrint->QuerySessionClosed())
-	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("m_pFingerPrint is NULL or connection closed.");
-		return Error_NoTarget;
-	}
-
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Start %dth scan fingerprint", collectExReq.times);
-	errCode = (*m_pFingerPrint)(EntityResource::getLink().upgradeLink())->GetImageAndFeatureEx(collectExReq, collectExAns, 30000, dwUserErrCode);//fingerprint entity loop duration is 15s
-
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("reserverd1[0] = %d", collectExAns.reserved1[0]);
-	if (errCode == Error_NotExist) {
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("cannot find finger img in dep!");
-		return Error_NotExist;
-	}
-	if (errCode == Error_Succeed && collectExAns.reserved1[0] == 3) {
-		return Error_Cancel;
-	}
-	if (errCode == Error_Succeed && collectExAns.reserved1[0] == 2) {
-		return Error_TimeOut;
-	}
-
-	CBlob data;
-	CSimpleStringA imgFullPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s"
-		, depPath.GetData(), collectExAns.imageName.GetData());
-	ErrorCodeEnum imgErrCode = GetImgBlob(data, imgFullPath);
-	if (imgErrCode != Error_Succeed)
-	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("Failed to load image(%s)", imgFullPath.GetData());
-		return Error_NotExist;
-	}
-
-	CSimpleStringA imageName(true);
-	CSimpleStringA imgPrefix = "finger";
-	CSimpleStringA imgSuffix = ".bmp";
-	switch (ctx->Req.FingerId)
-	{
-	case 1:
-		ctx->Ans.FingerImg1 = data;
-		break;
-	case 2:
-		ctx->Ans.FingerImg2 = data;
-		break;
-	case 3:
-		ctx->Ans.FingerImg3 = data;
-		for (size_t i = 0; i < 10; ++i)
-		{
-			imageName = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s%d%s", depPath.GetData(), imgPrefix.GetData(), i, imgSuffix.GetData());
-			if (ExistsFileA(imageName))
-				RemoveFileA(imageName);
-		}
-		imageName = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s%s", depPath.GetData(), imgPrefix.GetData(), imgSuffix.GetData());
-		if (ExistsFileA(imageName))
-			RemoveFileA(imageName);
-		break;
-	default:
-		break;
-	}
-
-	if (errCode == Error_Succeed && collectExAns.reserved1[0] == 1) {
-		if (ctx->Req.FingerId == COLLECT_TIMES)
-			ctx->Ans.feature = collectExAns.feature;
-	}
-	else if(errCode == Error_NotInit){
-		errCode = Error_DevNotAvailable;
-	}else {
-		errCode = Error_Unexpect;
-	}
-
-	if (errCode == Error_Succeed) {
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Register FingerPrint successfully.");
-	}
-	else {
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_USER)("Register FingerPrint failed! %s", SpStrError(errCode));
-	}
-	return errCode;
-}
 
 #pragma endregion
 
 #pragma region Save fingerprint process
 
-ErrorCodeEnum CCustMngrAuthFSM::SaveFingerPrint(SpReqAnsContext<CustMngrAuthService_SaveFingerPrint_Req, CustMngrAuthService_SaveFingerPrint_Ans>::Pointer ctx)
-{
-	LOG_FUNCTION();
-	EnterCriticalSection(&m_cs);
-	CSmartPointer<IConfigInfo> spConfig;
-	Json::FastWriter writer;
-	ErrorCodeEnum eErr;
-	eErr = GetEntityBase()->GetFunction()->OpenConfig(Config_Run, spConfig);
-	if (eErr != Error_Succeed) {
-		LogError(Severity_High, Error_DevLoadFileFailed, LOG_ERR_CUSTMNGRAUTH_OPEN_RUNINFO_FAILED_SAVEFINGERPRINT, "open runinfo file failed while save data to local.");
-		LeaveCriticalSection(&m_cs);
-		return Error_Unexpect;
-	}
-	if (ctx->Req.FPFeatureList == nullptr) {
-		return Error_Param;
-	}	
-	int fingerIDNum = ctx->Req.FingerIdList.GetCount();
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("FingerIDNum=%d", fingerIDNum);
-
-	FeatureData* fd = new FeatureData();
-	fd->FingerIDArray.Init(fingerIDNum);
-	fd->FingerIDLenArray.Init(fingerIDNum);
-
-	char fingerID[20];
-	Json::Value fingerInfo;
-
-	for (int i = 0; i < fingerIDNum; ++i)
-	{
-		memset(fingerID, 0, sizeof(fingerID));
-
-#ifdef RVC_OS_WIN
-		_snprintf_s(fingerID, 10, "FingerID%d", ctx->Req.FingerIdList[i]);
-#else
-		snprintf(fingerID, 10, "FingerID%d", ctx->Req.FingerIdList[i]);
-#endif // RVC_OS_WIN
-
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("writing %s", fingerID);
-		fingerInfo[fingerID] = ctx->Req.FPFeatureList[i].GetData();
-		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
-		m_featureData[ctx->Req.CustomerID] = fd;
-	}
-	else {
-		auto tempFD = m_featureData[ctx->Req.CustomerID];
-		m_featureData[ctx->Req.CustomerID] = fd;
-		if (tempFD) {
-			delete tempFD;
-			tempFD = NULL;
-		}
-	}
-
-	eErr = spConfig->WriteConfigValue(m_FingerSection.GetData(), ctx->Req.CustomerID.GetData(), writer.write(fingerInfo).c_str());
-	if (eErr != Error_Succeed) {
-		LogError(Severity_High, Error_DevLoadFileFailed, LOG_ERR_CUSTMNGRAUTH_REGISTER_WRITE_RUNINFO_FAILED, "write data into runinfo failed when commit.");
-		LeaveCriticalSection(&m_cs);
-		return Error_Unexpect;
-	}
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("write data into runinfo success when commit.");
-	LeaveCriticalSection(&m_cs);
-	return eErr;
-}
 
 #pragma endregion
 
@@ -994,9 +736,9 @@ ErrorCodeEnum CCustMngrAuthFSM::MatchFingerPrintEx(SpReqAnsContext<CustMngrAuthS
 	}
 
 	ULLINT l_beginTime, l_endTime;
-	l_beginTime = RVCGetTickCount();
+	l_beginTime = SP::Module::Comm::RVCGetTickCount();
 	errCode = (*m_pFingerPrint)(EntityResource::getLink().upgradeLink())->GetFingerPrint(GetFingerReq, GetFingerAns, 30000, dwUserErrCode);
-	l_endTime = RVCGetTickCount();
+	l_endTime = SP::Module::Comm::RVCGetTickCount();
 	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("GetFingerPrint").setBeginTime(l_beginTime).setEndTime(l_endTime)("MatchFingerPrintEx invoke GetFingerPrint return %s", SpStrError(errCode));
 
 	if (errCode == Error_DevNotAvailable) {
@@ -1097,6 +839,36 @@ void CCustMngrAuthFSM::DeleteBmp(int type)
 
 ErrorCodeEnum CCustMngrAuthFSM::DeleteFileIfExisted(const char* fileName)
 {
+#ifdef RVC_OS_WIN
+	if (strlen(fileName) == 0 || strchr(fileName, (int)'*') != NULL)
+	{
+		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Invalid or empty filename(%s)", fileName);
+		return Error_Param;
+	}
+	CSimpleStringA strPath, strObjPath;
+	ErrorCodeEnum errCode = m_pEntity->GetFunction()->GetPath("Dep", strPath);
+	strObjPath = strPath + "\\" + fileName;
+	WIN32_FIND_DATA findData;
+	if (FindFirstFileA((LPCTSTR)strObjPath, &findData) != INVALID_HANDLE_VALUE)
+	{
+		if (DeleteFileA((LPCTSTR)strObjPath) != 0)
+		{
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("DeleteFile(%s) success.", strObjPath.GetData());
+			return Error_Succeed;
+		}
+		else {
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("DeleteFile(%s) failed LastError(%s).", strObjPath.GetData(), GetLastError());
+			return Error_Unexpect;
+		}
+	}
+	if (GetLastError() == ERROR_FILE_NOT_FOUND)
+	{
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("file %s not exist.", fileName);
+		return Error_Succeed;
+	}
+	DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("DeleteFle(%s) Unexpect GetLastError(%s).", strObjPath.GetData(), GetLastError());
+	return Error_Unexpect;
+#else
 	if (strlen(fileName) == 0 || strchr(fileName, (int)'*') != NULL)
 	{
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Invalid or empty filename(%s)", fileName);
@@ -1122,6 +894,7 @@ ErrorCodeEnum CCustMngrAuthFSM::DeleteFileIfExisted(const char* fileName)
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("file %s not exist.", fileName);
 		return Error_Succeed;
 	}
+#endif	
 }
 
 void CCustMngrAuthFSM::BroadcastGetFinger(int status)
@@ -1131,199 +904,9 @@ void CCustMngrAuthFSM::BroadcastGetFinger(int status)
 	SpSendBroadcast(GetEntityBase()->GetFunction(), SP_MSG_OF(GetFinger), SP_MSG_SIG_OF(GetFinger), evt);
 }
 
-ErrorCodeEnum CCustMngrAuthFSM::MatchFingerPrint(SpReqAnsContext<CustMngrAuthService_StartAuthorize_Req, CustMngrAuthService_StartAuthorize_Ans>::Pointer ctx, bool& bStopAuthorize)
-{
-	LOG_FUNCTION();
-	LogWarn(Severity_Low, Error_Unexpect, LOG_ERR_CUSTMNGRAUTH_INVOKE_MATCH, "web invoke MatchFingerPrint");
 
-	ErrorCodeEnum errCode = ConnectFingerPrintEntity();
-	if (errCode != Error_Succeed)
-		return errCode;
 
-	MatchParams* matchParam = new MatchParams();
-	matchParam->sTotalNumOfTemplate = 0;
-	errCode = PrepareDataBeforeMatch(matchParam);
-	if (errCode != Error_Succeed)
-		return errCode;
 
-	errCode = MatchProcess(matchParam, bStopAuthorize);
-	return errCode;
-}
-
-ErrorCodeEnum CCustMngrAuthFSM::PrepareDataBeforeMatch(MatchParams* matchParam)
-{
-	EnterCriticalSection(&m_cs);
-
-	CAutoArray<CSimpleStringA> tempFeatureArray;
-	CAutoArray<int> tempFeatureLenArray;
-	int totalCustomerID = m_featureData.size();
-	int totalTemplate = totalCustomerID * FINGER_NUM;
-	tempFeatureArray.Init(totalTemplate);
-	tempFeatureLenArray.Init(totalTemplate);
-
-	if (totalCustomerID <= 0)
-	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("No FingerPrint data in local file or read local file failed.");
-		LeaveCriticalSection(&m_cs);
-		if (matchParam != NULL)
-			delete matchParam;
-		return Error_NoTarget;
-	}
-
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin copy feature to reqParams");
-	for (auto it = m_featureData.begin(); it != m_featureData.end(); ++it)
-	{
-		TemplateInfo ti;
-		memset(&ti, 0, sizeof(ti));
-		ti.CustomerID = it->first;
-		ti.TemplateNum = 0;
-
-		for (int index = 0; index < FINGER_NUM; ++index)
-		{
-			if (index >= it->second->FingerIDArray.GetCount()) //旧版本可能只有2个
-				break;
-
-			if (it->second->FingerIDArray[index].GetLength() <= 0)
-				continue;
-
-			tempFeatureArray[matchParam->sTotalNumOfTemplate] = it->second->FingerIDArray[index];
-			tempFeatureLenArray[matchParam->sTotalNumOfTemplate] = it->second->FingerIDLenArray[index];
-			ti.TemplateNum = ti.TemplateNum + 1;
-			++matchParam->sTotalNumOfTemplate;
-		}
-
-		if (ti.TemplateNum > 0)
-			matchParam->sFingerCount.push_back(ti);
-	}
-	LeaveCriticalSection(&m_cs);
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("num of template not empty:%d", matchParam->sTotalNumOfTemplate);
-
-	matchParam->sMatchReq.templateNum = matchParam->sTotalNumOfTemplate;
-	matchParam->sMatchReq.templates.Init(matchParam->sTotalNumOfTemplate);
-	matchParam->sMatchReq.templateLen.Init(matchParam->sTotalNumOfTemplate);
-
-	for (int i = 0; i < matchParam->sTotalNumOfTemplate; ++i)
-	{
-		matchParam->sMatchReq.templates[i] = tempFeatureArray[i];
-		matchParam->sMatchReq.templateLen[i] = tempFeatureLenArray[i];
-	}
-
-	DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("end copy feature to reqParams");
-	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("templateNum: %d", matchParam->sMatchReq.templateNum);
-
-	return Error_Succeed;
-}
-
-ErrorCodeEnum CCustMngrAuthFSM::MatchProcess(MatchParams* matchParam, bool& bStopAuthorize)
-{
-	ErrorCodeEnum errCode = Error_Succeed;
-
-	while (true)
-	{
-		if (m_pFingerPrint == NULL || m_pFingerPrint->QuerySessionClosed())
-		{
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("m_pFingerPrint is NULL or connection closed.");
-			return Error_Unexpect;
-		}
-		//fingerprint entity may not return immediately
-		SLEEP(100);
-
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("begin next invoke match.");
-		errCode = (*m_pFingerPrint)(EntityResource::getLink().upgradeLink())->Match(matchParam->sMatchReq, matchParam->sMatchAns, 20000);
-
-		if (m_bCancelAuthorize || errCode == Error_Cancel)
-		{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("cancel authorize task.");
-			bStopAuthorize = true;
-			m_bCancelAuthorize = false;
-			if (m_bAuthorizeTimeout)
-			{
-				m_bAuthorizeTimeout = false;
-				return Error_TimeOut;
-			}
-			return Error_Cancel;
-		}
-		else if (errCode == Error_Unexpect || errCode == Error_TimeOut)
-		{
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("invoke match error with errCode(%s)", SpStrError(errCode));
-			BroadcastGetFinger(2);
-		}
-		else if (errCode == Error_Succeed)
-		{
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("invoke match success, start analyze result.");
-			errCode = AnalyzeMatchResult(matchParam, bStopAuthorize);
-			if (errCode == Error_Succeed)
-				return Error_Succeed; //continue if other errCode
-		}
-		else {
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("invole match error(%s), stop authorize", SpStrError(errCode));
-			return Error_Unexpect;
-		}
-	}
-}
-
-ErrorCodeEnum CCustMngrAuthFSM::AnalyzeMatchResult(MatchParams* matchParam, bool& bStopAuthorize)
-{
-	int resTemplateNum = matchParam->sMatchAns.result.GetCount();
-	if (resTemplateNum != matchParam->sTotalNumOfTemplate)
-	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("result templateNum(%d) is not equale to the Req's(%d)."
-			, resTemplateNum, matchParam->sTotalNumOfTemplate);
-		return Error_Unexpect;
-	}
-	std::vector<TemplateInfo>tmpFingerCountInfo(matchParam->sFingerCount);
-	int matchIndex = -1; //matched CustomerID's index in array
-	int matchCount = 0;  //num of matched
-	int fingerCountIndex = 0; //index of fingerCountInfo
-	int FINGER_NUM = tmpFingerCountInfo[fingerCountIndex].TemplateNum;
-	for (int i = 0; i < resTemplateNum; i += FINGER_NUM)
-	{
-		int oneCustMatchResult = 0;
-		FINGER_NUM = tmpFingerCountInfo[fingerCountIndex].TemplateNum;
-		for (int j = 0; j < FINGER_NUM; ++j)
-		{
-			oneCustMatchResult += matchParam->sMatchAns.result[i + j];
-		}
-
-		if (oneCustMatchResult > 0) //one customer has more than one match, just as one
-		{
-			matchCount++;
-			matchIndex = fingerCountIndex;
-		}
-		if (matchCount > 1) //more than one customer's finger matched
-			break;
-		fingerCountIndex++;
-	}
-	int matchResult = matchCount;//0:no match; 1:just one match; 2: muti match
-
-	switch (matchResult)
-	{
-	case 0:
-	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("MatchResult: 0| no match");
-		BroadcastGetFinger(0);
-	}
-	break;
-	case 1:
-	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("MatchResult: 1| one and only one match, authorize done.");
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("Match Finger(CustomerID=%s)", (const char*)tmpFingerCountInfo[matchIndex].CustomerID);
-		m_authCtx.eAuthByWhich = AuthByFngPrnt;
-		m_authCtx.CustomerID = tmpFingerCountInfo[matchIndex].CustomerID;
-		bStopAuthorize = true;
-		return Error_Succeed;
-	}
-	break;
-	case 2:
-	{
-		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("MatchResult: 2 | two and more matches. be alerted");
-		BroadcastGetFinger(1);
-	}
-	break;
-	default:break;
-	}
-	return Error_Unexpect;
-}
 
 #pragma endregion
 
@@ -1333,10 +916,16 @@ ErrorCodeEnum CCustMngrAuthFSM::WaitForUkey(ErrorCodeEnum eErr)
 {
 	//与朱毅约定,4表示本地无指纹数据,3表示指纹仪实体异常(包括旧接口的其他错误码和新接口的Error_HardWare)
 	//4: no data in local, 3:enitty exception
+//	DbgInfo(CSimpleStringA::Format("WaitForUkey, eErr:%d(0x%x)", eErr, eErr));
+	DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("WaitForUkey, eErr:%d(0x%x)", eErr, eErr);
 	int status = (eErr == Error_NoTarget) ? 4 : 3;
 	BroadcastGetFinger(status);
 	while (1) {
+#ifdef RVC_OS_WIN
+		Sleep(300);
+#else
 		SLEEP(300);
+#endif
 		if (m_bCancelAuthorize) {
 			m_bCancelAuthorize = false;
 			if (m_bAuthorizeTimeout){
@@ -1375,7 +964,7 @@ ErrorCodeEnum CCustMngrAuthFSM::SwitchUSB(bool bOpen)
 	if (m_pDeviceControl != NULL) {
 		eErr = m_pDeviceControl->Connect();
 		if (eErr != Error_Succeed) {
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("m_pDeviceControl connect failed with errCode(%s)", SpStrError(eErr));
+			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("m_pDeviceControl connect failed with errCode %x0x", eErr);
 			m_pDeviceControl->SafeDelete();
 		}
 		else {
@@ -1406,21 +995,6 @@ ErrorCodeEnum CCustMngrAuthFSM::SwitchUSB(bool bOpen)
 	}
 }
 
-ErrorCodeEnum CCustMngrAuthFSM::ConnectFingerPrintEntity()
-{
-	ErrorCodeEnum errCode = Error_Succeed;
-	m_pFingerPrint = new FingerPrintService_ClientBase(m_pEntity);
-	errCode = m_pFingerPrint->Connect();
-	if (errCode != Error_Succeed)
-	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("ERROR: connect to fingerprint entity failed! %s", SpStrError(errCode));
-		m_pFingerPrint->SafeDelete();
-
-		errCode = Error_NoTarget;	//TODO::give one other errCode
-	}
-	return errCode;
-}
-
 #pragma endregion
 
 
@@ -1453,6 +1027,8 @@ ErrorCodeEnum CCustMngrAuthFSM::ConnectFingerPrintEntity()
 
 
 
+
+
 
 
 

+ 37 - 197
Module/mod_CustMngrAuth/CustMngrAuthFSM.h

@@ -30,7 +30,6 @@ using namespace std;
 using namespace DeviceControl;
 using namespace FingerPrint;
 
-using namespace SP::Module::Comm;
 //下载特征库所调用的分行服务接口
 #pragma region 废弃的参数
 //废弃参数
@@ -63,38 +62,7 @@ struct TemplateInfo
 	CSimpleStringA CustomerID;
 	int TemplateNum;
 };
-//废弃参数
-struct MatchParams
-{
-	FingerPrintService_Match_Req sMatchReq;
-	FingerPrintService_Match_Ans sMatchAns;
-	vector<TemplateInfo> sFingerCount;
-	int sTotalNumOfTemplate; //Total Num of template which is not empty
-};
-//废弃参数
-struct JsonParams
-{
-	Json::Value Root;
-	int Index;
-	Json::Value FingerInfo;
-};
-//废弃参数
-struct TempFeatureData
-{
-	CSimpleStringA MaxUpdateTime;
-	map<CSimpleStringA, FeatureData*> tmpFeatureMap;
-};
-//废弃参数
-struct RunInfoParams
-{
-	CSimpleStringA LatestTime;
-	CSimpleStringA UpdateTime;
-	CSimpleStringA CurrentTime;
-	bool IsFirstTimeQueryData;
 
-	CSimpleStringA SrcFile;
-	CSimpleStringA BackupFile;
-};
 #pragma endregion
 
 
@@ -596,37 +564,13 @@ public:
 
 	ErrorCodeEnum WaitForUkey(ErrorCodeEnum eErr);//未使用,废弃
 	ErrorCodeEnum SwitchUSB(bool bOpen);//未使用,废弃
-	ErrorCodeEnum ConnectFingerPrintEntity();//废弃
 #pragma region 废弃的方法
-	void FeatureUpdate();//废弃的方法
-	void InitBeforeUpdateData();//废弃的方法 FeatureUpdate引用
-	ErrorCodeEnum ReceiveDataFromServer(CAutoArray<CSimpleStringA>& dataArray, RunInfoParams runInfoParam);//废弃的方法 FeatureUpdate引用
-	ErrorCodeEnum LoadRunConfig(CSmartPointer<IConfigInfo>& spConfig);//废弃的方法 FeatureUpdate引用
-	void InitTimeParams(RunInfoParams& runInfoParam, CSmartPointer<IConfigInfo>& spConfig);//废弃的方法 FeatureUpdate引用
-	ErrorCodeEnum InitBeforeQueryData(RunInfoParams& runInfoParam, CSmartPointer<IConfigInfo>& spConfig);//废弃的方法 FeatureUpdate引用
-	ErrorCodeEnum BackupBeforeWriteData(RunInfoParams& runInfoParam, CSmartPointer<IConfigInfo>& spConfig);//废弃的方法 FeatureUpdate引用
-	ErrorCodeEnum WriteData(RunInfoParams& runInfoParam, CAutoArray<CSimpleStringA> dataArray, CSmartPointer<IConfigInfo>& spConfig);//废弃的方法 FeatureUpdate引用
-	ErrorCodeEnum ProcessFeatureData(JsonParams& jsonParam, TempFeatureData& tmpFeatureData, RunInfoParams runinfoParam, CSmartPointer<IConfigInfo>& spConfig);//废弃的方法 FeatureUpdate引用
+
 
 	ErrorCodeEnum MatchFingerPrint(SpReqAnsContext<CustMngrAuthService_StartAuthorize_Req, CustMngrAuthService_StartAuthorize_Ans>::Pointer ctx, bool& bStopAuthorize);//废弃的方法
-	ErrorCodeEnum PrepareDataBeforeMatch(MatchParams* matchParam);//废弃的方法 MatchFingerPrint引用
-	ErrorCodeEnum MatchProcess(MatchParams* matchParam, bool& bStopAuthorize);//废弃的方法 MatchFingerPrint引用
-	ErrorCodeEnum AnalyzeMatchResult(MatchParams* matchParam, bool& bStopAuthorize);//废弃的方法 MatchFingerPrint引用
 	ErrorCodeEnum CollectFingerPrint(SpReqAnsContext<CustMngrAuthService_CollectFingerPrint_Req, CustMngrAuthService_CollectFingerPrint_Ans>::Pointer ctx, DWORD& dwUserErrCode);//废弃的方法
-	ErrorCodeEnum CollectProcess(SpReqAnsContext<CustMngrAuthService_CollectFingerPrint_Req, CustMngrAuthService_CollectFingerPrint_Ans>::Pointer& ctx, DWORD& dwUserErrCode);//废弃的方法 CollectFingerPrint引用
-	ErrorCodeEnum CollectFingerPrintEx(SpReqAnsContext<CustMngrAuthService_CollectFingerPrintEx_Req, CustMngrAuthService_CollectFingerPrintEx_Ans>::Pointer ctx, DWORD& dwUserErrCode);//废弃的方法 CollectFingerPrintEx引用
-	ErrorCodeEnum CollectProcessEx(SpReqAnsContext<CustMngrAuthService_CollectFingerPrintEx_Req, CustMngrAuthService_CollectFingerPrintEx_Ans>::Pointer& ctx, DWORD& dwUserErrCode);//废弃的方法
+	ErrorCodeEnum CollectFingerPrintEx(SpReqAnsContext<CustMngrAuthService_CollectFingerPrintEx_Req, CustMngrAuthService_CollectFingerPrintEx_Ans>::Pointer ctx, DWORD& dwUserErrCode);//废弃的方法
 	ErrorCodeEnum SaveFingerPrint(SpReqAnsContext<CustMngrAuthService_SaveFingerPrint_Req, CustMngrAuthService_SaveFingerPrint_Ans>::Pointer ctx);//废弃的方法
-	
-	int CompareTime(CSimpleStringA time1, CSimpleStringA time2);//废弃的方法
-	int CompareUpdateTime(const char* time1, const char* time2);//废弃的方法
-	bool ReadDataIntoMemory(bool& bHasData);//废弃的方法
-	void UpdateDataIntoMemory(map<CSimpleStringA, FeatureData*> tempFeature, bool bIsFirstTimeQueryData);//废弃的方法
-	string ClearStringSpaceHeadTail(string& line);//废弃的方法
-	CSimpleStringA GetCurrentDate();//废弃的方法
-	bool BackupFile(CSimpleStringA srcFile, CSimpleStringA dstFile);//废弃的方法
-	CSimpleStringA GetMaxTime(CSimpleStringA maxTime, CSimpleStringA tempTime);//废弃的方法
-	CSimpleString GenerateAlarmJson(CSimpleString entityName, int cost);//废弃的方法
 
 #pragma endregion
 
@@ -634,7 +578,7 @@ private:
 	DeviceControlService_ClientBase *m_pDeviceControl;
 	FingerPrintService_ClientBase *m_pFingerPrint;
 
-	FeatureUpdateConn *m_pConnection;//中台连接
+
 	CSimpleStringA m_FingerSection;//人脸特征路径
 	CSimpleStringA m_RunInfoPath;
 
@@ -646,111 +590,7 @@ private:
 	CRITICAL_SECTION m_cs;//临界区变量
 };
 #pragma region 废弃的结构
-//特征更新连接(废弃)
-class FeatureUpdateConn : public SpSecureClient
-{
-public:
-	FeatureUpdateConn(CEntityBase *pEntity, CCustMngrAuthFSM *pFSM) : SpSecureClient(pEntity)
-	{
-		m_pFSM = pFSM;
-		m_jsonLen = 0;
-		m_GetErrMsg = false;
-		m_reply = NULL;
-		m_hPkgAnswer = ::CreateEventA(NULL, TRUE, FALSE, NULL);
-	}
-
-	virtual ~FeatureUpdateConn() {}
-
-	virtual void OnDisconnect()
-	{
-		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("FeatureUpdateConnection disconnected");
-	}
-
-	void SendFeatReq(const char* currAgent, const char* branchID, const char* lastTime = NULL)
-	{
-		LOG_FUNCTION();
-		m_reply = NULL;
-		m_jsonLen = 0;
-		FeatReq req = { 0 };
-		memcpy(req.BranchID, branchID, 16);
-		memcpy(req.CurrentAgent, currAgent, 16);//续传标志(代表已查到的最后一个客户经理
-		if (lastTime != NULL)
-		{
-			memcpy(req.UpdateTime, lastTime, 20);//本地指纹数据最新时间
-			DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("req.UpdateTime:%s", req.UpdateTime);
-		}
-
-#ifdef RVC_OS_WIN
-		DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("req.TerminalID = %s, m_pFSM->m_TerminalID = %s", req.TerminalID, m_pFSM->m_TerminalID.GetData());
-		strncpy_s(req.TerminalID, sizeof(req.TerminalID), m_pFSM->m_TerminalID, m_pFSM->m_TerminalID.GetLength());
-#else
-		strncpy(req.TerminalID, m_pFSM->m_TerminalID, m_pFSM->m_TerminalID.GetLength());
-#endif // RVC_OS_WIN
-		CSmartPointer<IPackage> pkt = CreateNewPackage("FETQYREQ");
-		pkt->AddStruct("FETQYREQ", false, false, (LPBYTE)&req, sizeof(FeatReq));
-		SendPackage(pkt);
-	}
-
-	virtual void OnPkgAnswer(const CSmartPointer<IPackage> &pRecvPkg)
-	{
-		//LOG_FUNCTION();
-		DWORD dwSysCode, dwUserCode;
-		string errMsg;
-
-		if (pRecvPkg->GetErrMsg(dwSysCode, dwUserCode, errMsg))
-		{
-			//错误处理
-			string serviceCode = pRecvPkg->GetServiceCode();
-			DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("receive %s ans packet is error, errormsg is %s", serviceCode.c_str(), errMsg.c_str());
-			m_GetErrMsg = true;
-			SetEvent(m_hPkgAnswer);
-		}else{
-			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("success, no error message.");
-			//判断result接受buff,resultcode判断,
-			string serviceCode = pRecvPkg->GetServiceCode();
-			if (serviceCode == "FETQYREQ")
-			{
-				int dataLen = pRecvPkg->GetStructLen("FETQYANS");
-				if (dataLen > 0 )
-				{
-					DbgWithLink(LOG_LEVEL_DEBUG, LOG_TYPE_SYSTEM)("GetStructData structlen: %d", dataLen);
-					BYTE *pBuffer = new BYTE[dataLen];
-					memset(pBuffer, 0, dataLen);
-
-					int arrayNum = 0;
-					if (pRecvPkg->GetStructData("FETQYANS", pBuffer, &dataLen, &arrayNum))
-					{
-						//初始化
-						LPBYTE pData = new BYTE[dataLen +1];
-						memcpy(pData, pBuffer, dataLen);
-						m_reply = (FeatReply*)pData;
-						if (m_reply != NULL)
-						{
-							pData[dataLen] = 0;
-							m_jsonLen = dataLen - sizeof(FeatReply);
-						}else
-							DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("ERROR: m_reply is null!");
-					}else
-						DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("ERROR: getstructdata(FETQYANS) failed!");
-					delete pBuffer;
-				}else
-					DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("ERROR: getstructlen(FETQYANS) = 0!");
-
-				SetEvent(m_hPkgAnswer);
-			}else
-				DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("ERROR: wrong service code!");
-		}
-	}
-	
-private:
-	CCustMngrAuthFSM *m_pFSM;
 
-public:
-	HANDLE m_hPkgAnswer;
-	bool m_GetErrMsg;
-	FeatReply* m_reply;
-	int m_jsonLen;
-};
 #pragma endregion
 
 //初始化:检查、配置路径、起特征更新任务(使用)
@@ -862,14 +702,14 @@ struct MatchFingerPrintTask : public ITaskSp
 	SpReqAnsContext<CustMngrAuthService_StartAuthorize_Req, CustMngrAuthService_StartAuthorize_Ans>::Pointer ctx;
 	void Process()
 	{
-		bool bStopAuthorize = false;
-		ErrorCodeEnum eErr = fsm->MatchFingerPrint(ctx, bStopAuthorize);
-		//if (bStopAuthorize)
-		//{
-			AuthorizeFinishedEvent *e = new AuthorizeFinishedEvent();
-			e->ctx = ctx;
-			e->param1 = eErr;
-			fsm->PostEventFIFO(e);
+		//bool bStopAuthorize = false;
+		//ErrorCodeEnum eErr = fsm->MatchFingerPrint(ctx, bStopAuthorize);
+		////if (bStopAuthorize)
+		////{
+		//	AuthorizeFinishedEvent *e = new AuthorizeFinishedEvent();
+		//	e->ctx = ctx;
+		//	e->param1 = eErr;
+		//	fsm->PostEventFIFO(e);
 		//}
 		//else
 		//{
@@ -889,16 +729,16 @@ struct CollectFingerPrintTask : public ITaskSp
 	CollectFingerPrintTask(CCustMngrAuthFSM* f) : fsm(f) {}
 	void Process()
 	{
-		LOG_FUNCTION();
-		CollectFingerPrintFinishedEvent* e = new CollectFingerPrintFinishedEvent();
-		e->ctx = ctx;
-		DWORD dwUserErrorCode = 0;
-		ErrorCodeEnum eErr = fsm->CollectFingerPrint(ctx, dwUserErrorCode);
-		if (eErr == Error_Unexpect && dwUserErrorCode > 0)
-			ctx->Answer(eErr, dwUserErrorCode);
-		else
-			ctx->Answer(eErr);
-		fsm->PostEventFIFO(e);
+		//LOG_FUNCTION();
+		//CollectFingerPrintFinishedEvent* e = new CollectFingerPrintFinishedEvent();
+		//e->ctx = ctx;
+		//DWORD dwUserErrorCode = 0;
+		//ErrorCodeEnum eErr = fsm->CollectFingerPrint(ctx, dwUserErrorCode);
+		//if (eErr == Error_Unexpect && dwUserErrorCode > 0)
+		//	ctx->Answer(eErr, dwUserErrorCode);
+		//else
+		//	ctx->Answer(eErr);
+		//fsm->PostEventFIFO(e);
 	}
 };
 
@@ -910,16 +750,16 @@ struct CollectFingerPrintExTask : public ITaskSp
 	CollectFingerPrintExTask(CCustMngrAuthFSM* f) : fsm(f) {}
 	void Process()
 	{
-		LOG_FUNCTION();
-		CollectFingerPrintExFinishedEvent* e = new CollectFingerPrintExFinishedEvent();
-		e->ctx = ctx;
-		DWORD dwUserErrorCode = 0;
-		ErrorCodeEnum eErr = fsm->CollectFingerPrintEx(ctx, dwUserErrorCode);
-		if (eErr == Error_Unexpect && dwUserErrorCode > 0)
-			ctx->Answer(eErr, dwUserErrorCode);
-		else
-			ctx->Answer(eErr);
-		fsm->PostEventFIFO(e);
+		//LOG_FUNCTION();
+		//CollectFingerPrintExFinishedEvent* e = new CollectFingerPrintExFinishedEvent();
+		//e->ctx = ctx;
+		//DWORD dwUserErrorCode = 0;
+		//ErrorCodeEnum eErr = fsm->CollectFingerPrintEx(ctx, dwUserErrorCode);
+		//if (eErr == Error_Unexpect && dwUserErrorCode > 0)
+		//	ctx->Answer(eErr, dwUserErrorCode);
+		//else
+		//	ctx->Answer(eErr);
+		//fsm->PostEventFIFO(e);
 	}
 };
 
@@ -931,12 +771,12 @@ struct SaveFingerPrintTask : public ITaskSp
 	SaveFingerPrintTask(CCustMngrAuthFSM* f) : fsm(f) {}
 	void Process()
 	{
-		LOG_FUNCTION();
-		SaveFingerPrintFinishedEvent* e = new SaveFingerPrintFinishedEvent();
-		e->ctx = ctx;
-		ErrorCodeEnum eErr = fsm->SaveFingerPrint(ctx);
-		ctx->Answer(eErr);
-		fsm->PostEventFIFO(e);
+		//LOG_FUNCTION();
+		//SaveFingerPrintFinishedEvent* e = new SaveFingerPrintFinishedEvent();
+		//e->ctx = ctx;
+		//ErrorCodeEnum eErr = fsm->SaveFingerPrint(ctx);
+		//ctx->Answer(eErr);
+		//fsm->PostEventFIFO(e);
 	}
 };
 #pragma endregion

+ 2 - 0
Module/mod_CustMngrAuth/CustMngrAuth_UserErrorCode.h

@@ -17,5 +17,7 @@
 #define LOG_ERR_CUSTMNGRAUTH_INVOKE_CollectFingerPrintInfo			0x1020020C	//web调用单次采集的注册接口 - LogWarn
 #define LOG_ERR_CUSTMNGRAUTH_INVOKE_GenerateTemplate				0x1020020D	//web调用合成模板接口 - LogWarn
 
+#define LOG_ERR_CUSTMNGRAUTH_REQUEST_REFUSE							0x1020020F	//旧接口请求拒绝
+
 
 #endif

+ 16 - 6
Module/mod_CustMngrAuth/mod_CustMngrAuth.cpp

@@ -2,7 +2,7 @@
 #include "stdafx.h"
 #include "SpBase.h"
 #include "mod_CustMngrAuth.h"
-
+#include "CustMngrAuth_UserErrorCode.h"
 CCustMngrAuthEntity::CCustMngrAuthEntity()
 {
 
@@ -193,7 +193,9 @@ void CustMngrAuthServerSession::Handle_StartAuthorize(SpReqAnsContext<CustMngrAu
 	LOG_FUNCTION();
 	DbgToBeidou(ctx->link, __FUNCTION__)();
 	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("StartAuthorize")("Invoke StartAuthorize");
-	m_pEntity->StartAuthorize(ctx);
+	LogWarn(Severity_Low, Error_Unexpect, LOG_ERR_CUSTMNGRAUTH_REQUEST_REFUSE, "web invoke StartAuthorize request refuse");
+	ctx->Answer(Error_Exception);
+	//m_pEntity->StartAuthorize(ctx);
 }
 //使用
 void CustMngrAuthServerSession::Handle_QueryAuthorInfo(SpReqAnsContext<CustMngrAuthService_QueryAuthorInfo_Req, CustMngrAuthService_QueryAuthorInfo_Ans>::Pointer ctx)
@@ -214,7 +216,9 @@ void CustMngrAuthServerSession::Handle_StopAuthorize(SpReqAnsContext<CustMngrAut
 	LOG_FUNCTION();
 	DbgToBeidou(ctx->link, __FUNCTION__)();
 	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("StopAuthorize")("Invoke StopAuthorize");
-	m_pEntity->StopAuthorize(ctx);
+	LogWarn(Severity_Low, Error_Unexpect, LOG_ERR_CUSTMNGRAUTH_REQUEST_REFUSE, "web invoke StopAuthorize request refuse");
+	ctx->Answer(Error_Exception);
+	//m_pEntity->StopAuthorize(ctx);
 }
 
 //使用
@@ -231,7 +235,9 @@ void CustMngrAuthServerSession::Handle_CollectFingerPrint(SpReqAnsContext<CustMn
 	LOG_FUNCTION();
 	DbgToBeidou(ctx->link, __FUNCTION__)();
 	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("CollectFingerPrint")("Invoke CollectFingerPrint");
-	m_pEntity->CollectFingerPrint(ctx);
+	LogWarn(Severity_Low, Error_Unexpect, LOG_ERR_CUSTMNGRAUTH_REQUEST_REFUSE, "web invoke CollectFingerPrint request refuse");
+	ctx->Answer(Error_Exception);
+	//m_pEntity->CollectFingerPrint(ctx);
 }
 //使用
 void CustMngrAuthServerSession::Handle_StopCollect(SpReqAnsContext<CustMngrAuthService_StopCollect_Req, CustMngrAuthService_StopCollect_Ans>::Pointer ctx)
@@ -247,7 +253,9 @@ void CustMngrAuthServerSession::Handle_CollectFingerPrintEx(SpReqAnsContext<Cust
 	LOG_FUNCTION();
 	DbgToBeidou(ctx->link, __FUNCTION__)();
 	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("CollectFingerPrintEx")("Invoke CollectFingerPrintEx");
-	m_pEntity->CollectFingerPrintEx(ctx);
+	LogWarn(Severity_Low, Error_Unexpect, LOG_ERR_CUSTMNGRAUTH_REQUEST_REFUSE, "web invoke CollectFingerPrintEx request refuse");
+	ctx->Answer(Error_Exception);
+	//m_pEntity->CollectFingerPrintEx(ctx);
 }
 //使用
 void CustMngrAuthServerSession::Handle_CollectFingerPrintInfo(SpReqAnsContext<CustMngrAuthService_CollectFingerPrintInfo_Req, CustMngrAuthService_CollectFingerPrintInfo_Ans>::Pointer ctx)
@@ -271,7 +279,9 @@ void CustMngrAuthServerSession::Handle_SaveFingerPrint(SpReqAnsContext<CustMngrA
 	LOG_FUNCTION();
 	DbgToBeidou(ctx->link, __FUNCTION__)();
 	DbgWithLink(LOG_LEVEL_INFO, ctx->link.checkEmpty() ? LOG_TYPE_SYSTEM : LOG_TYPE_USER).setAPI("SaveFingerPrint")("Invoke SaveFingerPrint");
-	m_pEntity->SaveFingerPrint(ctx);
+	LogWarn(Severity_Low, Error_Unexpect, LOG_ERR_CUSTMNGRAUTH_REQUEST_REFUSE, "web invoke SaveFingerPrint request refuse");
+	ctx->Answer(Error_Exception);
+	//m_pEntity->SaveFingerPrint(ctx);
 }
 //废弃
 void CustMngrAuthServerSession::Handle_CheckUkey(SpReqAnsContext<CustMngrAuthService_CheckUkey_Req, CustMngrAuthService_CheckUkey_Ans>::Pointer ctx)