At 03:53 PM 4/7/2008 -0400, Randy Joles wrote:
>Alan Bourke wrote:
> > On Mon, 07 Apr 2008 15:35:45 -0400, "Randy Joles" <[EMAIL PROTECTED]>
> > said:
> >  disconnect users who just happen to leave tables
> >
> >> open when they go home so that I can automate packing/reindexing, etc.
> >>
> >
> > That's probably not a good idea, especially with Fox 2.x tables. Do you
> > have the source for the project at all?
> >
>I do have the source, but I'm dealing with almost 8000 tables and 3200
>prg files.  How would you handle this?  Thanks


First, the danger of doing a disconnect is if a user is in the middle of an 
editing session: you mention Fox2.x which means it is likely the data entry 
screens are "directly" modifying the tables. If you disconnect in the 
middle of someone writing to the table (especially if they're writing to an 
index field) it's possible the CDX file could get corrupted. Early morning 
probably means that won't happen, but they could still be in the middle of 
editing data and that would mean you could get some records that are only 
half completed (and data may not have been validated). But, if the data 
entry screens used and approach, say, like SCATTER/GATHER (or editing a 
temporary cursor/table), things will probably be fine.

The win API function you want to look at is NetSessionDel (don't know about 
Vista - probably fine for XP and below - not sure). To invoke that API the 
"account" calling it has to be in the Administrator or Account Operators 
groups of the server.

I'm not sure what version of Fox you're using. VFP can access Fox 2.x 
tables. If you are using VFP, you could implement a "timer" type funciton: 
e.g. a system wide timer in the application that goes off every 30 seconds 
or so (based on your preference). In that timer's event code, you check for 
the existence of a certain file. If it's there, you shutdown the 
application "gracefully". So the application that sits on the user desktop 
would be watching for that file and close themselves down.

Another way to look at it is this: you could just do the maintenance 
without trying to close connections. Just put error-trapping code around 
the code that tries to open a table exclusive. If it can't, then you just 
move on to the next table. Write which tables didn't get packed in a log 
file, etc. Since you're doing it every night, you'll probably get them all 
in a day or 2. And if you notice a particular table that is always open, 
you could make a request during the day to have everyone log out of the app 
and do a quick routine on that table. A downside of this is if any of the 
tables use a SET RELATION into other tables using the record number as the 
relation. This approach would mess things up in that case and should be 
avoided.

One last side note: I'd recommend that the first thing that is done during 
that nightly maintenance run would be to backup all the files. I'm not sure 
what the total size is, but if it's under 25GB you could probably just .zip 
them all together and put the .zip somewhere. That way, no matter what 
comes up the next day, you can recover. Of course if the drive is already 
backed up before you do your routines you may be OK (but note - it seems to 
be "common" that "backups" cannot get restored - even the big-name backup 
software has problems sometimes). If you've got limited time, doing the 
.zip/backup may take too long. But I'd still strongly advise it and if you 
need more time, tell everyone you need more time. Heck, the network guys at 
my main client site pretty much shut things down for about 5 hours each night.

(sorry for the length)

-Charlie





_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/profox
OT-free version of this list: http://leafe.com/mailman/listinfo/profoxtech
Searchable Archive: http://leafe.com/archives/search/profox
This message: http://leafe.com/archives/byMID/profox/[EMAIL PROTECTED]
** All postings, unless explicitly stated otherwise, are the opinions of the 
author, and do not constitute legal or medical advice. This statement is added 
to the messages for those lawyers who are too stupid to see the obvious.

Reply via email to