I´m doing a commercial app that will be used by many users. The users has to log in and there the system gets what forms can he access.
Now, I need to log every action he does. When I say every action, I mean every AMD (add - modify - delete) done in the entities. Also, I want to log what fields did he changed/added/deleted and their values. (Just in case, I´m using entity framework 4)
I was thinking of an implementation similar to a version control.
What I thought was to do this:
I´ll add a log entry everytime a user does a AMD in some important entities. In that log entry, I will have id_entity_type, which is related to the type of entity that I´m saving. (ex: Client, Loan, Banks, etc). Every type will be saved in Entity_type. I will have to check in C# which kind of entity I´m working with to look for the correct one. id_entity is the ID of that entity. id_action_type is what kind of action the user done (ex. "CREATE" / "UPDATE / "DELETE") id_user is related to the user. date_time to log the entry with a date and time. And here is the important thing:
Values, is a text with all the fields and values of the entity for that time. Here is an example:
ENTITY CLIENT:
- name : John
- last name : Doe
- address : Oak st 123
- city : Buenos Aires
- country : Argentina
Then, in another log entry, another user updates the country to USA
- name : John
- last name : Doe
- address : Oak st 123
- city : Buenos Aires
- country : USA
Then, when a User want to check the changes of an entity, he can see through a TextDiff (similar to a version controller) the changes in the entity through time.
I want to get some advice if this is a good way to achive this or not.
I know that database´s triggers can be use to save this log. I know too little about this, but I guess I will need a log table for every entity I have.
Please if somebody knows what is a good way to do this I will be great.