public void Test1() { string xml = "<?xml version=\"1.0\" encoding=\"GBK\"?><Request Name=\"CMD_CHECKSELF_LLJ\" Method=\"WriteCalib\"><Result><Row><StartTime>2018-07-25 11:34:55</StartTime><EndTime>2018-07-25 11:35:30</EndTime><CalibName>流量计检查</CalibName><O2>20.50</O2><FLOW>95</FLOW><ALL_PD>1</ALL_PD><JCXH>1</JCXH></Row></Result></Request>"; var result = RegexXML.MatchProterty(xml, "Request Name"); Assert.Equal("CMD_CHECKSELF_LLJ", result); result = RegexXML.MatchProterty(xml, "Method"); GenerateSql <Moc> .Query("ID"); }
private void btnSearch_Click(object sender, EventArgs e) { //查询前清空之前的数据 picQRCode.BackgroundImage = null; carFiller.DisplayEntity(null); string hphm = combQueryAera.Text + txtQueryPlateNo.Text.Trim(); string vin = txtQueryVIN.Text.Trim(); string hpzl = AppHelper.GetCodeByName(combQueryPlateType.Text, "HPZL"); string result = ""; string loginUser = ""; LoadingForm frmLoading = new LoadingForm("正在查询..."); frmLoading.BackgroundWorkAction = delegate() { try { frmLoading.CurrentMsg = new KeyValuePair <int, string>(10, "正在查询..."); NetHelper netHelper = new NetHelper(); result = netHelper.QueryCar(hphm, hpzl, loginUser, vin); } catch (Exception ex) { MessageBox.Show("查询时出现错误:" + ex.Message); } }; frmLoading.ShowDialog(); if (string.IsNullOrEmpty(result)) { MessageBox.Show("查询结果为空"); return; } File.WriteAllText("18J52.txt", result); result = HttpUtility.HtmlDecode(result); string code = RegexXML.MatchField(result, "code", false); if ("1".Equals(code)) { X18J52 x18J52 = RegexXML.XmlToModelByName <X18J52>(result); string js = JsonConvert.SerializeObject(x18J52); Bitmap bitmap = Live0xUtils.QRCodeUtils.QRCodeHelper.CreateCode(js, -1, 3, true); picQRCode.BackgroundImage = bitmap; DateTime d; if (x18J52.ccrq != null && DateTime.TryParse(x18J52.ccrq, out d)) { x18J52.ccrq = d.ToString("yyyy年MM月dd日"); } if (x18J52.ccdjrq != null && DateTime.TryParse(x18J52.ccdjrq, out d)) { x18J52.ccdjrq = d.ToString("yyyy年MM月dd日"); } x18J52.cllx = AppHelper.GetNameByCode(x18J52.cllx, "CLZL"); x18J52.hpzl = AppHelper.GetNameByCode(x18J52.hpzl, "HPZL"); carFiller.DisplayEntity(x18J52); } else if (string.IsNullOrEmpty(code)) { MessageBox.Show("查询信息为空" + result); } else { MessageBox.Show(RegexXML.MatchField(result, "message", false)); } }