public void comm(string ip) { try { int online = 0, offline = 0; Ping ping = new Ping(); for (int i = 0; i < 6; i++) { PingReply pingReply = ping.Send(ip); if (pingReply.Status == IPStatus.Success) { online++; } else { offline++; } } var db = new DbHelp("192.168.36.162", "cmsdb", "sa", "xgmes"); string sql = "insert into a_ip_comm(ip,online,offline) values('" + ip + "'," + online + "," + offline + ")"; db.ExeSql(sql); } catch { } }
public void dianjian(int hour, string type = "自动") { try { var db = new DbHelp("192.168.36.162", "cmsdb", "sa", "xgmes"); string sql = "insert into a_ip_jl(ip,name,hour,type) values('" + GetLocalIP() + "','" + GetComputerName() + "'," + hour + ",'" + type + "')"; db.ExeSql(sql); label1.Text = DateTime.Now.ToString("HH:mm:ss") + "上传成功!"; } catch { shangchuan = false; } }