Click here to Skip to main content
15,891,431 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created web application in which an application no created and saved in database .When entry opertator users looks dashboard he tries to access application but if any other user is using that application then it creates problem.How to avoid proper way for multiple user should not use same object.

What I have tried:

We tried to set lock using database but in database it create problems in unlocking
Also I used locking methods but in this case how to lock this application object so that no other user should use it .
.So please help me to get proper solution.
thanks in advance ....
Posted
Updated 7-Oct-16 5:00am
Comments
[no name] 7-Oct-16 9:06am    
Being the we don't know anything at all about your project or your problem, re-architect your project in such a way that sharing objects does not cause a problem.
F-ES Sitecore 7-Oct-16 10:47am    
The problem you have is that the web is stateless so your site doesn't know who is editing what, or looking at what. If a person begins to edit something then goes away to lunch, or simply doesn't save or complete the edit then that item remains locked forever.

Instead of locking items the best solution is to have a timestamp for your records. So if you are editing "Person A" then that person's record in the db will have a timestamp column that your site will read and store. When the record is saved you check the timestamp is the same as it was before, save the data and update the timestamp. If you find the timestamp isn't the same then that means someone else has edited the data in the meantime so you can tell this to the user when they try and save and give them appropriate options to resolve the conflict, such as abandon their changes or override the previous person's changes, or somehow merge the two.
sp_suresh 10-Oct-16 2:13am    
F-ES Sitecore ....Thank you very much & sorry for delay .As you suggested we already maintained changed log.So we can track also changes done by user. Also We will check your solution.....

I think what you are looking for here is a named mutex - these work like locks, but across process boundaries. There is a little bit of work involved in learning to set them up properly, but if you look at the MSDN documentation, I'm sure you'll get there. A good starting point would be here[^].
 
Share this answer
 
Comments
sp_suresh 10-Oct-16 2:24am    
thanks and sorry for delay.We are studying mutex...
Your problem is probably because the record is locked in the DB, but for whatever reason, it may not be unlocked. You also haven't sufficiently engineered your locking strategy.

First, maintain some sort of indication in the DB when a record was locked and by whom. Then you can:

0) When the browser session ends, have it unlock any records that are locked by the user.

1) Establish some sort of timeout that will allow you to automatically unlock a given record.

2) Include code in your stored proc that will not allow a record to be updated by a user unless that user currently has it locked.

Nobody here can provide anything more than advice. How you engineer your locking/unlocking solution is wholly dependent on a) the database, and b) the nature of the web site.
 
Share this answer
 
Comments
sp_suresh 10-Oct-16 2:21am    
thanks for your solution and sorry for delay .As you suggested we have to created service which will monitor which application is locked and with time.So after specific timeout period object will released ...Ok...we will try this way also ...But is there any other solution in order to avoid service ?....thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900