コード例 #1
0
//设置指定xpath的节点值
BOOL CXmlBase::SetNodeValue(LPCTSTR lpszValue, MSXML2::IXMLDOMNodePtr pNode)
{
	if (pNode == NULL) return FALSE;
	if (lpszValue == NULL) return FALSE;
	MSXML2::IXMLDOMElementPtr pElem = pNode;
	pElem->Puttext(lpszValue);
	return TRUE;
}
コード例 #2
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;
}
コード例 #3
0
/******************************************************************************
Function Name  :  SetData
Input(s)       :  MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode
Output         :  HRESULT
Functionality  :   
Member of      :  CReplayEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
HRESULT CReplayEntity::SetData(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    if (pIDOMDoc != NULL)
    {
        MSXML2::IXMLDOMElementPtr pIDomWaitNode =  pIDOMDoc->createElement(_bstr_t(def_STR_REPLAY_NODE));
        pIDomWaitNode->Puttext(_bstr_t(m_omFilePath));
        pIDomTestCaseNode->appendChild(pIDomWaitNode);
    }
    return S_OK;
}
コード例 #4
0
/******************************************************************************
Function Name  :  bAddChildToNode
Input(s)       :  MSXML2::IXMLDOMElementPtr& pNodeElement, 
                  CString omNodeName 
                  CString omNodeval
Output         :  BOOL
Functionality  :   
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
BOOL CTestSetupEntity::bAddChildToNode(MSXML2::IXMLDOMElementPtr& pNodeElement, 
                                          CString omNodeName, CString omNodeval)
{
    BOOL bReturn = FALSE;
    MSXML2::IXMLDOMElementPtr pChildElement;
    MSXML2::IXMLDOMDocumentPtr m_pXMLDom;
    m_pXMLDom.CreateInstance(L"Msxml2.DOMDocument");
    if (pNodeElement != NULL)
    {
        pChildElement   =  m_pXMLDom->createElement(_bstr_t(omNodeName));
        if (pChildElement != NULL)
        {
            pChildElement->Puttext((_bstr_t)omNodeval);
            pNodeElement->appendChild(pChildElement);
            bReturn = TRUE;
        }
    }
    return bReturn;
}
コード例 #5
0
/******************************************************************************
Function Name  :  SetData
Input(s)       :  MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode
Output         :  HRESULT
Functionality  :   
Member of      :  CWaitEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
HRESULT CWaitEntity::SetData(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    if (pIDOMDoc != NULL)
    {
        MSXML2::IXMLDOMElementPtr pIDomWaitNode =  pIDOMDoc->createElement(_bstr_t(def_STR_WAIT_NODE));

        MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_STTRIB_PURPOSE);
        if(pIDomTSAtrrib!= NULL)
	    {
            pIDomTSAtrrib->value = _bstr_t(m_ouData.m_omPurpose);
		    pIDomWaitNode->setAttributeNode(pIDomTSAtrrib);
	    }
        omstrTemp.Format("%d", m_ouData.m_ushDuration);
        pIDomWaitNode->Puttext(_bstr_t(omstrTemp));

        pIDomTestCaseNode->appendChild(pIDomWaitNode);
    }
    return S_OK;
}
コード例 #6
0
/******************************************************************************
Function Name  :  nSaveHeader
Input(s)       :  
Output         :  INT
Functionality  :   
Member of      :  CTestSetupEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
Codetag        :  CS025
******************************************************************************/
INT CTestSetupEntity::nSaveHeader(MSXML2::IXMLDOMElementPtr& pIDomHeaderNode, CString& omStrFilePath)
{
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    MSXML2::IXMLDOMElementPtr pChildElement;
    MSXML2::IXMLDOMElementPtr pInfoElement;
    CString omstrTemp;
    //Module Info
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_INFO_NODE));
    if (pInfoElement != NULL)
    {
        bAddChildToNode(pInfoElement, def_STR_CATEGORY_NODE, m_ouTestSetupHeader.m_sModuleName.m_omCategory);
        bAddChildToNode(pInfoElement, def_STR_VALUE_NODE, m_ouTestSetupHeader.m_sModuleName.m_omValue);
    }
    pIDomHeaderNode->appendChild(pInfoElement);
 
    //Version
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_INFO_NODE));
    if (pInfoElement != NULL)
    {
        bAddChildToNode(pInfoElement, def_STR_CATEGORY_NODE, m_ouTestSetupHeader.m_sVersion.m_omCategory);
        bAddChildToNode(pInfoElement, def_STR_VALUE_NODE, m_ouTestSetupHeader.m_sVersion.m_omValue);
    }
    pIDomHeaderNode->appendChild(pInfoElement);
   
    //Engineer Name
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_INFO_NODE));
    if (pInfoElement != NULL)
    {
    bAddChildToNode(pInfoElement, def_STR_CATEGORY_NODE, m_ouTestSetupHeader.m_sEngineerInfo1.m_omCategory);
        bAddChildToNode(pInfoElement, def_STR_VALUE_NODE, m_ouTestSetupHeader.m_sEngineerInfo1.m_omValue);
    }
    pIDomHeaderNode->appendChild(pInfoElement);
    
    //Engineer Role
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_INFO_NODE));
    if (pInfoElement != NULL)
    {
        bAddChildToNode(pInfoElement, def_STR_CATEGORY_NODE, m_ouTestSetupHeader.m_sEngineerInfo2.m_omCategory);
        bAddChildToNode(pInfoElement, def_STR_VALUE_NODE, m_ouTestSetupHeader.m_sEngineerInfo2.m_omValue);
    }
    pIDomHeaderNode->appendChild(pInfoElement);

    //Bus Type
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_DBPATH_NODE));
    bAddChildToNode(pInfoElement, def_STR_DATABASE, m_ouTestSetupHeader.m_omDatabasePath);
    pIDomHeaderNode->appendChild(pInfoElement);


    //Database Path
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_BUS_TYPE));
    if(m_ouTestSetupHeader.m_eBus == CAN)
    {
         omstrTemp = "CAN";
    }
    pInfoElement->Puttext(_bstr_t(omstrTemp));
    pIDomHeaderNode->appendChild(pInfoElement);
    
    //Report File
    
    pInfoElement   =  pIDOMDoc->createElement(_bstr_t(def_STR_REPORT_NODE));

    

    if (pInfoElement != NULL)
    {
        switch(m_ouTestSetupHeader.m_sReportFile.m_eType)
        {
            case HTM:
                omstrTemp = "HTM";
                break;
            case TXT:
            default:
                omstrTemp = "TXT";
                break;
        };

        if(m_ouTestSetupHeader.m_sReportFile.m_omPath == "")
        {
            CString omReportPath(omStrFilePath);
            int nIndex = omReportPath.Find(".xml");
            omReportPath.Delete(nIndex, 4);

            CFile omFile(omStrFilePath,  CFile::modeRead);
            CString omReportName = omFile.GetFileTitle() + _T(".") + omstrTemp;
            omReportPath += omReportName;
            m_ouTestSetupHeader.m_sReportFile.m_omPath = omReportPath;
        }
        //Report Path
        bAddChildToNode(pInfoElement, def_STR_PATH_NODE, m_ouTestSetupHeader.m_sReportFile.m_omPath);
        //Extension
        bAddChildToNode(pInfoElement, def_STR_FORMAT_NODE, omstrTemp);

        switch(m_ouTestSetupHeader.m_sReportFile.m_eType)
        {
            case ABS:
                omstrTemp = "ABS";
                break;
            case REL:
            default:
                omstrTemp = "REL";
                break;
        }
        //Time
        bAddChildToNode(pInfoElement, def_STR_TIMEMODE_NODE, omstrTemp);
    }
    pIDomHeaderNode->appendChild(pInfoElement);
    
    return 0;
}