GetListUsingItems with Tridion Core Service 返回的项目比 TOM 多 [英] GetListUsingItems with Tridion Core Service returns more items than TOM

查看:19
本文介绍了GetListUsingItems with Tridion Core Service 返回的项目比 TOM 多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 GetListUsingItems 方法和 Tridion 核心服务获取蓝图项目的所有子项.与在 TOM 中使用旧方法相比,我使用 Core Service 获得了不同的结果(更多).看来我还通过组件链接取回了引用我的源组件的其他组件.我是否缺少核心服务中的过滤器选项?

I want to get all children of a Blueprint item using the GetListUsingItems approach with the Tridion Core Service. I get back different results (more) with the Core Service than with the old way in TOM. It appears I also get back other Components referencing my source Component via a Component Link. Am I missing a filter option in the Core Service?

Tridion 5.3:

Tridion 5.3:

Function GetLocalizedItemNodes(itemUri)
    Dim tridionItem : set tridionItem = tdse.GetObject(itemUri,1) 
    Dim rowFilter : set rowFilter = tdse.CreateListRowFilter()
    call rowFilter.SetCondition("ItemType", GetItemType(itemUri))
    call rowFilter.SetCondition("InclLocalCopies", true)
    Dim usingItemsXml : usingItemsXml = tridionItem.Info.GetListUsingItems(1919, rowFilter)

    Dim domDoc : set domDoc = GetNewDOMDocument()  
    domDoc.LoadXml(usingItemsXml)
    Dim nodeList : set nodeList = domDoc.SelectNodes("/tcm:ListUsingItems/tcm:Item[@CommentToken='LocalCopy']")

    set tridionItem = nothing
    set domDoc = nothing
    set GetLocalizedItemNodes = nodeList
End Function

Tridion 2011 SP1 核心服务:

Tridion 2011 SP1 Core Service:

   private XElement GetLocalizedItems(string itemUri)
    {
        XElement usingXML = null;
        try
        {
            CoreServiceClient client = new CoreServiceClient();
            client.ClientCredentials.Windows.ClientCredential.UserName = ConfigurationManager.AppSettings["impersonationUser"].ToString(); // "administrator";
            client.ClientCredentials.Windows.ClientCredential.Password = ConfigurationManager.AppSettings["impersonationPassword"].ToString();
            client.ClientCredentials.Windows.ClientCredential.Domain = ConfigurationManager.AppSettings["impersonationDomain"].ToString();

            // original code from http://www.tridiondeveloper.com/getting-used-items-using-the-core-service
            // Create a filter
            UsingItemsFilterData usingItemsFilterData = new UsingItemsFilterData
            {
                BaseColumns = ListBaseColumns.IdAndTitle, // to specify the detail in the XML
                IncludeLocalCopies = true,
                ItemTypes = new[] { ItemType.Component }
            };
            // Get the XML by calling .GetListXml on the client (assumes you have a 'client' object already)
            usingXML = client.GetListXml(itemUri, usingItemsFilterData);

        }
        catch (Exception ex)
        {
            throw;
        }
        return usingXML;
    }

推荐答案

你应该使用 BluePrintChainFilterData :

BluePrintChainFilterData filter = new BluePrintChainFilterData();
filter.Direction = BluePrintChainDirection.Down;
var result = ClientAdmin.GetListXml("tcm:3-1905", filter);

请注意,您可以指定方向属性.但是,此过滤器不会向您显示共享的项目.另外,尽量避免使用 UsingItemsFilterData,因为它对数据库很重

Please note that you can specify Direction property. This filter, however will not show you shared items. Also, try to avoid using UsingItemsFilterData as it is heavy on database

如果您还想包含共享项目,则可以使用 BluePrintFilterData:

If you want to include shared items as well, then you can use BluePrintFilterData:

BluePrintFilterData filter = new BluePrintFilterData();
filter.ForItem = new LinkToRepositoryLocalObjectData{ IdRef = "tcm:3-1905"};
var listXml = ClientAdmin.GetSystemWideListXml(filter);
var list = ClientAdmin.GetSystemWideList(filter);

您可以在此处指定 ForItem 属性来设置您的项目.它会返回如下内容:

You can specify ForItem property here to set your item. It will return you something like this:

<tcm:ListBluePrintNodes Managed="1" xmlns:tcm="http://www.tridion.com/ContentManager/5.0" xmlns:xlink="http://www.w3.org/1999/xlink">
  <tcm:BluePrintNode ID="tcm:0-3-1" Title="Test" Icon="T1L0P0">
    <tcm:Item ID="tcm:3-1905" Title="Test multimedia component" ItemType="16" IsShared="False" IsLocalized="False" IsPublished="False" LockType="0" LockUser="tcm:0-0-0" Icon="T16L0P0Mgif"></tcm:Item>
  </tcm:BluePrintNode>
  <tcm:BluePrintNode ID="tcm:0-172-1" Title="test_child" Icon="T1L0P0">
    <tcm:Parents>
      <tcm:Parent xlink:href="tcm:0-3-1" xlink:title="Test" Priority="1"></tcm:Parent>
    </tcm:Parents>
    <tcm:Item ID="tcm:172-1905" Title="Test multimedia component" ItemType="16" IsShared="True" IsLocalized="False" IsPublished="False" LockType="0" LockUser="tcm:0-0-0" Icon="T16L0P0Mgif"></tcm:Item>
  </tcm:BluePrintNode>
</tcm:ListBluePrintNodes>

系统范围列表的好处是您可以使用 GetSystemWideList 方法返回 BluePrintNodeData 对象数组,而不是 XML

The good thing about system wide list is that you can use GetSystemWideList method that will return you array of BluePrintNodeData objects instead of XML

这篇关于GetListUsingItems with Tridion Core Service 返回的项目比 TOM 多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆