FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Extract data from an open file is it possible?
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Extract data from an open file is it possible?
Posted: Mon Dec 06, 2010 09:06 PM

Is there a way to extract data from a database that has been opened exclusively. Two people looking at identical databases however the databases are in separate directories 1 & 2. With user permission directory 1 user would like to be able to exract data from the other data base in directory 2 while viewing a browse of the data. Without having to close the file and then reopen it in a shared mode. Can this be done and of course how? Both programs are fivewin.

Thank you

Harvey
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Extract data from an open file is it possible?
Posted: Tue Dec 07, 2010 04:24 PM

Harvey,

In a word, no. Once a database is opened exclusively, no one else can open it. That is the point of exclusivity.

Why does it need to be opened exclusively? Generally, this is only needed for such housekeeping chores as packing and indexing.

I am also curious as to why you have two exact copies of the same database in different directories? How are you insuring that they are both updated when a change is made to one of them? I am wondering why you can't just use one database in shared mode?

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Re: Extract data from an open file is it possible?
Posted: Tue Dec 07, 2010 06:23 PM

James:
I suspected her the answer was no way.
But to respond to your questions as to why I just can't open up the database in shared mode its simple. I have a program that is 21 years old it was never designed for multiuser. It is used to develop financial forecasts. The user can develop up to 99 separate forecast which means many many openings and closings of databases to allow sharing. That means for each database there could be 99 of them. They all use the same aliases, there are over 130 PRG's. As you might suspect it is an extremely complicated program with hundreds of calculations being made. To convert it to a multiuser program would be almost impossible.

So I've come up with my solution which is to have a four user networkable program. The main directory will be to access any of the four subdirectories (user has no idea there is 4 subdirectories). Each sub directory will automatically be updated as new info is added. So lets say user No. 1 is in forecast number 47 and changes the forecast. At some point each of the other 3 subdirectories will be updated with the data user No. 1 created. When anyone goes into thier files all the info will be the same. Actually each is a single user program but 4 people can use the program at the same time (they think) as long as each is in a separate forecast (one of the 99). So each user has access to the same 99 forecasts (they think) but its just a copy in there stand alone file.

However I would like to the ability to have a person (A) working on a forecast have a supervisor (B) see the data with permission from (A).
So i create a permission button to allow another viewer (B) to see what I'm doing and make changes. I can create an update button that (A) can use to update his file with (B) created data. Problem is when the info is transfered to (A) i have to close (B)'s file to give (A) access and update (A)'s file. Thats my problem and I'm looking for a solution.

Complicated YES.

Thank you

Harvey
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Extract data from an open file is it possible?
Posted: Tue Dec 07, 2010 11:14 PM

Harvey,

If I understand it correctly, then you have another 99 forecast files for the supervisor? One for each of the main forecasts? Doing this seems like it just doubles your problems.

With my limited understanding, the only solution I see is to have the user close their forecast file and then the supervisor can open it and make changes. When the super is done, then the user can open it and continue.

The only other way is to open the files in shared mode and if you are going to do this, then you don't need separate files for the supervisor. This might be accomplished without making the app a complete multi-user app, by only allowing one worker and one supervisor access to one forecast (at the same time). And when the super has access, then the worker cannot make updates. This would be done via a control record or file of some kind. How difficult this might be to accomplish depends on how your code is written.

Now, or years from now, you are probably going to have to address the multiuser issue. It always takes less work to do it sooner since your app inevitably gets more complicated as time goes on.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 207
Joined: Fri Oct 07, 2005 07:58 AM
Re: Extract data from an open file is it possible?
Posted: Wed Dec 08, 2010 11:38 AM
Hello!

I'm not an expert but AFAIK you can use Volume Shadow Service to copy locked files.
Then you can try to extract your data ...

The utility that uses VSS to copy files is here (it is x64 compatible):

http://alt.pluralsight.com/wiki/default ... oCopy.html

Because HoboCopy copies from a VSS snapshot, it is able copy even files that are in locked by some other program. Further, certain programs (such as SQL Server 2005) are VSS-aware, and will write their state to disk in a consistent state before the snapshot is taken, allowing a sort of "live backup". Files locked by VSS-unaware programs will still be copied in a "crash consistent" state (i.e. whatever happens to be on the disk). This is generally a lot better than not being able to copy the file at all.



Regards, Roman
© I'm not patented!
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Re: Extract data from an open file is it possible?
Posted: Wed Dec 08, 2010 04:05 PM

Roman:
Thanks for the info. I'll give it a try and keep u posted on how it works.

Thank you

Harvey
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Re: Extract data from an open file is it possible?
Posted: Thu Dec 09, 2010 12:37 AM

Roman and James:

Tried the program you suggested and it will copy a file even though being used by others. Very nice. This will make my life easier. Got it working with shellexec(). Now on to building my fake networking program. :D

Thank you

Harvey
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Extract data from an open file is it possible?
Posted: Thu Dec 09, 2010 01:19 AM

Harvey,

I am wondering how you are going to handle changes to both files.

It sounds like the worker is going to continue making changes to the file after the supervisor has made a copy (the worker won't even know that the supervisor has made a copy). At the same time the supervisor is making changes to their copy of the file. How are you going to handle updating the original file? And as long as the original file is open, the supervisor cannot post their changes to that file.

It seems that you don't really want the worker to continue making changes to the file while the supervisor is making changes. Any work the worker did at this time would be in vain if their work was going to be overwritten.

It seems like you really need to lock the worker out of the file while the supervisor makes updates to the original file.

Regards,
James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 598
Joined: Tue Apr 15, 2008 04:51 PM
Re: Extract data from an open file is it possible?
Posted: Thu Dec 09, 2010 01:45 AM

You are correct

Once the supervisor is finished with the file the file can be used by any user without permission. When super was finished the file updated in all 4 user directories.

If worker is working on file and super wants to work the file or see what worker is doing super needs permission from worker. Once worker gives permission (auto updates all 4 users) super now sees what worker doing. Worker can not use the file if super is in it. Super needs to give worker permission to get back into the file. When worker gives permision ( all 4 users files updated). Worker then sees file as adjusted by super.

If worker not in file and super wants to change or see data thats ok. When super finished the file will be updated in all 4 user directories.
Basically only one user at a time. When permission granted to a user the file automatically updates to all 4 directories from the user giving permission.

Because this is a budgeting forecasting program used for business access by too many at one time actually makes no sense.

Thank you

Harvey

Continue the discussion