Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
private int maxVersions = 5;
void IListEventSink.OnEvent(Microsoft.SharePoint.SPListEvent listEvent)
{
/* TODO: ***** PROVIDE YOUR IMPLEMENTATION HERE ****
Get the credentials (User_Alias, Domain, Password) that this event sink instance should run as
and initialize the wic object by calling the CreateIdentity method*/
WindowsImpersonationContext wic = CreateIdentity(User_Alias, Domain, Password).Impersonate();
if ((listEvent.Type == SPListEventType.Update) ||
(listEvent.Type == SPListEventType.CheckIn))
{
SPWeb site = listEvent.Site.OpenWeb();
SPFile file = site.GetFile(listEvent.UrlAfter);
int nDocVersions = file.Versions.Count;
while ((maxVersions > 0) && (nDocVersions > (maxVersions - 1)))
{
file.Versions.Delete(0);
nDocVersions = file.Versions.Count;
}
}
wic.Undo();
}