我想寫一個小函數來檢查是否通過Item對象在Tridion中籤出,如果是,那麼它將返回「true」並且我也想使用Tridion 2011核心服務獲取已結帳該項目的用戶的詳細信息。如何檢查當前組件是否簽出以及使用tridion coreservices簽出的用戶詳細信息
我知道我們的TryCheckout
以及Checkout
在我們的CoreServiceClient
中,但它僅返回可識別的對象。
我想寫一個小函數來檢查是否通過Item對象在Tridion中籤出,如果是,那麼它將返回「true」並且我也想使用Tridion 2011核心服務獲取已結帳該項目的用戶的詳細信息。如何檢查當前組件是否簽出以及使用tridion coreservices簽出的用戶詳細信息
我知道我們的TryCheckout
以及Checkout
在我們的CoreServiceClient
中,但它僅返回可識別的對象。
您需要查看該項目的LockType。考慮做這樣的事情
SessionAwareCoreService2010Client client = new SessionAwareCoreService2010Client();
ComponentData data = (ComponentData)client.Read("tcm:300-85609", new ReadOptions());
FullVersionInfo info = (FullVersionInfo)data.VersionInfo;
完整版本信息包含您需要的所有信息(即CheckOutUser和LockType)。鎖定類型是由Tridion.ContentManager.Data.ContentManagement.LockType限定的枚舉,幷包含有以下標誌集合:
下面是示例代碼來獲得ItemCheckedout的細節有用戶的詳細信息。
public static Dictionary<bool,string> ItemCheckedOutDetails(string ItemUri, CoreServiceClient client, ReadOptions readOpt, ItemType itemType)
{
Dictionary<bool, string> itemDetails = null;
FullVersionInfo itemInfo = null;
if (itemType == ItemType.Component)
{
// reading the component data
var itemData = (ComponentData)client.Read(ItemUri, readOpt);
itemInfo = (FullVersionInfo)itemData.VersionInfo;
}
else if (itemType == ItemType.Page)
{
// reading the page data
var itemData = (PageData)client.Read(ItemUri, readOpt);
itemInfo = (FullVersionInfo)itemData.VersionInfo;
}
else if (itemType == ItemType.StructureGroup)
{
// reading the structuregroup data
var itemData = (StructureGroupData)client.Read(ItemUri, readOpt);
itemInfo = (FullVersionInfo)itemData.VersionInfo;
}
else if (itemType == ItemType.Publication)
{
// reading the Publication data
var itemData = (PublicationData)client.Read(ItemUri, readOpt);
itemInfo = (FullVersionInfo)itemData.VersionInfo;
}
else if (itemType == ItemType.ComponentTemplate)
{
// reading the component template data
var itemData = (ComponentTemplateData)client.Read(ItemUri, readOpt);
itemInfo = (FullVersionInfo)itemData.VersionInfo;
}
else if (itemType == ItemType.PageTemplate)
{
// reading the Page template data
var itemData = (PageTemplateData)client.Read(ItemUri, readOpt);
itemInfo = (FullVersionInfo)itemData.VersionInfo;
}
else if (itemType == ItemType.MultimediaType)
{
// reading the Multimedia Type data
var itemData = (MultimediaTypeData)client.Read(ItemUri, readOpt);
itemInfo = (FullVersionInfo)itemData.VersionInfo;
}
if (itemInfo != null)
{
if (itemInfo.LockType.Value == LockType.CheckedOut)
{
itemDetails.Add(true, itemInfo.CheckOutUser.Title);
}
}
return itemDetails;
}
的鎖定類型值實際上是按位值,也可以有標誌'鎖定類型.LockType.Checkout「旁邊的」永久「設置。後一個if語句應該是: if((itemInfo.LockType.Value&LockType.CheckedOut)== LockType.CheckedOut) { itemDetails.Add(true,itemInfo.CheckOutUser.Title); }' –
LockType.CheckedOut似乎被LockType.Reserved取代。如果一個項目是LockType.Reserved,則CheckOutUser是空的,即使該項目也設置爲LockType.CheckOut。 –
這意味着Manoj代碼中的檢查應該是:if(((objVersion.LockType.Value&LockType.CheckedOut)== LockType.CheckedOut)&&((objVersion.LockType.Value&LockType.Reserved)== 0))' –
@克里斯...感謝它的LockType以及它會返回,因爲我想這兩個細節結帳以及用戶信息 –
回答更新上述 –