-1

I have to create a custom page having list of all pages with its published date within a publication. Can someone guide me how to use this code to get published date in custom page?

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;
}
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
AmateurCoder
  • 4,272
  • 3
  • 17
  • 31
  • 1
    The code you post seems hardly relevant to the question you are asking. – Frank van Puffelen Sep 03 '12 at 12:49
  • Have a look at this question too: http://stackoverflow.com/questions/10092156/how-to-get-the-published-timestamp-of-a-page-or-component-using-sdl-tridion-tom . It uses a different API, but it should allow you to get started. – Frank van Puffelen Sep 03 '12 at 12:51

2 Answers2

5

We can get the publish info from 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;
           

            var objectList = Generation.client.GetListPublishInfo([object tcm uri]);

dev.doc
  • 569
  • 3
  • 12
  • 18
Shekhar Gigras
  • 654
  • 3
  • 5
3

PublishEngine.GetPublishInfo returns the Publish Info of an Item. Which contains the Published Date. (PublishInfo.PublishedAt).

You can also use CoreService.GetListPublishInfo.

Bappi
  • 918
  • 1
  • 5
  • 9