Esempio n. 1
0
        private void AddIpButton_Click(object sender, RoutedEventArgs e)
        {
            string AllIp = IpListBox.Text;
            AllIp = AllIp.Replace("\r", "");
            string[] IpList = AllIp.Split('\n');
            DatabaseDataSet.ipsDataTable ipsDt = new DatabaseDataSet.ipsDataTable();
            foreach (string ip in IpList)
            {
                Regex rx = new Regex(@"((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))");
                if (rx.IsMatch(ip))
                {
                    DataRow row = ipsDt.NewRow();
                    row["ip"] = ip;
                    row["country"] = GetstringIpAddress(ip);
                    ipsDt.Rows.Add(row);
                }
            }
            DatabaseDataSetTableAdapters.ipsTableAdapter ipsTa = new DatabaseDataSetTableAdapters.ipsTableAdapter();
            try
            {
                ipsTa.Update(ipsDt);
                ipsTa.Fill(PublicClass.ipsDataTable);
            }
            catch (Exception ex)
            {

            }
            this.Close();
        }
Esempio n. 2
0
        private void AddIpButton_Click(object sender, RoutedEventArgs e)
        {
            string AllIp = IpListBox.Text;

            AllIp = AllIp.Replace("\r", "");
            string[] IpList = AllIp.Split('\n');
            DatabaseDataSet.ipsDataTable ipsDt = new DatabaseDataSet.ipsDataTable();
            foreach (string ip in IpList)
            {
                Regex rx = new Regex(@"((?:(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(?:25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d))))");
                if (rx.IsMatch(ip))
                {
                    DataRow row = ipsDt.NewRow();
                    row["ip"]      = ip;
                    row["country"] = GetstringIpAddress(ip);
                    ipsDt.Rows.Add(row);
                }
            }
            DatabaseDataSetTableAdapters.ipsTableAdapter ipsTa = new DatabaseDataSetTableAdapters.ipsTableAdapter();
            try
            {
                ipsTa.Update(ipsDt);
                ipsTa.Fill(PublicClass.ipsDataTable);
            }
            catch (Exception ex)
            {
            }
            this.Close();
        }