我必须创建一个自定义页面,其中包含所有页面的列表及其在出版物中的发布日期。有人可以指导我如何使用此代码在自定义页面中获取发布日期吗?
private ItemType GetTridionItemType(RepositoryLocalObjectData source)
{
string itemType = source.GetType().Name;
switch (itemType)
{
case "PageData":
return ItemType.Page;
}
return ItemType.UnknownByClient;
}
private string CreateNewItemCopy(string title, RepositoryLocalObjectData source,
string filename)
{
ItemType tridionItemType = GetTridionItemType(source);
string orgItemUri = source.LocationInfo.OrganizationalItem.IdRef;
var newItem = client.Copy(source.Id, orgItemUri, true, new ReadOptions());
newItem.Title = title;
if (tridionItemType == ItemType.Page)
{
PageData pageData = newItem as PageData;
pageData.FileName = filename;
client.Update(pageData, new ReadOptions());
}
else
{
client.Update(newItem, new ReadOptions());
}
return newItem.Id;
}
答案 0 :(得分:5)
我们可以从coreservice获取发布信息
TridionGeneration Generation = new TridionGeneration();
Generation.Settings = GetImportSetting();
var objclient = new CoreService2010Client();
objclient.ClientCredentials.Windows.ClientCredential.UserName = Generation.Settings.Username;
objclient.ClientCredentials.Windows.ClientCredential.Password = Generation.Settings.Password;
objclient.Open();
Generation.client = objclient;
![enter image description here][1]
var objectList = Generation.client.GetListPublishInfo([object tcm uri]);
答案 1 :(得分:3)
PublishEngine.GetPublishInfo返回项目的发布信息。其中包含发布日期。 (PublishInfo.PublishedAt)。
您还可以使用CoreService.GetListPublishInfo。