Example #1
0
void CBoxHttpHost::CallEvent(LPCWSTR strEvent, CBoxHttpContext *pContext, CBoxHttpSession *pSession, BOOL bAddHost)
{
	CBoxObject<CBoxScriptObject> pScriptObject;
	CBoxObject<CBoxHttpContext> pNullContext;
	CComDispatchDriver pDisp;

	pScriptObject.CreateInstance();
	if(pScriptObject->Load(m_strEventSink) != 0)
		return;

	if(pContext)pContext->Bind(NULL, pScriptObject);
	else
	{
		pNullContext.CreateInstance();
		pNullContext->m_strBasePath = m_strRoot;
		pScriptObject->AddNameItem(_T("Server"), pNullContext->GetIDispatch(FALSE));
		pScriptObject->AddNameItem(_T("Application"), m_pApplication);
	}
	if(pSession)pScriptObject->AddNameItem(_T("Session"), pSession->GetIDispatch(FALSE));
	if(bAddHost)pScriptObject->AddNameItem(_T("Host"), GetIDispatch(FALSE));

	if(pScriptObject->Init() != 0)
		return;

	pDisp.Attach(pScriptObject->get_Object());

	if(pDisp)
	{
		pDisp.Invoke0(strEvent);
		theApp.m_pSystem->ClearLock();
	}
}
void CPluginsDialog::SaveCmds()
{
	CString dir = L"data";
	CreateDirectory(dir,NULL);
	dir += L"/";
	dir += _plugins->name().c_str();
	CreateDirectory(dir,NULL);
	
	CComDispatchDriver spScript;
	if(S_OK != m_spHtmlDoc->get_Script(&spScript))
	{
		return;
	}
	CComVariant varRet;  
	if(S_OK != spScript.Invoke0(L"get_cmds", &varRet))
	{
		return;
	}
	CString str = varRet;
	std::string utf8 = dark::windows::utf::to_utf8(str.GetBuffer());
	std::ofstream outf(dir + L"/cmds.json",std::ios::binary | std::ios::trunc | std::ios::out);
	if(outf.is_open())
	{
		outf.write(utf8.data(),utf8.size());
	}
}
void CPluginsDialog::CallJsSetFocus()
{
	CComDispatchDriver spScript;
	if(S_OK != m_spHtmlDoc->get_Script(&spScript))
	{
		return;
	}
	spScript.Invoke0(L"set_focus");
}
LRESULT CIncrementSystemBFDlg::OnMyClickMessage(WPARAM wParam, LPARAM lParam)
{
	
	CComDispatchDriver spScript;
	IDispatch * pDocDisp = NULL;
   
   IHTMLDocument2  *pDoc=NULL;
   pDocDisp = m_MyIE.GetDocument(); 
   
   if (pDocDisp != NULL) 
   {
      // Obtained the document object by specifying the IHTMLDocument2 Interface.
		HRESULT hr= pDocDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc );
		
		pDoc->get_Script(&spScript);

		CComVariant varRet;  
		spScript.Invoke0(L"NoticeClient", &varRet); 

		CComDispatchDriver spData = varRet.pdispVal; 
		CComVariant varValue1;
		spData.GetPropertyByName(L"phone", &varValue1);

		CString strResult = _com_util::ConvertBSTRToString((_bstr_t)varValue1);

		szCharUrl.Format("%s%s", cUrls.QueryPhone, strResult);
		//szCharUrl.Format("http://www.baidu.com/s?wd=%s", strResult);
		//szCharUrl.Format("http://132.90.101.25:7001/portal");
		//szCharUrl.Format("http://132.77.51.11:7700/salemanm/salemanm?service=page/silverservice.silverJobExec.goldUnfinishedFrame&listener=initFrame&PROVINCEID=0011&STAFF_ID=yujp21&PASSWORD=H3B5VVJk0JFroCYwhWHbA9C8yes=&LOGIN_TYPE=KFSYS&inModeCode=1&cond_CONFIG=job&cond_FLAG=all&closeNavMethod=close&JOB_STATUS=1&VALID_FLAG=1&EPARCHY_CODE=0010&SERVER_NUMBER=18612452378");
		 
		CString sResult(_T(""));  
  
		// http://132.77.220.134:8081/window/servlet/CheckSerialNumber?serial_number=132.77.220.134
		

		//CString ip(tempUrl.Left(pos).rig);

		HttpRequestGet("132.77.220.134", 8081, "window/servlet/CheckSerialNumber?serial_number="+strResult, sResult);
		///m_MyIE.Navigate(szCharUrl, NULL, NULL, NULL, NULL);

   		//PostMessage(WM_SIZE,0,0);
   }
   return 1;
}