Logging using Unity Interception RRS feed

  • Question

  • Currently in our application we are using unity interception framework for auditing purposes(i.e. for logging values of certain properties resides inside certain DTO's) at our service layer.

    We are storing above values in our application database.

    We are defining all the DTO's that we will be send for auditing purposes in the unity config file itself.

    Logic for auditing:

    We have define in the unity config that whenever there is a call to a method containing verbs such as create, update , init at our Data Access layer there will be call to a handler(i.e. an callback handler of type ICallhandler provided by unity.unityInterceptionExtension) which will receive the input passed to a method and passed it to a handler inside which we have written the logic that if input contains any of the DTO's(i.e. DTO's which we have mentioned in the unity config) then extracts the property alongside it's value from a given DTO and give a call to the sql server in order to store the data which we will later used for auditing purposes.

    Database Schema We are currently storing data by marking it as INS, UPD or DEL in the underlying table by comparing old and new values of a given property ex.

    say we have a name property Then first time it will get store in our table as INS(since it's a new entry) Next time when same name will go for auditing , we have written a check inside the stored procedure which will compare previous and new values for the above name property and decide that next entry is going to be of type UPD or DEL

    If value has updated on the application side(say name value has changed) then it will be update or in case value is updated as empty on application side then we will be treating it as a delete operation.

    so for name database entries will be:


    Issue : The problem we are facing with the above solution is that since a given DTO can present at n number of places say at the data access layer there is no way to track whether value for that DTO has been changed or not since we are struggling with a way to carry both previous or new values for any given property to reduce number of calls going to database for auditing purposes which then filters out by the logic written inside the database i.e.

    it will iterate the records by firing select query on the current table to retrieve the current value for that property and then compare the value for that property with the one stored inside the database.

    i.e. if the value doesn't exist then there will be an insert statement with transaction Type "INS" else if value is updated then there will be an insert statement with transaction type 'UPD' else if value is deleted then there will be an delete statement with transaction type 'DEL'

    Above select logic written inside the stored procedure is a bit costly(we already have close to 6 million records inside the table and it is getting increased day by day). Though we have done the proper indexing to make it as fast as possible.

    We are looking out for a solution through which we will reduce unnecessary calls to the database by somehow carrying the previous and new values for a given property inside the application without adding extra load to the application.

    Based on the previous and new value for a given property inside a DTO we will decide whether to give a call to database or not.

    Application Specification: WPF 4.0(.Net Framework 4.0) LOB 4.0 (.Net Framework 4.0, Unity Framework MVVM Architect

    Note: Whole logic is written at the service layer for auditing

    Any help will be greatly appreciated.

    Thursday, September 15, 2016 1:18 PM

All replies

  • Hi rajbir1190,

    Based on your description, you use unity interception framework, so I would suggest that you could post your issue on the following link, which is the git of unity.

    Thank you for your understanding.

    Best regards,

    Cole Wu

    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 16, 2016 7:05 AM