Ejemplo n.º 1
0
 /// <summary>
 /// 测试解析非车信息
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void button6_Click(object sender, EventArgs e)
 {
     string        html1 = File.ReadAllText(@"D:\tmp\1.html", Encoding.Default);
     string        html2 = File.ReadAllText(@"D:\tmp\2.html", Encoding.Default);
     string        html3 = File.ReadAllText(@"D:\tmp\3.html", Encoding.Default);
     CaseInfoModel case1 = GetCaseInfo(html1);
     CaseInfoModel case2 = GetCaseInfo(html2);
     CaseInfoModel case3 = GetCaseInfo(html3);
 }
Ejemplo n.º 2
0
        private CaseInfoModel GetCaseInfo(String caseInfohtml)
        {
            CaseInfoModel caseInfoModel = new CaseInfoModel();

            try
            {
                HtmlAgilityPack.HtmlDocument curHtmlDoc = new HtmlAgilityPack.HtmlDocument();
                curHtmlDoc.LoadHtml(caseInfohtml);

                #region 1.获取头信息
                String regexNo = @"报案号:[\s|\S]*?[&|<]";
                if (Regex.IsMatch(caseInfohtml, regexNo))
                {
                    caseInfoModel.CaseNo = Regex.Match(caseInfohtml, regexNo).Value.Replace("报案号", "").Replace(":", "").Replace("<", "").Replace("&", "").Trim();
                }
                #endregion

                #region 2.获取流程信息
                HtmlAgilityPack.HtmlNodeCollection allTr = curHtmlDoc.DocumentNode.SelectNodes("//*[@id='tableSrc']/tr");
                caseInfoModel.FlowList = new List <CaseflowInfoModel>();
                foreach (HtmlAgilityPack.HtmlNode item in allTr)
                {
                    if (!String.IsNullOrEmpty(item.InnerText) && !item.InnerText.Contains("业务环节"))
                    {
                        List <HtmlAgilityPack.HtmlNode> curTd = item.SelectNodes("td").ToList();
                        if (curTd.Count == 8)
                        {
                            CaseflowInfoModel curInfo = new CaseflowInfoModel();
                            curInfo.CaseStep        = curTd[0].InnerText;
                            curInfo.CaseNo          = curTd[1].InnerText;
                            curInfo.CaseOperateName = curTd[2].InnerText;
                            curInfo.CaseSubmitName  = curTd[3].InnerText;
                            curInfo.CaseInDateTime  = curTd[4].InnerText;
                            curInfo.CaseOutDateTime = curTd[5].InnerText;
                            curInfo.CaseStatus      = curTd[6].InnerText;
                            curInfo.CaseCancelSign  = curTd[7].InnerText;
                            caseInfoModel.FlowList.Add(curInfo);
                        }
                    }
                }
                #endregion
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(caseInfoModel);
        }