/******************************************************************************
Function Name  :  SetData
Input(s)       :  MSXML2::IXMLDOMElementPtr& pIDomVerifyNode
Output         :  HRESULT
Functionality  :  Creates the XML file with pIDomVerifyNode
Member of      :  CVerify_MessageEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam, GT-Derka
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
HRESULT CVerify_MessageEntity::SetData(MSXML2::IXMLDOMElementPtr& pIDomVerifyNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");

    MSXML2::IXMLDOMElementPtr pChildElement, pSubElement;

    if (pIDOMDoc != nullptr)
    {
        pChildElement   =  pIDOMDoc->createElement(_bstr_t(_(def_STR_VERIFYMSG_NODE)));

        MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TCATTRIB_ID);
        if(pIDomTSAtrrib!= nullptr)
        {
            pIDomTSAtrrib->value = _bstr_t(m_ouData.m_dwMessageID);
            pChildElement->setAttributeNode(pIDomTSAtrrib);
        }

        pIDomTSAtrrib = pIDOMDoc->createAttribute(_(def_STR_TCATTRIB_UNIT));
        if(pIDomTSAtrrib!= nullptr)
        {
            switch(m_ouData.m_eSignalUnitType)
            {
                case ENG:
                    omstrTemp = "ENG";
                    break;
                default:
                case RAW:
                    omstrTemp = "RAW";
                    break;
            }
            pIDomTSAtrrib->value = _bstr_t(omstrTemp);
            pChildElement->setAttributeNode(pIDomTSAtrrib);
        }

        pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TCATTRIB_CHANNEL);
        if(pIDomTSAtrrib!= NULL)
        {
            pIDomTSAtrrib->value = _bstr_t(m_ouData.m_byChannelNumber);
            pChildElement->setAttributeNode(pIDomTSAtrrib);
        }

        INT lCount = (INT)m_ouData.m_odSignalConditionList.GetCount();
        for(INT i =0; i<lCount; i++)
        {
            POSITION pos = m_ouData.m_odSignalConditionList.FindIndex(i);
            CSignalCondition& ouSignalData = m_ouData.m_odSignalConditionList.GetAt(pos);
            pSubElement   =  pIDOMDoc->createElement(_bstr_t(_(def_STR_SIGNAL_NODE)));
            pIDomTSAtrrib = pIDOMDoc->createAttribute(_(def_NAME_NODE));
            pIDomTSAtrrib->value = _bstr_t(ouSignalData.m_omSigName);
            pSubElement->setAttributeNode(pIDomTSAtrrib);
            pSubElement->Puttext(_bstr_t(ouSignalData.m_omCondition));
            pChildElement->appendChild(pSubElement);
        }
        pIDomVerifyNode->appendChild(pChildElement);
    }
    return S_OK;
}
示例#2
0
/******************************************************************************
Function Name  :  SetData
Input(s)       :
Output         :  HRESULT
Functionality  :
Member of      :  CVerifyResponse
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
HRESULT CVerifyResponse::SetData(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    INT lCount = (INT)m_ouData.m_odVerify_MessageEntityList.GetCount();
    MSXML2::IXMLDOMElementPtr pIDomSendNode =  pIDOMDoc->createElement(_bstr_t(def_STR_VERIFYRES_NODE));
    MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_ATTRIB_FAIL);

    if(pIDomTSAtrrib!= NULL)
    {
        switch(m_ouData.m_eAttributeError)
        {
            case SUCCESS:
                omstrTemp = "SUCCESS";
                break;

            case WARNING:
                omstrTemp = "WARNING";
                break;

            case FATAL:
                omstrTemp = "FATAL";
                break;

            case ERRORS:
            default:
                omstrTemp = "ERRORS";
                break;
        }

        pIDomTSAtrrib->value = _bstr_t(omstrTemp);
        pIDomSendNode->setAttributeNode(pIDomTSAtrrib);
    }

    MSXML2::IXMLDOMAttributePtr pIDomTSAtrribWait = pIDOMDoc->createAttribute(def_STR_ATTRIB_WAITFOR);

    if(pIDomTSAtrribWait!= NULL)
    {
        CString omstrWaitFor;
        omstrWaitFor.Format("%d", m_ushDuration);
        pIDomTSAtrribWait->value = _bstr_t(omstrWaitFor);
        pIDomSendNode->setAttributeNode(pIDomTSAtrribWait);
    }

    for(INT i=0; i<lCount; i++)
    {
        POSITION pos = m_ouData.m_odVerify_MessageEntityList.FindIndex(i);
        CVerify_MessageEntity& ouVerifyMsgEntity = m_ouData.m_odVerify_MessageEntityList.GetAt(pos);
        ouVerifyMsgEntity.SetData(pIDomSendNode);
    }

    pIDomTestCaseNode->appendChild(pIDomSendNode);
    return S_OK;
}
/******************************************************************************
Function Name  :  SetData
Input(s)       :  MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode
Output         :  HRESULT
Functionality  :   
Member of      :  CTestCaseEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :  
******************************************************************************/
HRESULT CTestCaseEntity::SetData(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");
    
    MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TCATTRIB_ID);
    if(pIDomTSAtrrib!= NULL)
	{
        pIDomTSAtrrib->value = _bstr_t(m_ouData.m_omID);
		pIDomTestCaseNode->setAttributeNode(pIDomTSAtrrib);
	}

    pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TCATTRIB_TITLE);
    if(pIDomTSAtrrib!= NULL)
	{
        pIDomTSAtrrib->value = _bstr_t(m_ouData.m_omTitle);
		pIDomTestCaseNode->setAttributeNode(pIDomTSAtrrib);
	}

    pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_TCATTRIB_H_EXP);
    if(pIDomTSAtrrib!= NULL)
	{
        switch(m_ouData.m_eExcpAction)
        {
            case EXIT:
                omstrTemp = "EXIT";
                break;
            case CONTINUE:
            default:
                omstrTemp = "CONTINUE";
                break;
        }
        pIDomTSAtrrib->value = _bstr_t(omstrTemp);
		pIDomTestCaseNode->setAttributeNode(pIDomTSAtrrib);
	}

    INT lCount = (INT)m_ouData.m_odTAEntityList.GetCount();
    for(int i=0; i<lCount;i++)
    {
        POSITION pos = m_ouData.m_odTAEntityList.FindIndex(i);
        CBaseEntityTA* pEntity = m_ouData.m_odTAEntityList.GetAt(pos);
        pEntity->SetData(pIDomTestCaseNode);
    }
    
    
    return 0;
}
示例#4
0
bool XmlIOStreamImp::WriteNodeAttribute(const CString& attrName, const CString& attrValue)
{
	DATA_ASSERT(!mbIsRead);
	if(mbIsRead)
		return false; // Can't write to the read stream.

	DATA_ASSERT(mpCurrentNode != NULL);
	if(NULL == mpCurrentNode)
		return false;

	MSXML2::IXMLDOMDocumentPtr xmlDocument = mpCurrentNode->GetownerDocument();
	if (xmlDocument)
	{
		// Create attribute node
		MSXML2::IXMLDOMAttributePtr attr = xmlDocument->createAttribute((LPCTSTR)attrName);

		VARIANT va;
		va.vt=VT_BSTR;
		va.bstrVal = attrValue.AllocSysString();
		attr->put_value(va);

		mpCurrentNode->attributes->setNamedItem(attr);

		VariantClear(&va);

		return true;
	}

	return false;
}
示例#5
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;
}
示例#6
0
	void CXmlNodeWrapper::SetValue(LPCTSTR valueName,LPCTSTR value)
	{
		MSXML2::IXMLDOMDocumentPtr xmlDocument = m_xmlnode->GetownerDocument();
		if (xmlDocument)
		{
			MSXML2::IXMLDOMNamedNodeMapPtr attributes = m_xmlnode->Getattributes();
			if (attributes)
			{
				MSXML2::IXMLDOMAttributePtr attribute = xmlDocument->createAttribute(valueName);
				if (attribute)
				{
					attribute->Puttext(value);
					attributes->setNamedItem(attribute);
				}
			}
		}
	}
示例#7
0
/******************************************************************************
Function Name  :  SetData
Input(s)       :
Output         :  HRESULT
Functionality  :
Member of      :  CVerifyEntity
Friend of      :  -
Author(s)      :  Venkatanarayana Makam
Date Created   :  06/04/2011
Modifications  :
******************************************************************************/
HRESULT CVerifyEntity::SetData(MSXML2::IXMLDOMElementPtr& pIDomTestCaseNode)
{
    CString omstrTemp;
    MSXML2::IXMLDOMDocumentPtr pIDOMDoc;
    pIDOMDoc.CreateInstance(L"Msxml2.DOMDocument");


    int lCount = m_ouData->m_odVerifySubEntityList.size();
    MSXML2::IXMLDOMElementPtr pIDomSendNode =  pIDOMDoc->createElement(_bstr_t(def_STR_VERIFY_NODE));
    MSXML2::IXMLDOMAttributePtr pIDomTSAtrrib = pIDOMDoc->createAttribute(def_STR_ATTRIB_FAIL);
    if(pIDomTSAtrrib!= NULL)
    {
        switch(m_ouData->m_eAttributeError)
        {
            case SUCCESS:
                omstrTemp = "SUCCESS";
                break;
            case WARNING:
                omstrTemp = "WARNING";
                break;
            case FATAL:
                omstrTemp = "FATAL";
                break;
            case ERRORS:
            default:
                omstrTemp = "ERRORS";
                break;
        }
        pIDomTSAtrrib->value = _bstr_t(omstrTemp);
        pIDomSendNode->setAttributeNode(pIDomTSAtrrib);
    }

    for(INT i=0; i<lCount; i++)
    {
		CVerifySubEntity *pVerifySubEntity = m_ouData->m_odVerifySubEntityList[i];
        pVerifySubEntity->SetData(pIDomSendNode);
    }
    pIDomTestCaseNode->appendChild(pIDomSendNode);
    return S_OK;
}
/******************************************************************************
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;
}
//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;
}