Exemple #1
0
        public List <Indihiang.DomainObject.IPCountry> GetAllIpCountry()
        {
            SQLiteConnection con = null;
            SQLiteDataReader rd  = null;
            List <Indihiang.DomainObject.IPCountry> list = new List <Indihiang.DomainObject.IPCountry>();

            try
            {
                con = new SQLiteConnection(GetConnectionStrng());
                con.Open();

                string        query = "SELECT ip_start,ip_end,country_name FROM ip_country";
                SQLiteCommand cmd   = new SQLiteCommand(query, con);
                rd = cmd.ExecuteReader();
                while (rd.Read())
                {
                    Indihiang.DomainObject.IPCountry obj = new Indihiang.DomainObject.IPCountry();
                    if (!rd.IsDBNull(rd.GetOrdinal("ip_start")))
                    {
                        obj.IpStart = Convert.ToDouble(rd["ip_start"]);
                    }
                    else
                    {
                        obj.IpStart = 0;
                    }
                    if (!rd.IsDBNull(rd.GetOrdinal("ip_end")))
                    {
                        obj.IpEnd = Convert.ToDouble(rd["ip_end"]);
                    }
                    else
                    {
                        obj.IpEnd = 0;
                    }
                    if (!rd.IsDBNull(rd.GetOrdinal("country_name")))
                    {
                        obj.CoutryName = (string)rd["country_name"];
                    }


                    list.Add(obj);
                }
            }
            catch (Exception err)
            {
                System.Diagnostics.Debug.WriteLine(err.StackTrace);
            }
            finally
            {
                if (rd != null)
                {
                    rd.Close();
                }
                if (con != null)
                {
                    con.Close();
                }
            }

            return(list);
        }
Exemple #2
0
        public List <Indihiang.DomainObject.IPCountry> GetAllIpCountry()
        {
            List <Indihiang.DomainObject.IPCountry> list = new List <Indihiang.DomainObject.IPCountry>();

            if (Indihiang.Properties.Settings.Default.FindCountries == false)
            {
                return(list);
            }

            SQLiteConnection con = null;
            SQLiteDataReader rd  = null;

            try
            {
                con = new SQLiteConnection(GetConnectionStrng());
                con.Open();

                string        query = "SELECT ip_start,ip_end,country_name FROM ip_country";
                SQLiteCommand cmd   = new SQLiteCommand(query, con);
                rd = cmd.ExecuteReader();
                while (rd.Read())
                {
                    Indihiang.DomainObject.IPCountry obj = new Indihiang.DomainObject.IPCountry();
                    if (!rd.IsDBNull(rd.GetOrdinal("ip_start")))
                    {
                        obj.IpStart = Convert.ToDouble(rd["ip_start"]);
                    }
                    else
                    {
                        obj.IpStart = 0;
                    }
                    if (!rd.IsDBNull(rd.GetOrdinal("ip_end")))
                    {
                        obj.IpEnd = Convert.ToDouble(rd["ip_end"]);
                    }
                    else
                    {
                        obj.IpEnd = 0;
                    }
                    if (!rd.IsDBNull(rd.GetOrdinal("country_name")))
                    {
                        obj.CoutryName = (string)rd["country_name"];
                    }


                    list.Add(obj);
                }
            }
            catch (Exception err)
            {
                System.Diagnostics.Debug.WriteLine(err.StackTrace);

                System.Windows.Forms.MessageBox.Show("There was an error reading the country IP ranges.\n\nHave you installed the \'ipcountry.db\' database into (User Profile Application Data)\\Indihiang\\Media?\n\nException: " + err.Message, "Exception", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Warning);
            }
            finally
            {
                if (rd != null)
                {
                    rd.Close();
                }
                if (con != null)
                {
                    con.Close();
                }
            }

            return(list);
        }