void CCReCalQ::OnRecaleCal() { GetParamFromDlg(); m_RDB.ReCalculateQ(); UpWindowsText(); UpdateDB(); }
bool DataSearchConfig::TestConnectivity() { bool succes=false; if(!VerifyValues()) return false; UpdateDB(); bool dbOpen = mDataBase.open(); qDebug() << mSQLdriverName << mHostName << mDataBaseName << mUserName << mPassWord; if(dbOpen) { // QMessageBox::information(this, // tr("Succes...!"), // tr("Database succesfully opened.")); qDebug() << "Tables :" << mDataBase.tables(); if(mDataBase.tables().contains(mTableName,Qt::CaseInsensitive)) { QMessageBox::information(this, tr("Table Exists"), tr("Table '%0' exists in database '%1'") .arg(mTableName) .arg(mDataBaseName)); succes = true; } else { QMessageBox::critical(this, tr("Table not found..!"), tr("Table %0 not found in database %1\n Please create a table using 'Table' tab..!") .arg(mTableName) .arg(mDataBaseName)); } } else { QMessageBox::critical(this, tr("Database opening failed..!"), tr("Error :%0\n Please create a proper database first..!").arg(mDataBase.lastError().text())); } if(mDataBase.isOpen()) mDataBase.close(); return succes; }
bool DataSearchConfig::RunSqlQuery(QString query) { bool succes=false; UpdateDB(); if(mDataBase.open()) { mDataBase.exec(query); if(mDataBase.lastError().isValid()) { QMessageBox::critical(this, tr("Error in sql query"), tr("Could not excecute sql query..!")); } else succes = true; } return succes; }
void DataSearchConfig::on_btn_RefeshTableList_clicked() { ui->lst_Tables->clear(); UpdateDB(); if(mDataBase.open()) { ui->lst_Tables->addItems(mDataBase.tables()); } else { QMessageBox::critical(this, tr("Error"), tr("Could not open database")); } if(mDataBase.isOpen()) mDataBase.close(); }
int main(int argc, char *argv[]) { int err = 0; char path[] = "database.sqlite3"; sqlite3 * db; err = sqlite3_open(path, &db); if(SQLITE_OK != err) { return -1; } SelectDB(db, "select str from xx"); InsertDB(db, "insert or replace into xx values ('007','kkk','5pp')"); UpdateDB(db, "update xx set str='007' where sss='lll'"); DeleteDB(db, "delete from xx where str='789'"); printf("----------!!----------\n"); OperateDB(db, "create table if not exists nimei(woqu TEXT)"); SelectDB(db, "select * from xx"); return 0; }
static void GetFilesAndSpool() // GFTS assumes we are cd'd into the WorkingDir (main does this) { struct direct **nameList; int numfiles = scandir(".",&(nameList), (PFI)ScreenForData,NULL); if (numfiles <= 1) { LogMsg(0,LogLevel,LogFile,"No data to spool in directory %s",WorkingDir); return; } LogMsg(100,LogLevel,LogFile,"GFAS: Found %d data files",numfiles); time_t longest = 0; int longestIndex; struct stat buf; int i; for (i = 0; i<numfiles; i++) { stat(nameList[i]->d_name,&buf); if (buf.st_mtime == longest) { LogMsg(0,LogLevel,LogFile, "Two (or more) data files with the same mtime - CYa!"); return; } if (buf.st_mtime > longest) { longest = buf.st_mtime; longestIndex = i; } } LogMsg(10,LogLevel,LogFile,"GFAS: Least recent file: %s", nameList[longestIndex]->d_name); for (i=0; i<numfiles; i++) { if (i != longestIndex) { LogMsg(10,LogLevel,LogFile,"GFAS: Sending %s",nameList[i]->d_name); SendData(nameList[i]->d_name); } } UpdateDB(); }
void DataSearchConfig::on_btnImportCSV_clicked() { on_btnTestConnectivity_clicked(); UpdateDB(); if(!mDataBase.isOpen()) mDataBase.open(); if(mDataBase.isOpen()) { QSqlTableModel TableModel(this,mDataBase); TableModel.setTable(mTableName); TableModel.setEditStrategy(QSqlTableModel::OnManualSubmit); TableModel.select(); CSVimportDialog CSVImpDialog(&TableModel,this); if(CSVImpDialog.exec()) { } mDataBase.close(); } }
bool HTTPClient::Run(void* _ptr) { if(_ptr) { is_raise_error_multi_handle = true; code_multi = *(CURLMcode*)_ptr; return true; } if(is_raise_error_multi_handle) return true; if(is_recieve) { UpdateDB(); return true; } else { if(cache_type == HTTPResponse::CacheType_Expires) { code = CURLE_OK; response = HTTPResponse(cache_header_file_path, cache_body_file_path, cache_type); is_use_cache = true; return true; } else if(cache_type == HTTPResponse::CacheType_Last_Modified) { if(db_last_modified && last_modified) { if(last_modified == db_last_modified) { code = CURLE_OK; response = HTTPResponse(cache_header_file_path, cache_body_file_path, cache_type); is_use_cache = true; return true; } else { return false; } } else { return false; } } else { return false; } } }
int main(int argc, char *argv[]) { int err = 0; char path[] = "database.sqlite3"; sqlite3 * db; err = sqlite3_open(path, &db); if(SQLITE_OK != err) { return -1; } UpdateDB(db, "select str from xx"); UpdateDB(db, "insert into xx values ('789','kkk','pop')"); // UpdateDB(db, "update xx set str='007' where sss='lll'"); UpdateDB(db, "delete from xx where str='789'"); printf("----------!!----------\n"); UpdateDB(db, "create table nimei(woqu TEXT)"); UpdateDB(db, "select * from xx"); UpdateDB(db, "select * from tt"); return 0; }
void game::MainLoop() { // init steam we need to initialize this before the renderer for the overlay. { gSteam.InitSteam(); if(gSteam.steamID) { gUserProfile.RegisterSteamCallbacks(); } } InitRender(1); CurRenderPipeline = new r3dDefferedRenderer; CurRenderPipeline->Init(); SetFocus(win::hWnd); r3dMenuInit(); r3dParticleSystemInit(); InitDesktopSystem(); InitPostFX(); InitPointLightsRendererV2(); g_pWind = new r3dWind ; g_pEngineConsole = new EngineConsole; g_pDefaultConsole = g_pEngineConsole; g_pEngineConsole->Init(); g_pEngineConsole->SetCommandProcessor( g_pCmdProc ); g_DamageLib = new DamageLib ; g_DamageLib->Load(); g_MeshPropertyLib = new MeshPropertyLib; #ifndef FINAL_BUILD g_Manipulator3d.Init(); // show non-level specific art bugs r3dShowArtBugs() ; #endif g_cursor_mode->SetChangeCallback( &CursorModeCallback ) ; _r3d_bTerminateOnZ = r_terminateOnZ->GetInt(); // set dynamic matlib by default. // make it statis only in GAME mode r3dMaterialLibrary::IsDynamic = true; imgui_SetFixMouseCoords( false ); #ifdef FINAL_BUILD int m_ret = Menu_AppSelect::bStartGamePublic; // start game #else int m_ret = 0; if ( *d_map_force_load->GetString() || LevelEditName[0]!='\0' ) m_ret = Menu_AppSelect::bStartLevelEditor; else CALL_MENU(Menu_AppSelect); #endif #ifndef FINAL_BUILD // all choises is editors by default g_bEditMode = true; g_bStartedAsParticleEditor = false; #endif void InitGrass(); InitGrass(); g_pHUDCameraEffects = new HUDCameraEffects ; r3d_assert(g_pWeaponArmory == NULL); g_pWeaponArmory = new ClientWeaponArmory(); g_pWeaponArmory->Init(); r3dShowArtBugs(); // for editors, do not lock mouse. when we start game, in ExecuteNetworkGame we will set that var to true d_mouse_window_lock->SetBool(false); switch (m_ret) { #ifndef FINAL_BUILD case Menu_AppSelect::bUpdateDB: g_bEditMode = false; UpdateDB("198.50.211.32", "Data/Weapons/itemsDB.xml"); MessageBox(0, "Successfully updated English DB!", "Result", MB_OK); break; case Menu_AppSelect::bStartLevelEditor: g_pVisibilityGrid = new VisibiltyGrid ; ExecuteLevelEditor(); break; case Menu_AppSelect::bStartParticleEditor: g_bStartedAsParticleEditor = true; ExecuteParticleEditor(); break; case Menu_AppSelect::bStartPhysicsEditor: ExecutePhysicsEditor(); break; case Menu_AppSelect::bStartCharacterEditor: ExecuteCharacterEditor(); break; #endif case Menu_AppSelect::bStartGamePublic: // override server settings if special key isn't set if(strstr(__r3dCmdLine, "-ffgrtvzdf") == NULL) { // hardcoded IP for now //g_serverip->SetString("127.0.0.1"); } // override API settings g_api_ip->SetString("198.50.211.32"); // external g_serverip->SetString("198.50.211.32"); // external g_bEditMode = false; ExecuteNetworkGame(); break; }; #ifndef FINAL_BUILD if( g_bEditMode ) { SAFE_DELETE( g_pVisibilityGrid ); } #endif // shutdown steam if(gSteam.inited_) { gUserProfile.DeregisterSteamCallbacks(); gSteam.Shutdown(); } SAFE_DELETE( g_pWind ) ; r3dMaterialLibrary::UnloadManaged(); r3dMaterialLibrary::Reset(); MeshGlobalBuffer::unloadManaged(); g_pWeaponArmory->Destroy(); SAFE_DELETE(g_pWeaponArmory); #ifndef FINAL_BUILD g_Manipulator3d.Close(); #endif r3dMenuClose(); AI_Player_FreeStuff(); SAFE_DELETE( g_pHUDCameraEffects ) ; SAFE_DELETE( g_GameRewards ); void CloseGrass(); CloseGrass(); DestroyPointLightsRendererV2(); ClosePostFX(); SAFE_DELETE( g_DamageLib ); SAFE_DELETE( g_MeshPropertyLib ); r3dFreeGOBMeshes(); obj_Zombie::FreePhysSkeletonCache(); g_pEngineConsole->Release(); SAFE_DELETE( g_pEngineConsole ); g_pDefaultConsole = NULL; ReleaseDesktopSystem(); DoneDrawCollections(); r3dParticleSystemClose(); CurRenderPipeline->Close(); SAFE_DELETE(CurRenderPipeline); r3dMaterialLibrary::Destroy(); CloseRender(); if(gSurveyOutLink) ShellExecute(NULL, "open", gSurveyOutLink, "", NULL, SW_SHOW); /*r3dOutToLog("HackShield : UnInitialize...\n"); _AhnHS_StopService(); _AhnHS_Uninitialize();*/ HMODULE hMod; hMod = LoadLibrary(TEXT("WGCrash.dll")); //HackCheck _HackCheck; //_HackCheck = (HackCheck)GetProcAddress(hMod,"DetachProcess"); //_HackCheck(); FreeLibrary(hMod); TerminateProcess(GetCurrentProcess(),-1); return; }
int main(int argc,char* argv[]) { if ( argc<6 ) { exit_with_help(); return 0; } iDurationDay = atoi(argv[1]); iFromHour = atoi(argv[2]); iEndHour = atoi(argv[3]); strcpy(strDBTableList,argv[4]); strcpy(strDBFrom,argv[5]); if ( argc>6 ) { strcpy(strIP,argv[6]); } else { strcpy(strIP,"127.0.0.1"); }//*/ /*iDurationDay=1; iFromHour=9; iEndHour=10; strcpy(strDBTableList,"IMAGE_CJFD1994,IMAGE_CJFD1995,IMAGE_CJFD1996,IMAGE_CJFD1997,IMAGE_CJFD1998,IMAGE_CJFD1999,IMAGE_CJFD2000,IMAGE_CJFD2001,IMAGE_CJFD2002,IMAGE_CJFD2003,IMAGE_CJFD2004,IMAGE_CJFD2005,IMAGE_CJFD2006,IMAGE_CJFD2007,IMAGE_CJFD2007_ZHAOHUI,IMAGE_CJFD2008,IMAGE_CJFD2008_ZHAOHUI,IMAGE_CJFD2009,IMAGE_CJFD2010,IMAGE_CJFD2011,IMAGE_CJFD2011_INFOTEST,IMAGE_CJFD_UNKNOWN,IMAGE_CPFD1999,IMAGE_CPFD2000,IMAGE_CPFD2001,IMAGE_CPFD2002,IMAGE_CPFD2003,IMAGE_CPFD2004,IMAGE_CPFD2005,IMAGE_CPFD2006,IMAGE_CPFD2007,IMAGE_CPFD2008,IMAGE_CPFD2009,IMAGE_CPFD2010,IMAGE_CPFD2011,IMAGE_CPFD_UNKNOWN,IMAGE_CRFD,IMAGE_SCPD2009,INV_IMAGE_CJFD2007,INV_IMAGE_CJFD2008,INV_IMAGE_CJFD2009,INV_IMAGE_CJFD2010,INV_IMAGE_CJFD2011,INV_IMAGE_CJFD_UNKNOWN"); strcpy(strDBFrom,"CNKIIMAGE_2011"); strcpy(strIP,"192.168.100.101");//*/ TPI_LOGIN_PARA logpara ; strcpy(logpara.szUserName,"DBOWN") ; strcpy(logpara.szPassWord,"") ; strcpy(logpara.UserIp.szIp,strIP); int iStat=STAT_NULL; time_t timer; struct tm *tblock; timer=time(NULL); tblock=localtime(&timer); int iStartDay=-1; LogExec("\nbackgroud update begin\n"); while(true) { timer=time(NULL); tblock=localtime(&timer); if (( iStat==STAT_START || iStartDay==-1 || (tblock->tm_yday-iStartDay)==iDurationDay )) { if ( tblock->tm_hour>=iFromHour && ((iEndHour>=iFromHour && tblock->tm_hour<=iEndHour) || (iEndHour<iFromHour)) ) { int errorcode = -1 ; kbase_handle = TPI_OpenCon(strIP,4567,logpara,&errorcode) ; if(errorcode < 0) { LogExec("cant connect to server\n"); Sleep(1000*600); continue; } iStartDay=tblock->tm_yday; LogExec(asctime(tblock)); LogExec("start update\n"); iStat=UpdateDB(); timer=time(NULL); tblock=localtime(&timer); LogExec(asctime(tblock)); LogExec("update end\n"); TPI_CloseCon(kbase_handle); continue; } } LogExec("."); Sleep(600*1000); } return 0; }
nsresult nsPermissionManager::AddInternal(const nsAFlatCString &aHost, const nsAFlatCString &aType, PRUint32 aPermission, PRInt64 aID, PRUint32 aExpireType, PRInt64 aExpireTime, NotifyOperationType aNotifyOperation, DBOperationType aDBOperation) { if (!gHostArena) { gHostArena = new PLArenaPool; if (!gHostArena) return NS_ERROR_OUT_OF_MEMORY; PL_INIT_ARENA_POOL(gHostArena, "PermissionHostArena", HOST_ARENA_SIZE); } // look up the type index PRInt32 typeIndex = GetTypeIndex(aType.get(), PR_TRUE); NS_ENSURE_TRUE(typeIndex != -1, NS_ERROR_OUT_OF_MEMORY); // When an entry already exists, PutEntry will return that, instead // of adding a new one nsHostEntry *entry = mHostTable.PutEntry(aHost.get()); if (!entry) return NS_ERROR_FAILURE; if (!entry->GetKey()) { mHostTable.RawRemoveEntry(entry); return NS_ERROR_OUT_OF_MEMORY; } // figure out the transaction type, and get any existing permission value OperationType op; PRInt32 index = entry->GetPermissionIndex(typeIndex); if (index == -1) { if (aPermission == nsIPermissionManager::UNKNOWN_ACTION) op = eOperationNone; else op = eOperationAdding; } else { nsPermissionEntry oldPermissionEntry = entry->GetPermissions()[index]; // remove the permission if the permission is UNKNOWN, update the // permission if its value or expire type have changed OR if the time has // changed and the expire type is time, otherwise, don't modify. There's // no need to modify a permission that doesn't expire with time when the // only thing changed is the expire time. if (aPermission == oldPermissionEntry.mPermission && aExpireType == oldPermissionEntry.mExpireType && (aExpireType != nsIPermissionManager::EXPIRE_TIME || aExpireTime == oldPermissionEntry.mExpireTime)) op = eOperationNone; else if (aPermission == nsIPermissionManager::UNKNOWN_ACTION) op = eOperationRemoving; else op = eOperationChanging; } // do the work for adding, deleting, or changing a permission: // update the in-memory list, write to the db, and notify consumers. PRInt64 id; switch (op) { case eOperationNone: { // nothing to do return NS_OK; } case eOperationAdding: { if (aDBOperation == eWriteToDB) { // we'll be writing to the database - generate a known unique id id = ++mLargestID; } else { // we're reading from the database - use the id already assigned id = aID; } entry->GetPermissions().AppendElement(nsPermissionEntry(typeIndex, aPermission, id, aExpireType, aExpireTime)); if (aDBOperation == eWriteToDB && aExpireType != nsIPermissionManager::EXPIRE_SESSION) UpdateDB(op, mStmtInsert, id, aHost, aType, aPermission, aExpireType, aExpireTime); if (aNotifyOperation == eNotify) { NotifyObserversWithPermission(aHost, mTypeArray[typeIndex], aPermission, aExpireType, aExpireTime, NS_LITERAL_STRING("added").get()); } break; } case eOperationRemoving: { nsPermissionEntry oldPermissionEntry = entry->GetPermissions()[index]; id = oldPermissionEntry.mID; entry->GetPermissions().RemoveElementAt(index); // If no more types are present, remove the entry if (entry->GetPermissions().IsEmpty()) mHostTable.RawRemoveEntry(entry); if (aDBOperation == eWriteToDB) UpdateDB(op, mStmtDelete, id, EmptyCString(), EmptyCString(), 0, nsIPermissionManager::EXPIRE_NEVER, 0); if (aNotifyOperation == eNotify) { NotifyObserversWithPermission(aHost, mTypeArray[typeIndex], oldPermissionEntry.mPermission, oldPermissionEntry.mExpireType, oldPermissionEntry.mExpireTime, NS_LITERAL_STRING("deleted").get()); } break; } case eOperationChanging: { id = entry->GetPermissions()[index].mID; entry->GetPermissions()[index].mPermission = aPermission; if (aDBOperation == eWriteToDB && aExpireType != nsIPermissionManager::EXPIRE_SESSION) UpdateDB(op, mStmtUpdate, id, EmptyCString(), EmptyCString(), aPermission, aExpireType, aExpireTime); if (aNotifyOperation == eNotify) { NotifyObserversWithPermission(aHost, mTypeArray[typeIndex], aPermission, aExpireType, aExpireTime, NS_LITERAL_STRING("changed").get()); } break; } } return NS_OK; }
unsigned WINAPI cashierThread(void *arg) { topUpReader = false; while (true) { //차량신호올때까지 대기 watiAndcheckExited(T_hiCashier); //DB연결 SOCKET sock = openDB(); serchDB(sock, paydata.id); int visitresult = recvfromDB(sock); char buf[100]; sprintf(buf, "받은값 %d", visitresult); OutputDebugString(buf); if (visitresult == KEY_NOTFOUND) { exit(-1); } else { if (visitresult > 3) { paydata.cash = paydata.cash - paydata.cash / 2; chagneCloud(3, "20% 할인합니다", true); } else chagneCloud(3, "할인대상이 아닙니다", true); } UpdateDB(sock, "%d.2.%d.5.%d.6.1", paydata.id, paydata.cash, paydata.movietime); if (recvfromDB(sock) == KEY_NOTFOUND) exit(-1); closeDB(sock); chagneCloud(3, "계산이 끝났습니다.", true); chagneCloud(3, "안녕히 가세요.", true); //계산 다했다고 알려줌 ReleaseSemaphore(T_waitPay, 1, NULL); //차량인식기를 올림 topUpReader = true; Update(); std::this_thread::sleep_for(std::chrono::milliseconds(500)); chagneCloud(3, "NULL", false); //차량인식기를 내리는 신호 대기 watiAndcheckExited(T_downCashier); topUpReader = false; Update(); std::this_thread::sleep_for(std::chrono::milliseconds(500)); //다음차 오라고 신호줌 ReleaseSemaphore(T_waitCashier, 1, NULL); } return 0; }