private void GetInfo() { IHTMLDocument2 hdoc = doc.DomDocument as IHTMLDocument2; IHTMLWindow2 win = hdoc.parentWindow as mshtml.IHTMLWindow2; var d = win.execScript(@"function sucdd(){ return popUpWinQm;}", "javascript"); if (hdoc == null) { MessageBox.Show("hdoc is null"); } if (win == null) { MessageBox.Show("win is null"); } HTMLWindow2Class dddd1 = doc.InvokeScript("sucdd") as HTMLWindow2Class; IHTMLWindow2 dddd = doc.InvokeScript("sucdd") as IHTMLWindow2; IHTMLDocument2 popupdoc = dddd.document; IHTMLElementCollection elelist = popupdoc.all.tags("tr") as IHTMLElementCollection; Dictionary <string, string> dic = new Dictionary <string, string>(); int i = 0;//申请号,申请人类型(法人或其他组织,自然人),书式类型(中国大陆),申请人名称,身份证明文件号码 foreach (IHTMLElement item in elelist) { if (i < 3) { continue; } if (i >= elelist.length - 15) { break; } dic.Add(((item.children as IHTMLElementCollection).item(null, 0) as IHTMLElement).innerText, ((item.children as IHTMLElementCollection).item(null, 1) as IHTMLElement).innerText); } if (dic.Values.Contains("中国大陆")) { string regNum = ""; string applicantCategory = ""; string applicant = ""; string idCard = ""; dic.TryGetValue("申请号", out regNum); dic.TryGetValue("申请人类型", out applicantCategory); dic.TryGetValue("申请人名称", out applicant); dic.TryGetValue("身份证明文件号码", out idCard); CommonLibrary.CommonTool.GetResult(currentUrl + string.Format("api/AutoReport/GetAddApplicantRegNum?regNum={0}&category={1}&applicant={2}&idCard={3}&id={4}", regNum, applicantCategory, applicant, idCard, currentId)); } dddd.close(); }
/// <summary> /// 自动选择小项具体处理 /// </summary> /// <param name="pararray">小项中文说明列表</param> /// <param name="isLastItem">是否是最后一组要选择的小项</param> private void SelectItem(string[] pararray, bool isLastItem) { try { //获取弹出窗口对象信息 IHTMLDocument2 hdoc = doc.DomDocument as IHTMLDocument2; IHTMLWindow2 win = hdoc.parentWindow as mshtml.IHTMLWindow2; var d = win.execScript(@"function sucdd(){ return popUpWin;}", "javascript"); if (hdoc == null) { MessageBox.Show("hdoc is null"); } if (win == null) { MessageBox.Show("win is null"); } //HTMLWindow2Class dddd = doc.InvokeScript("sucdd") as HTMLWindow2Class; IHTMLWindow2 dddd = doc.InvokeScript("sucdd") as IHTMLWindow2; if (dddd == null) { MessageBox.Show("DDDDDD"); } IHTMLDocument2 popupdoc = dddd.document; win = popupdoc.parentWindow as IHTMLWindow2; string s = @"function confirm() {"; s += @"return true;"; s += @"}"; s += @"function alert() {}"; win.execScript(s, "javascript"); IHTMLElementCollection elelist = popupdoc.all.tags("table") as IHTMLElementCollection; IHTMLElement table_ele = null; foreach (var item in elelist) { table_ele = item as IHTMLElement; } if (table_ele != null) { //获取td列表 IHTMLElementCollection trlist = (table_ele.all as IHTMLElementCollection).tags("tr") as IHTMLElementCollection; IHTMLElement ele1 = null, ele2 = null; //匹配小项节点 foreach (IHTMLElement item in trlist) { IHTMLElementCollection tdlist = (item.all as IHTMLElementCollection).tags("td") as IHTMLElementCollection; if (tdlist.length == 3) { ele1 = tdlist.item(null, 0) as IHTMLElement; int i = 0; foreach (IHTMLElement trele in tdlist) { if (i == 0) { ele1 = trele; } if (i == 2) { ele2 = trele; } i++; } if (pararray.Contains(ele2.innerText.ToString().Trim())) { IHTMLElement inputele = (ele1.children as IHTMLElementCollection).item(null, 0) as IHTMLElement; inputele.setAttribute("checked", true); this.AutoSelectItemCount++; } } } IHTMLElement submitlist = popupdoc.all.item("b1", 0) as IHTMLElement; submitlist.click(); } if (isLastItem) { dddd.close(); if (AutoSelectItemCount != ItemCount) { MessageBox.Show("系统自动抓取的小项个数小于实际小项总数,请人工核对抓取,或者删除现有全部小项,并再次启动自动抓取"); } else { MessageBox.Show("OK"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }