渡されたアイテム オブジェクトが Tridion でチェックアウトされているかどうかをチェックする小さな関数を書きたいと思います。そうであれば、「true」を返します。また、Tridion 2011 コア サービスを使用して、アイテムをチェックアウトしたユーザーの詳細を取得したいと考えています。
私たちと同じように持っていることは知っていますTryCheckout
が、識別可能なオブジェクトのみを返します。Checkout
CoreServiceClient
渡されたアイテム オブジェクトが Tridion でチェックアウトされているかどうかをチェックする小さな関数を書きたいと思います。そうであれば、「true」を返します。また、Tridion 2011 コア サービスを使用して、アイテムをチェックアウトしたユーザーの詳細を取得したいと考えています。
私たちと同じように持っていることは知っています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)。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;
}