Преглед изворни кода

Z991239-5729 #comment feat: 指纹仪dep文件获取兼容以及告警

陈纪林80310970 пре 1 година
родитељ
комит
3f593c7e66

+ 47 - 3
Module/mod_FingerPrint/FingerPrintFSM.cpp

@@ -538,7 +538,7 @@ int CFingerPrintFSM::GetFingerPrint(SpReqAnsContext<FingerPrintService_GetFinger
 	int lpbLength = MAX_FEATURE_LEN;
 	
 
-	CSimpleStringA strPath;
+	CSimpleStringA strPath, strOldPath;
 	eErr = m_pEntity->GetFunction()->GetPath("Dep", strPath);
 	if(eErr != Error_Succeed)
 	{
@@ -587,6 +587,22 @@ int CFingerPrintFSM::GetFingerPrint(SpReqAnsContext<FingerPrintService_GetFinger
 		
 		if (eErr == Error_Succeed)
 		{
+			if (!ExistsFileA(strPath.GetData()))
+			{
+				ErrorCodeEnum eErrOld = m_pEntity->GetFunction()->GetPath("DepBak", strOldPath);
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[DepBak]%s,%s", SpStrError(eErrOld), strOldPath.GetData());
+				
+				strOldPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", strOldPath.GetData(), fileName.GetData());
+				DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_USER)("<GetFingerPrint> imageName = %s", strOldPath.GetData());
+
+				if (ExistsFileA(strOldPath.GetData())) //在旧Dep路径下找到文件时告警
+				{
+					strPath = strOldPath;
+					CSimpleStringA warnMsg = CSimpleStringA::Format("Find %s in OLD dep path!", strOldPath.GetData());
+					LogWarn(Severity_Middle, Error_Unexpect, FingerPrint_UserErrorCode_FindFile_in_DepBak, warnMsg.GetData());
+				}
+			}
+
 			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM).setAPI("DevAdapter::Image2Feature").setCostTime(l_endTime - l_beginTime)("GetFingerPrint::Image2Feature fileName:%s, lpbLength:%d", fileName.GetData(), lpbLength);
 #ifdef RVC_OS_WIN
 			Sleep(200);//save image may be delayed some time, not must happen
@@ -766,7 +782,7 @@ int CFingerPrintFSM::GenerateTemplate(SpReqAnsContext<FingerPrintService_Generat
 	int lpbLength = MAX_FEATURE_LEN;
 
 	std::vector<CSimpleStringA> imagePaths;
-	CSimpleStringA strPath;
+	CSimpleStringA strPath, strOldPath;
 	m_pEntity->GetFunction()->GetPath("Dep", strPath);
 
 	for (int i = 0; i < ctx->Req.FingerIDList.GetCount(); ++i)
@@ -776,6 +792,19 @@ int CFingerPrintFSM::GenerateTemplate(SpReqAnsContext<FingerPrintService_Generat
 		//_itoa(ctx->Req.FingerIDList[i], buf, 10);
 		//CSimpleStringA tempStr = strPath + "\\" + "finger" + CSimpleStringA(buf) + ".bmp";
 		CSimpleStringA tempStr = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "finger%d.bmp", strPath.GetData(), ctx->Req.FingerIDList[i]);
+		if (!ExistsFileA(tempStr.GetData()))
+		{
+			ErrorCodeEnum eErrOld = m_pEntity->GetFunction()->GetPath("DepBak", strOldPath);
+			DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[DepBak]%s,%s", SpStrError(eErrOld), strOldPath.GetData());
+			strOldPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "finger%d.bmp", strOldPath.GetData(), ctx->Req.FingerIDList[i]);
+
+			if (ExistsFileA(strOldPath.GetData())) //在旧Dep路径下找到文件时告警
+			{
+				tempStr = strOldPath;
+				CSimpleStringA warnMsg = CSimpleStringA::Format("Find %s in OLD dep path!", strOldPath.GetData());
+				LogWarn(Severity_Middle, Error_Unexpect, FingerPrint_UserErrorCode_FindFile_in_DepBak, warnMsg.GetData());
+			}
+		}
 		imagePaths.push_back(tempStr);
 		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("imageName:%s", imagePaths[i].GetData());
 #ifdef RVC_OS_WIN		
@@ -917,9 +946,24 @@ ErrorCodeEnum CFingerPrintFSM::DeleteFileIfExisted(const char* fileName)
 		DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM)("Invalid or empty filename(%s)", fileName);
 		return Error_Param;
 	}
-	CSimpleStringA strPath, strObjPath;
+	CSimpleStringA strPath, strOldPath, strObjPath;
 	ErrorCodeEnum errCode = m_pEntity->GetFunction()->GetPath("Dep", strPath);
 	strObjPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", strPath.GetData(), fileName);
+
+	if (!ExistsFileA(strObjPath.GetData()))
+	{
+		ErrorCodeEnum eErrOld = m_pEntity->GetFunction()->GetPath("DepBak", strOldPath);
+		DbgWithLink(LOG_LEVEL_INFO, LOG_TYPE_SYSTEM)("[DepBak]%s,%s", SpStrError(eErrOld), strOldPath.GetData());
+		strOldPath = CSimpleStringA::Format("%s" SPLIT_SLASH_STR "%s", strOldPath.GetData(), fileName);
+
+		if (ExistsFileA(strOldPath.GetData())) //在旧Dep路径下找到文件时告警
+		{
+			strObjPath = strOldPath;
+			CSimpleStringA warnMsg = CSimpleStringA::Format("Find %s in OLD dep path!", strOldPath.GetData());
+			LogWarn(Severity_Middle, Error_Unexpect, FingerPrint_UserErrorCode_FindFile_in_DepBak, warnMsg.GetData());
+		}
+	}
+
 #ifdef RVC_OS_WIN
 	WIN32_FIND_DATA findData;
 	if (FindFirstFileA((LPCTSTR)strObjPath, &findData) != INVALID_HANDLE_VALUE)

+ 2 - 0
Module/mod_FingerPrint/FingerPrint_UserErrorCode.h

@@ -49,4 +49,6 @@
 #define FingerPrint_UserErrorCode_DevOpen_Failed_Registe				( FingerPrint_UserErrorCode_Start + 37 )	//采集指纹时,指纹是打开失败状态
 #define FingerPrint_UserErrorCode_Real_Root_Config						( FingerPrint_UserErrorCode_Start + 41 )	//实际加载的root配置
 
+#define FingerPrint_UserErrorCode_FindFile_in_DepBak					( FingerPrint_UserErrorCode_Start + 50 )	//在旧Dep路径下找到文件
+
 #endif