|
@@ -7,6 +7,7 @@
|
|
|
#include <cv.h>
|
|
|
#include <cxcore.h>
|
|
|
#include <fstream>
|
|
|
+#include <iomanip>
|
|
|
#ifdef RVC_OS_LINUX
|
|
|
#include "CommDevEntityErrorCode.h"
|
|
|
#include <iostream>
|
|
@@ -1768,11 +1769,20 @@ ErrorCodeEnum CIDCertFSM::DeleteFileIfExisted(LPCTSTR fileName, int deleteTiming
|
|
|
strAimPath = strAimPath + SPLIT_SLASH_STR + fileName;
|
|
|
UpdateAndWarnFileFindInDepBak(strAimPath, fileName, IDCertificate_UserErrorCode_FindFile_in_DepBak);
|
|
|
|
|
|
+ std::map<std::string, std::string> errInfo;
|
|
|
+ CSimpleStringA errMsg;
|
|
|
+
|
|
|
if (ExistsFileA((LPCTSTR)strAimPath))
|
|
|
{
|
|
|
if (deleteTiming == 1) //检测到上次读证残留图片
|
|
|
{
|
|
|
- CSimpleStringA errMsg = CSimpleStringA::Format("检测到上次读证残留图片:[%s]", strAimPath.GetData());
|
|
|
+ errInfo["path"] = strAimPath.GetData();
|
|
|
+ errInfo["hash"] = GetFileHashStr(strAimPath).GetData();
|
|
|
+ errInfo["fodifytime"] = GetFileLastModifyTime(strAimPath).GetData();
|
|
|
+
|
|
|
+ errMsg = generateJsonStr(errInfo).second.c_str();
|
|
|
+
|
|
|
+ //CSimpleStringA errMsg = CSimpleStringA::Format("检测到上次读证残留图片:[%s]", strAimPath.GetData());
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA2112").setAPI("DeleteFileIfExisted")(errMsg.GetData());
|
|
|
}
|
|
|
|
|
@@ -1792,8 +1802,13 @@ ErrorCodeEnum CIDCertFSM::DeleteFileIfExisted(LPCTSTR fileName, int deleteTiming
|
|
|
{
|
|
|
rtaCode = "RTA2115";
|
|
|
}
|
|
|
+
|
|
|
+ errInfo.clear();
|
|
|
+ errInfo["path"] = strAimPath.GetData();
|
|
|
+ errInfo["lasterror"] = GetLastError();
|
|
|
+ errMsg = generateJsonStr(errInfo).second.c_str();
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode(rtaCode.GetData()).setAPI("DeleteFileIfExisted")
|
|
|
- ("DeleteFile(%s) failed LastError(%d).", (LPCTSTR)strAimPath, GetLastError());
|
|
|
+ (errMsg.GetData());
|
|
|
return Error_Unexpect;
|
|
|
}
|
|
|
}
|
|
@@ -1801,7 +1816,9 @@ ErrorCodeEnum CIDCertFSM::DeleteFileIfExisted(LPCTSTR fileName, int deleteTiming
|
|
|
{
|
|
|
if (deleteTiming == 2) //未发现本次读证生成的图片
|
|
|
{
|
|
|
- CSimpleStringA errMsg = CSimpleStringA::Format("未发现本次读证生成的图片:[%s]", strAimPath.GetData());
|
|
|
+ errInfo.clear();
|
|
|
+ errInfo["path"] = strAimPath.GetData();
|
|
|
+ errMsg = generateJsonStr(errInfo).second.c_str();
|
|
|
DbgWithLink(LOG_LEVEL_WARN, LOG_TYPE_SYSTEM).setResultCode("RTA2114").setAPI("DeleteFileIfExisted")(errMsg.GetData());
|
|
|
}
|
|
|
return Error_Succeed;
|
|
@@ -2322,6 +2339,70 @@ void CIDCertFSM::CheckEjectCardRes(ErrorCodeEnum errRf, ErrorCodeEnum errForceID
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+CSimpleStringA CIDCertFSM::GetFileHashStr(CSimpleStringA filePath)
|
|
|
+{
|
|
|
+ //calculate file hash value
|
|
|
+ std::map<std::string, std::string> termInfo;
|
|
|
+ char* strFileHash = new char[128];
|
|
|
+ if (ExistsFileA(filePath.GetData()))
|
|
|
+ {
|
|
|
+ BYTE fileHash[32];
|
|
|
+ SM3File(const_cast<char*>(filePath.GetData()), fileHash);
|
|
|
+ ZeroMemory(strFileHash, 128);
|
|
|
+ SP::Module::Util::HexBuf2StrBuf(fileHash, &strFileHash, 32);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ memset(strFileHash, '\0', sizeof(char) * 128);
|
|
|
+ }
|
|
|
+ if (strFileHash != nullptr)
|
|
|
+ {
|
|
|
+ delete[] strFileHash;
|
|
|
+ strFileHash = nullptr;
|
|
|
+ }
|
|
|
+
|
|
|
+ return strFileHash;
|
|
|
+}
|
|
|
+
|
|
|
+CSimpleStringA CIDCertFSM::GetFileLastModifyTime(CSimpleStringA filePath)
|
|
|
+{
|
|
|
+#if defined(_WIN32)
|
|
|
+ WIN32_FILE_ATTRIBUTE_DATA fileInfo;
|
|
|
+ if (!GetFileAttributesExA(filePath.GetData(), GetFileExInfoStandard, &fileInfo)) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ FILETIME localFileTime;
|
|
|
+ FileTimeToLocalFileTime(&fileInfo.ftLastWriteTime, &localFileTime);
|
|
|
+
|
|
|
+ SYSTEMTIME sysTime;
|
|
|
+ FileTimeToSystemTime(&localFileTime, &sysTime);
|
|
|
+
|
|
|
+ std::ostringstream oss;
|
|
|
+ oss << std::setfill('0')
|
|
|
+ << sysTime.wYear << "-"
|
|
|
+ << std::setw(2) << sysTime.wMonth << "-"
|
|
|
+ << std::setw(2) << sysTime.wDay << " "
|
|
|
+ << std::setw(2) << sysTime.wHour << ":"
|
|
|
+ << std::setw(2) << sysTime.wMinute << ":"
|
|
|
+ << std::setw(2) << sysTime.wSecond;
|
|
|
+ return oss.str().c_str();
|
|
|
+
|
|
|
+#else
|
|
|
+ struct stat fileStat;
|
|
|
+ if (stat(filePath.GetData(), &fileStat) != 0) {
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ time_t modTime = fileStat.st_mtime;
|
|
|
+ struct tm* timeInfo = localtime(&modTime);
|
|
|
+
|
|
|
+ char buffer[20];
|
|
|
+ strftime(buffer, sizeof(buffer), "%Y-%m-%d %H:%M:%S", timeInfo);
|
|
|
+ return buffer;
|
|
|
+#endif
|
|
|
+}
|
|
|
+
|
|
|
#ifdef RVC_OS_WIN
|
|
|
void CIDCertFSM::HttpsLogCallBack(const char* logtxt)
|
|
|
{
|