Well, for the WSS application developer exam, you’re supposed to know about programmatically checking in and out documents:
//*** Check out a document
Console.WriteLine("Check out {0}", myItem["Name"]);
myItem.File.CheckOut();
Console.ReadLine();
//*** Check in a Document (Minor Check in)
myItem.File.CheckIn("Checked in Programmatically", SPCheckinType.MinorCheckIn );
Console.WriteLine("Item Checked in");
Console.ReadLine();
One should also be able to list all versions of a document:
//*** List all versions of a document
Console.WriteLine(myItem.Name);
foreach (SPFileVersion ver in myItem.File.Versions)
{
Console.WriteLine(" - v{0} ({1})", ver.VersionLabel, ver.CheckInComment);
}
Console.ReadLine();
And restore a version:
//*** Restore to version 1.0
myItem.File.CheckOut();
myItem.File.Versions.RestoreByLabel("1.0");
myItem.File.CheckIn("Restored by Program to v1.0");
Console.WriteLine("{0} restored to v1.0", myItem.Name);
All pretty straight forward.
Great blog entry. One tidbit to add, if you want the restored version to be the “current” live verions, you need to publish it after the item.file checkin.
This is helpfull for when you want to restore the live version of pages to a version before date x.