Esempio n. 1
0
/******************************************************************************
Function Name  :  SaveFileAs
Input(s)       :  CString omFilePath
Output         :  HRESULT
Functionality  :
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
Codetag        :  CS006
******************************************************************************/
HRESULT CTestSetupEntity::SaveFileAs(CString omFilePath)
{
    if(omFilePath.IsEmpty() == TRUE)
    {
        return S_FALSE;
    }

    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;

    HRESULT hr = pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");

    if ( FAILED(hr) )
    {
        return S_FALSE;
    }


    MSXML2::IXMLDOMProcessingInstructionPtr pIDomPi;
    pIDomPi = pIDOMDoc->createProcessingInstruction(def_DOM_INSTRUCTION);
    VARIANT_BOOL b = TRUE;
    pIDOMDoc->put_preserveWhiteSpace(b);

    if (pIDomPi != nullptr)
    {
        pIDOMDoc->appendChild(pIDomPi);
    }

    //testSETUP Node <testsetup>
    MSXML2::IXMLDOMElementPtr pIDomTSNode = pIDOMDoc->createElement(_bstr_t(def_STR_TSNODE_NAME));
    pIDOMDoc->appendChild(pIDomTSNode);

    //Title Attribute <testsetup title = "">
    MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TSATTRIB_TITLE);
    if(pIDomTSAtrrib!= nullptr)
    {
        pIDomTSAtrrib->value = _bstr_t(m_omstrTestSetupTitle);
        pIDomTSNode->setAttributeNode(pIDomTSAtrrib);
    }

    //Descriprion Node <testsetup title = ""><description>
    MSXML2::IXMLDOMElementPtr pIDomDescriptionNode = pIDOMDoc->createElement(_bstr_t(def_STR_DESC_NODE));
    pIDomDescriptionNode->Puttext(_bstr_t(m_omstrDescription));
    pIDomTSNode->appendChild(pIDomDescriptionNode);

    //Heade Node
    MSXML2::IXMLDOMElementPtr pIDomHeaderNode = pIDOMDoc->createElement(_bstr_t(def_STR_HEADER_NAME));
    nSaveHeader(pIDomHeaderNode, omFilePath);
    pIDomTSNode->appendChild(pIDomHeaderNode);

    //TestCase List
    MSXML2::IXMLDOMElementPtr pIDomTestCaseNode = pIDOMDoc->createElement(_bstr_t(def_STR_TCLIST_NODE));
    SetData(pIDomTestCaseNode);
    pIDomTSNode->appendChild(pIDomTestCaseNode);
    FormatDOMDocument(pIDOMDoc, omFilePath);
    return S_OK;
}
// 向CAD窗口发送命令
void  SendMessageToCad(CString& strCommand, CStringArray& strParamArray)
{
	MSXML2::IXMLDOMDocumentPtr lpDocument;
	long hr = lpDocument.CreateInstance(__uuidof(DOMDocument));

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

	MSXML2::IXMLDOMProcessingInstructionPtr lpInstruction = lpDocument->createProcessingInstruction("xml","version='1.0' encoding='GB2312'");
	lpDocument->appendChild(lpInstruction);

	MSXML2::IXMLDOMElementPtr lpRoot = lpDocument->createElement(LPCTSTR("root"));

	lpDocument->appendChild(lpRoot);

	// 数据类型:命令或数据
	MSXML2::IXMLDOMElementPtr lpCommand = lpDocument->createElement("command");

	lpCommand->setAttribute("name", _variant_t(strCommand));

	lpRoot->appendChild(lpCommand);

	// 参数列表
	for (int i=0; i<strParamArray.GetSize(); i++)
	{
		CString strParam = strParamArray.GetAt(i);
		CString strName = strParam.Left(strParam.Find('='));
		CString strValue = strParam.Right(strParam.GetLength()-strParam.Find('=')-1);

		MSXML2::IXMLDOMElementPtr lpParam = lpDocument->createElement("param");
		lpParam->setAttribute("name", _variant_t(strName));
		lpParam->setAttribute("value", _variant_t(strValue));

		lpCommand->appendChild(lpParam);
	}

	CString strXML = (LPCTSTR)(lpDocument->xml);
	//	OutputDebugString(lpDocument->xml);

	COPYDATASTRUCT cds;
	cds.dwData = 0;
	cds.cbData = strXML.GetLength()+1;
	cds.lpData = (void*)strXML.GetBuffer(0);
	strXML.ReleaseBuffer();
	::SendMessage(acedGetAcadFrame()->m_hWnd, WM_COPYDATA, (WPARAM)NULL, (LPARAM)&cds);
}
Esempio n. 3
0
static HRESULT CreateWADO(MSXML2::IXMLDOMDocumentPtr &pXMLDom)
{
	HRESULT hr = pXMLDom.CreateInstance(__uuidof(MSXML2::DOMDocument30));
	if (FAILED(hr)) return hr;
	pXMLDom->preserveWhiteSpace = VARIANT_FALSE;
	pXMLDom->async = VARIANT_FALSE;

	MSXML2::IXMLDOMElementPtr wado;
	MSXML2::IXMLDOMProcessingInstructionPtr pi;
	pi = pXMLDom->createProcessingInstruction("xml", "version=\"1.0\" encoding=\"GBK\"");
	if (pi != NULL)
	{
		pXMLDom->appendChild(pi);
		pi.Release();
	}

	pi = pXMLDom->createProcessingInstruction("xml-stylesheet", "type=\"text/xml\" href=\"../xslt/wadolist.xsl\"");
	if (pi != NULL)
	{
		pXMLDom->appendChild(pi);
		pi.Release();
	}

	wado = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "wado_query", "http://www.weasis.org/xsd");
	wado->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
	wado->setAttribute("requireOnlySOPInstanceUID", "false");
	pXMLDom->appendChild(wado);
	wado->setAttribute("wadoURL", "http://localhost/pacs/cgi-bin/");
	/*
	MSXML2::IXMLDOMElementPtr httpTag;
	httpTag = pXMLDom->selectSingleNode("/wado_query/httpTag");
	if( ! httpTag )
	{
		httpTag = pXMLDom->createNode(MSXML2::NODE_ELEMENT, "httpTag", "http://www.weasis.org/xsd");
		wado->appendChild(httpTag);
	}
	httpTag->setAttribute("key", "callingAE");
	httpTag->setAttribute("value", "DEVICE");
	*/
	return S_OK;
}
Esempio n. 4
0
CyNode CyDoc::CreateRootNode(const std::wstring& lpNodeName, bool bCreateHeadRow /*= false*/)
{
	MSXML2::IXMLDOMDocumentPtr spDoc;
	try
	{		
		spDoc = GetDocument();
		if(spDoc){
			if ( bCreateHeadRow )
			{
				// Create a processing instruction targeted for xml.		
				MSXML2::IXMLDOMProcessingInstructionPtr pi;
				pi = spDoc->createProcessingInstruction(L"xml", L"version=\"1.0\" encoding=\"UTF-8\"");
				if (pi != NULL) {
					spDoc->appendChild(pi);
				}
			}
			
			// Create a comment for the document.
// 			MSXML2::IXMLDOMCommentPtr pc;
// 			pc = spDoc->createComment(_T("Generate by junyu application."));
// 			if (pc != NULL) {
// 				spDoc->appendChild(pc);
// 			}
					
			// Create the root element (i.e., the documentElement).
			MSXML2::IXMLDOMElementPtr pe;
			pe = spDoc->createElement(lpNodeName.c_str());		
			if (pe != NULL) {
				spDoc->appendChild(pe);
			}
		}

	} catch(...) {
		spDoc = NULL;
	}
	m_spDocument = spDoc;
	return CyNode(spDoc);
}
Esempio n. 5
0
BOOL WXmlParse::writeParam(const std::vector<WParamDefine *> &params)
{
	/*MSXML2::IXMLDOMDocumentPtr doc;
	MSXML2::IXMLDOMElementPtr docRoot;  
	MSXML2::IXMLDOMElementPtr docElement;  
	MSXML2::IXMLDOMNodeListPtr elementNodes;  
	MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
	MSXML2::IXMLDOMNodePtr xmlNode;  
	MSXML2::IXMLDOMNodePtr xmlSubNode; 
	MSXML2::IXMLDOMNodePtr xmlAttrNode; 
	doc.CreateInstance(__uuidof(DOMDocument30));  
	if (m_strFileName.IsEmpty())
	{
	return FALSE;
	}

	docRoot = doc->createElement("ModuleName");
	//docRoot->setAttribute(_T("name"), (_variant_t) _T("CategoryProduct"));

	MSXML2::IXMLDOMElementPtr inputElement = doc->createElement("InputParam");
	docRoot->appendChild(inputElement);
	for (int i = 0;i < params.size();i++)
	{

	}*/

	MSXML2::IXMLDOMDocumentPtr pDoc = NULL; 
	MSXML2::IXMLDOMElementPtr xmlRoot = NULL; 
	MSXML2::IXMLDOMElementPtr xmlInput = NULL; 
	MSXML2::IXMLDOMProcessingInstructionPtr pPI = NULL; 
	//创建DOMDocument对象 
	pDoc.CreateInstance(__uuidof(DOMDocument30)); 
	pPI = pDoc->createProcessingInstruction("xml","version='1.0' encoding='gb2312'"); 
	_variant_t vNullVal; 
	vNullVal.vt = VT_NULL; 
	pDoc->insertBefore(pPI, vNullVal);
	//创建元素并添加到文档中 
	xmlRoot = pDoc->createElement((_bstr_t)"ModuleName"); 
	//设置属性 
	
	pDoc->appendChild(xmlRoot);
	appendTextNode(pDoc,xmlRoot,1);

	xmlInput = pDoc->createElement((_bstr_t)"InputParams");
	xmlInput->setAttribute(_T("name"), (_variant_t) _T("CategoryProduct"));
	xmlRoot->appendChild(xmlInput);
	appendTextNode(pDoc, xmlInput, 2);

	for (int i = 0;i < params.size();i++)
	{
		MSXML2::IXMLDOMElementPtr pProperty = pDoc->createElement((_bstr_t)"Property");
		pProperty->setAttribute((_bstr_t)"name", (_bstr_t)(params[i]->m_name.c_str()));
		xmlInput->appendChild(pProperty);
		appendTextNode(pDoc, pProperty, 3);
		WExtraMap::iterator it = params[i]->m_extraParams.begin();
		while (it != params[i]->m_extraParams.end())
		{
			MSXML2::IXMLDOMElementPtr pText = pDoc->createElement((_bstr_t)it->first.c_str());
			pText->put_text((_bstr_t)it->second.c_str());
			pProperty->appendChild(pText);
			appendTextNode(pDoc, pProperty, 3);
			it++;
		}
	}

	//添加“author”元素 
// 	MSXML2::IXMLDOMElementPtr pNode; 
// 	pNode=pDoc->createElement((_bstr_t)"Bank"); 
// 	xmlRoot->appendChild(pNode);
// 
// 	appendTextNode(pDoc,pNode,2);
// 
// 	MSXML2::IXMLDOMElementPtr pNode2; 
// 	pNode2=pDoc->createElement((_bstr_t)"Head"); 
// 	pNode->appendChild(pNode2);
// 
// 	appendTextNode(pDoc,pNode2,3);
// 
// 	MSXML2::IXMLDOMElementPtr pNode3; 
// 	pNode3=pDoc->createElement((_bstr_t)"PBCCode"); 
// 	pNode3->Puttext("局势"); 
// 	pNode2->appendChild(pNode3);
// 
// 	appendTextNode(pDoc,pNode2,2);
// 
// 	pNode3=pDoc->createElement((_bstr_t)"Code"); 
// 	pNode3->Puttext("局势"); 
// 	pNode2->appendChild(pNode3);
// 
// 	///////////////////////////////////////////////////
// 	appendTextNode(pDoc,pNode2,2);
// 	//////////////////////////////////////////////////////
// 	appendTextNode(pDoc,pNode,2);
// 
// 	pNode2=pDoc->createElement((_bstr_t)"Table1"); 
// 	pNode->appendChild(pNode2);
// 
// 	appendTextNode(pDoc,pNode2,3);
// 
// 	pNode3=pDoc->createElement((_bstr_t)"PBCCode"); 
// 	pNode3->Puttext("局势"); 
// 	pNode2->appendChild(pNode3);
// 
// 	appendTextNode(pDoc,pNode2,2);
// 
// 	pNode3=pDoc->createElement((_bstr_t)"Code"); 
// 	pNode3->Puttext("局势"); 
// 	pNode2->appendChild(pNode3);
// 
// 	///////////////////////////////////////////////////
// 	appendTextNode(pDoc,pNode2,2);
// 	//////////////////////////////////////////////////////
// 
// 	appendTextNode(pDoc,pNode,1);
// 	appendTextNode(pDoc,xmlRoot,0);
// 
 	pDoc->save("D:\\he.xml");

	return TRUE;
}
Esempio n. 6
0
//保存项目
BOOL CUpdateBuilderDlg::SaveToXml(LPCTSTR pszFilePath)
{
	ASSERT(pszFilePath!=NULL);
	if (pszFilePath == NULL)
		return FALSE;

	HRESULT hr = S_OK;
	MSXML2::IXMLDOMDocumentPtr	pXmlDoc;
	MSXML2::IXMLDOMElementPtr pRoot, pFileList, pFileNode;
	_variant_t vFileName, vFileSize, vFileVersion, vMD5Key;

	try
	{
		hr = pXmlDoc.CreateInstance(__uuidof(MSXML2::DOMDocument30));
		if( FAILED( hr ) ) 
			_com_issue_error(hr);

		pXmlDoc->PutpreserveWhiteSpace(VARIANT_TRUE);
		pXmlDoc->Putasync(VARIANT_FALSE);

		pXmlDoc->appendChild(pXmlDoc->createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'"));

		pRoot = pXmlDoc->createElement("manifest");
		pRoot->setAttribute("version", "1.0");
		pRoot->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema");
		pXmlDoc->appendChild(pRoot);

		pFileList = pXmlDoc->createElement("filelist");
		pFileList->setAttribute("checksummode", "default");
		
		for( int i = 0; i < m_FileListCtrl.GetItemCount(); i++ )
		{
			vFileName = m_FileListCtrl.GetItemText(i, 0);
			vFILEVERSION 2,0,0,0
			vMD5Key = m_FileListCtrl.GetItemText(i, 3);
			vFileSize = (ULONG)m_FileListCtrl.GetItemData(i);

			pFileNode = pXmlDoc->createElement("file");
			pFileNode->setAttribute("filename", vFileName);
			pFileNode->setAttribute("filesize", vFileSize);
			pFileNode->setAttribute("fileversion", vFileVersion);
			pFileNode->setAttribute("md5", vMD5Key);
			pFileList->appendChild(pFileNode);
		}

		pRoot->appendChild(pFileList);

		hr = pXmlDoc->save(pszFilePath);
		if( FAILED( hr ) )
			_com_issue_error(hr);

		return TRUE;
		
	}
	catch(_com_error& e)
	{
		CString strError;
		strError.Format(_T("Error code:%d\nError Message:%s\nError Description:%s"), 
			(int)e.WCode(), e.ErrorMessage(), (char*)e.Description());
		MessageBox(strError, _T("错误"),MB_OK|MB_ICONSTOP);
	}

	return FALSE;
}
//dedek:
BOOL CDataSourcesManager::saveSourcesTab()
{
	BOOL ret = TRUE;

	MSXML2::IXMLDOMDocumentPtr pXMLDom;
    pXMLDom.CreateInstance(_T("Msxml2.DOMDocument"));
	
	MSXML2::IXMLDOMElementPtr root_el;	// korenovy element
	root_el = pXMLDom->createElement("SOURCES_LIST");
	pXMLDom->appendChild(root_el);

	MSXML2::IXMLDOMElementPtr source_el;	// source element
	source_el = pXMLDom->createElement("SOURCE");
	
	//atributy
	MSXML2::IXMLDOMAttributePtr attr;
	
	attr = pXMLDom->createAttribute("PUBLIC_ID");
	source_el->setAttributeNode(attr);
	attr.Release();

	attr = pXMLDom->createAttribute("PERZISTENT_ID");
	source_el->setAttributeNode(attr);
	attr.Release();

	attr = pXMLDom->createAttribute("PLUGIN_ID");
	source_el->setAttributeNode(attr);
	attr.Release();

	for (int a=0; a<getSourcesCount(); a++)
	{
		MSXML2::IXMLDOMElementPtr e = source_el->cloneNode(VARIANT_TRUE);

		e->setAttribute("PUBLIC_ID", (LPCTSTR) getSourcePublicID(a));
		e->setAttribute("PERZISTENT_ID", (LPCTSTR) getSourcePersistentID(a));
		e->setAttribute("PLUGIN_ID", (LPCTSTR) getSourcePlugin(a));
		root_el->appendChild(e);

		e.Release();

	}
	source_el.Release();



	//default zdroj:
	MSXML2::IXMLDOMElementPtr default_source;
	default_source = pXMLDom->createElement("DEFAULT_SOURCE");

	MSXML2::IXMLDOMAttributePtr src_attr;	
	src_attr = pXMLDom->createAttribute("PUBLIC_ID");
	src_attr->value = (LPCTSTR) getDefaultSource();
	default_source->setAttributeNode(src_attr);
	src_attr.Release();
	root_el->appendChild(default_source);

	default_source.Release();

	CDirectoriesManager & m = ((CReportAsistentApp *) AfxGetApp())->m_pGeneralManager->DirectoriesManager;
	
	// save list of data sources into config. file "ConfigDir/sources.xml"
	try
	{
		ret = S_OK == pXMLDom->save((LPCTSTR) m.getSourcesConfigFilePath());
	}
	catch(...)
	{
		CReportAsistentApp::ReportError(IDS_DSLISTSAVE_ERR);
	}


	root_el.Release();
	return ret;
}