Created
March 31, 2011 15:56
-
-
Save sclarson/896636 to your computer and use it in GitHub Desktop.
Unstoppable EPiServer Schedule Job Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using System.Text; | |
using EPiServer; | |
using EPiServer.Core; | |
using EPiServer.PlugIn; | |
namespace BlendInteractive.AppCode.Plugins | |
{ | |
[ScheduledPlugIn(DisplayName = "Delete Unpublished Faculty and Staff")] | |
public class DeleteUnpublishedPeople | |
{ | |
private static int staffPages; | |
private static int facultyPages; | |
public static string Execute() | |
{ | |
staffPages = 0; | |
facultyPages = 0; | |
StringBuilder returnValue = new StringBuilder(); | |
var facultyList = Utilities.GetFilteredPageCollection(PageReference.RootPage, "Faculty Page").Where(p => p.Status != VersionStatus.Published); | |
var stafflist = Utilities.GetFilteredPageCollection(PageReference.RootPage, "Staff Page").Where(p => p.Status != VersionStatus.Published); | |
foreach (var person in facultyList) | |
{ | |
DataFactory.Instance.MoveToWastebasket(person.PageLink); | |
returnValue.AppendLine("Added: " + person.PageName + " to wastebasket: id - " + person.PageLink.ID + "<br />"); | |
facultyPages++; | |
} | |
foreach (var person in stafflist) | |
{ | |
DataFactory.Instance.MoveToWastebasket(person.PageLink); | |
returnValue.AppendLine("Added: " + person.PageName + " to wastebasket: id - " + person.PageLink.ID + "<br />"); | |
staffPages++; | |
} | |
return "Deleted Pages: " + facultyPages + "<br />Deleted Staff Pages: " + staffPages + "<br />" + returnValue.ToString(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment