Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #11569
| Path | csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | "Karl-Heinz" <invalid@invalid.invalid> |
| Newsgroups | comp.lang.clipper.visual-objects |
| Subject | Re: Concurrent user count |
| Date | Sat, 28 Apr 2018 11:17:23 +0200 |
| Lines | 161 |
| Message-ID | <fkisldFe172U1@mid.individual.net> (permalink) |
| References | <8e056dac-ba36-432f-aa2e-8014c2ee0a75@googlegroups.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; format=flowed; charset="utf-8"; reply-type=original |
| Content-Transfer-Encoding | 8bit |
| X-Trace | individual.net 6Fy1Tc7saNxEC8SYqHHWTwWoOsnf1zbE2eJvZaO7/k7GJW2sg= |
| Cancel-Lock | sha1:5QDNGUzwX/4XgAbNM+HwKBV1FGc= |
| In-Reply-To | <8e056dac-ba36-432f-aa2e-8014c2ee0a75@googlegroups.com> |
| X-Priority | 3 |
| X-MSMail-Priority | Normal |
| Importance | Normal |
| X-Newsreader | Microsoft Windows Live Mail 16.4.3564.1216 |
| X-MimeOLE | Produced By Microsoft MimeOLE V16.4.3564.1216 |
| Xref | csiph.com comp.lang.clipper.visual-objects:11569 |
Show key headers only | View raw
Hi Kuno,
> Does anyone know of a way to find out how many concurrent users
> have opened a DBF file? Even just a way to see if it is more than one
> would do the trick.
>
> Any advice appreciated.
What you might do is to implement a "poor man" licencing system.
1. Create a dbf with some fields. Avoid to give the dbf a name like
licence.dbf, so a poweruser doesn´t know at first sight what the dbf is good
for.
2. Append e.g. 4 records. In that case a maximum of 4 users can use the app
at the same time. Also store in one of the fields a encrypted value that
must be checked each time the server is opened. So it´s not possible to
increase the licence by simply appending one more blank record.
Now when you call oApp:Usercount() laterone and the return value is 1
currently only one instance of your app is running.
Here´s some code.
----------------------
CLASS MyApp INHERIT App
PROTECT _oDBLicense AS DbServer
-----------------------
METHOD AddUser() CLASS MyApp
LOCAL lAllowed AS LOGIC
_oDBLicense:Gotop()
DO WHILE ! _oDBLicense:EoF
IF _oDBLicense:RLOCK ( _oDBLicense:RECNO )
lAllowed := TRUE
EXIT
ENDIF
_oDBLicense:skip ( 1 )
ENDDO
RETURN lAllowed
--------------
METHOD Start() CLASS MyApp
LOCAL oWin AS <YourFirstWindow>
SetExclusive(FALSE)
RddSetDefault ( "DBFCDX" )
_oDBLicense := DbServer { <yourLicenceDbf> }
IF SELF:AddUser()
oWin := <YourFirstWindow>{}
oWin:Show()
ELSE
MsgInfo ( "Only a maximum of " + NTrim (( _oDBLicense:RECCOUNT )) +
" users may use the application at the same time." , ;
"Licence notify" )
SELF:quit()
ENDIF
RETURN SELF
-------------------
METHOD UserCount() CLASS MyApp
LOCAL dwLockedRecno, dwCount AS DWORD
// Note: The RLockList array contains always one recno only !
dwLockedRecno := _oDBLicense:RLockList[1]
dwCount := 1
_oDBLicense:Gotop()
DO WHILE ! _oDBLicense:EoF
// ignore the dwLockedRecno recno
IF _oDBLicense:RECNO != dwLockedRecno
// Try to lock the current recno.
// if it´s not possible one more user has started the app.
IF ! _oDBLicense:RLOCK ( _oDBLicense:RECNO )
dwCount := dwCount + 1
ELSE
// don´t forget to unlock() the recno !
_oDBLicense:Unlock ( _oDBLicense:RECNO )
ENDIF
ENDIF
_oDBLicense:skip ( 1 )
ENDDO
RETURN dwCount
-------------------
FUNCTION Start()
LOCAL oApp AS MyApp
__SetAppObject( oApp := MyApp{} )
Send( oApp, #Start )
RETURN NIL
--------------------
regards
Karl-Heinz
Back to comp.lang.clipper.visual-objects | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Concurrent user count Kuno Egger <kuno.egger@gmail.com> - 2018-04-26 11:31 -0700
Re: Concurrent user count dlzc <dlzc1@cox.net> - 2018-04-26 12:00 -0700
Re: Concurrent user count Martin <Martin@spam.spam> - 2018-04-27 09:12 +0100
Re: Concurrent user count "Karl-Heinz" <invalid@invalid.invalid> - 2018-04-28 11:17 +0200
Re: Concurrent user count "Karl-Heinz" <invalid@invalid.invalid> - 2018-05-06 22:27 +0200
Re: Concurrent user count Kuno Egger <kuno.egger@gmail.com> - 2018-05-08 09:41 -0700
csiph-web