private string m_isDebugState = "0";//如果是1就打开debug状态 #endregion #region 公开的方法 /// <summary> /// 初始化 /// </summary> /// <param name="htmlWindow">调用页面</param> /// <param name="jsCallBackFun">回调方法</param> /// <param name="flag">1为html 2为WORD</param> /// <param name="url">上传服务器的地址</param> /// <param name="debug">可选参数为1时才弹出bug窗体</param> public void initService(IHTMLWindow2 htmlWindow, String jsCallBackFun, string flag, string url, string debug = "0") { myConvertType = (ConvertType)Enum.Parse(typeof(ConvertType), flag); this.m_htmlWindow = (HTMLWindow2Class)Marshal.CreateWrapperOfType(htmlWindow, typeof(HTMLWindow2Class)); this.m_jsCallBackFun = jsCallBackFun; m_isDebugState = debug; m_strURL = url; }
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(); }
private void button2_Click(object sender, EventArgs e) { IHTMLDocument2 hdoc = doc.DomDocument as IHTMLDocument2; IHTMLWindow2 win = hdoc.parentWindow as mshtml.IHTMLWindow2; var d = win.execScript(@"function sucdd(){ return popUpWin;}", "javascript"); HTMLWindow2Class dddd = doc.InvokeScript("sucdd") as HTMLWindow2Class; IHTMLDocument2 popupdoc = dddd.document; IHTMLElementCollection eleclt = popupdoc.all.tags("span") as IHTMLElementCollection; foreach (IHTMLElement item in eleclt) { if (item.innerText != null) { if (item.innerText.Contains("问题十四")) { item.click(); } } } //IHTMLElement ele=eleclt.item }