void GPageLoadRequestManager::ProcessNewRequest()
{
	LOG_LEVEL4("ProcessNewRequest()");

	LOG_LEVEL4(QString("Quantity of pending requests(") + QString::number(m_qlsReqs.count()) + ").");

	while( !m_qlsReqs.isEmpty() )
	{
		if( m_qlsReqs.first()->GetTypeOfRequest() == GAbsPageLoadRequest::eUpdateCurrentPageRequest )
		{
			GUpdateCurrentPageRequest* pRequest(static_cast<GUpdateCurrentPageRequest*>(m_qlsReqs.first()));
			ProcessRequest(pRequest);

			m_qlsReqs.removeFirst();
		}
		else if( m_qlsReqs.first()->GetTypeOfRequest() == GAbsPageLoadRequest::eUpdateURLCurrentPageRequest )
		{
			GUpdateURLCurrentPageRequest* pRequest(static_cast<GUpdateURLCurrentPageRequest*>(m_qlsReqs.first()));
			ProcessRequest(pRequest);

			m_qlsReqs.removeFirst();
		}
		else
		{
			break;
		}
	}

	if( !m_qlsReqs.isEmpty() )
	{
		if( m_qlsReqs.first()->GetTypeOfRequest() == GAbsPageLoadRequest::eSetPreloadedPagesRequest )
		{
			GSetPreloadedPagesRequest* pRequest(static_cast<GSetPreloadedPagesRequest*>(m_qlsReqs.first()));
			ProcessRequest(pRequest);
		}
		else if( m_qlsReqs.first()->GetTypeOfRequest() == GAbsPageLoadRequest::eLoadEntirePageRequest )
		{
			GLoadEntirePageRequest* pRequest(static_cast<GLoadEntirePageRequest*>(m_qlsReqs.first()));
			ProcessRequest(pRequest);
		}
		else if( m_qlsReqs.first()->GetTypeOfRequest() == GAbsPageLoadRequest::eUpdatePreloadedPageRequest )
		{
			GUpdatePreloadedPageRequest* pRequest(static_cast<GUpdatePreloadedPageRequest*>(m_qlsReqs.first()));
			ProcessRequest(pRequest);
		}
		else
		{
			throw(GException("Cannot found the request in the internal queue."));
		}
	}

	LOG_LEVEL4(QString("Quantity of pending requests(") + QString::number(m_qlsReqs.count()) + ").");
}
예제 #2
0
bool CLogThread::queueLog(const char *user, const char *realm, const char *peer, LOG_INFO& _LogStruct, IArrayOf<IEspLogInfo>& LogArray)
{
    if(!m_pLoggingService.get())
        return false;

    IClientLOGServiceUpdateRequest* tptrRequest;
    if( m_bModelRequest )
    {
        tptrRequest = dynamic_cast<IClientLOGServiceUpdateRequest*>(m_pLoggingService->createUpdateModelLogServiceRequest());
    } else {
        tptrRequest = m_pLoggingService->createUpdateLogServiceRequest();
    }
    Owned<IClientLOGServiceUpdateRequest> pRequest( tptrRequest );

    if (pRequest == 0)
        return false;


    pRequest->setUserName(user);
    pRequest->setDomainName(realm);
    pRequest->setRecordCount(_LogStruct.recordsReturned);
    pRequest->setServiceName(_LogStruct.serviceName);
    pRequest->setIP(peer);

    //This appends the tree structure into the correct format...
    pRequest->setLogInformation(LogArray);
    return queueLog(pRequest,_LogStruct);

}
예제 #3
0
void
hoxDbClient::set_player_info( const hoxPlayer_SPtr player,
                              const std::string&   sGameResult )
{
    const std::string sPlayerId = player->getId();

    hoxRequest_SPtr pRequest( new hoxRequest( hoxREQUEST_DB_PLAYER_SET ) );
    pRequest->setParam("pid", sPlayerId);
    pRequest->setParam("score", hoxUtil::intToString(player->getScore()));
    pRequest->setParam("result", sGameResult);

    s_requestList.push_back( pRequest );
    st_cond_signal( s_writeCond );
}
void GPageLoadRequestManager::Notify(GLoadersManagerRequestNotify &oNotify) throw(GException)
{
	LOG_LEVEL4("Notify()");

	QMutexLocker oLocker(&m_qmInternalMutex);

	GAbsPageLoadRequest* pRequest(0);

	for( int i = 0; i < m_qlsReqs.size(); ++i )
	{
		if( m_qlsReqs.at(i)->GetRequestId() == oNotify.GetRequest()->GetRequestId() )
		{
			pRequest = oNotify.GetRequest();
			m_qlsReqs.removeAt(i);
			break;
		}
	}

	if( pRequest != 0 )
	{
		QString sResult("Timeout");
		if( oNotify.GetNofifyType() == GLoadersManagerRequestNotify::eContentLoadComplete )
		{
			m_pMainView->setPage(oNotify.GetWebPage());
			sResult = "Completed";

			SetAsActive(oNotify.GetLoadersManagerId());
		}

		static QString const strTemp("RequestId(%1), has been completed with result (%2) for (%3).");
		LOG_LEVEL4(QString(strTemp) . arg(pRequest->GetRequestId()) . arg(sResult) . arg(GetSessionName(pRequest->GetSessionId())));

		if( pRequest->IsSynchronize() )
		{
			GAbsView::SignalSynchronize( (sResult=="Completed")?(true):(false) );
		}

		delete pRequest;

		ProcessNewRequest();

		return;
	}

	throw(GException("Cannot found the request in the internal queue."));
}
예제 #5
0
void THttpConnection::SendRequest(const Http::TRequestProtocol& Request)
{
	std::shared_ptr<Http::TRequestProtocol> pRequest( new Http::TRequestProtocol(Request) );
	SendRequest( pRequest );
}
예제 #6
0
///////////////Ajax  OnStateChange实现部分
STDMETHODIMP LuaAsynUtil::OnStateChange(CAJAX* pSource, const bool bSucceeded, const int nHttpState, const BSTR /*bstrResponse*/,   IDispatch* pDispath)
{
	if(bSucceeded &&  (nHttpState >= 200 && nHttpState < 300 ))
	{
		if (pSource->m_bOutDOM)
		{
			g_wndMsg.PostMessage(WM_AJAXDOWNLOADFILESUCCESS, pSource->m_nID, (LPARAM)pSource);
		}
		else //存成文件
		{
			if ((AjaxTaskFlag)pSource->m_nID == AJAXTASKFLAG_SENDHTTPSTAT || (AjaxTaskFlag)pSource->m_nID == AJAXTASKFLAG_SENDHTTPSTATEX)
			{
				g_wndMsg.PostMessage(WM_AJAXDOWNLOADFILESUCCESS, pSource->m_nID, (LPARAM)pSource);
			}
			else
			{
				CComBSTR bstrSavedPath = pSource->m_bstrSavedPath;
				MSXML::IXMLHttpRequestPtr pRequest(pDispath);
				if ((AjaxTaskFlag)pSource->m_nID == AJAXTASKFLAG_GETHTTPCONTENT)
				{
					//try
					//{
					CComBSTR bstrContent;
					pRequest->get_responseText(&bstrContent);
					pSource->m_bstrSavedPath = L"";
					pSource->m_bstrSavedPath.AppendBSTR(bstrContent);
					g_wndMsg.PostMessage(WM_AJAXDOWNLOADFILESUCCESS, pSource->m_nID, (LPARAM)pSource);
					//}
					//catch (...)
					//{
					//	g_wndMsg.PostMessage(WM_AJAXDOWNLOADFILEFAILED, pSource->m_nID, (LPARAM)pSource);
					//}				
				}
				else if ((AjaxTaskFlag)pSource->m_nID == AJAXTASKFLAG_GETHTTPFILE)
				{
					CComVariant varStream;
					pRequest->get_responseStream(&varStream);

					if (varStream.vt != VT_UNKNOWN && varStream.vt != VT_STREAM)
					{
						g_wndMsg.PostMessage(WM_AJAXDOWNLOADFILEFAILED, pSource->m_nID, (LPARAM)pSource);
					}
					else
					{
						wchar_t szPath[_MAX_PATH] = {0};
						wcsncpy(szPath, bstrSavedPath, _MAX_PATH);
						PathRemoveFileSpec(szPath);
						if(!PathFileExists(szPath))
							SHCreateDirectory(NULL, szPath);
						//写文件
						HANDLE hFile = ::CreateFile((LPCTSTR)bstrSavedPath,GENERIC_WRITE,0,
							NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
						// 可能目录只读, 存到programdata/temp下
						if (hFile == INVALID_HANDLE_VALUE)
						{
							static CComBSTR bstrPath;
							if(bstrPath.Length() <= 0)
							{
								wchar_t szPath[MAX_PATH] = {0};
								DWORD len = GetTempPath(MAX_PATH, szPath);
								bstrPath = szPath;
							}
							if(!PathFileExists(bstrPath))
								SHCreateDirectory(NULL, bstrPath);
							CComBSTR bstrFileName = PathFindFileName(bstrSavedPath);
							CComBSTR bstrPath2(bstrPath);
							bstrPath2.AppendBSTR(bstrFileName);
							bstrSavedPath = bstrPath2;
							hFile = ::CreateFile((LPCTSTR)bstrSavedPath,GENERIC_WRITE,0,
								NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
						}
						if (hFile != INVALID_HANDLE_VALUE)
						{
							DWORD cb, cbRead, cbWritten;
							BYTE bBuffer[4096];
							cb = sizeof bBuffer;
							CComQIPtr<IStream> pStream(varStream.punkVal);
							HRESULT hr = pStream->Read(bBuffer, cb, &cbRead);
							while (SUCCEEDED(hr) && 0 != cbRead)
							{
								if (!WriteFile(hFile, bBuffer, cbRead, &cbWritten, NULL))
									break;
								hr = pStream->Read(bBuffer, cb, &cbRead);
							} 
						}
						CloseHandle(hFile);
						pSource->m_bstrSavedPath = bstrSavedPath;
						g_wndMsg.PostMessage(WM_AJAXDOWNLOADFILESUCCESS, pSource->m_nID, (LPARAM)pSource);
					}
				}
				else
				{
					g_wndMsg.PostMessage(WM_AJAXDOWNLOADFILESUCCESS, pSource->m_nID, (LPARAM)pSource);
				}
			}
		}
	}
	else
	{
		CComBSTR bstrSavedPath(L"");
		if(!pSource->m_bOutDOM)
		{
			bstrSavedPath = pSource->m_bstrSavedPath;
		}
		g_wndMsg.PostMessage(WM_AJAXDOWNLOADFILEFAILED, pSource->m_nID, (LPARAM)pSource);
	}
	return S_OK;
}
예제 #7
0
bool CLogThread::queueLog(IEspContext & context,LOG_INFO& _LogStruct, IArrayOf<IEspLogInfo>& LogArray, IConstModelLogInformation* pModelLogInfo)
{
    if(!m_pLoggingService.get())
        return false;


    //Owned<IClientLOGServiceUpdateRequest> pRequest =  m_pLoggingService->createUpdateLogServiceRequest();
    IClientLOGServiceUpdateRequest* tptrRequest;
    if( m_bModelRequest )
    {
        IClientLOGServiceUpdateModelRequest* pUpdateModelRequest = m_pLoggingService->createUpdateModelLogServiceRequest();

        if(pModelLogInfo!=0)
        {
            pUpdateModelRequest->setModelLogInformation(*pModelLogInfo);
        }
        tptrRequest = dynamic_cast<IClientLOGServiceUpdateRequest*>(pUpdateModelRequest);
    } else {
        tptrRequest = m_pLoggingService->createUpdateLogServiceRequest();
    }
    Owned<IClientLOGServiceUpdateRequest> pRequest( tptrRequest );
    if (pRequest == 0)
        return false;



    StringBuffer UserID,realm,peer;
    pRequest->setUserName(context.getUserID(UserID).str());
    pRequest->setDomainName(context.getRealm(realm).str());
    pRequest->setRecordCount(_LogStruct.recordsReturned);
    pRequest->setServiceName(_LogStruct.serviceName);
    pRequest->setIP(context.getPeer(peer).str());
    bool bBlind = _LogStruct.Blind;
    bool bEncrypt = _LogStruct.Encrypt;

    ISecPropertyList* properties = context.querySecuritySettings();

    if( properties !=NULL)
    {
        if(bBlind==false)
        {
            if(properties->findProperty("blind")!=NULL)
                strncmp(properties->findProperty("blind")->getValue(),"1",1) == 0 ? bBlind=true : bBlind=false;
        }

        if(bEncrypt==false && properties->findProperty("encryptedlogging")!=NULL)
        {
            if(strncmp(properties->findProperty("encryptedlogging")->getValue(),"1",1) == 0)
                bEncrypt=true;
        }
    }
    if(bEncrypt==true)
    {
        //need to do encrpyted logging
        pRequest->setEncryptedLogging(true);
        pRequest->setRawLogInformation(_LogStruct.RequestStr.str());
    }

    pRequest->setBlindLogging(bBlind);
    pRequest->setLogInformation(LogArray);

    return queueLog(pRequest,_LogStruct);
}