Last Edit Date and Last Editor Name
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
Hi Jon,
The PageData has properties LastModifiedBy and and LastModified
Greetings,
Ivan Dimitrov
the Telerik team
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;
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
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);
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;
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
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 ??
""
);