Last Edit Date and Last Editor Name

Posted by Community Admin on 03-Aug-2018 16:07

Last Edit Date and Last Editor Name

All Replies

Posted by Community Admin on 20-Dec-2010 00:00

Hi Ivan,

          Is there a way to get the last edit date and the last editor name from the PageNode object ?
Thanks in advance.
Jon

Posted by Community Admin on 20-Dec-2010 00:00

Hi Jon,

The PageData has properties LastModifiedBy and and LastModified

Greetings,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 21-Dec-2010 00:00

Hi Ivan,

         The code below illustrates how to get the LastModifiedBy. However, it returns a Guid object. I need a way to get the name of the person once I get this Guid object. Is there a method that you are supposed to call that passes the Guid object that can get the persons name that last modified the page ? Is there another way of getting the name ?

Regards.
jon

PageManager pManager = PageManager.GetManager();
               string title = page1.Page.Title.ToString();
               PageData page = pManager.GetPageDataList().Where(t => t.Title == title).SingleOrDefault();
               dateModified = Convert.ToString(page.LastModified);
               Guid gui = new Guid();
               gui = page.LastModifiedBy;

Posted by Community Admin on 21-Dec-2010 00:00

Hello Jon,

LastModifyBy is a property that gets or sets the ID of the user that last edited the item. You can use Telerik.Sitefinity.Security.SecurityManager.GetFormattedUserName(id) to return the name of the user or SecurityManager.GetPrincipalName

Best wishes,
Ivan Dimitrov
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 21-Dec-2010 00:00

Hi Ivan,

        For some reason ( maybe this is a bug ) LastModifiedBy keeps returning null. page.Owner however, works fine in my code. Got any ideas ? I'm not sure why this is happening. I modified the page too.

Heres is my code .. simple .
jon

PageManager pManager = PageManager.GetManager();
PageData page = pManager.GetPageDataList().Where(t => t.Title ==title).SingleOrDefault();
    dateModified = Convert.ToString(page.LastModified);
    Guid gui = page.LastModifiedBy; <---- RETURNS AN EMPTY GUID OBJECT EVERY TIME 
    modifiedBy = SecurityManager.GetPrincipalName(gui);

Posted by Community Admin on 21-Dec-2010 00:00

Hello Jon,

Ok, you can use the VersionManager to get the latest version and the modifier together with all other data

sample

var itemId = node.Page.Id;
 
var vManager = VersionManager.GetManager();
var history = vManager.GetItemVersionHistory(itemId);
var first = history.First();
var change = new WcfChange(first);
var mod = change.CreatedByUserName;


Kind regards,
Ivan Dimitrov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 22-Dec-2010 00:00

Hi Ivan,

        Could you give me the assembly for VersionManager and WcfChange. I'm missing the assembly and my IDE will not resolve it for me ..

Thanks in advance,
jon

Posted by Community Admin on 22-Dec-2010 00:00

Hi Jon,

VersionManager is part of Telerik.Sitefinity.Versioning
WcfChange is part of Telerik.Sitefinity.Versioning.Web.Services, but instead of using WcfChange which was just for the sample you can use Telerik.Sitefinity.Versioning.Model.Change and its public property Owner which is Guid. This is the version owner which you can resolve

var user = UserManager.GetManager().GetUsers().Where(usr => usr.Id == changeOnwerId).FirstOrDefault();
if (user != null)
  
       var myser = (user.FirstName ?? "") + " " + (user.LastName ?? "");
 
  


Kind regards,
Ivan Dimitrov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed