Quellcode durchsuchen

!10789 合并当前st2:win的vtm.exe启动改造
Merge pull request !10789 from 80174847/ST2

杨诗友80174847 vor 3 Monaten
Ursprung
Commit
a6f634ce39

+ 28 - 0
CMakeLists.txt

@@ -887,6 +887,34 @@ if(WITH_PDB_SAVEV2)
 	install(CODE "MESSAGE(\"----Pack PDB File Done----\")" COMPONENT symbols)
 endif(WITH_PDB_SAVEV2)
 
+if(WITH_LABEL_RECORD AND DEVOPS_ON AND NOT DEVOPS_ON_CMAKE_PRD)
+	message(STATUS "PIPELINE_BRANCH: $ENV{PIPELINE_BRANCH}")
+	message(STATUS "PIPELINE_PRE_TAG: $ENV{PIPELINE_PRE_TAG}")
+	
+	set(LABEL_UPLOAD_ENV_STR $ENV{DEVOPS_ENV})
+	string(TOLOWER $ENV{DEVOPS_ENV} LABEL_UPLOAD_ENV_STR) #st|uat
+	
+	if(DEVOPS_ON_CMAKE_ST)
+		set(LABEL_UPLOAD_URL_PREFIX "http://55.11.56.122/rvc/LR04.02_RVCTerminalPlus_ST")
+	else()
+		set(LABEL_UPLOAD_URL_PREFIX "http://55.11.56.122/rvc/LR04.02_RVCTerminalPlus_UAT")
+	endif(DEVOPS_ON_CMAKE_ST)
+	set(LABEL_UPLOAD_URL "${LABEL_UPLOAD_URL_PREFIX}/RVCTerminalPlus-$ENV{PIPELINE_BRANCH}.zip")
+	set(LABEL_UPLOAD_URL_NAME "http://avsuser.paasst.cmbchina.cn/avsui/other-bean/insert-tmp-version-info")
+	if(MSVC)
+		set(LABEL_UPLOAD_PLATFORM "win")
+	else()
+		set(LABEL_UPLOAD_PLATFORM "uos")
+	endif(MSVC)
+	set(LABEL_UPLOAD_VERSION "${RVC_VERSION}")
+	set(LABEL_UPLOAD_UPDATER "DEVOPS_USER")
+	set(LABEL_UPLOADE_JSON_CONTENT "{\"version\":\"${LABEL_UPLOAD_VERSION}\",\"url\":\"${LABEL_UPLOAD_URL}\",\"env\":\"${LABEL_UPLOAD_ENV_STR}\",\"platform\":\"${LABEL_UPLOAD_PLATFORM}\",\"updater\":\"${LABEL_UPLOAD_UPDATER}\"}")
+	install(CODE "MESSAGE(\"----upload label info ${LABEL_UPLOAD_URL}----\")" COMPONENT symbols)
+	install(CODE "execute_process(COMMAND curl -X POST -H \"Content-Type: application/json\" -d ${LABEL_UPLOADE_JSON_CONTENT} ${LABEL_UPLOAD_URL_NAME})" COMPONENT symbols)
+	install(CODE "MESSAGE(\"----finished uploading label info ${LABEL_UPLOAD_URL}----\")" COMPONENT symbols)
+endif(WITH_LABEL_RECORD AND DEVOPS_ON AND NOT DEVOPS_ON_CMAKE_PRD)
+
+
 
 #appoint the component to install , except header file here.
  #set(CPACK_ARCHIVE_COMPONENT_INSTALL ON)

+ 3 - 0
Framework/Common/RVCEventCode.h

@@ -27,4 +27,7 @@ inline CSimpleStringA DWORD2Hex(DWORD cur)
 #define RTAERR_SPHOST_IOM_FAILED			"RTA0021"	//iom create failed
 
 
+#define VTM_LAUNCH_RESERVERD_START			"RTA0030"
+#define VTM_LAUNCH_RESERVERD_END			"RTA003Z"
+
 #endif

+ 3 - 3
Module/mod_ResourceWatcher/ResourceWatcherFSM.h

@@ -192,6 +192,7 @@ struct DeleteParam
 		delDirFlag = val;
 		if (delDirFlag) saveBackDay = 0;
 	}
+	//lpszPath:清理路径
 	CSimpleStringA path;
 	//控制是否将目录也一并删除,false 保留目录, true 删除目录
 	bool delDirFlag;
@@ -206,13 +207,12 @@ struct DeleteParam
 struct DeleteResult
 {
 	DeleteResult() :sucCnt(0), failCnt(0) {}
+	//删除成功个数
 	DWORD sucCnt;
+	//删除失败个数
 	DWORD failCnt;
-
 };
 
-const int DEFAULT_DAY_OF_BACKWARD = 90;
-
 class ResourceWatcherFSM : public FSMImpl<ResourceWatcherFSM>
 {
 public:

+ 141 - 71
Tool/VTMLauncher/VTM_IL.cpp

@@ -5,6 +5,7 @@
 #include "VTM_IL.h"
 
 #include<string>
+#include<regex>
 #include <windows.h>                  
 #include <shellapi.h>
 #include <fstream>
@@ -13,6 +14,7 @@
 using namespace std;
 
 #define MAX_LOADSTRING 100
+#define ERROR_TITILE "可视柜台终端应用程序"
 
 const int HOTKEY_ID = 1;
 
@@ -40,15 +42,14 @@ int APIENTRY _tWinMain(HINSTANCE hInstance,
 	UNREFERENCED_PARAMETER(hPrevInstance);
 	UNREFERENCED_PARAMETER(lpCmdLine);
 
- 	// TODO: 在此放置代码。
 	MSG msg;
 	HACCEL hAccelTable;
 
-	// 初始化全局字符串
+	// 初始化全局字符串	
 	LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING);
 	LoadString(hInstance, IDC_TEST, szWindowClass, MAX_LOADSTRING);
 	MyRegisterClass(hInstance);
-
+	Sleep(200);
 	// 执行应用程序初始化:
 	if (!InitInstance (hInstance, nCmdShow))
 	{
@@ -106,6 +107,45 @@ ATOM MyRegisterClass(HINSTANCE hInstance)
 	return RegisterClassEx(&wcex);
 }
 
+BOOL ExistsFileA(LPCSTR lpFilePath)
+{
+	DWORD dwRet = GetFileAttributesA(lpFilePath);
+	return (dwRet != INVALID_FILE_ATTRIBUTES) && !(dwRet & FILE_ATTRIBUTE_DIRECTORY);
+}
+
+BOOL ExistsDirA(LPCSTR lpDirPath)
+{
+	DWORD dwRet = GetFileAttributesA(lpDirPath);
+	return (dwRet != INVALID_FILE_ATTRIBUTES) && (dwRet & FILE_ATTRIBUTE_DIRECTORY);
+}
+
+UINT GetErrorMessage(CString& retMessage, LPCTSTR lpDefault, DWORD error = GetLastError())
+{
+	if (error == 0) {
+		retMessage = lpDefault;
+		return strlen(lpDefault);
+	}
+	LPVOID lpMsgBuf;
+	FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER
+		| FORMAT_MESSAGE_FROM_SYSTEM
+		| FORMAT_MESSAGE_IGNORE_INSERTS,
+		NULL,
+		error,
+		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+		(LPTSTR)&lpMsgBuf,
+		0,
+		NULL);
+	if (lpMsgBuf == NULL) {
+		retMessage = lpDefault;
+		return strlen(lpDefault);
+	}
+	CString strTemp;
+	strTemp.Format("错误描述:%s", (LPCTSTR)lpMsgBuf);
+	retMessage = strTemp;
+	LocalFree((LPVOID)lpMsgBuf);
+	return retMessage.GetLength();
+}
+
 int GetVersion(char** pVersion)
 {
 	char szFileName[MAX_PATH] = {0};
@@ -115,32 +155,45 @@ int GetVersion(char** pVersion)
 	int nPos = strFileName.find_last_of("\\");
 	string strDir = strFileName.substr(0, nPos);
 	sprintf_s(szFilePath, MAX_PATH,"%s\\active.txt", strDir.c_str());
+	if (!ExistsFileA(szFilePath)) {
+		CString strText;
+		strText.Format("[RTA0031] 版本文件不存在,请重新安装程序版本!");
+		MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
+		return 0;
+	}
 
-	char cVer[MAX_PATH] = {0};
 	ifstream infile(szFilePath);
-	if(infile) // 有该文件
+	if(infile.is_open())
 	{
-		if(infile.getline(cVer, MAX_PATH))
-		{
-			memcpy_s(*pVersion, MAX_PATH, cVer, MAX_PATH);
+		std::string line;
+		if(std::getline(infile, line)){
+			CString strVersionTxt(line.c_str());
+			memcpy_s(*pVersion, MAX_PATH, strVersionTxt.GetString(), MAX_PATH);
 			infile.close();
-
 			return 1;
 		}
 		else
 		{
-			MessageBoxA(NULL,"获取版本信息失败:文件内容为空",NULL,0);
+			CString strText;
+			strText.Format("[RTA0032] 版本文件内容为空,请重新安装程序版本!");
+			MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
+			infile.close();
 			return 0;
-		}		
+		}
 	}
-	else
-	{
-		MessageBoxA(NULL,"获取版本信息失败:文件打开失败",NULL,0);	
+	else {
+		const DWORD dwError = GetLastError();
+		CString strText;
+		CString strError;
+		char szDefault[128];
+		sprintf_s(szDefault, "错误描述:%u", dwError);
+		GetErrorMessage(strError, szDefault, dwError);
+		strText.Format("[RTA0033] 版本文件打开失败,请联系分行IT或厂商排查!\r\n\r\n%s", strError.GetBuffer());
+		MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
 		return 0;
 	}
 
 	infile.close();
-
 	return 0;
 }
 
@@ -156,34 +209,46 @@ BOOL GetSpShellPath(char** pPath)
 	int nPos = strFileName.find_last_of("\\");
 	string strDir = strFileName.substr(0, nPos);
 
-	if(GetVersion(&pVer))
+	if(!GetVersion(&pVer))
 	{
-		sprintf_s(szFilePath, MAX_PATH, "%s\\%s\\bin\\SpShell.exe", strDir.c_str(), pVer);
+		if (NULL != pVer)
+		{
+			delete [] pVer;
+			pVer = NULL;
+		}
+		return FALSE;
 	}
-	else
-	{
+	memset(szFileName, 0, sizeof(szFileName));
+	sprintf_s(szFileName, MAX_PATH, "%s\\%s", strDir.c_str(), pVer);
+	if (!ExistsDirA(szFileName)) {
+		CString strText;
+		strText.Format("[RTA0034] 版本文件夹 [%s] 不存在,请重新安装程序版本!",pVer);
+		MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
+		if (NULL != pVer)
+		{
+			delete[] pVer;
+			pVer = NULL;
+		}
 		return FALSE;
 	}
 
-	
+	sprintf_s(szFilePath, MAX_PATH, "%s\\%s\\bin\\SpShell.exe", strDir.c_str(), pVer);
 	memcpy_s(*pPath, MAX_PATH, szFilePath, MAX_PATH);
 
 	if (NULL != pVer)
 	{
-		free(pVer);
+		delete[] pVer;
 		pVer = NULL;
 	}
 
-	ifstream shellFile(*pPath);
-	if(shellFile)
-	{
-		return TRUE;
-	}
-	else
-	{
-		MessageBoxA(NULL,"获取执行文件失败:文件无效或文件不存在",NULL,0);
+	if (!ExistsFileA(*pPath)) {
+		CString strText;
+		strText.Format("[RTA0035] 程序执行文件不存在,请重新安装程序版本!(文件路径:%s)", *pPath);
+		MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
 		return FALSE;
 	}
+
+	return TRUE;
 }
 
 BOOL Execute(const char* cExeName)
@@ -195,11 +260,14 @@ BOOL Execute(const char* cExeName)
 
 	if (!ShellExecuteExA(&sei))
 	{
-		DWORD dwError = GetLastError();
-		char szError[128];
-		memset(szError, '\0', 128);
-		sprintf_s(szError, 128, "执行应用程序失败:%u", dwError);
-		MessageBoxA(NULL, szError,NULL,0);
+		const DWORD dwError = GetLastError();
+		CString strText;
+		CString strError;
+		char szDefault[128];
+		sprintf_s(szDefault, "错误描述:%u", dwError);
+		GetErrorMessage(strError, szDefault, dwError);
+		strText.Format("[RTA0036] 执行应用程序文件失败,请联系分行IT或厂商排查!\r\n\r\n%s", strError.GetBuffer());
+		MessageBoxA(NULL, strText, ERROR_TITILE, MB_OK | MB_ICONERROR);
 		return FALSE;
 	}
 
@@ -208,53 +276,60 @@ BOOL Execute(const char* cExeName)
 
 BOOL RunSpshell()
 {
+	BOOL ret = FALSE;
+
 	char* pSpPath = new char[MAX_PATH];
 	memset(pSpPath, 0, MAX_PATH);
 
-	if (!GetSpShellPath(&pSpPath))
+	do 
 	{
-		return FALSE;
-	}
+		if (!GetSpShellPath(&pSpPath))
+		{
+			break;
+		}
+		if (!Execute(pSpPath))
+		{
+			break;
+		}
+		ret = TRUE;
 
-	if (!Execute(pSpPath))
-	{
-		return FALSE;
-	}
+	} while (false);
 
 	if (NULL != pSpPath)
 	{
-		free(pSpPath);
+		delete[] pSpPath;
 		pSpPath = NULL;
 	}
-
-	return TRUE;
+	return ret;
 }
 
 //校正
-void checkActiveTxtAttr()
+int checkActiveTxtAttr()
 {
 	char vtmexePath[MAX_PATH] = {0};
 	GetModuleFileNameA(NULL, vtmexePath, sizeof(vtmexePath));
 	string strRunVtmPath = vtmexePath;
-	int nPosVtm = strRunVtmPath.find_first_of("\\version\\VTM.exe");
-	if(nPosVtm<0)
+	const auto nPosVtm = strRunVtmPath.find("\\version\\VTM.exe");
+	if(nPosVtm == -1)
 	{
-		MessageBoxA(NULL,"VTM.exe 不在X:\\version\\VTM.exe下",NULL,0);
-		return ;
+		MessageBoxA(NULL,"[RTA0030] 可视柜台应用程序不在规定路径下执行,请重新安装程序版本!", ERROR_TITILE, MB_OK | MB_ICONERROR);
+		return -1;
 	}
-	int nPos = strRunVtmPath.find_last_of("\\");
+	const int nPos = strRunVtmPath.find_last_of("\\");
 	string strVersionDir = strRunVtmPath.substr(0, nPos);
 	CString strActiveTxtPath=strVersionDir.c_str();//+"active.txt"; 
 	strActiveTxtPath +="\\"; 
 	strActiveTxtPath +="active.txt";
-
-    CFileStatus rStatus;
-    CFile::GetStatus(strActiveTxtPath,rStatus);//获得文件的属性设置
-	//如果文件为只读的,将只读属性去掉
-	if(rStatus.m_attribute&CFile::readOnly){
-		rStatus.m_attribute=rStatus.m_attribute & 0x3E ;      
-        CFile::SetStatus(strActiveTxtPath, rStatus );//更改文件的属性设置
+	if (ExistsFileA(strActiveTxtPath)) {
+		CFileStatus rStatus;
+		CFile::GetStatus(strActiveTxtPath, rStatus);//获得文件的属性设置
+		//如果文件为只读的,将只读属性去掉
+		if (rStatus.m_attribute & CFile::readOnly) {
+			rStatus.m_attribute = rStatus.m_attribute & 0x3E;
+			CFile::SetStatus(strActiveTxtPath, rStatus);//更改文件的属性设置
+		}
 	}
+	return 0;
 }
 
 void RegistHotkey() 
@@ -378,27 +453,22 @@ void GetDisplayScale()
 BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
 {
 	// 校正active.txt的属性
-	checkActiveTxtAttr();
-
-   //启动框架
-	if (RunSpshell()) {
+	if (0 == checkActiveTxtAttr() && RunSpshell()) {
 		HideTaskBar(TRUE);
 	}
 
     hInst = hInstance; // 将实例句柄存储在全局变量中
 
-   /*hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
-      CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
-
-   if (!hWnd)
-   {
-      return FALSE;
-   }
+   //HWND hWnd = CreateWindowA(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
+	  //CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL);
 
-   ShowWindow(hWnd, nCmdShow);
-   UpdateWindow(hWnd);*/
-   //MessageBoxA(NULL,"Hello",NULL,0);
+   //if (!hWnd)
+   //{
+	  //return FALSE;
+   //}
 
+   //ShowWindow(hWnd, nCmdShow);
+   //UpdateWindow(hWnd);
    return FALSE;
 }
 

+ 4 - 1
addin/cmake/ConfigOptions.cmake

@@ -52,4 +52,7 @@ option(DEVOPS_INSTALL_SWITCH "install at devpos for pkging as zip easily" OFF)
 
 option(WITH_PDB_SAVE "save pdb file, copy pdb 2 version and pack from it" OFF)
 
-option(WITH_PDB_SAVEV2 "save pdb file, pack pdb from build dir directily" OFF)
+option(WITH_PDB_SAVEV2 "save pdb file, pack pdb from build dir directily" OFF)
+
+option(WITH_LABEL_RECORD "save artificatory file label to avs" OFF)
+