[b]Warning:[/b]
[font=Verdana][color=navy]To be able to use the following code, you need to have valid Genesys license for related libraries. What you will find below is given here for experimental purposes.[/color][/font]
[size=10pt][b]Introduction[/b][/size]
As you know, retrieving real-time data from StatServer requires an additional product. Well, if you want to implement a stand-alone service that queries StatServer for current-, average-, total-, or stat-related data, then you need to use Stat Server Java libraries.
Plus, please keep in your mind that I am not here to reveal Genesys secrets. These libraries are open. What you need is to have a related Genesys license for development.
This entry focuses on how to query StatServer using related Java libraries. Here, what you have found are some code snippets.
[b]Libraries[/b]
There exist two main Genesys libraries:
[color=green]icom.genesyslab.statistics.lib.*;
Genesys.ComLib.TKV.TKVList;[/color]
You need to declare them beforehand.
[b]Arguments[/b]
1. Hostname or IP address of the StatServer
2. Port of the StatServer
3. Name of the tenant (e.g., "Resources")
4. Object_Type:
0 --> Agent
1 --> Place
2 --> RegDN
3 --> Queue
4 --> Routing Point
5 --> Group Agents
6 --> Group Places
5. Object_ID (e.g., "Agent_5610", "CreditCards", and etc.)
6. StatType (e.g., "CurrNumberNotReadyStatuses")
7. Subject (int)
8. Category (int)
9. Notification Mode (int)
10. Main Mask (BitMap)
11. Rel(ative) Mask (BitMap)
Declaration:
[code]public static String SS_hostname;
public static String SS_port;
public static String SS_tenant="Resources"; // "Resources is the default"
public static int SS_objectType;
public static String SS_objectID;
public static String SS_statType;
public static int SS_subject;
public static int SS_category;
public static int SS_notificationMode=1; // 1 is the default
public static String SS_mainMask;
public static String SS_relMask;
public static String Hostname;
public static int Port;
public static String GUID;[/code]
[b]Connecting StatServer[/b]
[code]QueryStatServer statlibtest = new QueryStatServer();
// Connect to the given Stat Server:
int rx;
rx=(int)(Math.random()*100);
// 0x1122f
int chk = statlib.SOpenServerEx(SS_hostname, SS_port, null, "Stn666", rx, statlibtest, 0); [/code]
Where,
[i]SOpenServerEx[/i] is used to get connected to the given statServer.
Once you have connected, you should notify StatServer with your tenant profile:
[code]STenantProfile stenantprofile = new STenantProfile(SS_tenant, "");
int j = statlib.SSetNextTenantProfile(stenantprofile);
SRequestParams srequestparams = getStatRequest();[/code]
[b]Querying StatServer[/b]
At first, initialize KVList (assuming that you all know what the heck KVPair/KVList is):
[code]TKVList tkvlist = new TKVList();
tkvlist.TKVListAddString("value", "A");[/code]
Well, let's query StatServer, for example, [color=blue]TotalLoginTime[/color],
[code]statlib.SLOpenStat(SS_objectType, SS_objectID, SS_statType, tkvlist, 0, 0);
int k = statlib.SOpenStat(srequestparams);[/code]
Where,
[code]public static SRequestParams [b]getStatRequest[/b]()
{
int num;
int i,n=0;
String dummy;
SRequestParams srequestparams = new SRequestParams();
srequestparams.objectID = SS_objectID;
srequestparams.objectType = SS_objectType;
srequestparams.subject = SS_subject;
srequestparams.category = SS_category;
srequestparams.notificationMode = 1; //SS_notificationMode;
// Configuration
srequestparams.tmNotificationFrequency = 3;
//srequestparams.insensitivityPercentage = 90;
// Setting the Main Mask
SActionsMask sactionsmask = new SActionsMask();
// Here, we have to check out the first two bytes
// of the given hash -- it gives us the number of
// bytes to be set.
// If the first two bytes = "00", then it means CLEAR ALL
// If the first two bytes = "FF", then it means SET ALL
// If the numerical value of the first two bytes <0,
// then set ALL except the given
// If the numerical value of the first two bytes >0,
// then set the given bits only.
// With the light of this knowledge,
dummy=SS_mainMask.substring(0, 2);
sactionsmask.clearAll(); // First clear the bitmap
if (dummy.equalsIgnoreCase("FF"))
sactionsmask.setAll(); // Set all bits
else if (dummy.equalsIgnoreCase("00"))
dummy="kek";// Nope
else
{
num=Integer.parseInt(dummy);
// just set the given bits
if(num>0)
{
n=0;
for(i=0;i<num;i++)
{
n=n+2;
sactionsmask.setBit(Integer.parseInt(SS_mainMask.substring(n, n+2)));
}
}
else
// set all except the given
// e.g., in CME, "*, ~CallOutbound, ~WaitForVic"
{
sactionsmask.setAll();
n=0;
for(i=0;i<num;i++)
{
n=n+2;
sactionsmask.clearBit(Integer.parseInt(SS_mainMask.substring(n, n+2)));
}
}
}
srequestparams.MainActionsMask = sactionsmask.getBytes();
// Setting the Relative (Rel) Mask:
srequestparams.interval = 0;
srequestparams.tmLength = 10;
SActionsMask sactionsmask1 = new SActionsMask();
dummy=SS_relMask.substring(0, 2);
if (dummy.equalsIgnoreCase("FF"))
sactionsmask1.setAll(); // Set all bits
else if (dummy.equalsIgnoreCase("00"))
sactionsmask1.clearAll(); // First clear the bitmap
else if (dummy.equalsIgnoreCase("DN"))
dummy="kedi";// Do Nothing!!!
else
{
num=Integer.parseInt(dummy);
// just set the given bits:
if(num>0)
{
n=0;
for(i=0;i<num;i++)
{
n=n+2;
sactionsmask1.setBit(Integer.parseInt(SS_mainMask.substring(n, n+2)));
}
}
else
// set all except the given
// e.g., in CME, "*, ~CallOutbound, ~WaitForVic"
{
sactionsmask1.setAll();
n=0;
for(i=0;i<num;i++)
{
n=n+2;
sactionsmask1.clearBit(Integer.parseInt(SS_mainMask.substring(n, n+2)));
}
}
}
srequestparams.RelActionsMask = sactionsmask1.getBytes();
return srequestparams;
}[/code]
Nice, eh?
Cheers,
Ali
[b]P.S.[/b] What given above belongs to former versions of Genesys Framework. Well, it might not work with current versions. On the other hand, here, my aim is to give you a clue about Genesys-programming.