/// <summary> /// 保存资质 /// </summary> /// <param name="info"></param> /// <param name="html"></param> private void AddCorpQual(CorpInfo info, string html) { Parser parser = new Parser(new Lexer(html)); NodeList nodeList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("class", "data-grid"))); if (nodeList != null && nodeList.Count > 0) { TableTag table = nodeList[0] as TableTag; for (int i = 1; i < table.RowCount; i++) { TableRow tr = table.Rows[i]; string CorpId = string.Empty, QualName = string.Empty, QualCode = string.Empty, QualSeq = string.Empty, qualNum = string.Empty, QualType = string.Empty, QualLevel = string.Empty, ValidDate = string.Empty, LicDate = string.Empty, LicUnit = string.Empty; CorpId = info.Id; QualName = tr.Columns[0].ToNodePlainString(); QualCode = tr.Columns[2].ToNodePlainString(); QualLevel = tr.Columns[1].ToNodePlainString(); QualType = info.CorpType; LicDate = tr.Columns[4].ToPlainTextString().GetDateRegex(); ValidDate = tr.Columns[5].ToPlainTextString().GetDateRegex(); LicUnit = tr.Columns[3].ToNodePlainString(); qualNum = QualLevel.GetLevel(); CorpQual qual = ToolDb.GenCorpQual(info.Id, QualName, QualCode, QualSeq, QualType, QualLevel, ValidDate, LicDate, LicUnit, info.Url, qualNum, "广东省", "广东地区"); ToolDb.SaveEntity(qual, string.Empty); } } }
protected void AddCorpQual(CorpInfo info, string infoUrl) { string htmldtl = string.Empty; try { htmldtl = ToolWeb.GetHtmlByUrl(infoUrl); } catch { } Parser parser = new Parser(new Lexer(htmldtl)); NodeList nodeList = parser.ExtractAllNodesThatMatch(new TagNameFilter("table")); if (nodeList != null && nodeList.Count > 0) { TableTag table = nodeList[0] as TableTag; for (int i = 1; i < table.RowCount; i++) { if (table.Rows[i].ColumnCount <= 1) { break; } string CorpId = string.Empty, QualName = string.Empty, QualCode = string.Empty, QualSeq = string.Empty, qualNum = string.Empty, QualType = string.Empty, QualLevel = string.Empty, ValidDate = string.Empty, LicDate = string.Empty, LicUnit = string.Empty; TableRow tr = table.Rows[i]; QualType = tr.Columns[1].ToNodePlainString(); QualCode = tr.Columns[2].ToNodePlainString(); string name = tr.Columns[3].ToNodePlainString(); LicDate = tr.Columns[4].ToPlainTextString().GetDateRegex(); ValidDate = tr.Columns[5].ToPlainTextString().GetDateRegex(); LicUnit = tr.Columns[6].ToNodePlainString(); if (name.Contains("不分")) { QualName = name.Remove(name.IndexOf("不分")); QualLevel = "不分级"; } else if (name.Contains("暂定级")) { QualName = name.Remove(name.IndexOf("暂定级")); QualLevel = "不分级"; } else if (!string.IsNullOrWhiteSpace(name) && name.Length > 2) { QualLevel = name.Substring(name.Length - 2, 2); QualName = name.Remove(name.Length - 2, 2); } if (QualType.Contains("监理")) { QualName = QualName + "监理"; } qualNum = QualLevel.GetLevel(); CorpQual qual = ToolDb.GenCorpQual(info.Id, QualName, QualCode, QualSeq, QualType, QualLevel, ValidDate, LicDate, LicUnit, info.Url, qualNum, info.Province, info.City); ToolDb.SaveEntity(qual, string.Empty); } } }
private void AddCorpInfo(CorpInfo info, string ctx) { if (ToolDb.SaveEntity(info, string.Empty)) { string QualName = string.Empty, QualCode = string.Empty, QualSeq = string.Empty, qualNum = string.Empty, QualType = string.Empty, QualLevel = string.Empty, ValidDate = string.Empty, LicDate = string.Empty, LicUnit = string.Empty; QualName = QualType = "物业管理"; QualCode = ctx.GetRegexBegEnd("zzzshm.value", ";").GetReplace(new string[] { "=", "'" }); LicDate = ctx.GetRegexBegEnd("zzzsfzrq.value", ";").GetReplace(new string[] { "=", "'" }); QualLevel = ctx.GetRegexBegEnd("qyzzmc.value", ";").GetReplace(new string[] { "=", "'" }); qualNum = QualLevel.GetLevel(); CorpQual qual = ToolDb.GenCorpQual(info.Id, QualName, QualCode, QualSeq, QualType, QualLevel, ValidDate, LicDate, LicUnit, info.Url, qualNum, "广东省", "深圳市"); ToolDb.SaveEntity(qual, string.Empty); } }
/// <summary> /// 保存资质 /// </summary> /// <param name="noList"></param> private void AddQual(TableTag table, string id, string url) { for (int i = 1; i < table.RowCount; i++) { TableRow tr = table.Rows[i]; string CorpId = string.Empty, QualName = string.Empty, QualCode = string.Empty, QualSeq = string.Empty, qualNum = string.Empty, QualType = string.Empty, QualLevel = string.Empty, ValidDate = string.Empty, LicDate = string.Empty, LicUnit = string.Empty; QualCode = tr.Columns[0].ToNodePlainString(); QualName = QualType = tr.Columns[1].ToNodePlainString(); QualLevel = tr.Columns[2].ToNodePlainString(); ValidDate = tr.Columns[3].ToPlainTextString().GetDateRegex(); LicDate = tr.Columns[4].ToPlainTextString().GetDateRegex(); LicUnit = tr.Columns[5].ToNodePlainString(); qualNum = QualLevel.GetLevel(); CorpQual qual = ToolDb.GenCorpQual(id, QualName, QualCode, QualSeq, QualType, QualLevel, ValidDate, LicDate, LicUnit, url, qualNum, "广东省", "佛山市"); ToolDb.SaveEntity(qual, string.Empty); } }
protected override IList ExecuteCrawl(bool crawlAll) { IList list = new List <CorpInfo>(); string html = string.Empty; string cookiestr = string.Empty; string viewState = string.Empty; int pageInt = 1, count = 0; string eventValidation = string.Empty; try { html = ToolWeb.GetHtmlByUrl(this.SiteUrl, Encoding.UTF8); } catch { return(null); } Parser parser = new Parser(new Lexer(html)); NodeList pageNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("align", "center"))); if (pageNode != null && pageNode.Count > 0) { try { string countTemp = pageNode.AsString().GetRegexBegEnd("\r", "条").Replace(" ", "").Replace("\r", "").Replace("\n", ""); string temp = pageNode.AsString().GetRegexBegEnd("/", "页").Replace(" ", ""); pageInt = int.Parse(temp); count = int.Parse(countTemp); } catch { } } for (int i = 1; i <= pageInt; i++) { if (i > 1) { NameValueCollection nvc = ToolWeb.GetNameValueCollection( new string[] { "datainfo_id", "datainfo_action", "count", "pages", "page", "dwmc", "zzdj", "zsbh", "szss" }, new string[] { string.Empty, string.Empty, count.ToString(), pageInt.ToString(), i.ToString(), string.Empty, string.Empty, string.Empty, string.Empty } ); try { html = ToolWeb.GetHtmlByUrl(this.SiteUrl, nvc, Encoding.UTF8); } catch { continue; } } parser = new Parser(new Lexer(html)); NodeList listNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("class", "list-table"))); if (listNode != null && listNode.Count > 0) { TableTag table = listNode[0] as TableTag; for (int j = 1; j < table.RowCount; j++) { TableRow tr = table.Rows[j]; string CorpId = string.Empty, QualName = string.Empty, QualCode = string.Empty, QualSeq = string.Empty, qualNum = string.Empty, QualType = string.Empty, QualLevel = string.Empty, ValidDate = string.Empty, LicDate = string.Empty, LicUnit = string.Empty; QualName = "计算机信息系统集成"; QualCode = tr.Columns[3].ToNodePlainString(); QualLevel = tr.Columns[2].ToNodePlainString(); LicDate = tr.Columns[5].ToPlainTextString().GetDateRegex(); qualNum = QualLevel.GetLevel(); string corpName = tr.Columns[1].ToNodePlainString(); string city = tr.Columns[6].ToNodePlainString(); object isCorp = ToolDb.ExecuteScalar("select Id from CorpInfo where CorpName='" + corpName + "'"); if (isCorp == null || isCorp.ToString() == "") { string CorpName = string.Empty, CorpCode = string.Empty, CorpAddress = string.Empty, RegDate = string.Empty, RegFund = string.Empty, BusinessCode = string.Empty, BusinessType = string.Empty, LinkMan = string.Empty, LinkPhone = string.Empty, Fax = string.Empty, Email = string.Empty, CorpSite = string.Empty, cUrl = string.Empty, ISOQualNum = string.Empty, ISOEnvironNum = string.Empty, OffAdr = string.Empty, Cert = string.Empty, ctxKc = string.Empty, corpRz = string.Empty; CorpInfo info = ToolDb.GenCorpInfo(corpName, CorpCode, CorpAddress, RegDate, RegFund, BusinessCode, BusinessType, LinkMan, LinkPhone, Fax, Email, CorpSite, string.Empty, city, city, "中华人民共和国工业和信息化部", this.SiteUrl, ISOQualNum, ISOEnvironNum, OffAdr); if (ToolDb.SaveEntity(info, null)) { CorpQual qual = ToolDb.GenCorpQual(info.Id, QualName, QualCode, QualSeq, QualType, QualLevel, ValidDate, LicDate, LicUnit, info.Url, qualNum, city, city); ToolDb.SaveEntity(qual, ""); } } else { CorpQual qual = ToolDb.GenCorpQual(isCorp.ToString(), QualName, QualCode, QualSeq, QualType, QualLevel, ValidDate, LicDate, LicUnit, this.SiteUrl, qualNum, city, city); ToolDb.SaveEntity(qual, "QualCode,CorpId,QualName", true); } } } } return(list); }
/// <summary> /// 企业资质信息 /// </summary> /// <param name="info"></param> /// <param name="html"></param> protected void AddCorpQual(CorpInfo info, string html) { Parser parser = new Parser(new Lexer(html)); NodeList nodeList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("id", "zzzsxx"))); if (nodeList != null && nodeList.Count > 0) { parser = new Parser(new Lexer(nodeList.ToHtml().Replace("th", "td"))); NodeList dtlNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("table")); if (dtlNode != null && dtlNode.Count > 0) { TableTag table = dtlNode[0] as TableTag; for (int i = 1; i < table.RowCount; i++) { string CorpId = string.Empty, QualName = string.Empty, QualCode = string.Empty, QualSeq = string.Empty, qualNum = string.Empty, QualType = string.Empty, QualLevel = string.Empty, ValidDate = string.Empty, LicDate = string.Empty, LicUnit = string.Empty; TableRow tr = table.Rows[i]; if (tr.Columns[0].ToPlainTextString().Contains("没有显示结果")) { break; } QualType = tr.Columns[1].ToNodePlainString(); QualCode = tr.Columns[2].ToNodePlainString(); parser = new Parser(new Lexer(html)); NodeList listDtlNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("id", "qyzz"))); if (listDtlNode != null && listDtlNode.Count > 0) { parser = new Parser(new Lexer(listDtlNode.ToHtml().Replace("th", "td"))); NodeList tableNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("table")); if (tableNode != null && tableNode.Count > 0) { TableTag dtlTable = tableNode[0] as TableTag; bool isAdd = false; for (int k = 1; k < dtlTable.RowCount; k++) { TableRow dr = dtlTable.Rows[k]; if (dr.Columns[0].ToPlainTextString().Contains("没有显示结果")) { isAdd = true; break; } QualName = dr.Columns[1].ToNodePlainString(); QualLevel = dr.Columns[2].ToNodePlainString(); LicUnit = dr.Columns[3].ToNodePlainString(); LicDate = dr.Columns[4].ToNodePlainString(); if (info.CorpType.Contains("监理")) { QualName = QualName + "监理"; } qualNum = QualLevel.GetLevel(); CorpQual qual = ToolDb.GenCorpQual(info.Id, QualName, QualCode, QualSeq, QualType, QualLevel, ValidDate, LicDate, LicUnit, info.Url, qualNum, "广东省", "深圳市"); ToolDb.SaveEntity(qual, string.Empty); } if (isAdd) { if (info.CorpType.Contains("监理")) { QualName = QualName + "监理"; } qualNum = QualLevel.GetLevel(); LicUnit = tr.Columns[3].ToNodePlainString(); LicDate = tr.Columns[4].ToPlainTextString().GetDateRegex(); QualName = QualType; CorpQual qual = ToolDb.GenCorpQual(info.Id, QualName, QualCode, QualSeq, QualType, QualLevel, ValidDate, LicDate, LicUnit, info.Url, qualNum, "广东省", "深圳市"); ToolDb.SaveEntity(qual, string.Empty); } } } } } } }
/// <summary> /// 企业资质信息 /// </summary> /// <param name="info"></param> /// <param name="html"></param> protected void AddCorpQual(CorpInfo info, string param, string corpType) { string url = "http://portal.szjs.gov.cn:8888/publicShow/queryCertificateInfo.html"; string[] postParams = new string[] { "param", "corpType", "orgCode", "page" }; string[] postValues = new string[] { param, corpType, info.CorpCode, "1" }; NameValueCollection nvc = ToolWeb.GetNameValueCollection(postParams, postValues); string html = string.Empty; try { html = ToolWeb.GetHtmlByUrl(url, nvc, Encoding.UTF8); } catch { Thread.Sleep(12 * 60 * 1000); try { html = ToolWeb.GetHtmlByUrl(url, nvc, Encoding.UTF8); } catch { Thread.Sleep(8 * 60 * 1000); return; } } JavaScriptSerializer java = new JavaScriptSerializer(); Dictionary <string, object> jsonResults = (Dictionary <string, object>)java.DeserializeObject(html); int pageInt = 1; try { pageInt = (int)jsonResults["totalPage"]; } catch { } for (int i = 1; i <= pageInt; i++) { if (i > 1) { postValues = new string[] { param, corpType, info.CorpCode, i.ToString() }; nvc = ToolWeb.GetNameValueCollection(postParams, postValues); try { html = ToolWeb.GetHtmlByUrl(url, nvc, Encoding.UTF8); } catch { Thread.Sleep(12 * 60 * 1000); try { html = ToolWeb.GetHtmlByUrl(url, nvc, Encoding.UTF8); } catch { Thread.Sleep(8 * 60 * 1000); continue; } } jsonResults = (Dictionary <string, object>)java.DeserializeObject(html); } object[] dicQuals = (object[])jsonResults["records"]; foreach (object dicQual in dicQuals) { Dictionary <string, object> dic = (Dictionary <string, object>)dicQual; string CorpId = string.Empty, QualName = string.Empty, QualCode = string.Empty, QualSeq = string.Empty, qualNum = string.Empty, QualType = string.Empty, QualLevel = string.Empty, ValidDate = string.Empty, LicDate = string.Empty, LicUnit = string.Empty; QualType = Convert.ToString(dic["name"]); QualCode = Convert.ToString(dic["cert_no"]); string certType = Convert.ToString(dic["cert_type"]); string certId = Convert.ToString(dic["cert_id"]); string htmldtl = string.Empty; string urlDtl = "http://portal.szjs.gov.cn:8888/publicShow/queryCertificateDetail.html"; NameValueCollection dtlNvc = ToolWeb.GetNameValueCollection(new string[] { "param", "corpType", "cert_id" }, new string[] { param, certType, certId }); try { htmldtl = ToolWeb.GetHtmlByUrl(urlDtl, dtlNvc, Encoding.UTF8); } catch { Thread.Sleep(12 * 60 * 1000); try { htmldtl = ToolWeb.GetHtmlByUrl(urlDtl, dtlNvc, Encoding.UTF8); } catch { Thread.Sleep(8 * 60 * 1000); continue; } } object[] dtlQuals = (object[])java.DeserializeObject(htmldtl); foreach (object objQual in dtlQuals) { Dictionary <string, object> dicDtl = (Dictionary <string, object>)objQual; QualName = Convert.ToString(dicDtl["name1"]); QualLevel = Convert.ToString(dicDtl["name2"]); LicUnit = Convert.ToString(dicDtl["appr_org"]); LicDate = Convert.ToString(dicDtl["appr_date"]); ValidDate = Convert.ToString(dicDtl["valid_period"]); qualNum = QualLevel.GetLevel(); CorpQual qual = ToolDb.GenCorpQual(info.Id, QualName, QualCode, QualSeq, QualType, QualLevel, ValidDate, LicDate, LicUnit, info.Url, qualNum, "广东省", "深圳市"); ToolDb.SaveEntity(qual, string.Empty); } } } }
protected void AddCorpQual(CorpInfo info, string enterpriseId) { string gridSearch = "false"; string nd = ToolHtml.GetDateTimeLong(DateTime.Now).ToString(); string PAGESIZE = "100"; string PAGE = "1"; string sortField = ""; string sortDirection = "asc"; string url = "http://202.104.65.182:8081/G2/webdrive/web-enterprise-qualification.do?enterpriseId=" + enterpriseId + "&data&filter_params_=rowNum,qualificationId,enterpriseBaseId,enterpriseId,qualificationBeforeId,qualificationCode,validEnd&defined_operations_=&nocheck_operations_=&"; NameValueCollection nvc = ToolWeb.GetNameValueCollection(new string[] { "gridSearch", "nd", "PAGESIZE", "PAGE", "sortField", "sortDirection" }, new string[] { gridSearch, nd, PAGESIZE, PAGE, sortField, sortDirection }); string strJson = string.Empty; try { strJson = ToolWeb.GetHtmlByUrl(url, nvc); } catch { return; } JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> smsTypeJson = (Dictionary <string, object>)serializer.DeserializeObject(strJson); object[] objList = smsTypeJson["data"] as object[]; if (objList != null) { foreach (object obj in objList) { Dictionary <string, object> dic = obj as Dictionary <string, object>; string enterpriseBaseId = Convert.ToString(dic["enterpriseBaseId"]); string validEnd = Convert.ToString(dic["validEnd"]); string qualificationCode = Convert.ToString(dic["qualificationCode"]); string enterpriseIds = Convert.ToString(dic["enterpriseId"]); string qualificationBeforeId = Convert.ToString(dic["qualificationBeforeId"]); string qualificationId = Convert.ToString(dic["qualificationId"]); string dtlUrl = "http://202.104.65.182:8081/G2/webdrive/none/web-enterprise-qualification-item.do?qualificationId=" + qualificationId + "&actionFlag=&data&filter_params_=rowNum,qualificationItemId,qualificationId,contentCodeValue,qualificationCode,contentCodeName,qualificationLevelName,mainItem,certificateIssuer,certificateDate,validDate&defined_operations_=&nocheck_operations_=&"; string dtlJson = string.Empty; try { dtlJson = ToolWeb.GetHtmlByUrl(dtlUrl, nvc); } catch { continue; } Dictionary <string, object> dtlDicJson = (Dictionary <string, object>)serializer.DeserializeObject(dtlJson); object[] objDtlList = dtlDicJson["data"] as object[]; if (objDtlList != null) { foreach (object objDtl in objDtlList) { Dictionary <string, object> dicDtl = objDtl as Dictionary <string, object>; string CorpId = string.Empty, QualName = string.Empty, QualCode = string.Empty, QualSeq = string.Empty, qualNum = string.Empty, QualType = string.Empty, QualLevel = string.Empty, ValidDate = string.Empty, LicDate = string.Empty, LicUnit = string.Empty; CorpId = info.Id; QualCode = qualificationCode; QualName = QualType = Convert.ToString(dicDtl["contentCodeName"]); QualLevel = Convert.ToString(dicDtl["qualificationLevelName"]); LicUnit = Convert.ToString(dicDtl["certificateIssuer"]); LicDate = Convert.ToString(dicDtl["certificateDate"]); ValidDate = Convert.ToString(dicDtl["validDate"]); qualNum = QualLevel.GetLevel(); Dictionary <string, object> mainItem = dicDtl["mainItem"] as Dictionary <string, object>; if (mainItem != null) { QualSeq = Convert.ToString(mainItem["desc"]); } CorpQual qual = ToolDb.GenCorpQual(CorpId, QualName, QualCode, QualSeq, QualType, QualLevel, ValidDate, LicDate, LicUnit, info.Url, qualNum, "广东省", "广东地区"); ToolDb.SaveEntity(qual, string.Empty); } } } } }
protected override IList ExecuteCrawl(bool crawlAll) { string html = string.Empty; string cookiestr = string.Empty; string viewState = string.Empty; int pageInt = 1; string eventValidation = string.Empty; try { html = ToolWeb.GetHtmlByUrl(SiteUrl, Encoding.UTF8, ref cookiestr); } catch { return(null); } string opValue = string.Empty, leveVlaue = string.Empty; string[] levelNode = new string[] { "特级", "特级(旧标准)", "一级", "一级(旧标准)", "二级", "二级(旧标准)", "三级", "三级(旧标准)", "暂定三级(旧标准)", "不分等级" }; Parser parser = new Parser(new Lexer(html)); NodeList typeNode = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("select"), new HasAttributeFilter("id", "ctl00_ContentPlaceHolder1_ddlENT_SORT_ID")), true), new TagNameFilter("option"))); if (typeNode != null && typeNode.Count > 0) { for (int t = 1; t < typeNode.Count; t++) { for (int l = 1; l < levelNode.Length; l++) { leveVlaue = levelNode[l]; OptionTag opTag = typeNode[t] as OptionTag; opValue = opTag.GetAttribute("value"); parser = new Parser(new Lexer(html)); NodeList inputNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("input"), new HasAttributeFilter("id", "ctl00_ContentPlaceHolder1_ValidateCode1_txtRanNum"))); string valiCode = string.Empty; if (inputNode != null && inputNode.Count > 0) { valiCode = (inputNode[0] as InputTag).GetAttribute("value"); } viewState = ToolWeb.GetAspNetViewState(html); NameValueCollection typeNvc = ToolWeb.GetNameValueCollection( new string[] { "ctl00_ContentPlaceHolder1_toolkitScriptManager1_HiddenField", "__EVENTTARGET", "__EVENTARGUMENT", "__LASTFOCUS", "__VIEWSTATE", "ctl00$ContentPlaceHolder1$ddlENT_SORT_ID", "ctl00$ContentPlaceHolder1$ddlRank", "ctl00$ContentPlaceHolder1$txtEnt_name", "ctl00$ContentPlaceHolder1$ValidateCode1$txtValidateCode", "ctl00$ContentPlaceHolder1$ValidateCode1$txtRanNum", "ctl00$ContentPlaceHolder1$btnsearch" }, new string[] { "", "", "", "", viewState, opValue, leveVlaue, "", valiCode, valiCode, "搜 索" }); try { html = ToolWeb.GetHtmlByUrl(SiteUrl, typeNvc, Encoding.UTF8, ref cookiestr); } catch { continue; } parser = new Parser(new Lexer(html)); NodeList pageList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("id", "ctl00_ContentPlaceHolder1_AspNetPager1"))); if (pageList != null && pageList.Count > 0) { try { string temp = pageList[0].ToPlainTextString().GetRegexBegEnd("共", "条"); int page = int.Parse(temp); int result = page / 15; if (page % 15 != 0) { pageInt = result + 1; } else { pageInt = result; } } catch { pageInt = 1; } } for (int i = 1; i <= pageInt; i++) { if (i > 20) { break; } if (i > 1) { try { parser = new Parser(new Lexer(html)); NodeList pageInputNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("input"), new HasAttributeFilter("id", "ctl00_ContentPlaceHolder1_ValidateCode1_txtRanNum"))); string pageValiCode = string.Empty; if (pageInputNode != null && pageInputNode.Count > 0) { pageValiCode = (pageInputNode[0] as InputTag).GetAttribute("value"); } viewState = ToolWeb.GetAspNetViewState(html); NameValueCollection nvc = ToolWeb.GetNameValueCollection( new string[] { "ctl00$ContentPlaceHolder1$ddlENT_SORT_ID", "ctl00$ContentPlaceHolder1$ddlRank", "ctl00$ContentPlaceHolder1$txtEnt_name", "ctl00$ContentPlaceHolder1$ValidateCode1$txtRanNum", "ctl00$ContentPlaceHolder1$ValidateCode1$txtValidateCode", "ctl00_ContentPlaceHolder1_toolkitScriptManager1_HiddenField", "__EVENTARGUMENT", "__EVENTTARGET", "__LASTFOCUS", "__VIEWSTATE" }, new string[] { opValue, leveVlaue, "", pageValiCode, "", "", i.ToString(), "ctl00$ContentPlaceHolder1$AspNetPager1", "", viewState } ); html = ToolWeb.GetHtmlByUrl(SiteUrl, nvc, Encoding.UTF8, ref cookiestr); } catch { continue; } } parser = new Parser(new Lexer(html)); NodeList nodeList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "tab_ent"))); if (nodeList != null && nodeList.Count > 0) { #region 循环列表 TableTag table = nodeList[0] as TableTag; for (int j = 1; j < table.RowCount; j++) { string CorpName = string.Empty, CorpCode = string.Empty, CorpAddress = string.Empty, RegDate = string.Empty, RegFund = string.Empty, BusinessCode = string.Empty, BusinessType = string.Empty, LinkMan = string.Empty, LinkPhone = string.Empty, Fax = string.Empty, Email = string.Empty, CorpSite = string.Empty, cUrl = string.Empty, ISOQualNum = string.Empty, ISOEnvironNum = string.Empty, corpType = string.Empty, qualCode = string.Empty, corpMgr = string.Empty, businessMgr = string.Empty, tecMgr = string.Empty; string htlCtx = string.Empty, QualType = string.Empty, CorpLevey = string.Empty; TableRow tr = table.Rows[j]; string qualStr = tr.Columns[2].ToHtml(); CorpName = tr.Columns[1].ToNodePlainString(); QualType = tr.Columns[2].ToPlainTextString(); CorpLevey = tr.Columns[3].ToNodePlainString(); qualCode = tr.Columns[4].ToNodePlainString(); if (QualType == "--") { QualType = ""; } cUrl = "http://113.108.219.40/PlatForm/SearchCenter/" + tr.Columns[1].GetATagHref(); List <string> quaList = new List <string>(); parser = new Parser(new Lexer(tr.Columns[4].ToHtml())); NodeList quaNodeList = parser.ExtractAllNodesThatMatch(new TagNameFilter("a")); if (quaNodeList != null && quaNodeList.Count > 0) { for (int q = 0; q < quaNodeList.Count; q++) { quaList.Add("http://113.108.219.40/PlatForm/SearchCenter/" + quaNodeList[q].GetATagHref()); } } string quaUrl = "http://113.108.219.40/PlatForm/SearchCenter/" + tr.Columns[4].GetATagHref(); string htldtl = string.Empty; try { htldtl = ToolWeb.GetHtmlByUrl(cUrl, Encoding.UTF8); } catch { continue; } parser = new Parser(new Lexer(htldtl)); NodeList dtlList = parser.ExtractAllNodesThatMatch(new TagNameFilter("table")); if (dtlList != null && dtlList.Count > 0) { TableTag tab = dtlList[0] as TableTag; string ctx = string.Empty; for (int k = 0; k < tab.RowCount; k++) { for (int d = 0; d < tab.Rows[k].ColumnCount; d++) { if ((d + 1) % 2 == 0) { ctx += tab.Rows[k].Columns[d].ToNodePlainString() + "\r\n"; } else { ctx += tab.Rows[k].Columns[d].ToNodePlainString().Replace(":", "").Replace(":", "") + ":"; } } } corpType = ctx.GetRegex(new string[] { "企业类型", "类型" }); CorpAddress = ctx.GetRegex(new string[] { "企业注册地址", "地址" }); BusinessCode = ctx.GetRegex(new string[] { "营业执照注册号", "注册号" }); RegDate = ctx.GetRegex(new string[] { "成立时间", "成立日期", "时间", "日期" }).GetDateRegex(); LinkMan = ctx.GetRegex(new string[] { "企业法定代表人", "法定代表人" }); RegFund = ctx.GetRegex(new string[] { "注册资金", "资金" }); if (!RegFund.Contains("万")) { RegFund += "万"; } corpMgr = ctx.GetRegex(new string[] { "企业经理" }); if (corpMgr.Contains("暂无")) { corpMgr = string.Empty; } businessMgr = ctx.GetRegex(new string[] { "经营负责人" }); if (businessMgr.Contains("暂无")) { businessMgr = string.Empty; } tecMgr = ctx.GetRegex(new string[] { "技术负责人" }); if (tecMgr.Contains("暂无")) { tecMgr = string.Empty; } CorpInfo info = ToolDb.GenCorpInfo(CorpName, CorpCode, CorpAddress, RegDate, RegFund, BusinessCode, BusinessType, LinkMan, LinkPhone, Fax, Email, CorpSite, corpType, "广东省", "广东地区", "广东省住房和城乡建设厅", cUrl, ISOQualNum, ISOEnvironNum, string.Empty); string strSql = string.Format("select Id from CorpInfo where CorpName='{0}' and Url='{1}'", info.CorpName, info.Url); object obj = ToolDb.ExecuteScalar(strSql); if (obj != null && obj.ToString() != "") { StringBuilder delCorpQual = new System.Text.StringBuilder(); StringBuilder delCorpLeader = new System.Text.StringBuilder(); delCorpQual.AppendFormat("delete from CorpQual where CorpId='{0}'", obj); delCorpLeader.AppendFormat("delete from CorpLeader where CorpId='{0}'", obj); ToolDb.ExecuteSql(delCorpQual.ToString()); ToolDb.ExecuteSql(delCorpLeader.ToString()); string corpSql = string.Format("delete from CorpInfo where Id='{0}'", obj); ToolCoreDb.ExecuteSql(corpSql); } if (ToolDb.SaveEntity(info, string.Empty)) { if (!string.IsNullOrEmpty(LinkMan)) { CorpLeader leader = ToolDb.GenCorpLeader(info.Id, LinkMan, "", "企业法定代表人", cUrl); ToolDb.SaveEntity(leader, string.Empty); } if (!string.IsNullOrEmpty(corpMgr)) { CorpLeader leader = ToolDb.GenCorpLeader(info.Id, corpMgr, "", "企业经理", cUrl); ToolDb.SaveEntity(leader, string.Empty); } if (!string.IsNullOrEmpty(businessMgr)) { CorpLeader leader = ToolDb.GenCorpLeader(info.Id, businessMgr, "", "经营负责人", cUrl); ToolDb.SaveEntity(leader, string.Empty); } if (!string.IsNullOrEmpty(tecMgr)) { CorpLeader leader = ToolDb.GenCorpLeader(info.Id, tecMgr, "", "技术负责人", cUrl); ToolDb.SaveEntity(leader, string.Empty); } if (!string.IsNullOrEmpty(qualStr)) { List <CorpQual> corpQuals = new List <CorpQual>(); string quaCtx = string.Empty; for (int c = 0; c < quaList.Count; c++) { string quaHtl = string.Empty; try { quaHtl = ToolWeb.GetHtmlByUrl(quaList[c], Encoding.UTF8); } catch { } parser = new Parser(new Lexer(quaHtl)); NodeList quaNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("table")); if (quaNode != null && quaNode.Count > 0) { TableTag quaTable = quaNode[0] as TableTag; for (int k = 0; k < quaTable.RowCount; k++) { for (int d = 0; d < quaTable.Rows[k].ColumnCount; d++) { string temp = quaTable.Rows[k].Columns[d].ToNodePlainString(); //string quatemp = quaTable.Rows[k].ToNodePlainString(); if ((d + 1) % 2 == 0) { quaCtx += temp + "\r\n"; } else { quaCtx += temp.Replace(":", "").Replace(":", "") + ":"; } } } } string qualctx = string.Empty; parser.Reset(); NodeList spanNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("span"), new HasAttributeFilter("id", "lblQuaInfo"))); if (spanNode != null && spanNode.Count > 0) { qualctx = spanNode.ToHtml().GetReplace("<br/>,<br />,<br>,</br>", "∈").ToCtxString(); } string str = qualctx.ToLower().Replace("<br/>", "∈").Replace("</br>", "∈").Replace("<br>", "∈"); str = Regex.Replace(str, "<[^>]*>", ""); string[] qual = str.Split('∈'); for (int q = 0; q < qual.Length; q++) { if (string.IsNullOrEmpty(qual[q]) || qual[q] == "--") { continue; } string CorpId = string.Empty, QualName = string.Empty, quaCode = string.Empty, QualSeq = string.Empty, qualNum = string.Empty, QualLevel = string.Empty, ValidDate = string.Empty, LicDate = string.Empty, LicUnit = string.Empty, quaType = string.Empty; LicDate = quaCtx.GetRegex("发证日期,发证时间").GetDateRegex(); LicUnit = quaCtx.GetRegex("发证机关,发证机构"); ValidDate = quaCtx.GetRegex("证书有效期").GetDateRegex(); quaType = quaCtx.GetRegex("证书类型"); string value = qual[q]; int len = value.IndexOf("/"); if (len != -1) { QualLevel = value.Substring(len, value.Length - len).Replace("/", ""); value = value.Remove(len); } else { QualLevel = CorpLevey; } string[] dtl = value.Split(' '); CorpId = info.Id; QualName = dtl[0].Trim(); if (string.IsNullOrEmpty(QualName)) { QualName = dtl[dtl.Length - 1]; } quaCode = quaCtx.GetRegex("证书编号");//qualCode; for (int ty = 1; ty < dtl.Length; ty++) { quaType += dtl[ty].Trim() + ","; } if (!string.IsNullOrEmpty(quaType) && quaType.Contains(",")) { quaType = quaType.Substring(0, quaType.Length - 1); if (quaType[0] == ',' || quaType[0] == ',') { quaType = quaType.Substring(1, quaType.Length - 1); } } qualNum = QualLevel.GetLevel(); CorpQual corpQual = null; corpQual = ToolDb.GenCorpQual(info.Id, QualName, quaCode, QualSeq, quaType, QualLevel, ValidDate, LicDate, LicUnit, quaUrl, qualNum, "广东省", "广东地区"); ToolDb.SaveEntity(corpQual, string.Empty); } } } } } } #endregion } } } } } ToolCoreDb.ExecuteProcedure(); return(null); }
protected override IList ExecuteCrawl(bool crawlAll) { string html = string.Empty; string cookiestr = string.Empty; string viewState = string.Empty; int pageInt = 1; string eventValidation = string.Empty; string pageHtl = string.Empty; try { html = ToolWeb.GetHtmlByUrl(SiteUrl, Encoding.UTF8, ref cookiestr); } catch { return(null); } Parser parser = new Parser(new Lexer(html)); NodeList enttypeNode = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("select"), new HasAttributeFilter("name", "selected2")), true), new TagNameFilter("option"))); parser.Reset(); NodeList typeNode = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("select"), new HasAttributeFilter("name", "selected")), true), new TagNameFilter("option"))); if (enttypeNode != null && enttypeNode.Count > 0 && typeNode != null && typeNode.Count > 0) { for (int t = 0; t < enttypeNode.Count; t++) { string entTag = (enttypeNode[t] as OptionTag).GetAttribute("value"); string entText = enttypeNode[t].ToNodePlainString(); for (int d = 0; d < typeNode.Count; d++) { string typeTag = (typeNode[d] as OptionTag).GetAttribute("value"); string corpType = typeNode[d].ToNodePlainString(); if (t == 1 && d == 0) { typeTag = "16"; corpType = "房地产开发企业"; } if (t == 1 && d == 1) { typeTag = "17"; corpType = "预拌商品混凝土企业"; } if (t == 1 && d == 2) { typeTag = "19"; corpType = "建筑业施工企业"; } try { NameValueCollection nvc = ToolWeb.GetNameValueCollection( new string[] { "pageMethod", "method", "selected2", "selected", "_state", "keyword", "currentPage", "currentPage_temp" }, new string[] { "", "searchHandBook", entTag, typeTag, "1", "", "1", "1" }); html = ToolWeb.GetHtmlByUrl("http://www.dgjs.gov.cn/dgweb/search.do", nvc, Encoding.UTF8, ref cookiestr); } catch { continue; } parser = new Parser(new Lexer(html)); NodeList pageNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("class", "mainNextPage"))); if (pageNode != null && pageNode.Count > 0) { try { string temp = pageNode.AsString().GetRegexBegEnd("/", "页").Replace("\r", "").Replace("\t", "").Replace("\n", ""); pageInt = int.Parse(temp); } catch { } } for (int i = 1; i <= pageInt; i++) { if (i > 1) { try { NameValueCollection nvc = ToolWeb.GetNameValueCollection( new string[] { "pageMethod", "method", "selected2", "selected", "_state", "keyword", "currentPage", "currentPage_temp", }, new string[] { "next", "searchHandBook", entTag, typeTag, "1", "", (i - 1).ToString(), i.ToString() }); html = ToolWeb.GetHtmlByUrl("http://www.dgjs.gov.cn/dgweb/search.do", nvc, Encoding.UTF8, ref cookiestr); } catch { continue; } } parser = new Parser(new Lexer(html)); NodeList tableNode = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("align", "center")), true), new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("class", "jsxmtb")))); if (tableNode != null && tableNode.Count > 0) { TableTag table = tableNode[0] as TableTag; for (int j = 2; t == 1 ? j <= table.RowCount : j < table.RowCount; j++) { string CorpName = string.Empty, CorpCode = string.Empty, CorpAddress = string.Empty, RegDate = string.Empty, RegFund = string.Empty, BusinessCode = string.Empty, BusinessType = string.Empty, LinkMan = string.Empty, LinkPhone = string.Empty, Fax = string.Empty, Email = string.Empty, CorpSite = string.Empty, cUrl = string.Empty, ISOQualNum = string.Empty, ISOEnvironNum = string.Empty, CorpLevey = string.Empty; TableRow tr = null; #region 信用手册 if (entText.Contains("手册")) { tr = table.Rows[j]; CorpName = tr.Columns[1].ToNodePlainString(); LinkMan = tr.Columns[3].ToNodePlainString(); CorpAddress = tr.Columns[5].ToNodePlainString(); CorpLevey = tr.Columns[2].ToNodePlainString(); if (corpType.Contains("担保企业")) { cUrl = "http://www.dgjs.gov.cn/dgweb/" + tr.Columns[10].GetATagHref(); } else { cUrl = "http://www.dgjs.gov.cn/dgweb/" + tr.Columns[9].GetATagHref(); } string htlDtl = string.Empty; try { htlDtl = ToolWeb.GetHtmlByUrl(cUrl, Encoding.UTF8).GetJsString(); } catch { continue; } parser = new Parser(new Lexer(htlDtl.Replace("th", "td").Replace("TH", "TD"))); NodeList dtlNode = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("id", "dgjsj")), true), new TagNameFilter("table"))); if (dtlNode != null && dtlNode.Count > 1) { string ctx = string.Empty; TableTag dtlTable = dtlNode[0] as TableTag; for (int c = 1; c < dtlTable.RowCount; c++) { for (int v = 0; v < dtlTable.Rows[c].ColumnCount; v++) { if (string.IsNullOrEmpty(dtlTable.Rows[c].Columns[v].ToNodePlainString())) { continue; } if ((v + 1) % 2 == 0) { ctx += dtlTable.Rows[c].Columns[v].ToNodePlainString() + "\r\n"; } else { ctx += dtlTable.Rows[c].Columns[v].ToNodePlainString() + ":"; } } } RegDate = ctx.GetRegex("设立时间,设立日期"); LinkPhone = ctx.GetRegex("联系电话"); Fax = ctx.GetRegex("传真"); Email = ctx.GetRegex("电子邮箱"); BusinessType = ctx.GetRegex("经济性质"); BusinessCode = ctx.GetRegex("营业执照注册号"); } CorpInfo info = ToolDb.GenCorpInfo(CorpName, CorpCode, CorpAddress, RegDate, RegFund, BusinessCode, BusinessType, LinkMan, LinkPhone, Fax, Email, CorpSite, corpType, "广东省", "东莞市", "东莞市住房和城乡建设局", cUrl, ISOQualNum, ISOEnvironNum, string.Empty); if (!string.IsNullOrEmpty(CorpName.GetNotChina())) { string strSql = string.Format("select Id from CorpInfo where CorpName='{0}' and InfoSource='{1}' and CorpType='{2}'", info.CorpName, info.InfoSource, info.CorpType); object obj = ToolDb.ExecuteScalar(strSql); if (obj != null && obj.ToString() != "") { StringBuilder delCorpQual = new System.Text.StringBuilder(); StringBuilder delCorpLeader = new System.Text.StringBuilder(); StringBuilder delCorpTecStaff = new System.Text.StringBuilder(); delCorpQual.AppendFormat("delete from CorpQual where CorpId='{0}'", obj); delCorpLeader.AppendFormat("delete from CorpLeader where CorpId='{0}'", obj); delCorpTecStaff.AppendFormat("delete from CorpTecStaff where CorpId='{0}'", obj); ToolDb.ExecuteSql(delCorpQual.ToString()); ToolDb.ExecuteSql(delCorpLeader.ToString()); ToolDb.ExecuteSql(delCorpTecStaff.ToString()); string corpSql = string.Format("delete from CorpInfo where Id='{0}'", obj); ToolCoreDb.ExecuteSql(corpSql); } if (ToolDb.SaveEntity(info, string.Empty)) { object corpId = ToolDb.ExecuteScalar("select Id from CorpInfo where Url='" + info.Url + "' and InfoSource='东莞市住房和城乡建设局' "); ToolDb.ExecuteSql("delete from CorpQual where CorpId='" + corpId + "'"); #region 企业资质 TableTag quaTable = dtlNode[1] as TableTag; for (int q = 2; q < quaTable.RowCount; q++) { TableRow quaTr = quaTable.Rows[q]; string CorpId = string.Empty, QualName = string.Empty, QualCode = string.Empty, QualSeq = string.Empty, qualNum = string.Empty, QualType = string.Empty, QualLevel = string.Empty, ValidDate = string.Empty, LicDate = string.Empty, LicUnit = string.Empty; CorpId = info.Id; QualName = quaTr.Columns[0].ToNodePlainString(); QualLevel = quaTr.Columns[1].ToNodePlainString(); QualCode = quaTr.Columns[5].ToNodePlainString(); LicUnit = quaTr.Columns[6].ToNodePlainString(); QualType = quaTr.Columns[0].ToNodePlainString(); ValidDate = quaTr.Columns[3].ToPlainTextString().GetDateRegex(); qualNum = QualLevel.GetLevel(); CorpQual qual = ToolDb.GenCorpQual(CorpId, QualName, QualCode, QualSeq, QualType, QualLevel, ValidDate, LicDate, LicUnit, cUrl, qualNum, "广东省", "东莞市"); ToolDb.SaveEntity(qual, ""); } #endregion #region 企业负责人 parser = new Parser(new Lexer(htlDtl)); NodeList leaderNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("id", "head2"))); if (leaderNode != null && leaderNode.Count > 0) { ToolDb.ExecuteSql("delete from CorpLeader where CorpId='" + corpId + "'"); ATag leaderTag = leaderNode.GetATag(1); if (!leaderTag.LinkText.Contains("负责人")) { leaderTag = leaderNode.GetATag(2); } if (!leaderTag.LinkText.Contains("负责人")) { leaderTag = leaderNode.GetATag(3); } if (!leaderTag.LinkText.Contains("负责人")) { leaderTag = leaderNode.GetATag(4); } if (leaderTag.LinkText.Contains("负责人")) { string leaderUrl = "http://www.dgjs.gov.cn/dgweb/" + leaderTag.Link; string leaderDtl = string.Empty; try { leaderDtl = ToolWeb.GetHtmlByUrl(leaderUrl, Encoding.UTF8).GetJsString(); } catch { } parser = new Parser(new Lexer(leaderDtl)); NodeList leaderDtlNode = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("id", "dgjsj")), true), new TagNameFilter("table"))); if (leaderDtlNode != null && leaderDtlNode.Count > 0) { TableTag leaderTable = leaderDtlNode[0] as TableTag; for (int l = 3; l < leaderTable.RowCount; l++) { TableRow leaderTr = leaderTable.Rows[l]; if (leaderTr.ToHtml().ToLower().Contains("none")) { continue; } string LeaderName = string.Empty, LeaderDuty = string.Empty, LeaderType = string.Empty, htlCtx = string.Empty; try { LeaderName = leaderTr.Columns[0].ToNodePlainString(); LeaderDuty = leaderTr.Columns[4].ToNodePlainString(); LeaderType = leaderTr.Columns[1].ToNodePlainString(); } catch { } if (!string.IsNullOrEmpty(LeaderName)) { CorpLeader corpLeader = ToolDb.GenCorpLeader(info.Id, LeaderName, LeaderDuty, LeaderType, leaderUrl); ToolDb.SaveEntity(corpLeader, string.Empty); } } } } } #endregion #region 企业技术力量 parser = new Parser(new Lexer(htlDtl)); NodeList tecNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("id", "head2"))); if (tecNode != null && tecNode.Count > 0) { ToolDb.ExecuteSql("delete from CorpTecStaff where CorpId='" + corpId + "'"); ATag leaderTag = tecNode.GetATag(1); if (!leaderTag.LinkText.Contains("技术")) { leaderTag = tecNode.GetATag(2); } if (!leaderTag.LinkText.Contains("技术")) { leaderTag = tecNode.GetATag(3); } if (!leaderTag.LinkText.Contains("技术")) { leaderTag = tecNode.GetATag(4); } if (!leaderTag.LinkText.Contains("技术")) { leaderTag = tecNode.GetATag(5); } if (leaderTag.LinkText.Contains("技术")) { string leaderUrl = "http://www.dgjs.gov.cn/dgweb/" + leaderTag.Link; string leaderDtl = string.Empty; try { leaderDtl = ToolWeb.GetHtmlByUrl(leaderUrl, Encoding.UTF8).GetJsString(); } catch { } parser = new Parser(new Lexer(leaderDtl)); NodeList leaderDtlNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("id", "maintable"))); if (leaderDtlNode != null && leaderDtlNode.Count > 0) { TableTag leaderTable = leaderDtlNode[0] as TableTag; for (int l = 2; l < leaderTable.RowCount - 1; l++) { TableRow leaderTr = leaderTable.Rows[l]; string StaffName = string.Empty, IdCard = string.Empty, CertLevel = string.Empty, CertNo = string.Empty, stffType = string.Empty; try { StaffName = leaderTr.Columns[1].ToNodePlainString(); stffType = leaderTr.Columns[6].ToNodePlainString(); if (stffType == "/") { stffType = null; } CertNo = leaderTr.Columns[8].ToNodePlainString(); } catch { } if (!string.IsNullOrEmpty(StaffName)) { CorpTecStaff staff = ToolDb.GenCorpTecStaff(info.Id, StaffName, IdCard, CertLevel, CertNo, leaderUrl, stffType); ToolDb.SaveEntity(staff, string.Empty); } } } } } #endregion } } } #endregion #region 资质证书企业 else { tr = table.Rows[j - 1]; try { CorpName = tr.Columns[0].ToNodePlainString(); CorpAddress = tr.Columns[1].ToNodePlainString(); LinkMan = tr.Columns[2].ToNodePlainString(); CorpInfo info1 = ToolDb.GenCorpInfo(CorpName, CorpCode, CorpAddress, RegDate, RegFund, BusinessCode, BusinessType, LinkMan, LinkPhone, Fax, Email, CorpSite, corpType, "广东省", "东莞市", "东莞市住房和城乡建设局", cUrl, ISOQualNum, ISOEnvironNum, string.Empty); if (!string.IsNullOrEmpty(CorpName.GetNotChina())) { string strSql = string.Format("select Id from CorpInfo where CorpName='{0}' and InfoSource='{1}' and CorpType='{2}'", info1.CorpName, info1.InfoSource, info1.CorpType); object obj = ToolDb.ExecuteScalar(strSql); if (obj != null && obj.ToString() != "") { string corpSql = string.Format("delete from CorpInfo where Id='{0}'", obj); ToolCoreDb.ExecuteSql(corpSql); } ToolDb.SaveEntity(info1, string.Empty); } } catch (Exception ex) { } } #endregion } } } } } } return(null); }