Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is the file open?
Message
 
À
20/07/2005 12:29:16
Information générale
Forum:
Visual FoxPro
Catégorie:
Contrôles ActiveX en VFP
Versions des environnements
Visual FoxPro:
VFP 8 SP1
Database:
Visual FoxPro
Divers
Thread ID:
01034303
Message ID:
01034311
Vues:
24
>I'm implementing image processing in my VMP application. In the form I move all of the file names, dates created, size, etc. (faxes stored in TIF format) of files from a folder into a cursor. The form allows the user to add some additional data based on who the fax is from and then when Saved, it creates a record in a table in my database. It is important that faxes are processed in the order received, so I order the records in the cursor/grid by the date the fax was created. When multiple users are processing these documents we run into issues as everyone is trying to process the earliest received faxes (at the top of the list). Users end up working on a fax that someone else is already working with.
>
>The form opens the TIF document with an ActiveX control. I want to prevent users from opening the same document at the same time. I'm trying to stay away from using semaphores because of the issues created if a user aborts abnormally, etc. I have tried doing a fopen("c:\fa\temp\~FP1C28.tif", 2) but it always gives me a valid handle even though I have the file opened with the ActiveX control. Is there a way of determining if the file is opened already using NT?
>
>Tim

Try with fopen("c:\fa\temp\~FP1C28.tif", 12), If FOPEN gives you a valid handle therefore ActiveX is closed the file.
You can create a table with char field and primary key based on it. Before you send the file name to the AciveX try to add a record with this name in the table, if somebody is already opened it you can't add the record, etc. After you finish the job delete this record. You can do this in BEGIN TRANSACTION so if the application crash the record can not be writed in table. If you go this way there is no need to dele the record just ROLLBACK.

Other (and easies) is just RLOCK the record in the table. Something like:
IF NOT RLOCK("AliasHere")
   *** Somebody already opened the FAx
   RETURN
ENDIF
*Proceed with Fax
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform