Author Topic: Reporting SDK  (Read 3173 times)

Offline carpio

  • Newbie
  • *
  • Posts: 34
  • Karma: 0
Reporting SDK
« 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.


Offline carpio

  • Newbie
  • *
  • Posts: 34
  • Karma: 0
Re: Reporting SDK
« Reply #1 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

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: Reporting SDK
« Reply #2 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.
« Last Edit: October 18, 2017, 02:54:35 PM by hsujdik »

Offline carpio

  • Newbie
  • *
  • Posts: 34
  • Karma: 0
Re: Reporting SDK
« Reply #3 on: October 19, 2017, 07:14:42 AM »
Thanks hsujdik, I will try it later

Offline carpio

  • Newbie
  • *
  • Posts: 34
  • Karma: 0
Re: Reporting SDK
« Reply #4 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?

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: Reporting SDK
« Reply #5 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

Offline carpio

  • Newbie
  • *
  • Posts: 34
  • Karma: 0
Re: Reporting SDK
« Reply #6 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'.
 
« Last Edit: October 19, 2017, 04:45:11 PM by carpio »

Offline hsujdik

  • Hero Member
  • *****
  • Posts: 541
  • Karma: 30
Re: Reporting SDK
« Reply #7 on: October 19, 2017, 06:04:57 PM »
Maybe this might help you:
https://docs.genesys.com/Documentation/PSDK/9.0.x/Developer/GetAgentState