// stdafx.cpp : 只包括标准包含文件的源文件 // SmartEvaluationLogic.pch 将作为预编译头 // stdafx.obj 将包含预编译类型信息 #include "stdafx.h" #include "basic_struct.h" void GetCurrentModuleDir( CString& modulDir ) { CString path; GetModuleFileName(NULL,path.GetBufferSetLength(MAX_PATH+1),MAX_PATH); path.ReleaseBuffer(); int pos = path.ReverseFind('\\'); modulDir = path.Left(pos); } CString GetTimeString() { CString time_string; SYSTEMTIME systime; GetLocalTime(&systime); time_string.Format(_T("%4d%02d%02d%02d%02d%02d%03d"),systime.wYear, systime.wMonth, systime.wDay, systime.wHour, systime.wMinute, systime.wSecond, systime.wMilliseconds); return time_string; } void split( const std::string& s, const std::string& delim,std::vector< std::string >* ret ) { size_t last = 0; size_t index=s.find_first_of(delim,last); while (index!=std::string::npos) { ret->push_back(s.substr(last,index-last)); last=index+1; index=s.find_first_of(delim,last); } if (index-last>0) { ret->push_back(s.substr(last,index-last)); } } void updatefile(CppSQLite3DB* bantch_db,long student_paper_id,const std::string & norimg_dir,const std::string & excimg_dir){ char sql5[512]; sprintf_s(sql5,"select * from student_paper sp where sp.student_paper_id =%d",student_paper_id); CppSQLite3Query query_s =bantch_db->execQuery(sql5); if(!query_s.eof()){ long paper_state=query_s.getInt64Field("paper_state"); const char * student_code=query_s.getStringField("student_code"); sprintf_s(sql5,"select * from page p where p.student_paper_id =%d",student_paper_id); CppSQLite3Query query_p =bantch_db->execQuery(sql5); CppSQLite3Statement stmt = bantch_db->compileStatement("update page set img_path =:img_path where page_id =:page_id"); while(!query_p.eof()){ std::string img_path=query_p.getStringField("img_path"); int page_id=query_p.getIntField("page_id"); int phy_number=atoi(query_p.getStringField("phy_number")); int page_index=query_p.getIntField("page_index"); int index_dirspeator=img_path.find_last_of('\\'); int index_dot=img_path.find_last_of('.'); std::string dir = img_path.substr(0,index_dirspeator); std::string filename =img_path.substr(index_dirspeator,img_path.length()-index_dirspeator); std::string extname =index_dot>index_dirspeator?img_path.substr(index_dot,img_path.length()-index_dot):".jpg"; std::string dir_new=(paper_state&(MEX_YICHANG))?excimg_dir:norimg_dir; char filename_new[512]; if(paper_state&(MEX_YICHANG)){ sprintf_s(filename_new, "%06d%s",phy_number,extname.c_str()); }else{ sprintf_s(filename_new, "%s_%01d_%06d%s",student_code,page_index,phy_number,extname.c_str()); } std::string img_path_new =dir_new+"\\"+filename_new; if(dir!=dir_new){ MoveFile(CString(img_path.c_str()),CString(img_path_new.c_str())); stmt.bind(":img_path",img_path_new.c_str()); stmt.bind(":page_id",page_id); stmt.execDML(); }else if(filename != filename_new){ rename(img_path.c_str(),img_path_new.c_str()); stmt.bind(":img_path",img_path_new.c_str()); stmt.bind(":page_id",page_id); stmt.execDML(); } query_p.nextRow(); } } } void setRunUploadFlag(CString str) { TCHAR FilePath[MAX_PATH]; GetModuleFileName(NULL, FilePath, MAX_PATH); (_tcsrchr(FilePath, '\\'))[0] = 0; (_tcsrchr(FilePath, '\\'))[1] = 0; lstrcat(FilePath, _T("config.ini")); //MessageBox(NULL, FilePath,str , MB_OK); WritePrivateProfileString(L"THIRD", L"uploadflag", str, FilePath); } void setRunFlag(CString str) { TCHAR FilePath[MAX_PATH]; GetModuleFileName(NULL, FilePath, MAX_PATH); (_tcsrchr(FilePath, '\\'))[0] = 0; (_tcsrchr(FilePath, '\\'))[1] = 0; lstrcat(FilePath, _T("config.ini")); //MessageBox(NULL, FilePath,str , MB_OK); WritePrivateProfileString(L"THIRD", L"flag", str, FilePath); } CString getRunFlag() { TCHAR FilePath[MAX_PATH]; GetModuleFileName(NULL, FilePath, MAX_PATH); (_tcsrchr(FilePath, '\\'))[0] = 0; (_tcsrchr(FilePath, '\\'))[1] = 0; lstrcat(FilePath, _T("config.ini")); TCHAR wcharFlag[10]; GetPrivateProfileString(L"THIRD", L"flag", L"0", wcharFlag, 10, FilePath); CString temp; temp = wcharFlag; return temp; }