Esempio n. 1
0
 public Filter getFilterFromLocation(string LatLong)
 {
     //we have to check all filters and see if we can get the lat and long from them
     Filter f = new Filter();
     foreach (Filter id in GlobalHandlers.DatabaseHandler.getFilters())
     {
         string lat = LatLong.Split(Char.Parse(","))[0];
         string longD = LatLong.Split(Char.Parse(","))[1];
         f.Lat = lat;
         f.Long = longD;
         if (id.Lat.Contains(lat) && id.Long.Contains(longD))
         {
             return id;
         }
     }
     return f;
 }
Esempio n. 2
0
        public List<Filter> getFilters()
        {
            List<Filter> filterList = new List<Filter>();
            if (MySqlConnection.State == System.Data.ConnectionState.Open)
            {
                try
                {
                    MySqlCommand cmd = new MySqlCommand("SELECT * FROM `filters`", MySqlConnection);

                    using (MySqlDataReader reader = cmd.ExecuteReader())
                    {
                        if (!reader.HasRows)
                        {
                            cmd.Dispose();
                            reader.Close();
                            return filterList;
                        }
                        while (reader.Read())
                        {
                            string id = reader["id"].ToString();
                            string name = reader["filter_text"].ToString();
                            string longx = reader["long"].ToString();
                            string lat = reader["lat"].ToString();
                            Filter filter = new Filter();
                            filter.Id = id;
                            filter.Name = name;
                            filter.Long = longx;
                            filter.Lat = lat;
                            filterList.Add(filter);
                        }
                        reader.Close();
                    }
                    return filterList;
                }
                catch (MySqlException ecc)
                {
                    GlobalHandlers.Debugger.write(ecc.ToString());
                }
            }
            return filterList;
        }
Esempio n. 3
0
        public Filter getDefaultFilter()
        {
            try
            {
                Filter toReturn = new Filter();
                toReturn.Name = GlobalHandlers.DatabaseHandler.globalInformation.School_Name;
                string latlong = GlobalHandlers.SettingHandler.Settings["default_filter"].ToString();
                string[] splited = latlong.Split(Char.Parse(","));
                toReturn.Lat = splited[0].Replace(" ", "");
                toReturn.Long = splited[1].Replace(" ", "");

                return toReturn;
            }
            catch (Exception ee)
            {
                GlobalHandlers.Debugger.write(ee.ToString());
                return new Filter();
            }
        }