我想使用GetListUsingItems方法和Tridion核心服務獲取Blueprint項目的所有子項。與TOM中的舊方式相比,使用Core Service獲得不同的結果(更多)。看來我也通過一個Component Link取回了引用我的源組件的其他組件。我是否缺少核心服務中的過濾器選項?使用Tridion核心服務的GetListUsingItems返回的項目多於TOM
外表套上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
外表套上2011 SP1核心服務:
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;
}
羅伯特嗨的陣列。它不應該影響你回來的組件的數量(因爲你的源項目是一個組件),但值得注意的是你的R5.3代碼設置了一個'ItemType'行過濾器(這意味着你將只獲得組件回來),但你的核心服務代碼不。這可能會影響您的結果總數,但不會影響組件的數量(如您所描述的那樣)。 – 2012-03-01 12:13:42
我添加了ItemTypes條件,但仍然得到相關的組件和子項。任何其他想法? – robrtc 2012-03-01 12:39:11