private void btnScanItPcBo_Click(object sender, EventArgs e) { DataTable dt = null; MvItToolBo bo = new MvItToolBo(); //dt = bo.compareMvNetworkByPcName(MvItToolBo.mvLanDefault); dt = bo.compareMvNetworkByPcName(new string[] { "192.168.161" }); dataGridView1.DataSource = dt; }
private void btnGetIPAliveByIpRange_Click(object sender, EventArgs e) { DataTable dt = null; IPEnumeration IPList = new IPEnumeration("192.168.161.0", "192.168.161.255"); MvLogger.write("start process"); MvItToolBo bo = new MvItToolBo(); dt = bo.scanComputerByIpRange(new string[] { "192.168.161" }, true); MvLogger.write("end process"); Console.WriteLine(dt.Rows.Count); richTextBox1.Clear(); foreach (IPAddress ip in IPList) { bool result = MvNetworker.isPingAlive(ip); string hostName = string.Empty; string strShow = string.Empty; if (result == false) { strShow = string.Format("{0} is not alive{1}", ip.ToString(), Environment.NewLine); Console.WriteLine(strShow); richTextBox1.Text += strShow; richTextBox1.Refresh(); continue; } try { // 取host name IPHostEntry host = Dns.GetHostEntry(ip); hostName = host.HostName; strShow = string.Format("{0} {1} is alive{2}", ip.ToString(), hostName, Environment.NewLine); Console.WriteLine(strShow); richTextBox1.Text += strShow; richTextBox1.Refresh(); } catch (SocketException) { strShow = string.Format("{0} host name is not alive{1}", ip.ToString(), Environment.NewLine); Console.WriteLine(strShow); richTextBox1.Text += strShow; richTextBox1.Refresh(); } } }