VOID WINAPI CCommands::XApplicationEvents::ManualCallBackProc( PMANUALCALLBACK lpManuallCallBack ) { CString strError; switch(lpManuallCallBack->dwError) { case HR_ERROR_NOERROR: // 无错误发生 if (lpManuallCallBack->IsFinished != 1 || 0 == _tcslen(lpManuallCallBack->szFileName)) { return; } strError = "无错误发生"; break; case HR_ERROR_CANTCONNECT_SERVER: // 无法连接到文件服务器 strError = "无法连接到文件服务器"; break; case HR_ERROR_OVERLIMITSIZE: // 单个文件超过限制大小 strError = "单个文件超过限制大小"; break; case HR_ERROR_GETSIZEFAIL: // 得到文件大小失败 strError = "得到文件大小失败"; break; case HR_ERROR_CANTACCESS: // 文件无法访问 strError = "文件无法访问"; break; case HR_ERROR_CANTALLOCMEMORY: // 堆分配空间错误 strError = "堆分配空间错误"; break; } SYSTEMTIME sysTime; CString strTime; GetLocalTime(&sysTime); strTime.Format("%d/%d/%d %d:%d:%d.%d", sysTime.wYear, sysTime.wMonth, sysTime.wDay, sysTime.wHour, sysTime.wMinute, sysTime.wSecond, sysTime.wMilliseconds); LPVOID lpMsgBuf; FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language (LPTSTR) &lpMsgBuf, 0, NULL); CString strFileName; strFileName.Format("FileName: %s\tSendSize: %d\tFinish: %d\tError: %s\tApiLastError: %s\t%s", lpManuallCallBack->szFileName, lpManuallCallBack->dwSendSize, lpManuallCallBack->IsFinished, strError, lpMsgBuf, strTime); LocalFree( lpMsgBuf ); #ifdef _DEBUG CCommands* pCommands = (CCommands*)lpManuallCallBack->dwUserData; IApplication *pApplication = pCommands->GetApplicationObject(); CComBSTR bsFileName(strFileName); pApplication->PrintToOutputWindow(bsFileName); #else OutputDebugString(strFileName); #endif // _DEBUG }
HRESULT CCommands::XApplicationEvents::BuildFinish(long nNumErrors, long nNumWarnings) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); if (nNumErrors == 0) { CComPtr<IGenericProject> pProjectItem = NULL; IApplication* pApplication; CComPtr<IConfiguration> pConfig = NULL; CComBSTR bsBuildName; CString strBuildName; pApplication = m_pCommands->GetApplicationObject(); VERIFY_OK(pApplication->get_ActiveProject((IDispatch **)&pProjectItem)); VERIFY_OK(pApplication->get_ActiveConfiguration((IDispatch **)&pConfig)); pConfig->get_Name(&bsBuildName); strBuildName = bsBuildName; if (!pProjectItem) { return S_OK; } CComBSTR bsFullName, bsName; CString strProjectFullName, strProjectPath, strConfigName, strProjectName; UINT uSvnVersion = 0; pProjectItem->get_FullName(&bsFullName); pProjectItem->get_Name(&bsName); strProjectFullName = bsFullName; strProjectName = bsName; TCHAR sDrive[_MAX_DRIVE] = {0}; TCHAR sDir[_MAX_DIR] = {0}; TCHAR sFname[_MAX_FNAME] = {0}; TCHAR sExt[_MAX_EXT] = {0}; _tsplitpath(strProjectFullName, sDrive, sDir, sFname, sExt); strProjectPath = CString(sDrive) + CString(sDir); strConfigName = CString(sDrive) + CString(sDir) + CString(sFname) + CString(_T(".ini")); CONFIG config; COptionDlg::GetConfig(config, strConfigName); if (config.bPdbAutoCommit && -1 != config.strCommitList.Find(strBuildName + '#')) { CString strPdbPath, strOutputDir, strReg, strOutPut, strOutData, strData; const TCHAR sReg[] = _T("IF[ ]+\"\\$\\(CFG\\)\" == \"%s\"([^!]+)"); const TCHAR sRegOutputDir[] = _T("^.+PROP Output_Dir[ ]+\"(.+)\"$"); const TCHAR sRegPdbPath[] = _T("^# ADD LINK32(?:.+/pdb:\"(?<PDB>[^\"]+)\".+/debug)|(?:.+(?<PDB>/debug))"); const TCHAR sRegOutPut[] = _T("^# ADD LINK32(?:.+/out:\"(?<OUT>[^\"]+)\")"); strReg.Format(sReg, strBuildName); // Get PDB File Path GetFileData(strProjectFullName, strOutData); if (strOutData.IsEmpty()) { return S_OK; } strData = GetRegexpData(strOutData, strReg, MULTILINE | IGNORECASE); strOutputDir = GetRegexpData(strData, sRegOutputDir, MULTILINE | IGNORECASE); strPdbPath = GetRegexpData(strData, sRegPdbPath, MULTILINE | IGNORECASE, "PDB"); strOutPut = GetRegexpData(strData, sRegOutPut, MULTILINE | IGNORECASE, "OUT"); if (strPdbPath.IsEmpty()) { pApplication->PrintToOutputWindow(CComBSTR("Not Find Pdb File Path So Can't Auto Commit PDB\r\n")); return S_OK; } if (!strPdbPath.CompareNoCase(_T("/debug"))) { if (strOutPut.IsEmpty()) { strPdbPath = strOutputDir + '\\' + strProjectName + ".pdb"; } else { TCHAR ssFname[_MAX_FNAME] = {0}; _tsplitpath(strOutPut, NULL, NULL, ssFname, NULL); strPdbPath = strOutputDir + '\\' + ssFname + ".pdb"; } } // Commit PDB File To Server MANUALBACKUP ManualBackup = {0}; ManualBackup.dwMaxSingleFileSize = -1; ManualBackup.dwUserData = (DWORD)m_pCommands; ManualBackup.pfnCallBackProc = ManualCallBackProc; strcpy(ManualBackup.szExtName, "*.pdb"); ManualBackup.pFileName = new ANSIPATH[1]; strcpy(ManualBackup.pFileName[0], strProjectPath + strPdbPath); ManualBackup.uFileCount = 1; strcpy(ManualBackup.szServerIP, config.strPdbServer); strcpy(ManualBackup.szReason, _T("PDB:")); ManualBackupToServer(&ManualBackup); delete []ManualBackup.pFileName; } } return S_OK; }