コード例 #1
0
ファイル: WXmlParse.cpp プロジェクト: cxwangwc/Rule
BOOL WXmlParse::readObject(std::vector<ExternalObject *> &objTree)
{
	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));  
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 3 :  递归获取对象树
	elementNodes->get_item(3, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		ExternalObject *objTmp = new ExternalObject();
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes);
		readObject(objTmp, xmlSubNode);
		objTree.push_back(objTmp);
	}

	return TRUE;
}
コード例 #2
0
ファイル: WXmlParse.cpp プロジェクト: cxwangwc/Rule
BOOL WXmlParse::readExtendModName(std::vector<std::pair<string, string> > &modNames)
{
	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));  
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 3 :  扩展模块列表
	elementNodes->get_item(1, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes);
		MSXML2::IXMLDOMNodePtr nameNode = elementAttributes->getNamedItem("name");
		MSXML2::IXMLDOMNodePtr descNode = elementAttributes->getNamedItem("description");
		modNames.push_back(std::make_pair(nameNode->text, descNode->text));
	}

	return TRUE;
}
コード例 #3
0
ファイル: WXmlParse.cpp プロジェクト: cxwangwc/Rule
BOOL WXmlParse::readCalculateParams(WCalcaulateParam &calParam)
{
	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;
	}
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 0 : 
	elementNodes->get_item(2, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes); 
		MSXML2::IXMLDOMNodePtr proNode = elementAttributes->getNamedItem("name");
		string proName = proNode->text;
		MSXML2::IXMLDOMNodeListPtr subAttrNodes; 
		xmlSubNode->get_childNodes(&subAttrNodes);
		subAttrNodes->get_length(&attrLength);
//		ASSERT(attrLength == 2);

		MSXML2::IXMLDOMNodePtr descNode;
		MSXML2::IXMLDOMNodePtr stateNode;
		subAttrNodes->get_item(0, &descNode);
		subAttrNodes->get_item(1, &stateNode);
		std::vector<string> vecParam;
		string descText = descNode->text;
		string stateText = stateNode->text;
		vecParam.push_back(proName);
		vecParam.push_back(descText);
		vecParam.push_back(stateText);

		calParam.addParam(vecParam);
	}

	return TRUE;
}
コード例 #4
0
ファイル: WXmlParse.cpp プロジェクト: cxwangwc/Rule
BOOL WXmlParse::readParam(std::vector<WParamDefine *> &outParams)
{
	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;
	}
	doc->load((_variant_t)m_strFileName);

	docRoot = doc->GetdocumentElement();//获得根节点;  
	docRoot->get_childNodes(&elementNodes);  
	LONG length, subLength, attrLength;
	elementNodes->get_length(&length);
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 

	// 0 : 
	elementNodes->get_item(0, &xmlNode);
	xmlNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&subLength);
	for (int j = 0; j < subLength;j++)
	{
		subElementNodes->get_item(j, &xmlSubNode);//获得某个属性
		xmlSubNode->get_attributes(&elementAttributes); 
		MSXML2::IXMLDOMNodePtr proNode = elementAttributes->getNamedItem("name");
		string proName = proNode->text;
		WParamDefine *paramTest = new WParamDefine(proName);
		MSXML2::IXMLDOMNodeListPtr subAttrNodes;  
		xmlSubNode->get_childNodes(&subAttrNodes);
		subAttrNodes->get_length(&attrLength);
		for (int k = 0;k < attrLength;k++)
		{
			subAttrNodes->get_item(k, &xmlAttrNode);
			string attrName = xmlAttrNode->nodeName;
			string attrText = xmlAttrNode->text;
			paramTest->addValue(attrName, attrText);
		}
		outParams.push_back(paramTest);
	}

	return TRUE;
}
コード例 #5
0
/******************************************************************************
Function Name  :  nLoadTestCases
Input(s)       :  MSXML2::IXMLDOMNodePtr& pTSDOM
Output         :  INT
Functionality  :
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam, GT-Derka
Date Created   :  06/04/2011
Modifications  :
Codetag        :  CS004
******************************************************************************/
INT CTestSetupEntity::nLoadTestCases(MSXML2::IXMLDOMNodePtr& pTSDOM)
{
    LONG lDefaultChannelUsed = 0;
    LONG lCount;
    _bstr_t bstrNodeName(def_STR_TESTCASE_NODE);

    MSXML2::IXMLDOMNodeListPtr pDOMTCNodeList;
    MSXML2::IXMLDOMNodePtr pIXMLDOMTestCase;
    pDOMTCNodeList = pTSDOM->selectNodes(bstrNodeName);
    pDOMTCNodeList->get_length(&lCount);
    for(int i=0; i<lCount; i++)
    {
        CTestCaseEntity odTestCaseEntity;

        pIXMLDOMTestCase = pDOMTCNodeList->Getitem(i);
        odTestCaseEntity.GetData(pIXMLDOMTestCase);
        m_odTestCaseEntityList.AddTail(odTestCaseEntity);
        lDefaultChannelUsed += odTestCaseEntity.m_lDefaultChannelUsed;
    }
    if(lDefaultChannelUsed == 1)
    {
        AfxMessageBox(_("1 entity without channel-information loaded.\nCAN-Channel 1 selected."), MB_OK | MB_ICONINFORMATION );
    }
    else if(lDefaultChannelUsed > 1)
    {
        CString str;
        str.Format("%d", lDefaultChannelUsed);
        AfxMessageBox(str + _(" entities without channel-information loaded.\nCAN-Channel 1 selected in each case."), MB_OK | MB_ICONINFORMATION );
    }
    return S_OK;

}
コード例 #6
0
ファイル: XMLParser3.cpp プロジェクト: daiybh/GPSGater
int CXMLParser3::GetNodeText_len(LPCTSTR strNodeName,TCHAR *pDestBuffer,int nNode/*=0*/)
{
	try
	{
		HRESULT hr;
		MSXML2::IXMLDOMNodeListPtr List = m_pXMLDom->getElementsByTagName((_bstr_t)strNodeName);
		long lNodesCount = 0;
		hr = List->get_length(&lNodesCount);
		if(SUCCEEDED(hr) && (nNode<lNodesCount ))
		{
			MSXML2::IXMLDOMNodePtr Node = List->item[nNode];
			int nLen = _tcslen(Node->text);
			if(pDestBuffer==NULL)
			{
				pDestBuffer = new TCHAR[nLen+1];
			}
			_tcscpy(pDestBuffer,Node->text);
			pDestBuffer[nLen+1]='\0';
			return nLen;
		}
		return 0;
	}
	catch (_com_error &e)
	{
		m_nError = e.Error();
		m_strError = e.ErrorMessage();
		return 0;
	}
	catch (...)
	{
	}
	return 0;
}
コード例 #7
0
ファイル: ImplXMLNode.cpp プロジェクト: bjliugq/SmartDoctor
// 获取当前节点的最后一个Element子节点
IBpXMLNode* CBpXMLNode::GetLastElementChild() const
{
	if (m_pDOMNode == NULL)
		return NULL;

	if (m_pDOMNode->GetnodeType() == MSXML2::NODE_ELEMENT) 
	{ 
		MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes(); 
		if (pNodeList == NULL)
			return NULL;
		long nListLen = 0;
		pNodeList->get_length(&nListLen);;
		MSXML2::IXMLDOMNodePtr pNode = NULL;
		for (long i = 0; i < nListLen; i++) 
		{ 
			pNodeList->get_item(nListLen - 1 - i, &pNode); 
			if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT) 
			{ 
				CBpXMLNode *pNodeCreated  = new CBpXMLNode();	
				pNodeCreated->m_pDOMNode = pNode;
				return (IBpXMLNode*)pNodeCreated;
			} 
		} 
	}
	return NULL;
}
コード例 #8
0
ファイル: WXmlParse.cpp プロジェクト: cxwangwc/Rule
BOOL WXmlParse::readObject(ExternalObject *objRet, MSXML2::IXMLDOMNodePtr &xmlSubNode)
{
	MSXML2::IXMLDOMNamedNodeMapPtr elementAttributes;
	MSXML2::IXMLDOMNodeListPtr subElementNodes; 
	MSXML2::IXMLDOMNodeListPtr subSubElementNodes; 
	MSXML2::IXMLDOMNodePtr xmlNodeTmp; 
	xmlSubNode->get_attributes(&elementAttributes);

	LONG attrLength;
	attrLength = elementAttributes->Getlength();
	MSXML2::IXMLDOMNodePtr nameNode = elementAttributes->getNamedItem("name");
	MSXML2::IXMLDOMNodePtr clsNode = elementAttributes->getNamedItem("type");
	objRet->objName = nameNode->text;
	objRet->clsName = clsNode->text;
	LONG length, subLength;
	xmlSubNode->get_childNodes(&subElementNodes);
	subElementNodes->get_length(&length);
	objRet->attri.clear();

	for (int i = 0;i < length;i++)
	{
		subElementNodes->get_item(i, &xmlNodeTmp);
		string childName = xmlNodeTmp->nodeName;
		if (strcmp(xmlNodeTmp->nodeName,"child") != 0)
		{
			xmlNodeTmp->get_attributes(&elementAttributes);
			if (!elementAttributes)
				return FALSE;
			MSXML2::IXMLDOMNodePtr typeNode = elementAttributes->getNamedItem("type");
			objRet->attri.push_back(std::make_pair(xmlNodeTmp->nodeName, std::make_pair(typeNode->text, xmlNodeTmp->text)));
		}
		else
		{
			xmlNodeTmp->get_childNodes(&subSubElementNodes);
			subSubElementNodes->get_length(&subLength);
			for (int j = 0;j < subLength;j++)
			{
				ExternalObject *objSub = new ExternalObject();
				subSubElementNodes->get_item(j, &xmlNodeTmp);
				readObject(objSub, xmlNodeTmp);
				objRet->children.push_back(objSub);
			}
		}
	}

	return TRUE;
}
コード例 #9
0
ファイル: VerifyEntity.cpp プロジェクト: GT-Pfand/busmaster
/******************************************************************************
Function Name  :  GetData
Input(s)       :
Output         :  HRESULT
Functionality  :
Member of      :  CVerifyEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
HRESULT CVerifyEntity::GetCommonVerifyData(MSXML2::IXMLDOMNodePtr& pIDomNode, CVerifyData *verifyData)
{
	m_ouData = verifyData;
    _bstr_t bstrNodeName = def_STR_VERIFYMSG_NODE;
    CComVariant NodeValue;
    MSXML2::IXMLDOMNamedNodeMapPtr pDOMVerifyAtrributes;
    MSXML2::IXMLDOMNodePtr pIDOMChildNode;

    pDOMVerifyAtrributes = pIDomNode->Getattributes();
    //bstrNodeName = L"failure";
    bstrNodeName.Assign(SysAllocString(CT2W("failure")));
    pIDOMChildNode = pDOMVerifyAtrributes->getNamedItem(bstrNodeName);
    pIDOMChildNode->get_nodeTypedValue(&NodeValue);
    CString strTemp;
    strTemp = strCopyBSTRToCString(NodeValue);

	//m_ouData = new CVerifyData();
    if(strTemp == "SUCCESS")
    {
        m_ouData->m_eAttributeError = SUCCESS;
    }
    else if(strTemp == "WARNING")
    {
        m_ouData->m_eAttributeError = WARNING;
    }
    else if(strTemp == "ERRORS")
    {
        m_ouData->m_eAttributeError = ERRORS;
    }
    else
    {
        m_ouData->m_eAttributeError = FATAL;
    }
    MSXML2::IXMLDOMNodeListPtr pIDOMSendList;

    LONG lCount;
    //bstrNodeName = def_STR_VERIFYMSG_NODE;
    bstrNodeName.Assign(SysAllocString(CT2W(def_STR_VERIFYMSG_NODE)));
    pIDOMSendList = pIDomNode->selectNodes(bstrNodeName);
    pIDOMSendList->get_length(&lCount);

    for(int i = 0; i < lCount; i++)
    {
        CVerifySubEntity *odVerifySubEntity;
        MSXML2::IXMLDOMNodePtr pIXMLDOMVerifyMsgEntity;
        pIXMLDOMVerifyMsgEntity = pIDOMSendList->Getitem(i);
		//if(CVerifySubEntity::GetData(&odVerifySubEntity, pIXMLDOMVerifyMsgEntity) == S_OK)
		if(this->GetSubEntityData(&odVerifySubEntity, pIXMLDOMVerifyMsgEntity) == S_OK)
        {
            m_ouData->m_odVerifySubEntityList.push_back(odVerifySubEntity);
        }
    }
    return S_OK;
}
コード例 #10
0
ファイル: XMLUtils.cpp プロジェクト: Inzaghi2012/ie-toolbar
size_t getChildrenCount(MSXML2::IXMLDOMNodePtr& node) {
  MSXML2::IXMLDOMNodeListPtr children;
  const HRESULT getChildNodesRes = node->get_childNodes(&children);
  if (FAILED(getChildNodesRes)) { 
    _com_raise_error(getChildNodesRes);
  }

  LONG chilrenCount = 0;
  const HRESULT getChildenCountRes = children->get_length(&chilrenCount);
  if (FAILED(getChildenCountRes)) {
    _com_raise_error(getChildenCountRes);
  }

  return chilrenCount;
}
コード例 #11
0
ファイル: ImplXMLNode.cpp プロジェクト: bjliugq/SmartDoctor
// 获取当前节点的指定位置的Element子节点
IBpXMLNode *CBpXMLNode::GetElementChildByIndex(int nIndex) const
{
	if (m_pDOMNode == NULL)
		return NULL;

	if (m_pDOMNode->GetnodeType() != MSXML2::NODE_ELEMENT)
		return NULL;

	MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes();
	if (pNodeList == NULL)
		return NULL;

	long nListLen = 0;
	pNodeList->get_length(&nListLen);
	if (nIndex <= 0 || nIndex > nListLen)
		return NULL;

	MSXML2::IXMLDOMNodePtr pNode = NULL;
	int nRealIndex = 0;
	int nCount = 0;
	for (int i = 0; i < nListLen; i++) 
	{ 
		pNodeList->get_item(i, &pNode);
		if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT) 
		{
			nCount++;
			if (nCount == nIndex)
			{
				nRealIndex = i;	
				break;
			}
		}
	} 	

	if (nRealIndex < 0 || nRealIndex >= nListLen)
		return NULL;

	pNodeList->get_item(nRealIndex, &pNode);
	if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT) 
	{ 
		CBpXMLNode *pNodeCreated  = new CBpXMLNode();	
		pNodeCreated->m_pDOMNode = pNode;
		return (IBpXMLNode*)pNodeCreated;
	} 

	return NULL;
}
コード例 #12
0
ファイル: ImplXMLNode.cpp プロジェクト: bjliugq/SmartDoctor
// 获取当前结点,指定名称的第index个Element子结点
IBpXMLNode *CBpXMLNode::GetElementChildByName(const wchar_t *szChildNodeName, int nIndex) const
{
	if (m_pDOMNode == NULL || nIndex <= 0)
		return NULL;

	int nCount = nIndex;
	if (m_pDOMNode->GetnodeType() == MSXML2::NODE_ELEMENT) 
	{ 
		MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes(); 
		if (pNodeList == NULL)
			return NULL;
		long nListLen = 0;
		pNodeList->get_length(&nListLen);; 
		int i = 0;
		MSXML2::IXMLDOMNodePtr pNode = NULL;
		for (;;)
		{ 
			pNodeList->get_item(i, &pNode); 
			if (pNode == NULL)
				break;

			if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT) 
			{ 
				BSTR bstrText = NULL;
				m_pDOMNode->get_nodeName(&bstrText);
				CString strTempNodeName(bstrText);
				if (strTempNodeName.CompareNoCase(szChildNodeName))
				{
					nCount--;
					if(nCount == 0)
					{
						CBpXMLNode *pNodeCreated  = new CBpXMLNode();	
						pNodeCreated->m_pDOMNode = pNode;
						return (IBpXMLNode*)pNodeCreated;
					}
				}
			} 
			i++;
			if(i == nListLen)
				break;
		} 
	}
	return NULL;
}
コード例 #13
0
////////////////////////////////////////////////////////////////////////////
// Function: Walk all the Elements in a loaded XML document.
////////////////////////////////////////////////////////////////////////////
HRESULT CXMLDocument::WalkTree(CString& strSearchPattern)
{
	HRESULT hr = S_OK;

	if (strSearchPattern.IsEmpty())
	{
		MSXML2::IXMLDOMNodePtr pNode = m_pDoc;
		if (pNode == NULL)
			return E_FAIL;

		hr = WalkTree(0/*iLevel*/, pNode);
	}
	else
	{
		//j	("//video");
		//j	("//video[@id='crap1']");
		//j	("//video[@id='crap1']");

		// filter the nodes using the search pattern
		MSXML2::IXMLDOMNodeListPtr pNodeList = NULL;
		hr = m_pDoc->selectNodes(CComBSTR(strSearchPattern), &pNodeList);
		hr = CheckHR(hr, "in the search pattern");

		// get the length of the resulting node list
		if (pNodeList)
		{
			long lLength;
			hr = pNodeList->get_length(&lLength);
			hr = CheckHR(hr, "retrieving node list length");

			MSXML2::IXMLDOMNodePtr pNode = NULL;
			for (long i = 0; i < lLength; i++)
			{
				hr = pNodeList->get_item(i, &pNode);
				hr = WalkTree(0/*iLevel*/, pNode);
				if (hr != S_OK)
					return hr;
			}
		}
	}

	return hr;
}
コード例 #14
0
/******************************************************************************
Function Name  :  nLoadTestCases
Input(s)       :  MSXML2::IXMLDOMNodePtr& pTSDOM
Output         :  INT
Functionality  :   
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
Codetag        : CS004
******************************************************************************/
INT CTestSetupEntity::nLoadTestCases(MSXML2::IXMLDOMNodePtr& pTSDOM)
{
    LONG lCount;
    _bstr_t bstrNodeName(def_STR_TESTCASE_NODE);
    
    MSXML2::IXMLDOMNodeListPtr pDOMTCNodeList;
    MSXML2::IXMLDOMNodePtr pIXMLDOMTestCase;
    pDOMTCNodeList = pTSDOM->selectNodes(bstrNodeName);
    pDOMTCNodeList->get_length(&lCount);
    for(int i=0; i<lCount;i++)
    {
        CTestCaseEntity odTestCaseEntity;
        pIXMLDOMTestCase = pDOMTCNodeList->Getitem(i);
        odTestCaseEntity.GetData(pIXMLDOMTestCase);
        m_odTestCaseEntityList.AddTail(odTestCaseEntity);
    }
    return S_OK;

}
コード例 #15
0
ファイル: ImplXMLNode.cpp プロジェクト: bjliugq/SmartDoctor
// 获取当前节点的所有Element子节点个数
int CBpXMLNode::GetElementCount() const
{
	if (m_pDOMNode == NULL)
		return 0;

	long nResult = 0;
	MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes();
	if (pNodeList != NULL)
	{
		MSXML2::IXMLDOMNodePtr pNode = NULL;
		long nListLen = 0;
		pNodeList->get_length(&nListLen);
		for (long i = 0; i < nListLen; i++) 
		{ 
			pNodeList->get_item(i, &pNode);
			if (pNode != NULL && pNode->GetnodeType() == MSXML2::NODE_ELEMENT)
				nResult++;
		} 	
	}

	return (int)nResult;
}
コード例 #16
0
ファイル: SendEntity.cpp プロジェクト: Fetze/busmaster
/******************************************************************************
Function Name  :  GetData
Input(s)       :  MSXML2::IXMLDOMNodePtr& pIDomNode
Output         :  HRESULT
Functionality  :  Reads the XML node and constructs the data structure 
Member of      :  CSendEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
HRESULT CSendEntity::GetData(MSXML2::IXMLDOMNodePtr& pIDomNode)
{
    MSXML2::IXMLDOMNodeListPtr pIDOMSendList;
    _bstr_t bstrNodeName = def_STR_SENDMSG_NODE;
    long lCount;
    
    pIDOMSendList = pIDomNode->selectNodes(bstrNodeName);
    pIDOMSendList->get_length(&lCount);
    
    for(int i = 0; i < lCount; i++)
    {
        CSend_MessageEntity odSend_MessageEntity;
        MSXML2::IXMLDOMNodePtr pIXMLDOMSendMsgEntity;
        pIXMLDOMSendMsgEntity = pIDOMSendList->Getitem(i);
        if(odSend_MessageEntity.GetData(pIXMLDOMSendMsgEntity)==S_OK)
        {
            m_ouData.m_odSend_MessageDataList.AddTail(odSend_MessageEntity);
        }
    }
    
    return  S_OK;
}
コード例 #17
0
ファイル: ImplXMLNode.cpp プロジェクト: bjliugq/SmartDoctor
// 判断当前节点是否存在Element子结点
bool CBpXMLNode::HasElementChildNodes() const
{
	if(m_pDOMNode == NULL)
		return false;
	
	if (m_pDOMNode->GetnodeType() == MSXML2::NODE_ELEMENT) 
	{ 
		MSXML2::IXMLDOMNodeListPtr pNodeList = m_pDOMNode->GetchildNodes(); 
		if (pNodeList == NULL)
			return false;

		long nListLen = 0;
		pNodeList->get_length(&nListLen);
		MSXML2::IXMLDOMNodePtr pNode = NULL;
		for (int i = 0; i < nListLen; i++)
		{
			pNodeList->get_item(i, &pNode);
			if (pNode->GetnodeType() == MSXML2::NODE_ELEMENT)
				return true;			
		}
	}

	return false;
}
コード例 #18
0
long findControllerInfoXML(fwi::OHCI1394_DEV_INFO * devInfo)
{
    MSXML2::IXMLDOMNodeList *pNodes=NULL;
    MSXML2::IXMLDOMNode *pNode=NULL;
    static VARIANT_BOOL status;
    static VARIANT var;
    BSTR bstr = NULL;
    HRESULT hr;
    long num_controllers;
    long num_attributes;
    BOOL bVendorMatch = FALSE;
    BOOL bDeviceMatch = FALSE;
    long lMinutes = 0;

    MSXML2::IXMLDOMElementPtr pXMLDocElement = NULL;
    MSXML2::IXMLDOMNodeListPtr pXMLDomNodeList = NULL;

    VariantInit(&var);

    // the URL below has a server-side redirect to the actual xml file in the svn repo
    var = VariantString(L"http://www.tctechnologies.tc/appdata/ohci1394db.xml");

    // reload online file if cached data is stale
    lMinutes = getDBCacheAge();
    if ( (lMinutes < 0) || (lMinutes > 10) )
    {
        if (gpXMLDom) gpXMLDom->Release();
        gpXMLDom = DomFromCOM();
        if (!gpXMLDom) return 1;

        HRCALL(gpXMLDom->load(var, &status), "dom->load(): ");

        if (status!=VARIANT_TRUE)
        {
            if (&var) VariantClear(&var);

            return FWI_ERROR_FILE_NOT_FOUND;
        }
        else
        {
            GetLocalTime(&gLastLoadTime);
        }
    }

    gpXMLDom->get_documentElement(&pXMLDocElement);
    pXMLDocElement->selectNodes(TEXT("//controller"), &pXMLDomNodeList);
    pXMLDomNodeList->get_length(&num_controllers);

    for (long n=0; n<num_controllers; n++)
    {
        TCHAR buf[32];
        StringCchPrintf( buf, 20, TEXT("//controller[%i]/*"), n);

        // Query the node-set.
        HRCALL(gpXMLDom->selectNodes(buf, &pNodes), "selectNodes ");
        if (!pNodes) {
            ReportParseError(gpXMLDom, "Error while calling selectNodes ");
        }
        else {
            HRCALL(pNodes->get_length(&num_attributes), "get_length: ");
            for (long i=0; i<num_attributes; i++) {
                if (pNode) pNode->Release();
                HRCALL(pNodes->get_item(i, &pNode), "get_item: ");
                if (bstr) SysFreeString(bstr);
                HRCALL(pNode->get_nodeName(&bstr), "get_nodeName: ");

                if (_tcsicmp((TCHAR*)bstr,TEXT("vendorid"))==0)
                {
                    BSTR nodeTextStr;
                    HRCALL(pNode->get_text(&nodeTextStr), "get_text: ");
                    if (_tcsicmp((TCHAR*)nodeTextStr, devInfo->vendorId)==0)
                    {
                        bVendorMatch = TRUE;
                    }
                    SysFreeString(nodeTextStr);
                }
                else if (_tcsicmp((TCHAR*)bstr,TEXT("deviceid"))==0)
                {
                    BSTR nodeTextStr;
                    HRCALL(pNode->get_text(&nodeTextStr), "get_text: ");
                    if (_tcsicmp((TCHAR*)nodeTextStr, devInfo->deviceId)==0)
                    {
                        bDeviceMatch = TRUE;
                    }
                    SysFreeString(nodeTextStr);
                }

                if (bVendorMatch)
                {
                    if ( (_tcsicmp((TCHAR*)bstr,TEXT("vendorname"))==0) && (_tcsicmp(TEXT("Unknown"),&devInfo->vendorName[0]))==0 )
                    {
                        BSTR nodeTextStr;
                        HRCALL(pNode->get_text(&nodeTextStr), "get_text: ");
                        _tcscpy_s(&devInfo->vendorName[0], VENDOR_SIZE, nodeTextStr);
                        SysFreeString(nodeTextStr);
                    }
                }

                if (bVendorMatch && bDeviceMatch)
                {
                    devInfo->bFound = TRUE;
                    if (_tcsicmp((TCHAR*)bstr,TEXT("chipset"))==0)
                    {
                        BSTR nodeTextStr;
                        HRCALL(pNode->get_text(&nodeTextStr), "get_text: ");
                        _tcscpy_s(&devInfo->chipset[0], CHIPSET_SIZE, nodeTextStr);
                        SysFreeString(nodeTextStr);
                    }
                    else if (_tcsicmp((TCHAR*)bstr,TEXT("maxtx"))==0)
                    {
                        BSTR nodeTextStr;
                        HRCALL(pNode->get_text(&nodeTextStr), "get_text: ");
                        _tcscpy_s(&devInfo->maxTx[0], NUM_STR_SIZE, nodeTextStr);
                        SysFreeString(nodeTextStr);
                    }
                    else if (_tcsicmp((TCHAR*)bstr,TEXT("maxrx"))==0)
                    {
                        BSTR nodeTextStr;
                        HRCALL(pNode->get_text(&nodeTextStr), "get_text: ");
                        _tcscpy_s(&devInfo->maxRx[0], NUM_STR_SIZE, nodeTextStr);
                        SysFreeString(nodeTextStr);
                    }
                    else if (_tcsicmp((TCHAR*)bstr,TEXT("maxspeed"))==0)
                    {
                        BSTR nodeTextStr;
                        HRCALL(pNode->get_text(&nodeTextStr), "get_text: ");
                        swscanf_s(nodeTextStr, TEXT("%04d"), &devInfo->maxspeed);
                        SysFreeString(nodeTextStr);
                    }
                    else if (_tcsicmp((TCHAR*)bstr,TEXT("notes"))==0)
                    {
                        BSTR nodeTextStr;
                        HRCALL(pNode->get_text(&nodeTextStr), "get_text: ");
                        _tcscpy_s(&devInfo->notes[0], NOTES_SIZE, nodeTextStr);
                        SysFreeString(nodeTextStr);
                    }
                    else if (_tcsicmp((TCHAR*)bstr,TEXT("support"))==0)
                    {
                        BSTR nodeTextStr;
                        HRCALL(pNode->get_text(&nodeTextStr), "get_text: ");
                        swscanf_s(nodeTextStr, TEXT("%04x"), &devInfo->support);
                        devInfo->bValid = true;
                        SysFreeString(nodeTextStr);
                        if (&var) VariantClear(&var);
                        if (bstr) SysFreeString(bstr);
                        if (pNodes) pNodes->Release();
                        if (pNode) pNode->Release();

                        return FWI_NO_ERROR;
                    }
                }
            }
        }
    }
clean:
    if (&var) VariantClear(&var);
    if (bstr) SysFreeString(bstr);
    if (pNodes) pNodes->Release();
    if (pNode) pNode->Release();

    return FWI_ERROR_END_OF_FILE;
}
コード例 #19
0
/******************************************************************************
Function Name  :  nLoadHeader
Input(s)       :  MSXML2::IXMLDOMNodePtr& pHeaderDOMNode
Output         :  INT
Functionality  :  Retrives the Header info 
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
Codetag        :  
******************************************************************************/
INT CTestSetupEntity::nLoadHeader(MSXML2::IXMLDOMNodePtr& pHeaderDOMNode)
{
   // CComPtr<IXMLDOMNode> pHeaderDOMNode;
    MSXML2::IXMLDOMNodeListPtr pXMLDOMInfoList;
    MSXML2::IXMLDOMNodePtr pInfoNode;
    MSXML2::IXMLDOMNodePtr pInfoCategoryNode;
    MSXML2::IXMLDOMNodePtr pInfoValueNode;
    _bstr_t bstrNodeName = "info";
    CComVariant NodeValue;		
    pXMLDOMInfoList = pHeaderDOMNode->selectNodes(bstrNodeName);

    LONG lCount = 0;
    pXMLDOMInfoList->get_length(&lCount);
    SInfo ouTempSInfo;
    for(int i = 0; i<lCount; i++)
    {
        pInfoNode = pXMLDOMInfoList->Getitem(i);

        //bstrNodeName = def_STR_CATEGORY_NODE;
		bstrNodeName.Assign(SysAllocString(CT2W(def_STR_CATEGORY_NODE)));
        pInfoCategoryNode = pInfoNode->selectSingleNode(bstrNodeName);
        pInfoCategoryNode->get_nodeTypedValue(&NodeValue);		
				
		ouTempSInfo.m_omCategory = strCopyBSTRToCString(NodeValue);
		
        pInfoCategoryNode.Release();
        
        //bstrNodeName = def_STR_VALUE_NODE;
		bstrNodeName.Assign(SysAllocString(CT2W(def_STR_VALUE_NODE)));
        pInfoCategoryNode = pInfoNode->selectSingleNode(bstrNodeName);
        pInfoCategoryNode->get_nodeTypedValue(&NodeValue);			
		ouTempSInfo.m_omValue = strCopyBSTRToCString(NodeValue);
        pInfoCategoryNode.Release();
        
        pInfoNode.Release();


        if(ouTempSInfo.m_omCategory == def_STR_MODULENAME)
        {
            m_ouTestSetupHeader.m_sModuleName.m_omCategory = ouTempSInfo.m_omCategory;
            m_ouTestSetupHeader.m_sModuleName.m_omValue = ouTempSInfo.m_omValue;
        }
        if(ouTempSInfo.m_omCategory == def_STR_ENGINEERNAME)
        {
            m_ouTestSetupHeader.m_sEngineerInfo1.m_omCategory = ouTempSInfo.m_omCategory;
            m_ouTestSetupHeader.m_sEngineerInfo1.m_omValue = ouTempSInfo.m_omValue;
        }
        if(ouTempSInfo.m_omCategory == def_STR_ENGINERROLE)
        {
            m_ouTestSetupHeader.m_sEngineerInfo2.m_omCategory = ouTempSInfo.m_omCategory;
            m_ouTestSetupHeader.m_sEngineerInfo2.m_omValue = ouTempSInfo.m_omValue;
        }
        if(ouTempSInfo.m_omCategory == def_STR_VERSION)
        {
            m_ouTestSetupHeader.m_sVersion.m_omCategory = ouTempSInfo.m_omCategory;
            m_ouTestSetupHeader.m_sVersion.m_omValue = ouTempSInfo.m_omValue;
        }
    }
//Taking Database
    
    //bstrNodeName = def_STR_LISTOFDB;
	bstrNodeName.Assign(SysAllocString(CT2W(def_STR_LISTOFDB)));
    pInfoNode = pHeaderDOMNode->selectSingleNode(bstrNodeName);
    pInfoNode->get_nodeTypedValue(&NodeValue);		
	m_ouTestSetupHeader.m_omDatabasePath = strCopyBSTRToCString(NodeValue);
    //Set The Database Path
    SetDatabaseFile(m_ouTestSetupHeader.m_omDatabasePath);
    pInfoNode.Release();

    //bstrNodeName = def_STR_REPORT_FORMAT;
	bstrNodeName.Assign(SysAllocString(CT2W(def_STR_REPORT_FORMAT)));
    pInfoNode = pHeaderDOMNode->selectSingleNode(bstrNodeName);
    pInfoNode->get_nodeTypedValue(&NodeValue);
	CString omStrExt;	
	omStrExt = strCopyBSTRToCString(NodeValue);
    pInfoNode.Release();

    
    if(omStrExt == "HTM")
    {
        m_ouTestSetupHeader.m_sReportFile.m_eType = HTM;
    }
    else
    {
        m_ouTestSetupHeader.m_sReportFile.m_eType = TXT;
    }

    //bstrNodeName = def_STR_REPORT_PATH;
	bstrNodeName.Assign(SysAllocString(CT2W(def_STR_REPORT_PATH)));
    pInfoNode = pHeaderDOMNode->selectSingleNode(bstrNodeName);
    pInfoNode->get_nodeTypedValue(&NodeValue);		
	m_ouTestSetupHeader.m_sReportFile.m_omPath = strCopyBSTRToCString(NodeValue);
    pInfoNode.Release();
    
    


    //bstrNodeName = def_STR_REPORT_TIMEMODE;
	bstrNodeName.Assign(SysAllocString(CT2W(def_STR_REPORT_TIMEMODE)));
    pInfoNode = pHeaderDOMNode->selectSingleNode(bstrNodeName);
    pInfoNode->get_nodeTypedValue(&NodeValue);
	CString strTemp;	
	strTemp = strCopyBSTRToCString(NodeValue);
    if(strTemp == "ABS")
    {
        m_ouTestSetupHeader.m_sReportFile.m_eTimeMode = ABS;
    }
    else                    //Default
    {
        m_ouTestSetupHeader.m_sReportFile.m_eTimeMode = REL;
    }
    pInfoNode.Release();


    //bstrNodeName = def_STR_BUS_TYPE;
	bstrNodeName.Assign(SysAllocString(CT2W(def_STR_BUS_TYPE)));
    pInfoNode= pHeaderDOMNode->selectSingleNode(bstrNodeName);
    pInfoNode->get_nodeTypedValue(&NodeValue);		
	strTemp = strCopyBSTRToCString(NodeValue);

    if(strTemp == "CAN")
    {
        m_ouTestSetupHeader.m_eBus = CAN;
    }

    pInfoNode.Release();
    
    return 0;
}
コード例 #20
0
/******************************************************************************
Function Name  :  GetData
Input(s)       :  MSXML2::IXMLDOMNodePtr& pIDomNode
Output         :  HRESULT
Functionality  :  Fills the datastructure from the XML node 
Member of      :  CTestCaseEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
HRESULT CTestCaseEntity::GetData(MSXML2::IXMLDOMNodePtr& pIDomNode)
{
//Getting Attributes
    _bstr_t bstrNodeName;
    CComVariant NodeValue;	
    MSXML2::IXMLDOMNamedNodeMapPtr pDOMTCAtrributes;
    pDOMTCAtrributes = pIDomNode->Getattributes();
    MSXML2::IXMLDOMNodePtr pIDOMChildNode;

    //bstrNodeName = L"identifier";
	bstrNodeName.Assign(SysAllocString(CT2W("identifier")));
    pIDOMChildNode = pDOMTCAtrributes->getNamedItem(bstrNodeName);
    pIDOMChildNode->get_nodeTypedValue(&NodeValue);		
	m_ouData.m_omID = strCopyBSTRToCString(NodeValue);
    pIDOMChildNode.Release();
    
    //bstrNodeName = L"title";
	bstrNodeName.Assign(SysAllocString(CT2W("title")));
    pIDOMChildNode = pDOMTCAtrributes->getNamedItem(bstrNodeName);
    pIDOMChildNode->get_nodeTypedValue(&NodeValue);		
	m_ouData.m_omTitle = strCopyBSTRToCString(NodeValue);
    pIDOMChildNode.Release();

    //bstrNodeName = L"exp_handler";
	bstrNodeName.Assign(SysAllocString(CT2W("exp_handler")));
    pIDOMChildNode = pDOMTCAtrributes->getNamedItem(bstrNodeName);
    pIDOMChildNode->get_nodeTypedValue(&NodeValue);
	CString strTemp;	
	strTemp = strCopyBSTRToCString(NodeValue);
    pIDOMChildNode.Release();
    
    if(strTemp == "CONTINUE")
    {
        m_ouData.m_eExcpAction = CONTINUE;
    }
    else
    {
        m_ouData.m_eExcpAction = EXIT;
    }

//Getting Testcases
    MSXML2::IXMLDOMNodeListPtr pDOMChildList = pIDomNode->GetchildNodes();
    LONG lCount;
    pDOMChildList->get_length(&lCount);
    CComBSTR NodeName;
    for(int i = 0;i < lCount; i++)
    {
        pIDOMChildNode = pDOMChildList->Getitem(i);
        pIDOMChildNode->get_nodeName(&NodeName);        
		
        CBaseEntityTA *odpBaseEntity = NULL;
		if(NodeName == def_STR_SEND_NODE)
        {
            odpBaseEntity = new CSendEntity();
        }
        else if(NodeName == def_STR_VERIFY_NODE)
        {
            odpBaseEntity = new CVerifyEntity();
        }
        else if(NodeName == def_STR_WAIT_NODE)
        {
            odpBaseEntity = new CWaitEntity();
        }
        else if(NodeName == def_STR_REPLAY_NODE)
        {
            odpBaseEntity = new CReplayEntity();
        }
        else if(NodeName == def_STR_VERIFYRES_NODE)
        {
            odpBaseEntity = new CVerifyResponse();
        }
        if(odpBaseEntity == NULL)
        {
            //TODO::return a correct value
            return -1;
        }
        odpBaseEntity->GetData(pIDOMChildNode);
        m_ouData.m_odTAEntityList.AddTail(odpBaseEntity);
        //pIDOMChildNode->Release();
    }
    return S_OK;
}
コード例 #21
0
ファイル: DBManage_WebServer.cpp プロジェクト: minicool/IOCP
//通过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;
}