My solution requires that I describe “Who is Online” similar to the Servoy Forum Index.
I can get a value list of all registered users, thanks to “The Servoy Guy”, but how do I know who is online now?
I assume your referring to http://www.servoyguy.com/code_repositor … rvoy_users
Currently, there isn’t a way to know which users are online, but you can use this…
//run on startup for each client
application.addClientInfo(“someUniqueIdentifier”)
//then get the number of clients with that info
application.getClientCountForInfo(“someUniqueIdentifier”)
However, that only gets you the count, not a direct handle to the clients. So you can’t get information about the connected clients, like what is their username, user groups, etc. I’ve been working on a plugin for this which may be released in a few weeks.
Thanks Scott, I look forward to your next reply.
The main reason I would like to know this is…
Re: 4.1
If I sell somebody 10 Servoy licenses I would like them to know when it is time to buy more.
It is real hard for me to sell more licenses when they don’t have a handle on how many they are actualy using.
I will take any suggestions.
Hi Briggsy,
If you want to know the used up licenses at any time then you can use the technique described by Scott.
I use it myself in a SaaS situation to make sure a client doesn’t use more than his/hers paid licenses.
Thanks Robert
How could I put this into a progress bar showing green to red!
Do you know?
Hi Briggsy,
Well at startup of a solution you need to set the unique identifier like Scott mentioned.
After that you can use something like this method to set a form global that is used as dataprovider on a field (using display type HTML_AREA).
function setUsedClientsHTML() {
var _sHTML = '<html><table width="100%" cellpadding="0" cellspacing="0"><tr>',
_nMax = 10,
_nCurrent = application.getClientCountForInfo("someUniqueIdentifier"),
_nThreshold = 8,
_nPercUsed = (_nMax/100)*_nCurrent;
// the progressbar
_sHTML += "<td width="' + _nPercUsed + '%" bgcolor="';
if ( _nCurrent >= _nThreshold ) {
_sHTML += "#ff0000"; // red
} else {
_sHTML += "#00ff00"; // green
}
'"></td>';
_sHTML += "<td width="' + (100-_nPercUsed) + '%"></td>'; // what's left
forms.yourForm.yourFormGlobal = _sHTML + '</tr></table></html>';
}
Okay, this is untested code but you get the idea.
Now how you will trigger this method is up to you. You can do it on an onShow, or via a scheduler process. It all depends on how much you want this to refresh.
Hope this helps.
That’s Awsome dude!
Thank you very much, I will refine and post code.
Assuming every client is shut down each day.
Solution on open method:
var vtoday = plugins.DateUtils.DateTime();
vtoday = vtoday.day
//run on startup for each client
application.addClientInfo(vtoday)
//then get the number of clients with that info
globals.number_online = application.getClientCountForInfo(vtoday)
I created the folowing Form Field
to look like this…
Create globals.number_online_html
function license_count_html()
{
var sHTML = '<html> <body> <table width="100%" cellpadding="0" cellspacing="0"> <tr> <td width="',
nMax = globals._number_of_licenses, // Maximum number of licenses
nCurrent = globals.number_online,
nYellowThreshold = .75,
nRedThreshold = .85,
nPercUsed = nCurrent / nMax;
// the progressbar
sHTML += nPercUsed * 100 + '%" bgcolor="';
if ( nPercUsed >= nRedThreshold )
{
sHTML += '#ff0000'; // red
}
else if ( nPercUsed >= nYellowThreshold )
{
sHTML += '#FFCC00'; // yellow
}
else
{
sHTML += '#006600'; // green
}
sHTML += '"></td>';
sHTML += '<td width="' + (100-nPercUsed*100) + '%"></td>'; // what's left
globals.number_online_html = sHTML + '</tr></table></html>';
}
How do you determine how many licenses are available with code please?
Briggsy-is-back!:
How do you determine how many licenses are available with code please?
Available on the server ? As far as I know you can’t.
I guess you can file a feature request for this, with Servoy or with Patrick for in his commercial UserManager plugin.