Author Topic: Extracting StatServer EventInfo data  (Read 686 times)

Offline oceanblue

  • Newbie
  • *
  • Posts: 18
  • Karma: 0
Extracting StatServer EventInfo data
« on: November 12, 2020, 05:38:17 AM »
To all PSDK gurus :

I wrote a small Java PSDK(StatServer) script which prints EventInfo event generated by the StatServer reflecting Agent Place/DB info. Following is a sample output :


'EventInfo' (2) attributes:
        VOID_VALUE [object] = ObjectValue: AgentStatus {
  AgentId = 07008
  LoginId = 07008
  Status = 8
  Time = 1605122633
  Place = PlaceStatus {
    PlaceId = Test_Agent_Place
    PlaceStatus = 8
    Time = 1605122633
    DnStatuses = DnStatusesCollection (size=1) [
     
  • DnStatus {

        DN Id = 9100057
        SwitchId = SIPSwitch1
        GSW DN TYPES = 1
        DN Status = 8
        Time = 1605122633
        Actions = DnActionCollection (size=1) [
         
  • DnAction {

            Action = NotReadyForNextCall
            Time = 1605122633
            ActionDataType = CallData
            ConnectionId = 0000000000000000
            DNIS = null
            ANI = null
            UserData = KVList:
'ReasonCode' [str] = "Login"
'INTERACTION_WORKSPACE' [str] = "8.5.126.7"
          }
        ]
      }
    ]
  }
}


        TM_LENGTH [int] = 0
        LONG_VALUE [int] = 0
        USER_REQ_ID [int] = -1
        TM_SERVER [int] = 1605124112
        REQ_ID [int] = 53829
 


My Challenge is that I couldn't find a way to extract various PlaceStatus and DNStatus info from the above output. I tried different permutations of casting the EventInfo/message to PlaceStatus/DnStatus objects without any success.

Could someone tell me how it can be done leveraging the current StatServer API methods?

Thank you so much for reading this and I will appreciate your input into it.

cheers,


Offline PeteHoyle

  • Full Member
  • ***
  • Posts: 121
  • Karma: 11
Re: Extracting StatServer EventInfo data
« Reply #1 on: November 14, 2020, 01:20:12 AM »
Hi,

You first need to cast it to an AgentStatus, then from there you can get the PlaceStatus and from there the DN Status

I don't have an easy to ready Java example at the moment, but here is a C# example:

Code: [Select]

        private void OnEventInfo(IMessage theMessage)
        {
            EventInfo statisticsInfo = theMessage as EventInfo;
            if (statisticsInfo != null)
            {
                if (statisticsInfo.StateValue is AgentStatus)
                {
                    AgentStatus status = (AgentStatus)statisticsInfo.StateValue;

                    PlaceStatus place_status = status.Place;

                    string myStatus = place_status.Status.ToString();
                    DnCollection dn_coll = place_status.DnStatuses;
                    foreach (DnStatus dn_status in dn_coll)
                    {
                        Console.WriteLine("DN IS : " + dn_status.DnId);
                    }
                }
                Console.WriteLine("EventInfo:\n" + statisticsInfo + "");
                writeLog(statisticsInfo.ToString());
            }
        }

It should be easy enough to convert to Java, if you have problems let me know..


Pete