public static void Read() { string connectionString = "Data Source=192.168.111.10;User ID=sa;Password=8g3k5!w;"; using (var conn = new SqlConnection(connectionString)) { try { conn.Open(); string sql = "SELECT IP FROM UserPacket.dbo.IP"; var command = new SqlCommand(sql); command.Connection = conn; using (var reader = command.ExecuteReader()) { try { while (reader.Read()) { string ip = reader.GetString(0); var msg = IP.Find(ip); if (msg[0].Length > 4) { Console.WriteLine(ip + " - " + string.Join(",", msg)); // break; } } } catch { } finally { reader.Close(); } } } catch { } finally { conn.Close(); } } }
private static void Main(string[] args) { var sw = new Stopwatch(); sw.Start(); IP.EnableFileWatch = true; // IP.Load(@"D:\17monipdb.dat"); IP.Load("IP.dat"); //Console.WriteLine(string.Join(",", IP.Find("113.108.146.106"))); //string str = string.Empty; //do //{ // str = Console.ReadLine(); // Console.WriteLine(string.Join(",", IP.Find(str))); //} //while (!string.IsNullOrWhiteSpace(str)); var ipList = FileHelper.Read(); foreach (var ip in ipList) { var msg = IP.Find(ip); Console.WriteLine(ip + " - " + string.Join(",", msg)); } //SqlHelper.Read(); sw.Stop(); Console.WriteLine("Count = " + ipList.Count); Console.WriteLine("Timespan = " + sw.ElapsedMilliseconds); Console.WriteLine("\nFinish"); Console.ReadKey(true); }