private List <MachineInfo> getWebData() { string strJson = string.Empty; try { strJson = WebInfo.GetPageInfo("http://pcis/projects/power/correct_power.asp?callback=?"); //strJson = Ini.GetItemValue("general", "json"); int startIdx = strJson.IndexOf('('), endIdx = strJson.IndexOf(')'); strJson = strJson.Substring(startIdx, endIdx - startIdx + 1); } catch { } if (!strJson.Contains("POWER")) { this.webFailCount++; if (this.webFailCount >= 5) { this.timerWeb.Enabled = false; MessageBox.Show("网络读取数据失败"); } return(null); } List <MachineInfo> infoList = JSON.parse <List <MachineInfo> >(strJson); this.webFailCount = 0; return(infoList); }
private void btnTest_Click(object sender, EventArgs e) { string strHTML = WebInfo.GetPageInfo(tbUrl.Text); this.rtbWebContent.Text = strHTML; }