3

我想编写一个小函数来检查传递的项目对象是否在 Tridion 中签出,如果是,那么它将返回“true”,并且我想使用 Tridion 2011 核心服务获取已签出项目的用户的详细信息。

我知道我们和我们的TryCheckout一样CheckoutCoreServiceClient但它只返回可识别对象。

4

2 回答 2

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 定义的枚举,包括以下标志集:

  • - 项目未锁定。
  • CheckedOut - 项目已签出。这可能意味着临时(编辑)锁定、永久锁定(由用户执行的显式签出)或工作流锁定。
  • 永久- 项目永久签出,即使用显式签出操作。
  • NewItem - 该项目是一个新项目,即它已被创建,但尚未首次签入。
  • InWorkflow - 项目在工作流中。
于 2013-01-10T20:43:16.157 回答
0

下面是获取 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;
}
于 2013-01-12T07:39:14.693 回答