I wouldn't recommend using RequestGetStatistic for cumulative statistics (TotalNumber, TotalTime, AverageNumber, etc). It works well for Current numbers, but can have some weird behavior when using with cummulative numbers.

Instead, use RequestOpenStatistic (or RequestOpenStatisticEx) and handle the EventInfo in your EventHandler function.

Take a look on this code that could be similar to your needs:

http://www.sggu.com/smf/index.php/topic,12271.msg54747.html#msg54747

Hey!

When you say cumulative, you mean TotalNumber being total inbound and outbound calls? Maybe there is another statistic I could pull? I am really only looking for the amount of inbound calls the agent has received on the day I run my application, I also don't want to periodically listen for events I just kind of want to read it and then close it.

Is there any example for Current number because I am not sure what you mean by that? (I thought Totalnumber of CallsAnswered was current number)

TotalNumber is a cummulative (or rather, aggregated) statistic. All the statistics that has some amount calculated over time is a cummulative/aggregated statistic. For instance - Total Number of call answered = total number since when?? Then, the TimeProfile comes into play, to let StatServer know the span which the numbers are valid. The Default time profile, for example, is a Growing profile that resets at midnight. You can have different ones, like "SinceLogin", or a Window of time (e.g. last 24 hours, last 1 hour, total within the hour, etc).

That said, for all those aggregated statistics, statserver needs to know that they will be needed and they need to be persisted. And that's where the RequestOpenStatistic comes into play.

Per the Stat Server's users guide:

Persistent Statistics

The term persistence means that a statistic, once requested by a client, continues to be calculated even after the client disconnects. Stat Server treats all requested statistics as persistent. When a statistic that is not already available on the server side is requested, it is automatically added to the Persistent Statistic Pool. Stat Server continues to calculate the statistic even after the requesting client closes it. When the client reopens the request for this statistic, the Persistent Statistic Pool resends it with accurate values to the client. By default, a statistic becomes obsolete and is removed from this pool three days after a client last requested it.

Now, If somebody had opened this statistic* before within the last 3 days, you should receive the correct return either with RequestOpenStatistic or RequestGetStatistic. However, my suggestion was merely because I have seen before RequestGetStatistic not as it should sometimes, so I always take the RequestOpenStatistic approach for any cummulative/aggregated statistic. Should you really need to get with RequestGetStatistic and are getting wrong values (given that this Very Same Statitistic* has been used in the previous 3 days), you should talk to Genesys Technical Support because might be some bug.

Now, I have marked "statistic" with an * for the following reason:

An statistic means a combination of things, and if one of those things is different, it is another statistic:

Object + Statistical Type + Time Profile + Time Range(s) (when applicable) + Filter, being Statistical Type a combination of Category + Main Mask + Relative Mask + Formula

So, for example, if you have used an statistic with Time Profile "A" in the past, it is still open, and then you need the very same data for the same object, but with Time Profile "B", it will start counting from the time you first requested (and will continue for as long as Stat Server keeps it open).