protected override void execute() { try { int _type; int.TryParse(parameters[0], out _type); callStatsType = (CallStatsType)_type; short.TryParse(parameters[1], out key); CallStats _callStats; if (callStatsType == CallStatsType.Total) { _callStats = Dispatcher.GetCallStats(); } else if (callStatsType == CallStatsType.Customer) { _callStats = Dispatcher.GetCustomerCallStats(key); } else if (callStatsType == CallStatsType.Carrier) { _callStats = Dispatcher.GetCarrierCallStats(key); } else { throw new ArgumentException("Unknown CallStats Type: " + callStatsType); } AddResponseField("true", false); AddResponseField(_callStats.Startup, false); AddResponseField(_callStats.Running, false); AddResponseField(_callStats.TotalCalls.ToString(), false); AddResponseField(_callStats.TotalSuccessfullCalls.ToString(), false); AddResponseField(_callStats.OpenCalls.ToString(), false); AddResponseField(_callStats.ConnectingCalls.ToString(), false); AddResponseField(_callStats.ConnectedCalls.ToString(), false); AddResponseField(_callStats.TotalCurrentCalls.ToString(), true); } catch (Exception _ex) { TimokLogger.Instance.LogRbr(LogSeverity.Critical, "OnGetCallStats.Execute:", string.Format("Exception:\r\n{0}", _ex)); SetResponseToException((int)RbrResult.ExceptionThrown); } }
//--------------------- Call Stats API ------------------------------------------- public CallStats GetCallStatistics(CallStatsType pCallStatsType, int pKey) { try { var _parameters = new[] { ((int)pCallStatsType).ToString(), pKey.ToString() }; //-- Send command string _strResult; var _success = udpClient.SendAndReceive(RbrApi.Name, RbrApi.OnGetCallStats, _parameters, out _strResult); if (_success) { var _outParams = UdpMessageParser.GetOutParameters(_strResult); return(new CallStats(_outParams)); } throw new Exception("Rbr communication error"); } catch (Exception _ex) { throw new Exception("Rbr communication exception", _ex); } }