Genesys CTI User Forum

Genesys CTI User Forum => Genesys-related Development => Topic started by: carpio on October 18, 2017, 12:27:40 PM

Title: Reporting SDK
Post by: carpio on October 18, 2017, 12:27:40 PM
Hello,

Im trying to get a specific value of a statserver request

[code] StatServerProtocol stat_prot = new StatServerProtocol(new Endpoint(ip,port));
            stat_prot.Open();

            var obj = StatisticObject.Create("1234@switch", StatisticObjectType.RegularDN, "Environment");
            var metric = StatisticMetric.Create("CurrentDNState");
            var notification = Notification.Create(NotificationMode.Immediate, 1, 1);

            RequestGetStatistic req = RequestGetStatistic.Create(obj, metric);
            req.ReferenceId = 1;
           
           
            var response = stat_prot.Request(req);
            MessageBox.Show(response.ToString());[/code]

the response is showing me some values but how can I get just the specific values?
for example, I would liket to get the dn status and time.

Title: Re: Reporting SDK
Post by: carpio on October 18, 2017, 01:43:07 PM
it would have been to nice  ;D
Then I'll have to do it this way.

Thanks
Title: Re: Reporting SDK
Post by: hsujdik on October 18, 2017, 02:45:35 PM
If I remember well, you can cast the response as an EventInfo object... I'll try to find my old codes experimenting on this to give a better response.

Edit:

I used something like this (on Java):

[code]
StatServerProtocol primaryStatServer = new StatServerProtocol(primary, primaryConnectTimeout);
primaryStatServer.setMessageHandler(statHandler);

...
...

private MessageHandler statHandler = new MessageHandler() {
@Override
public void onMessage(Message message) {
if (null == message) return;
if (message.messageName().equalsIgnoreCase("EventInfo")) {
EventInfo ev = (EventInfo) message;
metric.setLastMetricValue(ev.getIntValue());
}
}
};
[/code]

In the code above, every time I get a message of type EventInfo from StatServer, I update my own internal object "metric" with the stat value by using the .getIntValue() method.
Title: Re: Reporting SDK
Post by: carpio on October 19, 2017, 07:14:42 AM
Thanks hsujdik, I will try it later
Title: Re: Reporting SDK
Post by: carpio on October 19, 2017, 10:58:34 AM
I have tried ou code but the I do not know the metric function in c#
This is my code:
[code]IMessage message = ((MessageEventArgs)e).Message;
            if (message.Name.Equals("EventInfo"))
            {
                EventInfo ev = (EventInfo)message;
                Console.WriteLine(ev.StateValue.ToString());
            }[/code]

I get this as result so far:

AgentId = testagent
AgentStatus = 23
Time = 1508410088
PlaceStatus = PlaceStatus = 23
Time = 1508410088
LoginId = LoggedOut

If I try code:[code]if (message.Name.Equals("EventInfo"))
            {
                EventInfo ev = (EventInfo)message;
                Console.WriteLine(ev.IntValue.ToString());
            }[/code]

I get the result 0 no matter if the agent is logged in or not.


Is it possible to get the agentStatus without to write a parse method?
Title: Re: Reporting SDK
Post by: hsujdik on October 19, 2017, 01:37:29 PM
Ah, I just now realized you were getting the DN State. Try cast your StateValue as DNStatus and then get the Actions property to check if it suits what you need
Title: Re: Reporting SDK
Post by: carpio on October 19, 2017, 02:41:02 PM
I have tried

[code]public void OnMessageReceived(object sender, EventArgs e)
        {
            IMessage message = ((MessageEventArgs)e).Message;
            if (message.Name.Equals("EventInfo"))
            {
               
                EventInfo ev = (EventInfo)message;
                DnStatus ds = (DnStatus)ev.StateValue;
                MessageBox.Show(ds.ToString());
             
            }
               
        }[/code]

and:
[code]public void OnMessageReceived(object sender, EventArgs e)
        {
            IMessage message = ((MessageEventArgs)e).Message;
            DnStatus ds = (DnStatus)message;
            MessageBox.Show(ds.ToString());
}[/code]

But I always get a exception:

System.InvalidCastException was unhandled by user code
  HResult=-2147467262
  Message=Unable to cast object of type 'Genesyslab.Platform.Reporting.Protocols.StatServer.AgentStatus' to type 'Genesyslab.Platform.Reporting.Protocols.StatServer.DnStatus'.
 
Title: Re: Reporting SDK
Post by: hsujdik on October 19, 2017, 06:04:57 PM
Maybe this might help you:
https://docs.genesys.com/Documentation/PSDK/9.0.x/Developer/GetAgentState