Use CSLA for auditing?

212 views Asked by At

We have CSLA v2.0.50727, and they are asking me to take an audit check. So I would like to know if:

  • ¿Can I know With CSLA what properties of my object have changed?
  • ¿What recommendations do I have for mapping table names and fields in my database, with the values and names of my properties?, We intended to use custom annotations on properties; Although we are investigating how.

The purpose is to be able to save in a table that values changed of a certain field and table. Example.

Audit_table

Audit_id

Field_name

value

Table_name

Row_id

1

There are 1 answers

0
Skyler Sanders On BEST ANSWER

If possible auditing can be done at the database level so you do not need to implement auditing ever again / (foreach app that accesses the database write code to audit the exact same thing -- doesn't make much sense).

What you do is create a table exactly like the production table with a post or prefix and add additional fields to your needs. For each of your stored procedures add the parameter(s) & for each audit table add column(s); a time stamp, a username (from the app) and action (DELETE, UPDATE, READ, CREATE or whatever you need to describe what happened to the record).

Then before a CRUD select from table and insert into audit table with the operation/action details & additional params.

This also allows for additional security when querying data as each time an app accesses the database to perform an operation it will audit the CREATE, READ, UPDATE or DELETE. With the required parameter of a user, it can also can go to the extent to check if the user has access to the record, checks if the the user even exists and/or has particular privileges to perform an action on a record or object.

The only change in code is additional params passed to the database in a manner that suits your specific needs.

This solution is agnostic.