Date:  12/10/2002 11:30:13 AM Msg ID:  001103
From:  Don Dascher Thread:  001063
Subject:  Re: Skipping right to a real problem
I have implemented the Method 2 shown below ...
 
I have discovered one very important flaw ...
 
If user A begins to edit a record and does not save his edits for over 5 minutes he will not be able to save them ... UNLESS ... and this is a huge unless ...   Unless another user is editing now editing the record.  Then the timestamp is greated than the datetime() value and the save will take place.  In addition, the other user editing it will also be able to save, thus wiping out the previous users edits.
 
Therefore, either the original timestamp placed on the record has to be saved in the form or some sort of "cookie" identifying who is trying to save the record.
 
I think saving the orginal timestamp with the form is the simplest.  Then, I can disallow the save based on that timestamp and the one in the file will be used only to keep others from editing it.
 
Nevertheless, this is a good idea and I plan to utilize it.
 
Thanks again.
 
 
Sent by James Williams on 12/07/2002 04:33:06 PM:

I may have two methods you can use to aceive record locking. They both use a datetime stamp.

 

Method 1

1. Create a Datetime field on all tables called "timestamp".

2. On edit of a record STORE the timestamp field value in the web page for checking later

3. On Save of a record check that the stored timestamp value is the same as the timestamp field value.

4. If timestamps are the same update the record and update the timestamp with the current date and time.

5. If timestamps are different you can give the user the option of forcing the update, or refresh the page with the new timestamp value and get the user to edit again.

 

This method i thought of because you mentioned a timeout.

Method 2

1. Create a Datetime field on all tables called "timestamp".

2. On Edit of record check if datetime stamp is less than current date and time if so then Edit if not tell user that record is currently being edited.

3. On allowing of Edit SET the timestamp field value to the current date and time plus 5 minutes (Replace TimeStamp with Datetime()+5*60).

4. On Save, check that the timestamp field is greater than the current date and time. if so update the record as normal but also update the timestamp with the current date and time (Replace TimeStamp with Datetime()) this will re-enable editing. if not tell the user their edit has timed out

 

Both methods will work without any outside program checking and clearing record locks.

 

PS. these methods are just thoughts as i was reading your posts.
 
Sent by Gene Gerard on 12/05/2002 06:07:55 PM:
Hi Don,

It took me about 2 months to get a handle on some of the things FoxWeb can do and not do  . . . and I feel I still have a long way to go.

My biggest problem was with how to transfer variables back and forth between HTML/Javascript and FoxWeb . . . but now I have a pretty good handle on it. Once you understand how to do that, you can create a lot of good code.

If you ever need help, send me a post directly at gbuza@logisticle.com

Regards,

Gene
Sent by Don Dascher on 12/05/2002 05:21:58 PM:
Well, you obviously have logged a few hours with this stuff ( I have none) so I guess you have a real world perspective.  I have to learn to walk first then take a shot at running. 
 
I like to keep everything real simple.  I am worried that this might not be easy to implement with this Web Stuff.  But I am in no rush ... I will just work into it a step at a time.
 
Good Luck with your new site.
 
Don