Exemplo n.º 1
0
        public void OnGet()
        {
            try
            {
                SnortContext DB = HttpContext.RequestServices.GetService(typeof(SnortContext)) as SnortContext;
                geolocationTable.LoadIPLocations(ref StaticData.iplocations, DB.GetConnection());

                Geolocator.Geolocate(StaticData.iplocations, DB);

                alerts = StaticData.alerts;
                if (HttpContext.Request.Query.Count > 0)
                {
                    Filtering.applyFilter(ref alerts, HttpContext.Request.Query);
                }
                JSONcountries = Stats.GraphDataByCountry(alerts, StaticData.iplocations, out country_attacks);

                RegionInfo info;
                country_table = new List <Country>();

                foreach (KeyValuePair <string, int> pair in country_attacks.OrderByDescending(x => x.Value))
                {
                    if (pair.Key == "n/a")
                    {
                        country_table.Add(new Country
                        {
                            country = pair.Key,
                            count   = pair.Value
                        }
                                          );
                        continue;
                    }
                    try
                    {
                        info = new RegionInfo(pair.Key);
                    }
                    catch (Exception)
                    {
                        continue;
                    }
                    country_table.Add(new Country
                    {
                        country = info.EnglishName,
                        count   = pair.Value
                    }
                                      );
                }
                StaticData.country_table = country_table;
                ;
            }
            catch (Exception e)
            {
                error = e.Message;
                return;
            }
        }