BOOL APBuf::setBuffer(BSTR str, MSXML2::IXMLDOMDocumentPtr & xml)
{
	
	xml.CreateInstance(_T("Msxml2.DOMDocument"));
	xml->async = VARIANT_FALSE; // default - true,
	//vytvoreni XML DOM z nacteneho XML stringu

	CDirectoriesManager & m = ((CReportAsistentApp *) AfxGetApp())->m_pGeneralManager->DirectoriesManager;
	CString str_b = str;
	CFile f;
	f.Open(m.getXMLFilesDirectory() + "\\plug_out_example1.xml", CFile::modeWrite |CFile::modeCreate);
	f.Write((LPCTSTR) str_b, str_b.GetLength());
	f.Close();


	HRESULT hRes=xml->loadXML(str);
	if (xml->parseError->errorCode != S_OK)
	{
		if ((str == NULL) || (* str == 0)) return FALSE;

		CReportAsistentApp::ReportError(IDS_SIMPLE_FILTER_FAILED_SOURCE_LOAD, (LPCTSTR) xml->parseError->reason);

		xml.Release();
		xml = NULL;	

		return FALSE;
	}

	return TRUE;
}
Esempio n. 2
0
/*
 * Private method that loads XML into an MSXML DomDocument object and passes
 * this object to the event handler.
 */
bool XMPPXMLParser::NotifyHandler(const UTF32String& stanzaName)
{
	bool continueParsing;

	FixXMLNS();

	MSXML2::IXMLDOMDocumentPtr xmlDoc;
	xmlDoc.CreateInstance(CLSID_DOMDocument);
	BOOL bSuccess = xmlDoc->loadXML(
		_bstr_t(UTF::utf32to16(m_ParsedData).c_str()));

	if(bSuccess)
	{
		m_Handlers.OnStanza(
			xmlDoc, _bstr_t(UTF::utf32to16(stanzaName).c_str()));
		continueParsing = true;
	}
	else
	{
		m_Logger.LogLoadXMLError(xmlDoc, UTF::utf32to16(m_ParsedData));
		continueParsing = false;
	}

	return continueParsing;
}
// saves a list of Word styles to configutation XML file
BOOL CWordManager::saveStylesToXML(LPCTSTR file_path)
{
	CString XMLString = "";
	XMLString += "<word_styles>";
		XMLString += "<templates>";
			XMLString += m_WordTemplates.getItemsInXML();
		XMLString += "</templates>";

		XMLString += "<paragraph_styles>";
			XMLString += m_WordParagraphStyles.getItemsInXML();
		XMLString += "</paragraph_styles>";

		XMLString += "<character_styles>";
			XMLString += m_WordCharacterStyles.getItemsInXML();
		XMLString += "</character_styles>";
	XMLString += "</word_styles>";

	CString FName;	// jmeno (cesta) ke konfig. souboru
	FName = file_path;

	MSXML2::IXMLDOMDocumentPtr pXMLDom;  // koren XML stromu
	HRESULT hr;
    
      //Vytvori COM objekt (resp. instanci objektu)
    hr = pXMLDom.CreateInstance(_T("Msxml2.DOMDocument"));
    if (FAILED(hr)) 
       return FALSE;
    pXMLDom->async = VARIANT_FALSE;
   
       //nacti DOM ze stringu
    if ( pXMLDom->loadXML((_bstr_t) XMLString) != VARIANT_TRUE)
	{
		pXMLDom.Release();
		return FALSE;
	}
	
	BOOL ret = FALSE;

	try
	{
		ret = S_OK == pXMLDom->save((LPCTSTR) FName);
	}
	catch(...)
	{
		ret = FALSE;
	}
	
	pXMLDom.Release();

	return ret;
}
Esempio n. 4
0
CyNode CyDoc::LoadXML(const std::wstring& lpContent)
{
	MSXML2::IXMLDOMDocumentPtr spDoc;
	try
	{
		spDoc = GetDocument();
		if(spDoc!=NULL){
			spDoc->loadXML(lpContent.c_str());
		}
	} catch(...) {
	}
	m_spDocument = spDoc;
	return CyNode(spDoc);
}
Esempio n. 5
0
MSXML2::IXMLDOMDocumentPtr
CREBUS::getPluginParmsDef(_bstr_t coclass)
{
	PluginTypeLib::PluginPtr plugin;
	plugin.CreateInstance((char *) coclass);

	MSXML2::IXMLDOMDocumentPtr xml;
	xml.CreateInstance(MSXML2::CLSID_DOMDocument26);
	
	try {
		xml->loadXML( _bstr_t(plugin->getParmsDef(_variant_t())) );
	}
	catch(_com_error e) {
		_bstr_t text = e.Description();
	}

	return xml;
}
void LoadToolBars(LPCTSTR lpXml)
{
	if (Glb_toolbarArray.GetCount() > 0)
		return;

	IAcadMenuGroup *mnuGrp = NULL;
	if (!getAcadMenuGroup(&mnuGrp))
		return ;

	IAcadToolbars  *tlbrs = NULL;
	HRESULT hr = S_OK;
	hr = mnuGrp->get_Toolbars(&tlbrs);
	mnuGrp->Release();

	// 得到arx所在路径
	TCHAR lpPath[MAX_PATH] = {0};
	GetModuleFileName(GetModuleHandle("DistToolBar.arx"), lpPath, MAX_PATH);
	PathRemoveFileSpec(lpPath);
	PathAddBackslash(lpPath);

	// 得到icon路径
	PathAppend(lpPath, "icon");
	PathAddBackslash(lpPath);

	MSXML2::IXMLDOMDocumentPtr lpDocument;
	hr = lpDocument.CreateInstance(__uuidof(DOMDocument));

	if ( FAILED(hr) ) 
		_com_raise_error(hr);

	VARIANT_BOOL isSuccessful;

	// 装载XML字符串
	if (!lpDocument->loadXML(_bstr_t(lpXml)))
	{
		OutputDebugString("LoadXML failed!");

		return;
	}

	MSXML2::IXMLDOMElementPtr lpDocElement = NULL;
	lpDocument->get_documentElement(&lpDocElement);

	// toolbar list
	MSXML2::IXMLDOMNodeListPtr lpToolbarList = lpDocElement->getElementsByTagName(_bstr_t("toolbar"));

	MSXML2::IXMLDOMNodePtr lpToolbar = NULL;

	for ( ; (lpToolbar = lpToolbarList->nextNode()) != NULL ; )
	{

		MSXML2::IXMLDOMNodePtr lpCaptionNode = lpToolbar->attributes->getNamedItem("caption");
		CString strCaption = (char*)lpCaptionNode->text;

		OutputDebugString(strCaption);

		// 添加工具条
		IAcadToolbar  *tlbr = NULL;
		hr = tlbrs->Add(CComBSTR(strCaption), &tlbr);

		if FAILED(hr)
			continue;

		Glb_toolbarArray.Add(strCaption);

		// button list
		MSXML2::IXMLDOMNodeListPtr lpButtonList = lpToolbar->GetchildNodes();

		MSXML2::IXMLDOMNodePtr lpButton = NULL;

		for ( ; (lpButton = lpButtonList->nextNode()) != NULL ; )
		{
			MSXML2::IXMLDOMNodePtr lpToolTipNode = lpButton->attributes->getNamedItem("tooltip");
			CString strToolTip = (char*)lpToolTipNode->text;

			MSXML2::IXMLDOMNodePtr lpCommandNode = lpButton->attributes->getNamedItem("command");
			CString strCommand = (char*)lpCommandNode->text;
			strCommand += " ";

			MSXML2::IXMLDOMNodePtr lpIconNode = lpButton->attributes->getNamedItem("icon");
			CString strIcon = (char*)lpIconNode->text;

			OutputDebugStringX("tooltip=%s, command=%s, icon=%s", strToolTip, strCommand, strIcon);

			// 添加工具按钮
			IAcadToolbarItem *button=NULL;
			VARIANT index;
			index.vt = VT_I4;
			index.lVal = 100l;

			VARIANT vtFalse;
			vtFalse.vt = VT_BOOL;
			vtFalse.boolVal = VARIANT_FALSE;

			CString strIconFile = lpPath;
			strIconFile += strIcon;

			if (!PathFileExists(strIconFile))
			{
				strIconFile = lpPath;
				strIconFile += "dist.ico";
			}

			if (!PathFileExists(strIconFile)) continue;

			hr = tlbr->AddToolbarButton(index, CComBSTR(strToolTip), CComBSTR(strToolTip), CComBSTR(strCommand), vtFalse, &button);

			hr = button->SetBitmaps(CComBSTR(strIconFile), CComBSTR(strIconFile));

			button->Release();
		}

		tlbr->Dock(acToolbarDockRight);//acToolbarFloating
		tlbr->Release();
	}

	tlbrs->Release();

	return;
}
Esempio n. 7
0
//通过WebService查询在巡防的终端信息,当终端发来GPS数据时,用来判断该终端是否在巡防,
//如果是还要将该GPS数据发给巡防管理服务
BOOL CDBManage_WebServer::WebServer_LoadDB_PatrolDeviceInfo(BOOL isUpdateOnLineDeviceList)
{
	BOOL bRet = FALSE;
	
	if (!gPGisMainCtrlProc.m_BusinessManage_ConnectToGPSCheckServer.m_PatrolDevListData.IsEmpty())
	{
		gPGisMainCtrlProc.m_BusinessManage_ConnectToGPSCheckServer.m_PatrolDevListData.ClearAll();
	}
	
	if(m_bWebServiceConn)
	{
		MSXML2::IXMLDOMDocumentPtr pDoc;
		HRESULT	hr;
		hr=pDoc.CreateInstance(__uuidof(MSXML2::DOMDocument));
		if(FAILED(hr))
		{  
			gWriteLogApp.WriteLog( FOR_ALARM,_T("%s [SYS] 无法创建DOMDocument对象,请检查是否安装了MS XML Parser 运行库\n"),CTime::GetCurrentTime().Format("%H:%M:%S"));
			return FALSE;
		}

		CComBSTR hiResult;
		m_pWebService->HYTPGIS_PatroAreaUser_QueryAllDevice(&hiResult);
		char *pStr = NULL;
		pStr = _com_util::ConvertBSTRToString(hiResult);
		CString strXML;
		strXML.Format("<?xml version=\"1.0\" encoding=\"utf-8\" ?><DataSet xmlns=\"http://tempuri.org/\"> %s</DataSet>",pStr);

		VARIANT_BOOL bRet = pDoc->loadXML((_bstr_t)strXML);
		if(bRet == -1)
		{
			MSXML2::IXMLDOMNodeListPtr	 pListNode;
			pListNode = pDoc->selectNodes("//Table");
			if(pListNode != NULL)
			{
				int i;
				long tLen;
				pListNode->get_length(&tLen);
				CString strTemp;

				for(i = 0 ; i < tLen; i++)
				{
					int j = 0;
					MSXML2::IXMLDOMNode	 *pTempNode;
					pListNode->get_item(i,&pTempNode);

					MSXML2::IXMLDOMNodeList *TempChildList;
					pTempNode->get_childNodes(&TempChildList);

					long listCount = 0;
					TempChildList->get_length(&listCount);

					MSXML2::IXMLDOMNode *tempListItem = NULL;
					_variant_t	tempValue;
					for(j = 0 ; j < listCount; j++)
					{
						TempChildList->get_item(j,&tempListItem);

						tempListItem->get_nodeTypedValue(&tempValue);
						strTemp.Format("%s",(char *)(_bstr_t)tempValue);
						strTemp = strTemp.TrimLeft();
						strTemp = strTemp.TrimRight();
						gPGisMainCtrlProc.m_BusinessManage_ConnectToGPSCheckServer.m_PatrolDevListData.AddItem(strTemp);
						if(isUpdateOnLineDeviceList) //当巡防路线修改时为TRUE,此时要更新在线终端的巡防状态字段
						{
							gPGisMainCtrlProc.m_BusinessManage_ConToPub.Update_OnlineDeviceList_PatrolState(strTemp);	//
						}
						TRACE("添加巡防用户信息 %s \n",strTemp);
					}
				} //end for(i = 0

				bRet = TRUE;
                gWriteLogApp.WriteLog( FOR_ALARM,_T("%s [SYS] 加载巡防终端信息 %d 成功 \n"),CTime::GetCurrentTime().Format("%H:%M:%S"),tLen);
				m_bWebConnOK = TRUE;
			}
		}

		if(pStr)
		{
			delete []pStr;
			pStr = NULL;
		}
	}

	return bRet;
}