Example #1
0
        private void SaveExpertJson(string html, string guid, string url, bool isUpdate)
        {
            List <BidProjectExpert> listExpert = new List <BidProjectExpert>();

            try
            {
                int    startInx = html.IndexOf("suiJiList");
                int    endInx   = html.LastIndexOf("qiTaList");
                string htmldtl  = "{" + (html.Substring(startInx, endInx - startInx - 1)) + "}"; //.GetReplace("suiJiList", "{\"suiJiList\"")+"}";//("{" + html.Substring(startInx, endInx - startInx - 1) + "}").GetReplace("{", "{\"").GetReplace(":", "\":").GetReplace("\":", "\":\"").Replace(",", "\",").Replace("\",", "\",\"").GetReplace("}", "\"}");
                                                                                                 //List<Expert> list =  Newtonsoft.Json.JsonConvert.<Expert>(htmldtl);

                DataTable dt = JsonToDataTable(htmldtl);
                if (dt != null && dt.Rows.Count > 0)
                {
                    foreach (DataRow row in dt.Rows)
                    {
                        string bBidProjectId = string.Empty, bExpertname = string.Empty, bBidtype = string.Empty, bExpertspec = string.Empty,
                                     bExpertunit = string.Empty,
                                     bRemark = string.Empty, bInfourl = string.Empty, bCreator = string.Empty, bCreatetime = string.Empty, bLastmodifier = string.Empty,
                                     bLastmodifytime = string.Empty;
                        bExpertname = Convert.ToString(row["pwName"]);
                        bBidtype    = Convert.ToString(row["pbLeiXing"]);
                        bExpertspec = Convert.ToString(row["zhuanYeName"]);
                        bExpertunit = Convert.ToString(row["gongZuoDanWei"]);
                        BidProjectExpert info = ToolDb.GenProjectExpert(guid, bExpertname, bBidtype, bExpertspec, bExpertunit, string.Empty, url);
                        listExpert.Add(info);
                    }
                }
            }
            catch
            {
            }

            if (listExpert.Count > 0)
            {
                if (isUpdate)
                {
                    string delSql = string.Format("delete from BidProjectExpert where BidProjectId='{0}'", guid);
                    string result = Convert.ToString(ToolDb.ExecuteScalar(delSql));
                    if (string.IsNullOrEmpty(result))
                    {
                        ToolDb.SaveDatas(listExpert, "");
                    }
                }
                else
                {
                    ToolDb.SaveDatas(listExpert, "");
                }
            }
        }
Example #2
0
        private void SaveExpert(string guid, string url, string htmltxt, bool isUpdate)
        {
            List <BidProjectExpert> list = new List <BidProjectExpert>();
            Parser   parser   = new Parser(new Lexer(htmltxt));
            NodeList pageNode = parser.ExtractAllNodesThatMatch(new TagNameFilter("table"));

            if (pageNode != null && pageNode.Count > 1)
            {
                TableTag table = pageNode[1] as TableTag;
                for (int i = 1; i < table.RowCount; i++)
                {
                    string bBidProjectId = string.Empty, bExpertname = string.Empty, bBidtype = string.Empty, bExpertspec = string.Empty,
                           bExpertunit = string.Empty,
                           bRemark = string.Empty, bInfourl = string.Empty, bCreator = string.Empty, bCreatetime = string.Empty, bLastmodifier = string.Empty,
                           bLastmodifytime = string.Empty;
                    TableRow tr            = table.Rows[i];
                    bExpertname = tr.Columns[0].ToNodePlainString();
                    bBidtype    = tr.Columns[2].ToPlainTextString();
                    bExpertspec = tr.Columns[3].ToPlainTextString();
                    try
                    {
                        bExpertunit = tr.Columns[4].ToPlainTextString();
                    }
                    catch
                    { }
                    BidProjectExpert info = ToolDb.GenProjectExpert(guid, bExpertname, bBidtype, bExpertspec, bExpertunit, string.Empty, url);
                    list.Add(info);
                }
            }
            if (list.Count > 0)
            {
                if (isUpdate)
                {
                    string delSql = string.Format("delete from BidProjectExpert where BidProjectId='{0}'", guid);
                    string result = Convert.ToString(ToolDb.ExecuteScalar(delSql));
                    if (string.IsNullOrEmpty(result))
                    {
                        ToolDb.SaveDatas(list, "");
                    }
                }
                else
                {
                    ToolDb.SaveDatas(list, "");
                }
            }
        }
Example #3
0
        public void AddExpert(string html, string infourl, string id)
        {
            Parser   parser   = new Parser(new Lexer(html));
            NodeList nodelist = parser.ExtractAllNodesThatMatch(new AndFilter(new HasAttributeFilter("id", "ctl00_ContentPlaceHolder1_GridView1"), new TagNameFilter("table")));

            if (nodelist != null && nodelist.Count > 0)
            {
                string bBidProjectId = string.Empty, bExpertname = string.Empty, bBidtype = string.Empty, bExpertspec = string.Empty,
                       bExpertunit = string.Empty,
                       bRemark = string.Empty, bInfourl = string.Empty, bCreator = string.Empty, bCreatetime = string.Empty, bLastmodifier = string.Empty,
                       bLastmodifytime = string.Empty;
                TableTag table         = nodelist[0] as TableTag;
                for (int i = 1; i < table.RowCount; i++)
                {
                    TableRow tr = table.Rows[i];
                    bExpertname = tr.Columns[0].ToPlainTextString();
                    bBidtype    = tr.Columns[1].ToPlainTextString();
                    bExpertspec = tr.Columns[2].ToPlainTextString();
                    bExpertunit = tr.Columns[3].ToPlainTextString();
                    BidProjectExpert info = ToolDb.GenProjectExpert(id, bExpertname, bBidtype, bExpertspec, bExpertunit, string.Empty, infourl);
                    ToolDb.SaveEntity(info, "");
                }
            }
        }