![]() | ![]() Products ![]() ![]() ![]() ![]() |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 9 of 9 total |
![]() |
Fri, Oct 9 2009 5:21 AM | Permanent Link |
"Petter Topp" | Hi.
I have a desktop app using Dbisam4 where I would like to perform a backup when last user closed the application. Can I use some of the already built in functions of Dbisam to detect wheter the running application is the last user (session) connected to the database? I know that I can run the Dbisam backup at any time, but this is to avoid every user being asked for backup when closing the application. Regards Petter Topp |
Fri, Oct 9 2009 6:15 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | Petter
File server or client server? Roy Lambert |
Fri, Oct 9 2009 6:37 AM | Permanent Link |
"Petter Topp" | Hi Roy.
File server Petter "Roy Lambert" <roy.lambert@skynet.co.uk> skrev i melding news:8CB66CA2-B8B0-43AC-94AA-F3059E5BF383@news.elevatesoft.com... > Petter > > > File server or client server? > > Roy Lambert > |
Fri, Oct 9 2009 9:02 AM | Permanent Link |
"Eduardo [HPro]" | Peter
It does not matter if you are using C/S or F/S because you can use this simple approach: Try to open the tables in exclusive mode, if you can get it, them you are "alone" in the application and therefore you can backup your data. Eduardo |
Fri, Oct 9 2009 9:36 AM | Permanent Link |
Roy Lambert NLH Associates ![]() | Petter
Four approaches that you could take: 1. try and open a table that would be open whenever a user starts your app in exclusive mode. If you can do it you've cracked it - quick close it and start the backup. 2. try starting the backup in the onclose event after closing the tables. Since it requires exclusive access it will only work if no one else is using the tables. Remember to trap the exception. 3. look in the elevatedb.extension ng grab Terry Swires usercount code, modify it for DBISAM and log users on/off properly 4. somewhere in the binaries there should still be an example Tim posted using semaphore flags. As long as there are less than (I think) 255 users then you can set a semaphore as a user logs on, clear it when they log off (I think it happens automagically) and when you want to test for if you should backup try setting all the semaphore flags. Be warned this will take a bit of time Roy Lambert [Team Elevate] |
Fri, Oct 9 2009 3:03 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Petter,
<< Can I use some of the already built in functions of Dbisam to detect wheter the running application is the last user (session) connected to the database? >> Yes, you can use the semaphore locks in DBISAM to do this: http://www.elevatesoft.com/manual?action=mancompmethod&id=dbisam4&product=d&version=7&comp=TDBISAMTable&method=LockSemaphore http://www.elevatesoft.com/manual?action=mancompmethod&id=dbisam4&product=d&version=7&comp=TDBISAMTable&method=UnlockSemaphore Just have each application lock a specific semaphore "slot" when the application starts up by walking the range of semaphores, and then have the backup try to lock all semaphores by walking the entire range of slots up until the maximum number of expected users. Application code: CurrentSlot:=1; while (not LockSemaphore(CurrentSlot)) do Inc(CurrentSlot); Backup code: CurrentSlot:=1; while (CurrentSlot <= MaxUsers) do begin while (not LockSemaphore(CurrentSlot)) do Sleep(20); << Use whatever value you want here Inc(CurrentSlot); end; -- Tim Young Elevate Software www.elevatesoft.com |
Fri, Oct 9 2009 3:57 PM | Permanent Link |
"Robert" | "Tim Young [Elevate Software]" <timyoung@elevatesoft.com> wrote in message news:9625C47D-5EBA-4845-8F80-28209509717E@news.elevatesoft.com... > > Backup code: > > CurrentSlot:=1; > while (CurrentSlot <= MaxUsers) do > begin > while (not LockSemaphore(CurrentSlot)) do > Sleep(20); << Use whatever value you want here > Inc(CurrentSlot); > end; > function NumberOfUsers : integer; CurrentSlot := 1; Result := 0; while CurrentSlot <= MaxUsers do begin if LockSemaphore(CurrentSlot) then begin Sleep(20); UnlockSemaphore; end else Result := Result + 1; inc(CurrentSlot); end; that way you don't leave any semaphores set if NumberOfUsers = 1 then backup else whatever Robert |
Fri, Oct 9 2009 4:49 PM | Permanent Link |
"Petter Topp" | Great help guys.
I have plenty to work with. Have a nice weekend. Petter "Petter Topp" <petter.topp@atcdata.no> skrev i melding news:07411317-F512-4877-A479-B97E079A8D49@news.elevatesoft.com... > Hi. > > I have a desktop app using Dbisam4 where I would like to perform a backup > when last user closed the application. > > Can I use some of the already built in functions of Dbisam to detect > wheter the running application is the last user (session) connected to the > database? > > I know that I can run the Dbisam backup at any time, but this is to avoid > every user being asked for backup when closing the application. > > Regards > Petter Topp > > |
Fri, Oct 9 2009 10:59 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. ![]() | Robert,
<< that way you don't leave any semaphores set >> Yes, but what I was going for was having the Backup procedure lock all available slots so that an application cannot start up during the backup and acquire a slot. -- Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Wednesday, August 14, 2024 at 07:31 PM | Privacy Policy![]() © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? ![]() |