Last post Jan 12, 2010 10:04 AM by evandroaraujo
Jan 07, 2010 03:54 PM|evandroaraujo|LINK
Here in my company We're thinking in start a new project using ASP.Net MVC 2 and Entity Framework.
We have some libraries to access the database, make selects, updates, deletes, insert, etc. It's old and hard to make changes.
These libraries are ready to make audits, inserting new records every time that the users change something in database. It means that I have two tables. The first to store the data and the second to store audits.
Triggers can be an option, but I really don't like to use them.
I thought to create a partial class and override methods to make this audit, but I'm not sure if is the better choice.
Anyone can help me?
entity Framework mvc architecture
Jan 07, 2010 10:45 PM|dinudany|LINK
When considering about audit, you need to have a track of the user and the details of the data inserted or even modified. But if you consider to use the trigger then it seems to be a bad idea, because it may slow down the operation, and also think of some
thing when you may have an option for the user for bulk insert, then...
I would suggest you to have a different service for auditing, ie a windows service which will be used for auditing rather than the application. The windows service based of MSMQ will be good practice, just push the message into the queue and then pop the
message and insert records into your audit database.
Jan 08, 2010 07:18 AM|evandroaraujo|LINK
Good idea man. I really liked.
Even using MSMQ, I still have to create a partial for each model in my project to call the method to push the message into the queue. I don't know if it's possible avoid this.
I keep searching another ways to handle this audits, but I prefer MSMQ.
Thanks (by the way) =)
Jan 08, 2010 08:58 AM|nick-w|LINK
You could just create one DAL class that has all of the methods to insert into your audit tables. You could then store in your MSMQ the method name to call with the data in an XML format, and then use Reflection to invoke that method.
Or maybe Im totally off base?
Jan 08, 2010 09:32 AM|evandroaraujo|LINK
It's a good way too. It's gonna be easy because my application always will call the same method.
I can serialize the object (in my mvc application) and send by parameter to MSMQ. The Windows Service application can get this serialized object and insert data on database through DAL.
I never worked with MSMQ, so I'm searching googling it. I really don't know if it's possible send a serialized object to the queue.
I'd like to attach a method to be executed every time that an object was added to Model (myMode.AddToUsers(objUser)). Anyone know if is it possible?
Jan 08, 2010 09:52 AM|nick-w|LINK
You can send anything you want to MSMQ including Serialized objects.
Jan 11, 2010 11:27 PM|dinudany|LINK
I would suggest you to use the HttpHandler class, where you call the MSMQ dll to insert the audit into queue by the broser file in asp.net.
Jan 12, 2010 10:04 AM|evandroaraujo|LINK