void CTransformationsDialog::AddOptionToPropetryEditor(
			MSXML2::IXMLDOMElementPtr & option_element,
			MSXML2::IXMLDOMElementPtr & transformation_element,
			CPropertyEditor & property_editor)
{
    CString option_type = (LPCTSTR) option_element->nodeName;
    CString variable_name = (LPCTSTR) (_bstr_t) option_element->getAttribute("variable_name");
    CString value_query_str; //dotaz na default value
    value_query_str.Format("visualization_values/variable[@name=\"%s\"]/@value", (LPCTSTR) variable_name);
	
	CString value;
	try
	{
		value = (LPCTSTR) transformation_element->selectSingleNode((LPCTSTR) value_query_str)->text;
	}
	catch (_com_error &)
	{
		CString err_msg;
		err_msg.Format("Value of variable \"%s\" is missing.", variable_name);
		throw err_msg;
	}

        
    if (option_type == "enum_option")
    {
		//enum

		property_editor.AddProperty(
		  CreateEnumProperty(option_element, value));

    }
    else if (option_type == "string_option")
    {
      //string
      
      property_editor.AddProperty(new CStringProperty(
        (_bstr_t) option_element->getAttribute("title"),  //label
        value));  //default value
    }
    else if (option_type == "color_option")
    {
      //color
      
      property_editor.AddProperty(new CColorProperty(
        (_bstr_t) option_element->getAttribute("title"),  //label
        value));  //default value
    }
    else if (option_type == "number_option")
    {
      if ((_bstr_t) option_element->getAttribute("num_type") == _bstr_t("float"))
      {
        //float

		  property_editor.AddProperty(
			  CreateDoubleProperty(option_element, value));
      }
      else if ((_bstr_t) option_element->getAttribute("num_type") == _bstr_t("integer"))
      {
        //integer
		  
  		  property_editor.AddProperty(
			  CreateIntProperty(option_element, value));
  
      }
    }
}
// InitSourcesTab
BOOL CDataSourcesManager::initSourcesTab(LPCTSTR config_file_path)
{
	CString FName;	// jmeno (cesta) ke konfig. souboru
	FName = config_file_path;
	BSTR FileName = FName.AllocSysString();

   // nacteni konfiguracniho souboru zdroju

	MSXML2::IXMLDOMDocumentPtr pXMLDom;  // koren XML stromu
	MSXML2::IXMLDOMElementPtr pNode;	// korenovy element
	MSXML2::IXMLDOMNodeListPtr pChildren;  // seznam podelementu korenoveho elementu
	MSXML2::IXMLDOMElementPtr pChild;	//  podelement korenoveho elementu

    int i = 0;	// indexova promenna
	_variant_t  Atr_val;	// textova hodnota atributu
	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 souboru
	if ( pXMLDom->load((LPCTSTR) FName) == VARIANT_TRUE)
    {
		pNode = pXMLDom->GetdocumentElement();
		if (pNode != NULL)
		{
			if (pNode->baseName == (_bstr_t) "SOURCES_LIST") // spravny nazev korenoveho elementu
			{
				pChildren = pNode->childNodes;	// ziskani seznamu potomku
				pChild = NULL;
				while((pChild = pChildren->nextNode()) != NULL)  // zpracovavaji se potomci
				{
					if(pChild->baseName == (_bstr_t) "SOURCE")  // definice polozky v tabulce zdroju
					{
						// pridani prvku do tabulky zdroju
						SourcesTab.Add(new CSourceRec);
							// PUBLIC_ID
						Atr_val = pChild->getAttribute("PUBLIC_ID");
						if(Atr_val.vt != VT_NULL)
							SourcesTab[i]->PublicID = (BSTR) (_bstr_t) Atr_val;
							// PERZISTENT_ID
						Atr_val = pChild->getAttribute("PERZISTENT_ID");
						if(Atr_val.vt != VT_NULL)
							SourcesTab[i]->PerzistID = (BSTR) (_bstr_t) Atr_val;

							// PLUGIN_ID
						Atr_val = pChild->getAttribute("PLUGIN_ID");
						if(Atr_val.vt != VT_NULL)
							SourcesTab[i]->PluginID = (BSTR) (_bstr_t) Atr_val;

						i++;
					}
				}
			}


			//dedek: nacteni default source

			MSXML2::IXMLDOMElementPtr el_default_source = pNode->selectSingleNode("DEFAULT_SOURCE");
			if (el_default_source)
				setDefaultSource((public_source_id_t) (LPCTSTR) (_bstr_t) el_default_source->getAttribute("PUBLIC_ID"));



		}
	}

	SysFreeString(FileName);
	pXMLDom.Release();

	// nastaveni odkazu na tabulku zasuvek prvkum z tabulky zdroju
	
	for(int j=0; j<= SourcesTab.GetUpperBound(); j++)	// pres polozky v tabulce zdroju
	{
		for(int k=0; k<=PlugsTab.GetUpperBound(); k++)
		{
			if(SourcesTab[j]->PluginID == PlugsTab[k].PluginName)
			{
				SourcesTab[j]->PluginIndex = k;	// nastaveni indexu v tabulce zasuvek
				break;
			}
		}
		
	}

	return TRUE;
}
예제 #3
0
BOOL CVoucherFile::LoadXml(const CString& strFileName, VoucherFileInfo &voucherInfo)
{	
	CString strFullPath = strFileName;
	BOOL bRet = FALSE;
	try
	{
		voucherInfo.Reset();

		::CoInitialize(NULL);
		MSXML2::IXMLDOMDocumentPtr pXmlDoc(__uuidof(MSXML2::DOMDocument));
		MSXML2::IXMLDOMElementPtr pRootNode = NULL;
		CString strTemp;
		
		pXmlDoc->put_async(VARIANT_FALSE);
		pXmlDoc->load(_bstr_t(strFullPath.AllocSysString()));
		pRootNode = pXmlDoc->GetdocumentElement();
		if (pRootNode == NULL)
			return FALSE;

		// 错误类型
		MSXML2::IXMLDOMElementPtr pNode = pRootNode->selectSingleNode(_T("error"));
		if (pNode != NULL)
		{
			voucherInfo.strError = _GetNodeText(pNode);
		}

		// 模型信息
		pNode = pRootNode->selectSingleNode(_T("model"));
		if (pNode != NULL)
		{
			// 版本
			MSXML2::IXMLDOMElementPtr pChildNode = pNode->selectSingleNode(_T("version"));
			if (pChildNode != NULL)
				voucherInfo.strModelVersion = _GetNodeText(pChildNode);

			// 日期
			pChildNode = pNode->selectSingleNode(_T("date"));
			if (pChildNode != NULL)
				voucherInfo.strModelDate = _GetNodeText(pChildNode);

			// 时间
			pChildNode = pNode->selectSingleNode(_T("time"));
			if (pChildNode != NULL)
				voucherInfo.strModelTime = _GetNodeText(pChildNode);

			// 大小
			pChildNode = pNode->selectSingleNode(_T("size"));
			if (pChildNode != NULL)
				voucherInfo.strModelSize = _GetNodeText(pChildNode);
		}
		
		// 用户列表
		MSXML2::IXMLDOMElementPtr pUserNode = pRootNode->selectSingleNode(_T("nodeinfo"));
		if (pUserNode != NULL)
		{
			CString strText;
			MSXML2::IXMLDOMNodeListPtr pList = pUserNode->selectNodes(_bstr_t("username"));
			if (pList != NULL)
			{
				int nUserCount = pList->Getlength();
				for(int i = 0; i < nUserCount; i++)
				{
					MSXML2::IXMLDOMNodePtr pChiledNode = pList->Getitem(i);
					if (pChiledNode != NULL)
					{
						strText = _GetNodeText(pChiledNode);
						voucherInfo.vecUser.push_back(strText);
					}
				}
			}
		}
		bRet = TRUE;
	}
	catch (...)
	{
		bRet = FALSE;
	}
	return bRet;
}
예제 #4
0
void ConfigReader::Initialise()
{
	MSXML2::IXMLDOMDocument2Ptr spConfigXML = ValidateConfigXML();
	MSXML2::IXMLDOMElementPtr spRootElement = spConfigXML->documentElement;
	if(spRootElement == 0)
		throw Workshare::Exception(_T("Failed to get the root element of the config xml file."));

	_bstr_t testOption = spRootElement->selectSingleNode(_T("TestOptions/DismissUI"))->text;
	m_dismissUI = (0 == _tcsicmp(_T("true"), (LPCTSTR)testOption));

	testOption = spRootElement->selectSingleNode(_T("TestOptions/ShowInfo"))->text;
	m_showInfo = (0 == _tcsicmp(_T("true"), (LPCTSTR)testOption));

	testOption = spRootElement->selectSingleNode(_T("TestOptions/SupportsVersions"))->text;
	m_supportsVersions = (0 == _tcsicmp(_T("true"), (LPCTSTR)testOption));

	testOption = spRootElement->selectSingleNode(_T("TestOptions/SupportsDrafts"))->text;
	m_supportsDrafts = (0 == _tcsicmp(_T("true"), (LPCTSTR)testOption));

	m_openDialogCancelId = _wtoi(spRootElement->selectSingleNode(_T("TestOptions/OpenDialog/@cancelId"))->text);
	m_openDialogTitle = spRootElement->selectSingleNode(_T("TestOptions/OpenDialog/@title"))->text;

	m_createDialogCancelId = _wtoi(spRootElement->selectSingleNode(_T("TestOptions/CreateDialog/@cancelId"))->text);
	m_createDialogTitle = spRootElement->selectSingleNode(_T("TestOptions/CreateDialog/@title"))->text;

	m_textEditorCancelId = _wtoi(spRootElement->selectSingleNode(_T("TestOptions/TextEditor/@cancelId"))->text);
	m_textEditorTitle = spRootElement->selectSingleNode(_T("TestOptions/TextEditor/@title"))->text;

	MSXML2::IXMLDOMNodePtr spConnectorType = spRootElement->selectSingleNode(_T("Connector/@type"));
	if(spConnectorType == 0)
		throw Workshare::Exception(_T("Failed to get the connector type from the config xml file."));

	m_type = spConnectorType->text;
	m_progIDOrModule = spRootElement->selectSingleNode(_T("Connector/@progIDOrModule"))->text;

	m_repositoryId = spRootElement->selectSingleNode(_T("Connector/Repository/@repositoryId"))->text;

	m_artifactId = spRootElement->selectSingleNode(_T("Connector/Repository/Artifact/ArtifactId"))->text;
	m_artifactName = spRootElement->selectSingleNode(_T("Connector/Repository/Artifact/Name"))->text;
	m_artifactFileExtension = spRootElement->selectSingleNode(_T("Connector/Repository/Artifact/FileExtension"))->text;
	m_artifactVersionLabel = spRootElement->selectSingleNode(_T("Connector/Repository/Artifact/VersionLabel"))->text;

	m_relatedArtifactId = spRootElement->selectSingleNode(_T("Connector/Repository/Artifact/RelatedArtifact/ArtifactId"))->text;
	m_relatedArtifactVersionLabel = spRootElement->selectSingleNode(_T("Connector/Repository/Artifact/RelatedArtifact/VersionLabel"))->text;
}
예제 #5
0
BOOL CIconImgList::LoadGroups( MSXML2::IXMLDOMDocumentPtr& piDocument)
{
    // グループの追加処理
    MSXML2::IXMLDOMElementPtr piRoot;
    piRoot = piDocument->GetdocumentElement();
    if( NULL == piRoot)
    {
        return FALSE;
    }

    MSXML2::IXMLDOMElementPtr piGroups;
    piGroups = piRoot->selectSingleNode( _bstr_t( _T( "GROUPS")));
    if( NULL == piGroups)
    {
        return FALSE;
    }

    m_nGroupCount = GetGroupCount( piGroups);
    if( 0 < m_nGroupCount)
    {
        int nParent = 0;
        m_astGroupData = new GROUPDATA*[ m_nGroupCount];
        ZeroMemory( m_astGroupData, sizeof( GROUPDATA*) * m_nGroupCount);

        PickUpGroups( piGroups, nParent);
        /*
        _bstr_t cBstrName;
        BOOL blEnable;

        MSXML2::IXMLDOMElementPtr piGroup;
        _bstr_t cBstr;
        _variant_t cVariant;
        TCHAR szWork[ 32];

        for( int nIndex = 0; nIndex < m_nGroupCount; nIndex++)
        {
        	wsprintf( szWork, _T( "//GROUP[@ID='%d']"), nIndex + 1);
        	piGroup = piRoot->selectSingleNode( _bstr_t( szWork));
        	if( NULL == piGroup)
        	{
        		continue;
        	}

        	cBstrName = piGroup->getAttribute( _bstr_t( _T( "TITLE")));

        	cVariant = piGroup->getAttribute( _bstr_t( _T( "ENABLE")));
        	VariantChangeType( &cVariant, &cVariant, 0, VT_BOOL);
        	blEnable = ( VARIANT_FALSE == cVariant.boolVal) ? FALSE : TRUE;

        	if( 0 >= cBstrName.length())cBstrName = _T( "new group!");

        	m_astGroupData[ nIndex] = ( GROUPDATA*)malloc( sizeof( GROUPDATA) + ( sizeof( TCHAR) * ( cBstrName.length() + 1)));
        	if( NULL != m_astGroupData[ nIndex])
        	{
        		m_astGroupData[ nIndex]->nParent = nParent;
        		if( 1 <= nParent)
        		{
        			if( FALSE == m_astGroupData[ nParent - 1]->blEnable)
        			{
        				blEnable = FALSE;
        			}
        		}
        		m_astGroupData[ nIndex]->blEnable = blEnable;
        		lstrcpy( m_astGroupData[ nIndex]->szName, cBstrName);
        	}
        }*/
    }
    return TRUE;
}
예제 #6
0
BOOL CIconImgList::LoadIcons( MSXML2::IXMLDOMDocumentPtr& piDocument)
{
    BOOL blResult = FALSE;

    MSXML2::IXMLDOMElementPtr piRoot;
    piRoot = piDocument->GetdocumentElement();
    if( NULL == piRoot)
    {
        return FALSE;
    }

    MSXML2::IXMLDOMElementPtr piGroups;
    piGroups = piRoot->selectSingleNode( _bstr_t( _T( "GROUPS")));


    MSXML2::IXMLDOMElementPtr piIcons;
    piIcons = piRoot->selectSingleNode( _bstr_t( _T( "ICONS")));
    if( NULL == piIcons)
    {
        return FALSE;
    }

    MSXML2::IXMLDOMNodeListPtr piIconsList;
    piIconsList = piIcons->GetchildNodes();
    if( NULL == piIconsList)
    {
        return FALSE;
    }

    long lIconsCount;
    lIconsCount = piIconsList->Getlength();
    if( 0 >= lIconsCount)
    {
        return FALSE;
    }

    m_nCountExtend = lIconsCount;
    if( 0 < m_nCountExtend)
    {
        m_astIconStatus = new ICONSTATUS[ m_nCountExtend];
        if( NULL != m_astIconStatus)
        {
            /*
            ZeroMemory( m_astIconStatus, sizeof( ICONSTATUS) * m_nCountExtend);
            */
            for( int nIndex = 0; nIndex < m_nCountExtend; nIndex++)
            {
                m_astIconStatus[ m_nEnableCount].nID = 0;
                m_astIconStatus[ m_nEnableCount].blEnable = FALSE;
                m_astIconStatus[ m_nEnableCount].nParent = 0;
                m_astIconStatus[ m_nEnableCount].nPosition = 0;
                m_astIconStatus[ m_nEnableCount].cStrIconName.Empty();
            }

            int nHeight = ( m_nCountExtend / 10) + ( ( m_nCountExtend % 10) ? 1 : 0);

            m_hBmpExtend = ::CreateBitmap( _ICON_WIDTH * 10, _ICON_HEIGHT * nHeight, 1, 1, NULL);
            HDC hExtDC = ::CreateCompatibleDC( NULL);
            HDC hDefDC = ::CreateCompatibleDC( NULL);
            HDC hWorkDC = ::CreateCompatibleDC( NULL);
            HBITMAP hOldExtBmp = ( HBITMAP)::SelectObject( hExtDC, m_hBmpExtend);
            HBITMAP hOldDefBmp = ( HBITMAP)::SelectObject( hDefDC, m_hBmpDefault);

            m_nEnableCount = 0;
            CString cStrEntry;
            LPBYTE lpabyData;
            TCHAR szWork[ 64];
            MSXML2::IXMLDOMElementPtr piIcon;
            MSXML2::IXMLDOMElementPtr piImage;
            MSXML2::IXMLDOMElementPtr piParent;
            _variant_t cVariant;
            _bstr_t cBstr;
            CString strTitle;
            for( int nIndex = 0; nIndex < m_nCountExtend; nIndex++)
            {
                cVariant = VARIANT_TRUE;
                if( NULL != piGroups)
                {
                    wsprintf( szWork, _T( "//ITEM[@REF='%d']"), nIndex + 1);
                    piIcon = piGroups->selectSingleNode( _bstr_t( szWork));
                    if( NULL != piIcon)
                    {
                        cVariant = piIcon->getAttribute( _bstr_t( _T( "ENABLE")));
                        if( cVariant.vt != VT_NULL)
                        {
                            VariantChangeType( &cVariant, &cVariant, 0, VT_BOOL);
                        }
                        else
                        {
                            cVariant = VARIANT_TRUE;
                        }
                    }
                }

                if( VARIANT_FALSE != cVariant.boolVal)
                {
                    wsprintf( szWork, _T( "//ICON[@ID='%d']"), nIndex + 1);
                    piIcon = piRoot->selectSingleNode( _bstr_t( szWork));
                    if( NULL == piIcon)
                    {
                        continue;
                    }

                    cVariant = piIcon->getAttribute( _bstr_t( _T( "TITLE")));
                    if( cVariant.vt != VT_NULL)
                    {
                        strTitle = cVariant;
                    }
                    else
                    {
                        strTitle = _T( "NoTitle");
                    }

                    piImage = piIcon->selectSingleNode( _bstr_t( _T( "IMAGE")));
                    if( NULL == piImage)
                    {
                        continue;
                    }
                    cBstr = piImage->Gettext();
                    int nSize = Base64Decode( NULL, 0, cBstr);
                    lpabyData = new BYTE [ nSize];
                    Base64Decode( lpabyData, nSize, cBstr);

                    HBITMAP hWork = ::CreateBitmap( _ICON_WIDTH, _ICON_HEIGHT, 1, 1, lpabyData);

                    delete [] lpabyData;

                    HBITMAP hOldWorkBmp = ( HBITMAP)::SelectObject( hWorkDC, hWork);
                    ::BitBlt( hExtDC, ( nIndex % 10) * _ICON_WIDTH, ( nIndex / 10) * _ICON_HEIGHT, _ICON_WIDTH, _ICON_HEIGHT, hWorkDC, 0, 0, SRCCOPY);
                    ::SelectObject( hWorkDC, hOldWorkBmp);
                    ::DeleteObject( hWork);
                    m_astIconStatus[ m_nEnableCount].nID = nIndex;
                    m_astIconStatus[ m_nEnableCount].blEnable = TRUE;
                    m_astIconStatus[ m_nEnableCount].cStrIconName = strTitle;

                    m_nEnableCount++;
                    continue;
                }
                ::BitBlt( hExtDC, ( nIndex % 10) * _ICON_WIDTH, ( nIndex / 10) * _ICON_HEIGHT, _ICON_WIDTH, _ICON_HEIGHT, hDefDC, ( COUNT_DEFAULTICON) * _ICON_WIDTH, 0, SRCCOPY);
            }

            ::SelectObject( hExtDC, hOldExtBmp);
            ::SelectObject( hDefDC, hOldDefBmp);

            ::DeleteDC( hExtDC);
            ::DeleteDC( hDefDC);
            ::DeleteDC( hWorkDC);

            m_astIconStatus4Menu = new ICONSTATUS*[ m_nEnableCount];
            if( m_astIconStatus4Menu)
            {
                for( int nIndex = 0; nIndex < m_nEnableCount; nIndex++)
                {
                    m_astIconStatus4Menu[ nIndex] = &m_astIconStatus[ nIndex];
                }
                qsort( m_astIconStatus4Menu, m_nEnableCount, sizeof( ICONSTATUS*), IconCompare);

                blResult = TRUE;
            }
        }
    }

    return blResult;
}