CountryStats Class Properties and Methods (.NET)

 

The CountryStats class exposes statistics on the total number of hits per country. It also provides methods for persisting statistics to disk so that the statistics can be loaded to keep running counts the next time your application is started (by default statistics are keep in memory only for the lifetime of the running application).

 

To obtain a list of statistics by country, simply use foreach enumeration. The following examples demonstrate how to enumerate the CountryStats object to obtain a list of statistics by country:

VB.NET Example:

 

dim ctyStats as new CountryStats()

dim chObj as CountryObj

for Each chObj in ctyStats

 Response.Write(chObj.CountryName + " ")

 Response.Write(chObj.CountryCode + " ") 

 Response.Write(chObj.HitCount.ToString() + "<br>")

next chObj

C# Example:

 

CountryStats ctyStats = new CountryStats();

foreach (CountryObj chObj in ctyStats)

{

 Response.Write(chObj.CountryName + " ");

 Response.Write(chObj.CountryCode + " ");

 Response.Write(chObj.HitCount.ToString() + "<br>");

}

 

Note: See the ch_statsByCountry_vb.aspx sample for more details.

 

Note: You can control the sort order of the returned results by specifying a member of the StatsSortOrder class.

 

Tip: To obtain the total number of hits for a particular country, instead of for all countries, see the HitCount property of the CountryObj class.

 

Note: Use of the CountryStats class requires the Enterprise Edition of CountryHawk.