Guest User

Untitled

a guest
Jun 25th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. public class ScheduledPageEventReceiver : SPItemEventReceiver
  2. {
  3. protected void HandleScheduling(PublishingPage page)
  4. {
  5. Type t = typeof(PublishingPage);
  6. MethodInfo notificationMethod = t.GetMethod("UpdateNotificationList",BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.InvokeMethod);
  7. if (notificationMethod != null)
  8. {
  9. notificationMethod.Invoke(page, null);
  10. }
  11. }
  12.  
  13. public override void ItemUpdating(SPItemEventProperties properties)
  14. {
  15. if (properties == null)
  16. {
  17. throw new ArgumentNullException("properties");
  18. }
  19. if (properties.AfterProperties == null)
  20. {
  21. throw new ArgumentNullException("properties.AfterProperties");
  22. }
  23. object status = properties.AfterProperties["vti_doclibmodstat"];
  24. if ((status != null) && (Convert.ToInt32(status, CultureInfo.InvariantCulture) == 0)) //Approved
  25. {
  26. using (SPWeb web = properties.OpenWeb())
  27. {
  28. SPListItem item = web.GetFile(properties.BeforeUrl).Item;
  29. if (PublishingPage.IsPublishingPage(item) && PublishingPage.IsScheduledItem(item))
  30. {
  31. PublishingPage page = PublishingPage.GetPublishingPage(item);
  32. HandleScheduling(page);
  33. return;
  34. }
  35. }
  36. }
  37. }
  38. }
Add Comment
Please, Sign In to add comment