LONG CuDlgSqlQueryPageXML::OnDisplayResult (WPARAM wParam, LPARAM lParam) { CaSqlQuerySelectData* pData = (CaSqlQuerySelectData*)lParam; ASSERT (pData); if (!pData) return 0L; ASSERT (m_pQueryRowParam); if (!m_pQueryRowParam) return 0L; CWaitCursor waitCursor; try { CaSession* pCurrentSession = m_pQueryRowParam->GetSession(); pCurrentSession->SetSessionNone(); CString strTitle; strTitle.LoadString(IDS_TITLE_FETCHING_ROW); #if defined (_ANIMATION_) CxDlgWait dlgWait(strTitle, NULL); dlgWait.SetDeleteParam(FALSE); dlgWait.SetExecParam (m_pQueryRowParam); dlgWait.SetUseAnimateAvi(AVI_FETCHR); dlgWait.SetUseExtraInfo(); dlgWait.SetShowProgressBar(FALSE); dlgWait.SetHideCancelBottonAlways(TRUE); dlgWait.DoModal(); #else m_pQueryRowParam->Run(); #endif CuWebBrowser2* pIe = (CuWebBrowser2*)GetDlgItem (IDC_EXPLORER1); if (pIe && IsWindow (pIe->m_hWnd)) { pIe->ShowWindow(SW_SHOW); CString strFile = m_bXMLSource? m_pQueryRowParam->GetFileXML(): m_pQueryRowParam->GetFileXSL(); if (!strFile.IsEmpty() && _taccess(strFile, 0) == 0) { COleVariant vaURL(strFile); pIe->Navigate2 (vaURL, 0, NULL, NULL, NULL); } } } catch(CMemoryException* e) { theApp.OutOfMemoryMessage(); e->Delete(); } catch (CeSqlException e) { AfxMessageBox (e.GetReason(), MB_ICONEXCLAMATION|MB_OK); } catch (...) { AfxMessageBox (_T("CuDlgSqlQueryPageXML::OnDisplayResult: unknown error")); } return (LONG)0; }
inline void CaUserDefault::Init(CaNode* pNode) { m_strVirtualNodeUser = _T(""); CaSessionManager& sessionMgr = theApp.GetSessionManager(); CaSession session; session.SetNode(pNode->GetName()); session.SetDatabase(_T("iidbdb")); session.SetIndependent(TRUE); session.SetDescription(sessionMgr.GetDescription()); CaSessionUsage UseSession (&sessionMgr, &session); m_strVirtualNodeUser = INGRESII_llDBMSInfo(_T("username")); // session_user? }
BOOL CaSessionManager::Disconnect(CaSession* pInfo, BOOL bCommit) { CaSession* pObj = NULL; int i, nSize = m_listObject.GetSize(); for (i=0; i<nSize; i++) { pObj = m_listObject[i]; if (pObj && pInfo == pObj) { m_listObject[i] = NULL; pObj->Disconnect(); delete pObj; return TRUE; } } return FALSE; }
CaSession* CaSessionManager::SearchSession(CaSession* pInfo) { CaSession* pObj = NULL; int i, nAvail = -1; for (i=0; i<m_nMaxSession; i++) { pObj = m_listObject[i]; if (!pObj && nAvail == -1) { nAvail = i; } if (pObj && pObj->IsReleased() && (*pObj == *pInfo)) return pObj; } // // Create a new session: // Find the first released session and disconnect it. for (i=0; i<m_nMaxSession && nAvail ==-1; i++) { pObj = m_listObject[i]; if (!pObj) { nAvail = i; break; } if (pObj && pObj->IsReleased()) { // // Disconnected the unused session to free the slot: nAvail = i; pObj->Disconnect(); delete pObj; m_listObject[i] = NULL; break; } } if (nAvail != -1) { try { pObj = new CaSession (*pInfo); pObj->SetSessionNum (nAvail + m_nSessionStart); pObj->Connect(); m_listObject[nAvail] = pObj; return pObj; } catch(CeSqlException e) { if (pObj) delete pObj; throw e; } } return NULL; }
BOOL DML_QueryGroup(CdSqlQuery* pDoc, CTypedPtrList< CObList, CaDBObject* >& listObj) { BOOL bOK = FALSE; CaLLQueryInfo queryInfo (OBT_GROUP, pDoc->GetNode(), _T("iidbdb")); CString strDefault; CString strNode = pDoc->GetNode(); CString strServer = pDoc->GetServer(); CString strUser = pDoc->GetUser(); strDefault.LoadString(IDS_DEFAULT_SERVER); if (strDefault.CompareNoCase(strServer) == 0) strServer = _T(""); strDefault.LoadString(IDS_DEFAULT_USER); if (strDefault.CompareNoCase(strUser) == 0) strUser = pDoc->GetDefaultConnectedUser(); queryInfo.SetServerClass(strServer); CaSessionManager& sessionMgr = theApp.GetSessionManager(); SETLOCKMODE lockmode; memset (&lockmode, 0, sizeof(lockmode)); lockmode.nReadLock = LM_NOLOCK; CaSession session; session.SetFlag(queryInfo.GetFlag()); session.SetNode(queryInfo.GetNode()); session.SetDatabase(queryInfo.GetDatabase()); session.SetUser(queryInfo.GetUser()); session.SetServerClass(queryInfo.GetServerClass()); session.SetOptions(queryInfo.GetOptions()); session.SetDescription(sessionMgr.GetDescription()); CaSessionUsage useSession (&sessionMgr, &session); CaSession* pSession = useSession.GetCurrentSession(); if (pSession) pSession->SetLockMode(&lockmode); bOK = INGRESII_llQueryObject2 (&queryInfo, listObj, pSession); return bOK; }
BOOL IJA_llQueryTableTransactionData ( CaQueryTransactionInfo* pQueryInfo, CaTableTransactionItemData* pTableTrans) { CString strStatement; CString strDatabase; CString strDatabaseOwner; CString strTable; CString strTableOwner; if (!pQueryInfo) return FALSE; pQueryInfo->GetDatabase (strDatabase, strDatabaseOwner); pQueryInfo->GetTable (strTable, strTableOwner); CaSessionManager& smgr = theApp.GetSessionManager(); CaSession session; session.SetNode(pQueryInfo->GetNode()); session.SetDatabase(strDatabase); session.SetIndependent(TRUE); CaSessionUsage sessionUsage(&smgr, &session, SESSION_COMMIT); // commit on release // // TODO: Replace this statement to select from the temporary table: strStatement.Format (_T("select * from %s.%s"), (LPCTSTR)strTableOwner, (LPCTSTR)strTable); CaIjaCursor* pCursor = new CaIjaCursor (1, strStatement); if (pCursor && pCursor->Open()) { int nCount = 0; CStringList& listData = pTableTrans->GetListData(); // // Fetch only one row for a transaction <pTableTrans> pCursor->Fetch(listData, nCount); pCursor->Close(); } return TRUE; }
void CaSessionManager::Cleanup() { CaSession* pObj = NULL; int nSize = m_listObject.GetSize(); for (int i=0; i<nSize; i++) { pObj = m_listObject[i]; try { if (pObj) pObj->Disconnect(); m_listObject[i] = NULL; } catch(...) { TRACE1("Disconnect session failed: %s\n", (LPCTSTR)pObj->GetConnection()); } // // Continue to proceed anyhow ! if (pObj) delete pObj; } }
CaSession* CaSessionManager::GetSession(CaSession* pInfo) { // // First of all, check if the session number exceeds the limit. // If so, try to destroy those extra sessions: CaSession* pObj = NULL; int i, nSize = m_listObject.GetSize(); if (nSize > m_nMaxSession) { for (i=(nSize -1); i>=m_nMaxSession; i--) { pObj = m_listObject[i]; if (pObj && pObj->IsReleased()) { m_listObject[i] = NULL; pObj->Disconnect(); delete pObj; pObj = NULL; } } } // // Search if there is an available session: pObj = SearchSession(pInfo); if (pObj) { if (pObj->IsConnected()) pObj->Activate(); else pObj->Connect(); return pObj; } else { // // No session available in the cache and there is no more entry for the new session ! // All session are used! int nExtra = nSize; for (i = m_nMaxSession; i < nSize; i++) { pObj = m_listObject[i]; if (!pObj) { nExtra = i; break; } } pObj = new CaSession (*pInfo); if (nExtra >= nSize) { nExtra = m_listObject.Add(pObj); pObj->SetSessionNum (nExtra + m_nSessionStart); } else { pObj->SetSessionNum (nExtra + m_nSessionStart); m_listObject.SetAt(nExtra, pObj); } pObj->Connect(); return pObj; } return NULL; }