bool Init() { bool bRet = false; try { nMax_Updating_Num = atoi(GetIniFileString("OtherSet" , "maxUpCount" , "" , "DeviceUpgrade.ini").c_str()); nUpdating_Num = 0; SvIniFile inifile; SvIniFile::iterator pMap; GetSvIniFileBySections(inifile , "SipDownload.ini" , "default"); pMap = inifile.begin(); while(pMap != inifile.end()) { string strTemp = pMap->second.find("UpdateState")->second; // if(pMap->second.find("UpdateState")->second.compare("正在升级") == 0) if(strTemp.compare("正在升级") == 0) { string delayTime = pMap->second.find("DelayTime")->second; if(delayTime.empty()) { nUpdating_Num++; pMap++; continue; } string beginTime = pMap->second.find("BeginTime")->second; time_t CT; //当前时间 time_t ST; //开始时间 time_t DT; //超时时间 CTime t1 = CTime::GetCurrentTime(); CT = t1.GetTime(); Update::ConvertTime(beginTime , ST); DT = (atoi(delayTime.c_str()))*60*1000; if((ST+DT) > CT) { WriteIniFileString(pMap->first , "UpdateState" , "升级失败" , "SipDownload.ini"); } else { nUpdating_Num++; } } pMap++; } bRet = true; } catch(...) { char strErrorMsg[1024] = {0}; GetErrorMsg(strErrorMsg); WriteLog(strErrorMsg); bRet = false; } return bRet; }
/* * 函数介绍:程序入口函数 * 输入参数:argv[1]为-install是安装服务,-remove时删除服务,argv[2]安装时为服务控制台显示服务名称 删除时为注册服务名称,此程序为AlertService * 输出参数:无 * 返回值: */ int _tmain(int argc, _TCHAR* argv[]) { int nRetCode = 0; if(WriteIniFileString("testsection","testkey","testvalue","alert.ini")) { DeleteIniFileSection("testsection","alert.ini"); } if(WriteIniFileString("testsection","testkey","testvalue","TxtTemplate.ini")) { DeleteIniFileSection("testsection","TxtTemplate.ini"); } if(WriteIniFileString("testsection","testkey","testvalue","smsconfig.ini")) { DeleteIniFileSection("testsection","smsconfig.ini"); } if(WriteIniFileString("testsection","testkey","testvalue","general.ini")) { DeleteIniFileSection("testsection","general.ini"); } if(WriteIniFileString("testsection","testkey","testvalue","itsmConfig.ini")) { DeleteIniFileSection("testsection","itsmConfig.ini"); } if(WriteIniFileString("testsection","testkey","testvalue","watchsheetcfg.ini")) { DeleteIniFileSection("testsection","watchsheetcfg.ini"); } if(WriteIniFileString("testsection","testkey","testvalue","email.ini")) { DeleteIniFileSection("testsection","email.ini"); } if(WriteIniFileString("testsection","testkey","testvalue","emailAdress.ini")) { DeleteIniFileSection("testsection","emailAdress.ini"); } if(WriteIniFileString("testsection","testkey","testvalue","smsphoneset.ini")) { DeleteIniFileSection("testsection","smsphoneset.ini"); } if(WriteIniFileString("testsection","testkey","testvalue","interfacedll.ini")) { DeleteIniFileSection("testsection","interfacedll.ini"); } if(WriteIniFileString("testsection","testkey","testvalue","OfbizConfig.ini")) { DeleteIniFileSection("testsection","OfbizConfig.ini"); } #if 1 try { if(hasrun()) return 0; CAlertMain alertmain; alertmain.Init(); //MSG msg; //BOOL bRet=TRUE; //while((bRet=::GetMessage(&msg,NULL,0,0))!=0) //{ // if(bRet==-1) // { // continue; // } // TranslateMessage(&msg); // ::DispatchMessage(&msg); //} MSG msg; while(::GetMessage(&msg,NULL,0,0)) { TranslateMessage(&msg); ::DispatchMessage(&msg); switch(msg.message) { case WM_QUIT: exit(1); break; default: break; } } } catch(...) { } #else // argc = 2; // argv[1] = "-remove"; // argv[2] = "AlertService"; //#if 1 // RunThread(NULL); //#else // initialize MFC and print and error on failure if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0)) { // TODO: change error code to suit your needs cerr << _T("Fatal Error: MFC initialization failed") << endl; nRetCode = 1; } g_strRootPath= FuncGetInstallRootPath(); SERVICE_TABLE_ENTRY Table[] = { {"AlertService7",StartAlertService}, {NULL, NULL} }; CString outStr = "parameter required in the command line"; if(argc <= 1) { cout << (LPCTSTR)outStr << endl; } else { if(_stricmp(argv[1],"-install") == 0) { InstallService(argv[2]); } else if(_stricmp(argv[1],"-remove") == 0) { StopService(argv[2]); } else { cout << outStr << endl; } } if(!StartServiceCtrlDispatcher(Table)) { g_strMessage.Format("StartServiceCtrlDispatcher error = %d\r\n", GetLastError()); WriteLogFile(g_strMessage); } #endif //CAlertMain::pSender.Release(); return nRetCode; }
void CTuopList::EditReturn(int keyCode) { string strUserID = GetWebUserID(); HitLog LogItem; LogItem.sUserName = strUserID; LogItem.sHitPro = "TuopList"; LogItem.sHitFunc = "EditReturn"; LogItem.sDesc = strReturnSave; DWORD dcalBegin=GetTickCount(); InsertHitRecord(LogItem.sUserName, LogItem.sHitPro, LogItem.sHitFunc, LogItem.sDesc, 0, 0); // OutputDebugString("EditReturn\n"); if(keyCode == 13) { char buf[1024]; memset(buf, 0, 1023); string str = pCurrEditUserName->text(); sprintf(buf, "%s", str.c_str()); // OutputDebugString(buf); std::list<string> keylist; std::list<string>::iterator itemkey; #ifdef Tuopu bool bret = GetIniFileKeys("filename", keylist, "tuopfile.ini"); #else bool bret = GetIniFileKeys("filename", keylist, "maintainfile.ini"); #endif if(!bret) { // } bool bExist1 = true; std::string sVal = ""; std::string defaultret = "error"; std::string sret = ""; //此名字是否已经存在? for(itemkey = keylist.begin(); itemkey != keylist.end(); itemkey++) { sVal = *itemkey; #ifdef Tuopu sret = GetIniFileString("filename", sVal, defaultret, "tuopfile.ini"); #else sret = GetIniFileString("filename", sVal, defaultret, "maintainfile.ini"); #endif if(strcmp(sret.c_str(), bStrCurr.c_str()) == 0) { continue; } if(strcmp(sret.c_str(), str.c_str()) == 0) { bExist1 = false; } } // OutputDebugString("befor bExtit1\n"); if(bExist1) { for(itemkey = keylist.begin(); itemkey != keylist.end(); itemkey++) { sVal = *itemkey; #ifdef Tuopu sret = GetIniFileString("filename", sVal, defaultret, "tuopfile.ini"); #else sret = GetIniFileString("filename", sVal, defaultret, "maintainfile.ini"); #endif if(strcmp(sret.c_str(), bStrCurr.c_str()) == 0) { // OutputDebugString("befor write1\n"); #ifdef Tuopu WriteIniFileString("filename", sVal, str, "tuopfile.ini"); #else WriteIniFileString("filename", sVal, str, "maintainfile.ini"); #endif break; } } string strOpen; strOpen = "<a href=./showtuopu.exe?pageid="; strOpen += ReplaceStdString(sVal, ".htm", ""); #ifdef Tuopu strOpen += "&version=0"; #else strOpen += "&version=0&usrleader=0&maintain=1"; #endif strOpen += " target=_blank>"; strOpen += buf; strOpen += "</a>"; pCurrName->setText(strOpen.c_str()); pCurrName->show(); pCurrEditUserName->hide(); //插记录到UserOperateLog表 string strUserID = GetWebUserID(); TTime mNowTime = TTime::GetCurrentTimeEx(); OperateLog m_pOperateLog; m_pOperateLog.InsertOperateRecord("UserOperateLog",strUserID,mNowTime.Format(),strEditTip,strMainTitle,buf); } else { WebSession::js_af_up = "alert('"; WebSession::js_af_up += "have same name tuop"; WebSession::js_af_up += "')"; } } DWORD dcalEnd1=GetTickCount(); InsertHitRecord(LogItem.sUserName, LogItem.sHitPro, LogItem.sHitFunc, LogItem.sDesc, 1, dcalEnd1 - dcalBegin); }
std::list<string> CTuopList::ReadFileName(string path) { WIN32_FIND_DATA fd; std::list<string> strlist; path += "\\*.*"; HANDLE fr=::FindFirstFile(path.c_str(),&fd); while(::FindNextFile(fr,&fd)) { if(fd.dwFileAttributes&FILE_ATTRIBUTE_DIRECTORY) { // } else { std::string str1 = fd.cFileName; int npos = str1.find(".htm", 0); if(npos >= 0) { std::list<string> keylist; std::list<string>::iterator itemkey; #ifdef Tuopu bool bret = GetIniFileKeys("filename", keylist, "tuopfile.ini"); #else bool bret = GetIniFileKeys("filename", keylist, "maintainfile.ini"); #endif if(!bret) { // } bool bExist = false; for(itemkey = keylist.begin(); itemkey != keylist.end(); itemkey++) { std::string str = *itemkey; if(strcmp(str.c_str(), fd.cFileName) == 0) { bExist = true; break; } } //用户权限 if(GetUserRight(fd.cFileName)) { if(bExist) { std::string defaultret = "error"; #ifdef Tuopu std::string sret = GetIniFileString("filename", fd.cFileName, defaultret, "tuopfile.ini"); #else std::string sret = GetIniFileString("filename", fd.cFileName, defaultret, "maintainfile.ini"); #endif //int npos = sret.find(".htm", 0); //if(npos >= 0) if(sret != defaultret) { strlist.push_back(sret); } } else { #ifdef Tuopu WriteIniFileString("filename", fd.cFileName, fd.cFileName, "tuopfile.ini"); #else WriteIniFileString("filename", fd.cFileName, fd.cFileName, "maintainfile.ini"); #endif strlist.push_back(fd.cFileName); } } } } } return strlist; }
void CSVReportSet::SavePhone(SAVE_REPORT_LIST * report) { //nullTable -> clear(); if(strcmp(chgstr.c_str(), "") != 0) { Edit_Phone(report); return; } //judge report name/(ini section) is right std::list<string> sectionlist; std::list<string>::iterator Item; GetIniFileSections(sectionlist, "reportset.ini"); bool bRe = false; for(Item = sectionlist.begin(); Item != sectionlist.end(); Item++) { std::string str = *Item; if(strcmp(str.c_str(), report->szTitle.c_str()) == 0) { bRe = true; break; } } if(bRe)//有重复 { std::list<string> errorMsgList; errorMsgList.push_back(m_formText.szConnErr); m_pReportListTable->ShowErrorMsg(errorMsgList); //show error msg //m_pConnErr ->setText(m_formText.szConnErr); //m_pConnErr ->show(); } else { //int numRow = m_ptbPhone->numRows(); int numRow = m_pReportListTable->GeDataTable()->numRows(); m_pReportListTable->InitRow(numRow); WCheckBox * pCheck = new WCheckBox("", (WContainerWidget*)m_pReportListTable->GeDataTable()->elementAt(numRow, 0)); m_pReportListTable->GeDataTable()->elementAt(numRow, 0)->setContentAlignment(AlignCenter); std::string strlinkname; std::string hrefstr = RepHrefStr(report->szTitle); strlinkname ="<a href=/fcgi-bin/statsreportlist.exe?id="+hrefstr+">"+report->szTitle+"</a>"; WText *pName = new WText(strlinkname, (WContainerWidget*)m_pReportListTable->GeDataTable()->elementAt(numRow , 2)); m_pReportListTable->GeDataTable()->elementAt(numRow, 2)->setContentAlignment(AlignCenter); WText *pPeriod = new WText(report->szPeriod, (WContainerWidget*)m_pReportListTable->GeDataTable()->elementAt(numRow, 4)); m_pReportListTable->GeDataTable()->elementAt(numRow, 4)->setContentAlignment(AlignCenter); WImage *pEdit = new WImage("/Images/edit.gif", (WContainerWidget*)m_pReportListTable->GeDataTable()->elementAt(numRow , 6)); m_pReportListTable->GeDataTable()->elementAt(numRow, 6)->setContentAlignment(AlignCenter); pEdit->decorationStyle().setCursor(WCssDecorationStyle::Pointer); //m_ptbPhone->adjustRowStyle("tr1","tr2"); m_signalMapper.setMapping(pEdit, report->szTitle); bool isWriteIni = false; isWriteIni = WriteIniFileString(report->szTitle, "Title", report->szTitle, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Descript", report->szDescript, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Plan", report->szPlan, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Period", report->szPeriod, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "StatusResult", report->szStatusresult, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ErrorResult", report->szErrorresult, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Graphic", report->szGraphic, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ComboGraphic", report->szComboGraphic, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListData", report->szListData, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListNormal", report->szListNormal, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListError", report->szListError, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListDanger", report->szListDanger, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListAlert", report->szListAlert, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "EmailSend", report->szEmailSend, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Parameter", report->szParameter, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Deny", report->szDeny, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Generate", report->szGenerate, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ClicketValue", report->szClicketValue, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListClicket", report->szListClicket, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "GroupRight", report->szGroupRight, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "StartTime", report->szStartTime, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "EndTime", report->szEndTime, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileInt(report->szTitle, "WeekEndTime", report->nWeekEndIndex, "reportset.ini"); if(!isWriteIni) { } //Ticket #123 start -------苏合 isWriteIni = WriteIniFileString(report->szTitle, "GenExcel", report->szExcel, "reportset.ini"); if(!isWriteIni) { } //Ticket #123 end -------苏合 m_pReportListTable->HideNullTip(); //REPORT_LIST list; REPORT_LIST list; list.pSelect = pCheck; list.pName = pName; list.pPeriod = pPeriod; list.pEdit = pEdit; m_pListReport.push_back(list); chgstr = ""; connect(pEdit, SIGNAL(clicked()), "showbar();",&m_signalMapper, SLOT(map()),WObject::ConnectionType::JAVASCRIPTDYNAMIC ); } }
void CSVReportSet::Edit_Phone(SAVE_REPORT_LIST * report) { bool isWriteIni = false; isWriteIni = EditIniFileSection(chgstr, report->szTitle, "reportset.ini"); if(!isWriteIni) { } std::list<string> sectionlist; std::list<string>::iterator sectionitem; GetIniFileSections(sectionlist, "reportgenerate.ini"); int num =2; for(sectionitem = sectionlist.begin(); sectionitem != sectionlist.end(); sectionitem++) { std::string tempsection = *sectionitem; int pos = tempsection.find("$", 0); if(pos < 0) { continue; } std::string substr = tempsection.substr(0, pos); std::string rightstr = tempsection.substr(pos, tempsection.size() - pos); if(strcmp(substr.c_str(), chgstr.c_str()) == 0) { //bool EditIniFileSection(string oldsection,string newsection,string filename,string addr="localhost"); std::string nsec = report->szTitle; nsec += rightstr; EditIniFileSection(tempsection, nsec, "reportgenerate.ini"); } } isWriteIni = WriteIniFileString(report->szTitle, "Title", report->szTitle, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Descript", report->szDescript, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Plan", report->szPlan, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Period", report->szPeriod, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "StatusResult", report->szStatusresult, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ErrorResult", report->szErrorresult, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Graphic", report->szGraphic, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ComboGraphic", report->szComboGraphic, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListData", report->szListData, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListNormal", report->szListNormal, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListError", report->szListError, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListDanger", report->szListDanger, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListAlert", report->szListAlert, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "EmailSend", report->szEmailSend, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Parameter", report->szParameter, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Deny", report->szDeny, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "Generate", report->szGenerate, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ClicketValue", report->szClicketValue, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "ListClicket", report->szListClicket, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "GroupRight", report->szGroupRight, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "StartTime", report->szStartTime, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileString(report->szTitle, "EndTime", report->szEndTime, "reportset.ini"); if(!isWriteIni) { } isWriteIni = WriteIniFileInt(report->szTitle, "WeekEndTime", report->nWeekEndIndex, "reportset.ini"); if(!isWriteIni) { } //Ticket #123 start -------苏合 isWriteIni = WriteIniFileString(report->szTitle, "GenExcel", report->szExcel, "reportset.ini"); if(!isWriteIni) { } //Ticket #123 end -------苏合 for(m_pListItem = m_pListReport.begin(); m_pListItem != m_pListReport.end(); m_pListItem++) { if(strcmp(chgstr.c_str(), m_pListItem->pName->text().c_str()) == 0) { m_pListItem->pName->setText(report->szTitle); m_pListItem->pPeriod->setText(report->szPeriod); m_signalMapper.setMapping(m_pListItem->pEdit, report->szTitle); break; } } UpdatePhoneList(); chgstr = ""; }