Search code examples
c#sharepointsharepoint-2007

Specific change-info in a sharepoint list/listitem


I'm trying to create a replacement Alert Me notification feature for sharepoint.

I've done most of the hard work. I just need to know the best way to get the changes in a timespan.

I know about the SPChange class, and the list.GetChanges() method. However the only information I can from this is what has been done like "Update"/"Rename" and so on.

I'd like more specific information, like what was created/updated/deleted and by who and so on. Should this be done with the SPAudit class? or am I missing something else?


Solution

  • I would recommend checking out my question here: How to create a daily summary alert for any change in a SharePoint site.

    I followed Mark's advice in using the SPAudit framework with a couple of tweaks. I ended up adding some custom SPAudit entries of my own in an event receiver attached to the list. Then, each night a console application runs and reads all of the audit entries for that day to send out the alerts.

    It sounds like you may want alerts for only one list so you'll have to do more filtering. Also keep in mind that if you want to know more than basic information (for example: which fields have changed) then you'll need to look at creating your own custom SPAudit entries.

    *Edit*

    For a custom audit entry, I first created a bean that was serializable. Then you can just serialize the bean containing all of your info from your event receiver into the SPAudit entry:

    public static void AddEvent(MyCustomBeanClass e, SPSite site)
    {
        StringWriter sw = new StringWriter();
        XmlSerializer xs = new XmlSerializer(typeof(MyCustomBeanClass));
        xs.Serialize(sw, e);
        site.Audit.WriteAuditEvent(SPAuditEventType.Custom, "MyCustomAuditing", sw.ToString());
    }
    

    Also, I think this post of mine will help you visualize (1) what the entries look like out of the box and (2) some of the extra processing you will need to do (ex: determining if an item was created).