Tooltip for Audit Log Approach

I am currently developing an ASP.NET human resource system. I am using a tiered architecture with Factory web-based client software, which is based on the MVP pattern. ORM is NHibernate. And I need to implement the audit log module. I read a lot about different approaches. Most of them describe how to track the date, timashamp, and the identity of the person who made this change, but no one could tell me about it: how to track changes to a property in my domain? I do not need a rollback function, I only need a log with: who, when and what property of which object was changed, the old value and the new value of this property.

I cannot decide where to place the handler for these changes. Fowler pointed out the audit trail to the setter method of properties, but I still want my domain classes to be just POCO. Maybe there is another approach?

+3
source share
4 answers

I had to do this a few years ago for the HR system. I executed it when all my "fields" implement the template (general):

Here is an example of a template that I cropped:

class DataField<T>
{
    public T Current { get; set; }
    public T Original { get; set; }
    // stores the field name as a nice textual readable representation.
    // would default to property name if not defined.
    public string FieldName { get; set; }
    public bool Modified
    {
        get { return !(Current.Equals(Original));
    }

    public DataField(T value)
    {
        Original = Current = value;
    }

    public DataField(T value, T fieldName)
    {
        Original = Current = value;
        FieldName = fieldName;
    }
}

, , , . , x "" GetAudit , , , val, val .. "DataField" . , double, int .. , , , Audit.

, , , . GetAudit, .

, - , ..

, .

, , . , .

+2

, , , .net ( ), , .

, "" , (, ), , . , deepcopies .net( , ),

0
0

Have you checked the "Logging Protocol" in the Microsoft Enterprise Library?

-1
source

Source: https://habr.com/ru/post/1711207/


All Articles