A library can have item scheduling enabled. This allows you to specify a window in time in which a page should be visible to the world. When you enable item scheduling through the GUI you first have to enable "Minor versions" and "Moderation" in the versioning settings. This is quite easy in code:
//pageLibrary is a SPList object. I assume you know how to get to it.
pageLibrary.EnableMinorVersions = true;
pageLibrary.EnableModeration = true;
pageLibrary.Update();
The next part is where you hit a brick wall. There is no "Manage Item Scheduling" property for list objects. What shows as a checkbox in the GUI hides a couple of things that happen when you turn Item Scheduling on. The most important is that EventReceivers are added to the list. Normally, when working with EventRecievers you're making your own. Here the objective is to add Microsoft's own EventReceivers through code:
pageLibrary.EventReceivers.Add(SPEventReceiverType.ItemAdded, "Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c", "Microsoft.SharePoint.Publishing.Internal.ScheduledItemEventReceiver");
pageLibrary.EventReceivers.Add(SPEventReceiverType.ItemUpdating, "Microsoft.SharePoint.Publishing, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c", "Microsoft.SharePoint.Publishing.Internal.ScheduledItemEventReceiver");
Thats it! Seems easy enough, don't you think? These 5 lines of code made up a days work though.
Harrah's Casino & Resort - Mapyro
ReplyDeleteHarrah's Cherokee Casino 원주 출장샵 & Resort is the first casino in North Carolina to accept 제주 출장샵 slots and video 충청남도 출장샵 poker. 안동 출장마사지 The 속초 출장샵 casino opened its doors in September 2009