I recently got the requirement for a person to receive a daily summary alert for any change within a SharePoint site; each site has an owner who is in charge of the content on their site.
The current way we have something working is to automatically set up alerts for every list/library within the site.
// Get the Lists on this Site
SPListCollection siteLists = currentSite.Lists;
foreach (SPList list in siteLists)
{
if (!list.ToString().Equals("Master Page Gallery"))
{
if (list.ReadSecurity == 1) // user has read access to all items
{
// Create an Alert for this List
Guid alertID = currentUser.Alerts.Add(list, SPEventType.All, SPAlertFrequency.Daily);
// Set any additional properties
SPAlert newAlert = currentUser.Alerts[alertID];
}
}
}
This creates two problems:
Q: How can I create a daily summary alert for all changes in a site?
I believe the solution you're looking for is available through the auditing framework. Auditing is very robust in SP, unfortunately it's easy to get overwhelmed by the output.
The Audit is a property available on the SPSite, SPWeb, SPList, and SPItem properties.
Adjust the specific audit flags (using the .Audit.AuditFlags properties) using this property to suite your needs (the specifics will depend on how you define "change" but almost anything you can think of is available).
Details about the SPAudit object are available on MSDN.
Once you've defined what/where you want to audit, you'll have to get that information back to your users.
By default, SP sets up some nice reports that available at the site collection level ([url of site collection]/_layouts/Reporting.aspx?Category=Auditing). These may meet your needs.
Your initial solution mentioned alerts via email for the users. Given that most users want to centralize their information in email (though their MySite is great place to put a link to the reports!) you'll have a little more work to do.
You can pull the required audit information through the object model using the SPAuditQuery and SPAuditEntryCollection objects. Again, MSDN has some information on how to use these objects.
I would recommend setting up a custom SPJobDefinition that runs at the end of the day to email the users the audit report for their site. Andrew Connell has a great explaination of how to setup a custom job on his blog.
To summarize:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With