How to know if the client is already open on another computer?

Asked

Viewed 161 times

1

I’m building a system that can and will open on possibly two to seven computers. There is concern in the following case:

  1. PC1 opened the João client file and began editing.
  2. PC4 opened the João client’s file just to see some data.
  3. PC1 finished editing and saved.
  4. PC4 decided to make a small change in the record and saved also.

In this situation the change that will prevail is that of PC4 that saved the chip last, thus losing all data changed by PC1.

What way can I use to check if the plug is already open? Taking into account that the database is on a local network.

Is there any smart, low-performance way to do this? No database to make queries like "if (Emuso == true)".

Who knows some file, some direct communication between computers. Anyway, I accept suggestions to get around this problem.

  • 1

    There are N ways to have this control. Is it a desktop or web application? Which framework are you using for data access and persistence?

  • If you are a web application, you can use Application State: http://msdn.microsoft.com/en-us/library/ms178594.aspx. Please specify the type of application.

  • @Caputo Desktop, Fluent Nhibernate and Mysql

1 answer

1

Researching a little I found this post from Soen

from which I draw the following part:

User B would be able to see the record, but trying to save would give an error?

This would happen if [optimistic concurrency] were being used. In Nhibernate, optimistic concurrency works by adding a field of Version. Save/update commands are sent with the version data on which the change is based. If the submitted version is different from the persisted one, Nhibernate will fire an exception

So, to protect the situation, I believe this feature helps you.

If you want to create your own solution, you can implement a Rigger to control this version number in the database and in your application, from time to time, validate if the version number on the screen is different and notify the user, in addition to protecting the save operation to validate the registry version.

I found no material in Portuguese about the functionality optimistic concurrency, if I find edit the answer and add here.

  • I’ll look into that function, and if you help me, I’ll mark the answer as correct

Browser other questions tagged

You are not signed in. Login or sign up in order to post.