2013-01-10 19 views

回答

11

您需要查看該項目的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限定的枚舉,幷包含有以下標誌集合:

  • - 該項未鎖定。
  • CheckedOut - 該物品已檢出。這可能意味着臨時(編輯)鎖定,永久鎖定(用戶執行的顯式檢出)或工作流程鎖定。
  • 永久 - 該項目被永久檢出,即使用顯式檢出操作。
  • NewItem - 該項目是一個新項目,即它已創建,但尚未首次簽入。
  • InWorkflow - 該項目位於工作流程中。
+0

@克里斯...感謝它的LockType以及它會返回,因爲我想這兩個細節結帳以及用戶信息 –

+0

回答更新上述 –

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; 
} 
+0

的鎖定類型值實際上是按位值,也可以有標誌'鎖定類型.LockType.Checkout「旁邊的」永久「設置。後一個if語句應該是: if((itemInfo.LockType.Value&LockType.CheckedOut)== LockType.CheckedOut) { itemDetails.Add(true,itemInfo.CheckOutUser.Title); }' –

+0

LockType.CheckedOut似乎被LockType.Reserved取代。如果一個項目是LockType.Reserved,則CheckOutUser是空的,即使該項目也設置爲LockType.CheckOut。 –

+0

這意味着Manoj代碼中的檢查應該是:if(((objVersion.LockType.Value&LockType.CheckedOut)== LockType.CheckedOut)&&((objVersion.LockType.Value&LockType.Reserved)== 0))' –

相關問題