我想编写一个小函数来检查传递的Item对象是否在Tridion中结帐,如果是,那么它将返回“true”并且我还想获得使用Tridion 2011核心结账的用户的详细信息服务。
我知道我们TryCheckout
中有Checkout
和CoreServiceClient
,但它只返回可识别对象。
答案 0 :(得分:11)
您需要查看项目上的LockType。考虑做这样的事情
SessionAwareCoreService2010Client client = new SessionAwareCoreService2010Client();
ComponentData data = (ComponentData)client.Read("tcm:300-85609", new ReadOptions());
FullVersionInfo info = (FullVersionInfo)data.VersionInfo;
完整版本信息包含您需要的所有信息(即CheckOutUser和LockType)。 LockType是由Tridion.ContentManager.Data.ContentManagement.LockType定义的枚举,包括以下标志集:
答案 1 :(得分:0)
下面是获取ItemCheckout详情的示例代码,其中包含用户详细信息。
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;
}