Показать сообщение отдельно
Старый 26.06.2014, 21:53   #8  
sukhanchik is offline
sukhanchik
Administrator
Аватар для sukhanchik
MCBMSS
Злыдни
Лучший по профессии 2015
Лучший по профессии AXAWARD 2013
Лучший по профессии 2011
Лучший по профессии 2009
 
3,275 / 3476 (122) ++++++++++
Регистрация: 13.06.2004
Адрес: Москва
Еще одно решение. Подглядел идею в \Classes\SysStartupCmdBuildVisualStudioProjects
Немного подкорректировал:
X++:
/// <summary>
/// Builds a <c>Set</c> object containing node paths to the SSRS Reports that the project references.
/// </summary>
/// <param name="projectNode">
/// The <c>VSProjectNode</c> object.
/// </param>
/// <returns>
/// A <c>Set</c> object containing node paths to the SSRS Reports that the project references.
/// </returns>
private Set getVSProjectNodeReportReferences(VSProjectNode projectNode, str _ssrsName)
{
    Set reportReferences = new Set(Types::String);

    VSProjectFileNode projectFileNode;
    str source, xpath, reportReference;
    int pos, len;

    System.IO.StringReader reader;
    System.Xml.XPath.XPathDocument doc;
    System.Xml.XPath.XPathNavigator navigator, nodeNavigator;
    System.Xml.XPath.XPathExpression expression;
    System.Xml.XPath.XPathNodeIterator nodeIterator;
    System.Xml.XmlNamespaceManager namespaceManager;

    // check for the Project node, the Project Content node and a project file node
    if (projectNode && projectNode.aoTfirstChild() && projectNode.aoTfirstChild().AOTfirstChild())
    {
        projectFileNode = projectNode.aoTfirstChild().AOTfirstChild();
        source = projectFileNode.AOTgetSource();
        len = strLen(source);
        if (len)
        {
            // remove any unwanted characters from the beginning of the string
            pos = strFind(source, @"<", 1, len);
            if (source && pos)
            {
                source = subStr(source, pos, len);
            }

            if (source)
            {
                // load the source into an XPathDocument object and find all report references using xpath select
                reader = new System.IO.StringReader(source);
                doc = new System.Xml.XPath.XPathDocument(reader);
                navigator = doc.CreateNavigator();

                namespaceManager = new System.Xml.XmlNamespaceManager(navigator.get_NameTable());
                namespaceManager.AddNamespace(@"msbuild", @"http://schemas.microsoft.com/developer/msbuild/2003");

                xpath = @"//msbuild:Project/msbuild:ItemGroup/msbuild:Compile/@Include";
                expression = System.Xml.XPath.XPathExpression::Compile(xpath);
                expression.SetContext(namespaceManager);

                nodeIterator = navigator.Select(expression);
                if (nodeIterator)
                {
                    while (nodeIterator.MoveNext())
                    {
                        nodeNavigator = nodeIterator.get_Current();
                        reportReference = nodeNavigator.get_Value();

                        if (reportReference && reportReference == _ssrsName)
                        {
                            reportReferences.add(reportReference);
                        }
                    }
                }
            }
        }
    }

    return reportReferences;
}
X++:
/// <summary>
/// Builds a <c>Map</c> object that whose key is a <c>VSProjectNode</c> object and value is a <c>Set</c> object
/// containing the AOT node paths of the SSRS Reports the project references.
/// </summary>
private void buildDynamicsAXModelProjectToReportsMap(str _ssrsName)
{
    TreeNode treeNode;
    VSProjectNode projectNode;
    Set reportSet;

    // Key is VSProjectNode
    // Value is Set of strings - AOT paths to the SSRS reports used in the project
//    dynamicsAXModelProjectToReportsMap = new Map(Types::Class, Types::Class);

    treeNode = TreeNode::findNode(#VSProjectsAXModelPath);
    if (treeNode)
    {
        projectNode = treeNode.AOTfirstChild();
        while (projectNode)
        {
            reportSet = this.getVSProjectNodeReportReferences(projectNode, _ssrsName);

            if (reportSet && reportSet.elements() > 0)
            {

                info(projectNode.name());
//                dynamicsAXModelProjectToReportsMap.insert(projectNode, reportSet);
            }

            projectNode = projectNode.aoTnextSibling();
        }
    }
}
Вызов:
X++:
    this.buildDynamicsAXModelProjectToReportsMap(#SSRSReportsPath + '\\' + 'VendInvoice');
__________________
Возможно сделать все. Вопрос времени
За это сообщение автора поблагодарили: mazzy (5), trud (3).