Hi
query 1:-
Ours is a publishing portal. Max time it works, but there are instances when it does not work.
There are few documens in our doc library for which expiration date is less than current date, still they moderation status is approved!!!!
Could you please suggest what may be the reason for this ?
query 2:-
to expire few pages with our code, we shedule the page to current time + 1 minute by a timer job. max times it works fine, but there are few instances for which page file keep checked out by system account infinitely.sample code:-
/// <summary>
/// Expires the page by setting the Scheduled End Date to Current Time + 1 minute
/// </summary>
/// <param name="item">SPListItem that needs to be scheduled to expire</param>
/// <param name="pagesLibraryUrl">Pages Library URL in the Site Collection</param>
private static void ExpireExistingPage(SPListItem item)
{
try
{
ScheduledItem scheduledItem = null;
if (ScheduledItem.IsScheduledItem(item))
{
scheduledItem = ScheduledItem.GetScheduledItem(item);
if (scheduledItem.ListItem.Properties["PublishingExpirationDate"] == null || DateTime.Parse(scheduledItem.ListItem.Properties["PublishingExpirationDate"].ToString()) > DateTime.Now)
{
if (CheckOutPage(item.File))
{
scheduledItem.EndDate = DateTime.Now.AddMinutes(1);
scheduledItem.ListItem.Update();
scheduledItem.Schedule();
string expireSuccessfullMsg = string.Format(EXPIRE_SUCCESSFULLY_MSG, item.ContentType.Name, item.Title);
LogInFile(expireSuccessfullMsg, CommonEnums.LogEntryType.Information);
}
}
}
}
catch (Exception ex)
{
LogInFile(ex.Message, CommonEnums.LogEntryType.Exception);
}
}
Reply1 by http://social.technet.microsoft.com/profile/aryan30/?ws=usercard-mini
Hi Hemant,
Possible reason of some pages not expiring could be that you might have been setting the wrong time in End Date field and doing System Update after that.
Can you try by updating (using System Update)the end date in past say 1 day before and check whether sharepoint expires that page.
Another reason could be some particular field within sharepoint didn't got updated during updation of time (due to some async moss event or something like that).
Can you try by removing all other code from your code except setting of end date. Do you still find some pages which didn't expired?
Seems to be some trick of asynchronus moss events which are overlapping with each other. Trying giving sleep time b/w these events and check if Checked out error gets solved.Sleep time should vary from 1-4 secs.