Exemplo n.º 1
0
        /// <summary>
        /// 企业负责人信息
        /// </summary>
        /// <param name="info"></param>
        /// <param name="html"></param>
        public void AddCorpLeader(CorpInfo info, string html)
        {
            Parser   parser   = new Parser(new Lexer(html));
            NodeList nodeList = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("id", "fzrxx")));

            if (nodeList != null && nodeList.Count > 0)
            {
                parser = new Parser(new Lexer(nodeList.ToHtml().Replace("th", "td")));
                NodeList tableNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("table"));
                if (tableNode != null && tableNode.Count > 0)
                {
                    TableTag table = tableNode[0] as TableTag;
                    for (int i = 1; i < table.RowCount; i++)
                    {
                        TableRow tr = table.Rows[i];
                        if (tr.Columns[0].ToPlainTextString().Contains("没有显示结果"))
                        {
                            break;
                        }

                        string LeaderName = string.Empty, LeaderDuty = string.Empty, LeaderType = string.Empty, htlCtx = string.Empty, phone = string.Empty;
                        LeaderName = tr.Columns[1].ToNodePlainString();
                        LeaderDuty = tr.Columns[2].ToNodePlainString();
                        phone      = tr.Columns[3].ToNodePlainString();
                        LeaderType = tr.Columns[4].ToNodePlainString();
                        CorpLeader corpLeader = ToolDb.GenCorpLeader(info.Id, LeaderName, LeaderDuty, LeaderType, info.Url, phone);
                        ToolDb.SaveEntity(corpLeader, string.Empty);
                    }
                }
            }
        }
Exemplo n.º 2
0
        protected void AddCorpLeader(CorpInfo info, string enterpriseId)
        {
            string url = "http://202.104.65.182:8081/G2/webdrive/web-enterprise-leader.do?enterpriseId=" + enterpriseId + "&data&filter_params_=rowNum,leaderId,name,title,safetyLicenseCode,safetyLicenseIssuer,safetyLicenseValidEnd&defined_operations_=&nocheck_operations_=&";

            string gridSearch       = "false";
            string nd               = ToolHtml.GetDateTimeLong(DateTime.Now).ToString();
            string PAGESIZE         = "1000";
            string PAGE             = "1";
            string sortField        = "";
            string sortDirection    = "asc";
            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 LeaderName = string.Empty, LeaderDuty = string.Empty, LeaderType = string.Empty, htlCtx = string.Empty, phone = string.Empty;

                    LeaderName = Convert.ToString(dic["name"]);
                    LeaderType = Convert.ToString(dic["title"]);

                    CorpLeader corpLeader = ToolDb.GenCorpLeader(info.Id, LeaderName, LeaderDuty, LeaderType, info.Url, phone);
                    ToolDb.SaveEntity(corpLeader, string.Empty);
                }
            }
        }
Exemplo n.º 3
0
        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(this.SiteUrl, Encoding.UTF8, ref cookiestr);
            }
            catch { return(null); }
            Parser   parser   = new Parser(new Lexer(html));
            NodeList pageNode = parser.ExtractAllNodesThatMatch(new AndFilter(new HasParentFilter(new AndFilter(new TagNameFilter("div"), new HasAttributeFilter("id", "ContentPlaceHolder1_AspNetPager1")), true), new TagNameFilter("a")));

            if (pageNode != null && pageNode.Count > 0)
            {
                try
                {
                    string temp = pageNode[pageNode.Count - 1].GetATagHref().Replace("&#39;", "").Replace(")", "kdxx").Replace(",", "xxdk");
                    pageInt = int.Parse(temp.GetRegexBegEnd("xxdk", "kdxx"));
                }
                catch { }
            }
            for (int i = 1; i <= pageInt; i++)
            {
                if (i > 1)
                {
                    try
                    {
                        if (i == 2)
                        {
                            viewState       = ToolWeb.GetAspNetViewState(html);
                            eventValidation = ToolWeb.GetAspNetEventValidation(html);
                        }
                        NameValueCollection nvc = ToolWeb.GetNameValueCollection(
                            new string[] {
                            "ctl00$ContentPlaceHolder1$ScriptManager1",
                            "ctl00$ContentPlaceHolder1$txtORGNAME",
                            "ctl00$ContentPlaceHolder1$txtORGCODE",
                            "ctl00$ContentPlaceHolder1$txtPNAME",
                            "ctl00$ContentPlaceHolder1$txtIDNUM",
                            "ctl00$ContentPlaceHolder1$txtHIREERORGNAME",
                            "ctl00$ContentPlaceHolder1$txtHIREERORGCODE",
                            "ctl00$ContentPlaceHolder1$ddlRegType",
                            "ctl00$ContentPlaceHolder1$ddlTitle",
                            "ctl00$ContentPlaceHolder1$ddlABC",
                            "ctl00$ContentPlaceHolder1$ddlCert",
                            "__VIEWSTATE",
                            "__EVENTTARGET",
                            "__EVENTARGUMENT",
                            "__EVENTVALIDATION",
                            "__ASYNCPOST"
                        },
                            new string[] {
                            "ctl00$ContentPlaceHolder1$UpdatePanel1|ctl00$ContentPlaceHolder1$AspNetPager1",
                            "", "", "", "", "", "", "", "", "", "",
                            viewState,
                            "ctl00$ContentPlaceHolder1$AspNetPager1",
                            i.ToString(),
                            eventValidation,
                            "true"
                        }
                            );

                        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("class", "data-grid")));
                if (nodeList != null && nodeList.Count > 0)
                {
                    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, CorpType,
                               ISOQualNum = string.Empty, ISOEnvironNum = string.Empty, OffAdr = string.Empty, Cert = string.Empty;

                        TableRow tr = table.Rows[j];
                        CorpName = tr.Columns[0].ToNodePlainString();
                        LinkMan  = tr.Columns[1].ToNodePlainString();
                        cUrl     = tr.Columns[0].GetATagValue("onclick").Replace("OpenWin('", "");
                        if (cUrl.IndexOf("'") > 0)
                        {
                            cUrl = "http://113.108.219.40/intogd/" + cUrl.Remove(cUrl.IndexOf("'"));
                        }
                        string htmldtl = string.Empty;
                        try
                        {
                            htmldtl = ToolWeb.GetHtmlByUrl(cUrl, Encoding.UTF8);
                        }
                        catch { continue; }
                        parser = new Parser(new Lexer(htmldtl));
                        NodeList dtlNode = parser.ExtractAllNodesThatMatch(new AndFilter(new TagNameFilter("table"), new HasAttributeFilter("class", "data-table")));
                        if (dtlNode != null && dtlNode.Count > 0)
                        {
                            string   ctx      = string.Empty;
                            TableTag dtlTable = dtlNode[0] as TableTag;
                            for (int k = 0; k < dtlTable.RowCount; k++)
                            {
                                for (int d = 0; d < dtlTable.Rows[k].ColumnCount; d++)
                                {
                                    TableColumn col = dtlTable.Rows[k].Columns[d];
                                    if (col.GetAttribute("class") == "td-left")
                                    {
                                        ctx += col.ToNodePlainString() + ":";
                                    }
                                    else
                                    {
                                        ctx += col.ToNodePlainString() + "\r\n";
                                    }
                                }
                            }


                            RegDate      = ctx.GetRegex("成立时间,注册时间").GetDateRegex();
                            RegFund      = ctx.GetRegex("注册资本");
                            BusinessCode = ctx.GetRegex("营业执照注册号");
                            CorpType     = "外地进粤企业";
                            CorpAddress  = ctx.GetRegex("注册详细地址");
                            if (!string.IsNullOrEmpty(RegFund) && !RegFund.Contains("万"))
                            {
                                RegFund += "万";
                            }

                            CorpInfo  corp   = ToolDb.GenCorpInfo(CorpName, CorpCode, CorpAddress, RegDate, RegFund, BusinessCode, BusinessType, LinkMan, LinkPhone, Fax, Email, CorpSite, CorpType, "广东省", "广东地区", "广东省住房和城乡建设厅", cUrl, ISOQualNum, ISOEnvironNum, OffAdr);
                            string    strSql = string.Format("select Id from CorpInfo where CorpName='{0}' and CorpType='{1}'", corp.CorpName, corp.CorpType);
                            DataTable dt     = ToolCoreDb.GetDbData(strSql);
                            if (dt != null && dt.Rows.Count > 0)
                            {
                                string        id                 = dt.Rows[0]["Id"].ToString();
                                StringBuilder delCorpQual        = new System.Text.StringBuilder();
                                StringBuilder delCorpLeader      = new System.Text.StringBuilder();
                                StringBuilder delCorpSecLicStaff = new System.Text.StringBuilder();
                                StringBuilder delCorpInstitution = new StringBuilder();
                                delCorpInstitution.AppendFormat("delete from CorpInstitution where CorpId='{0}'", id);
                                delCorpQual.AppendFormat("delete from CorpQual where CorpId='{0}'", id);
                                delCorpLeader.AppendFormat("delete from CorpLeader where CorpId='{0}'", id);
                                delCorpSecLicStaff.AppendFormat("delete from CorpTecStaff where CorpId='{0}'", id);
                                ToolCoreDb.ExecuteSql(delCorpInstitution.ToString());
                                ToolCoreDb.ExecuteSql(delCorpQual.ToString());
                                ToolCoreDb.ExecuteSql(delCorpLeader.ToString());
                                ToolCoreDb.ExecuteSql(delCorpSecLicStaff.ToString());
                                string corpSql = string.Format("delete from CorpInfo where Id='{0}'", id);
                                ToolCoreDb.ExecuteSql(corpSql);
                            }
                            if (ToolDb.SaveEntity(corp, this.ExistCompareFields))
                            {
                                if (!string.IsNullOrEmpty(LinkMan))
                                {
                                    CorpLeader leader = ToolDb.GenCorpLeader(corp.Id, LinkMan, "", "企业法定代表人", cUrl);
                                    ToolDb.SaveEntity(leader, "");
                                }
                                if (!string.IsNullOrEmpty(tr.Columns[2].ToNodePlainString()))
                                {
                                    CorpLeader leader = ToolDb.GenCorpLeader(corp.Id, tr.Columns[2].ToNodePlainString(), "", "技术负责人", cUrl);
                                    ToolDb.SaveEntity(leader, "");
                                }
                                if (!string.IsNullOrEmpty(tr.Columns[3].ToNodePlainString()))
                                {
                                    CorpLeader leader = ToolDb.GenCorpLeader(corp.Id, tr.Columns[3].ToNodePlainString(), "", "驻粤负责人", cUrl);
                                    ToolDb.SaveEntity(leader, "");
                                }
                                AddCorpQual(corp, htmldtl);
                                AddCorpTecStaff(corp, htmldtl);
                                GetOffAddress(htmldtl, cUrl, corp);
                            }
                        }
                    }
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 企业负责人信息
        /// </summary>
        /// <param name="info"></param>
        /// <param name="html"></param>
        public void AddCorpLeader(CorpInfo info, string param, string corpType)
        {
            string url = "http://portal.szjs.gov.cn:8888/publicShow/queryPrincipal.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[] dicRecords = (object[])jsonResults["records"];
                foreach (object dicRecord in dicRecords)
                {
                    Dictionary <string, object> dic = (Dictionary <string, object>)dicRecord;
                    string LeaderName = string.Empty, LeaderDuty = string.Empty, LeaderType = string.Empty, htlCtx = string.Empty, phone = string.Empty;

                    LeaderName = Convert.ToString(dic["name"]);
                    LeaderDuty = Convert.ToString(dic["duty"]);
                    phone      = Convert.ToString(dic["tel"]);
                    LeaderType = Convert.ToString(dic["emptype"]);

                    CorpLeader corpLeader = ToolDb.GenCorpLeader(info.Id, LeaderName, LeaderDuty, LeaderType, info.Url, phone);
                    ToolDb.SaveEntity(corpLeader, string.Empty);
                }
            }
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        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);
        }