PDA

View Full Version : Multiple users on 1 component



Angilo
9 Sep 2010, 1:57 AM
Hi everyone,

I'm running in a (I think) very complex situation. Multiple users working on (let's say) 1 form.
How do you prevent data loss?

User A is working on form 1, User B is working on form 1, user A changes the data on form 1, how can I make sure user B receives has the newest information available?

Here are some solutions that I have thought of:



Timestamps + timers (e.g. Windows)
Everytime an user opens (let's say) order A, it saves a timestamp in the database with the action taken, that's either 'load' or 'save'.
When the action is save and user B already had order A open, a pop up will appear with "this file has been edited by someone else, would you like to reload it?".
Therefore I need to create a timer, which sends every 1 second a request to the server (like hyves or facebook). This brings a higher network load, but that's the only way to do it.

Locking (e.g. CMS systems like Joomla)
Same scenario as before, but when the action is load on time 1 by user A, every other user on time 1+ gets a lock. There are multiple ways of the lock.
Joomla for example has the lock not available to open. This is possible when there is no module information crossing other module information. It is not possible when for example sales has the same data as warehouse, because when someone opened the sales order, the warehouse can't ship the order.

I'd suggest using a save lock + timestamps + timers.
This means:

When the action is load, on time 1, performed by user A, every other user on time 1+, can still perform the action load. But they can not launch the action save.
When user A executed the action save, the action will be released. User B and User C receive a popup, "this file has been edited by someone else, would you like to reload it?" and they can either press yes or no.
By clicking no, the order will still not be available for saving. By clicking yes, the client sends a request for locking the order. So let's say User B clicked on yes FIRST, the lock will be turned on again, with a new timestamp and a new user.
When User B performs the save action, the lock will be released again.
The first user that clicks yes, get's the lock.

With timers it is possible to create some more handy tools. For example, when there is a lock it should be possible to click on the lock and see who is editing the page. There should be a tool with " request release", which sends a request to release the lock to user A. When user A accepts, user B receives the lock.


Does anyone else has any suggestions?

Thanks for your advice!

laurentParis
9 Sep 2010, 3:42 AM
make versionning on your formquery..
when user save form, server check version =>
* if it the same version => save form AND update formquery version
* if it's different version => exception AND reload form with new values

Angilo
11 Sep 2010, 1:32 AM
make versionning on your formquery..
when user save form, server check version =>
* if it the same version => save form AND update formquery version
* if it's different version => exception AND reload form with new values

Thank you for your input, versionning is a good idea, except for the timing. The users first saves his form, then he receives an exception and the form reloads. With 10+ users it will really frustrate the user. Therefor, this is no option.

Since there is no push method, there must be a timer, pulling the data.

In order to limit the overhead (html requests comes with a lot overhead), the timer should be activated when the tab is opened, or when any activity takes place. When there is no activity for 2 * the timers time, the timer will be disabled. This way the amount of requests will be limited.

Is there any option in ExtJS to obtain the user activeness?

aritchie
11 Sep 2010, 3:10 AM
ExtJS is a javascript framework. It can't check user activity since the users aren't connected directly. On the server, you do have an option.

I did a system last year that had a similar requirement and they didn't want to do all the work only to be told someone had already made changes (ie. old version). What we did was make a call to check if a "document/business object" was locked and if it wasn't, obtain a lock. By "lock", it only meant a collection on the server holding the document type, id, user, & the time they locked the document. If a concurrent user came on and could NOT get a lock, it would return the lock info of the user that had the document.

There is no need for a timer. Just try to acquire the lock on loading the form and dispose of it closing the form. You could put a thread timer on the server to automatically remove a lock on someone who has sat on the document for hours (possibly from closing their browser).

Angilo
11 Sep 2010, 4:22 AM
ExtJS is a javascript framework. It can't check user activity since the users aren't connected directly. On the server, you do have an option.

I think with javascript it is possible to detect activity on the client.


I did a system last year that had a similar requirement and they didn't want to do all the work only to be told someone had already made changes (ie. old version). What we did was make a call to check if a "document/business object" was locked and if it wasn't, obtain a lock. By "lock", it only meant a collection on the server holding the document type, id, user, & the time they locked the document. If a concurrent user came on and could NOT get a lock, it would return the lock info of the user that had the document.

There is no need for a timer. Just try to acquire the lock on loading the form and dispose of it closing the form. You could put a thread timer on the server to automatically remove a lock on someone who has sat on the document for hours (possibly from closing their browser).

That's true, that's also my idea, but at that point you still point the finger to the user. The user has to reload the document in order to check if he can get the lock now. That's not really what should happen, the system should automatically update the data for the user.

I think I'll use your idea, with a client timer. The client timer will check if the lock is available, if the lock is available, the data is automatically updated.