//建立ISocketRS列表 public ISocketRSlist[] CreateISocketRSlist() { try { string sql = "select DISTINCT [IPAddress] from tb_Gprs"; DataTable dt = Tool.DB.getDt(sql); ISocketRSlist[] _ISocketRSlist = new ISocketRSlist[dt.Rows.Count]; for (int i = 0; i < dt.Rows.Count; i++) { _ISocketRSlist[i]._ip = dt.Rows[i]["IPAddress"].ToString(); } return _ISocketRSlist; } catch { MessageBox.Show("建立ISocketRS列表失败!请检查数据库连接!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); return null; } }
//通过ip获取ISocketRSlist private ISocketRSlist GetISocketRSlist(string ip) { ISocketRSlist isl = new ISocketRSlist(); for (int i = 0; i < _ISocketRSlist.Length; i++) { if (_ISocketRSlist[i]._ip == ip) { isl = _ISocketRSlist[i]; break; } } return isl; }