Unlocking the record of a table from asp.net 2.0
Posted on 2007-07-29
I am developing an enterprise system backend using ASP.NET 2.0 and C#. This is my first enterprise system. In one of the tables of the Database (which is called Booking) I have a column called (IsLockedFromDashboard which is a boolean). I am using Pessimistic and Optimistic concurrencies (a mix of both). The 'IsLockedFromDashboard' will be true when the administrator of the system is trying to modify(update) the values of a specific booking. I want to lock this booking so the users of the front end won't have access to it untill the administrator is done updating the booking.
The first parts (Locking the booking which is being updated and preventing the users to access the booking) are fairly easy and is done. The problem is unlocking the Booking record. As you found out I am not using DB triggers to change the value of the 'IsLockedFromDashboard', I am locking the record from the asp.net (I have designed the Data Access Layer, Business Logic Layer, and Presentation Layer). Let me explain it more clearly, the administrator selects a booking to update it, a function will be called to change the value of the 'IsLockedFromDashboard' of that booking to "true", then in the front end the hyperlink which takes the user to the booking information will be "Enabled=false" so the user cannot retrieve the info from the DB for that particular booking.
Now, my problem is changing that 'IsLockedFromDashboard' to "false" when the admin is done with updating that specific booking. I can add the code to the "Commit Button" I have so when the admin is done updating and he clicks on the commit button i will change the value. BUT, what happens if the admin do not click on the commit button. For example, he clicks on "Logout" or any other link or button. Still I can add calling the method to change the lock value for every single one of the controls (which i believe is not a good design), but what happens if he closes the browser or something happens and the system goes down suddenly. Then that booking will be locked forever. In case of 1,000-100,000 bookings it is hard to find out which one was locked and why they could not be unlocked. Is there any way I can unlock (i have the function just let me know where to call the function) the booking.
* Assume the signature of the function is Bookings_ChangeLockStatus(Int64 ID,bool Status) which the status is the status of the "IsLockedFromDashboard" (true/false).