void webbrowserUpload(object sender, NavigationEventArgs e) { mshtml.HTMLDocument mhtml = (mshtml.HTMLDocument)web1.Document; string html = mhtml.body.innerHTML; IHtmlDocument document = new JumonyParser().Parse(html); IEnumerable <IHtmlElement> result = document.Find(".house-list-wrap"); IEnumerable <IHtmlElement> t = result.Find("li"); Dictionary <string, string> dir = new Dictionary <string, string>(); bool ToNotDown = true; int ret = 0; foreach (var item in t) { #region MyRegion newWORD.Class1 _class = new newWORD.Class1(); _class.TextName = MainWindow.GetN_value(item, ".title>a"); _class.href = item.Exists(".title > a") ? item.FindFirst(".title>a").Attribute("href").Value() : string.Empty; _class.Quyu = "同城"; _class.PersonName = MainWindow.GetN_value(item, ".jjrname-outer"); _class.Laiyuan = "58"; IEnumerable <IHtmlElement> adds = item.Find(".baseinfo"); IEnumerable <IHtmlElement> addsa = adds.Find("a"); string adess = ""; foreach (var addsaa in addsa) { adess += addsaa.InnerText(); } _class.Address = adess; string Timestr = MainWindow.GetN_value(item, ".time"); DateTime Dte = DateTime.Now; _class.FbTime = Convert.ToDateTime(Dte.Year.ToString() + "-" + Dte.Month.ToString() + "-" + Dte.Day.ToString()); if (Timestr != "今天") { if (Timestr.IndexOf("分钟") > -1) { _class.FbTime = Dte.AddMinutes(-(Convert.ToInt32(Timestr.Replace("分钟", string.Empty)))); } else if (Timestr.IndexOf("小时") > -1) { _class.FbTime = Dte.AddHours(-(Convert.ToInt32(Timestr.Replace("小时", string.Empty)))); } else { string[] strTime = Timestr.Split('-'); _class.FbTime = Convert.ToDateTime(_class.FbTime.Year + "-" + strTime[0] + "-" + strTime[1]); } if (_class.FbTime <= MaxTime) { if (ret >= 2) { ToNotDown = false; break; } ret++; } } else { var datalist = iqdata.ToList(); if (iqdata.FirstOrDefault(x => x.HLName == _class.TextName && x.Address == _class.Address) != null) { continue; } } _class.datetime = ""; _class.Image_Count = MainWindow.GetInt_value(item, ".picNum"); _class.Image_str = _class.Image_Count > 0 ? "有" : string.Empty; if (ret == 0) { L_Class.Add(_class); } r++; #endregion } int nextI = 0; #region 跳转倒下一页 if (ToNotDown) { //mshtml.IHTMLDocument2 doc2 = (mshtml.IHTMLDocument2)web1.Document; //foreach (IHTMLElement ele in doc2.all) //{ // if (ele.tagName.ToLower().Equals("a")) // { // IHTMLElement aa = (IHTMLElement)ele; // if (ZantingI >= 1) // { // break; // } // if (aa.innerText == "下一页") // { // ZantingI++; // nextI++; // aa.click(); // retStr = "读取主目录" + ZantingI; // } // } //} } #endregion loadingS = nextI > 0 ? true : false; }
private void NewHTMLhreper() { string url = ""; this.Dispatcher.Invoke(new Action(() => { url = UPURL58.Text; })); int cityItems = 0; this.Dispatcher.Invoke(new Action(() => { cityItems = Convert.ToInt32(tongcheCombx.SelectedValue); })); try { string ALLhtml = GetHTMLstr(url); using (var ctx = new oaEntities()) { DateTime DBtime = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString()); DateTime NOtime = DateTime.Now; var drtme = ctx.T_FGJHtmlData.DefaultIfEmpty().Where(x => x.FbTime != DBtime && x.Laiyuan == "58" && x.CityID == cityItems && x.FbTime <= NOtime).FirstOrDefault(); MaxTime = drtme == null?DBtime.AddDays(-1) : ctx.T_FGJHtmlData.DefaultIfEmpty().Where(x => x.FbTime != DBtime && x.Laiyuan == "58" && x.CityID == cityItems && x.FbTime <= NOtime).Max(x => x.FbTime); #region 开始读取网站列表信息 IHtmlDocument document = new JumonyParser().Parse(ALLhtml); IEnumerable <IHtmlElement> result = document.Find(".house-list-wrap"); IEnumerable <IHtmlElement> t = result.Find("li"); Dictionary <string, string> dir = new Dictionary <string, string>(); int ret = 0; foreach (var item in t) { #region MyRegion newWORD.Class1 _class = new newWORD.Class1(); _class.TextName = MainWindow.GetN_value(item, ".title>a"); IEnumerable <IHtmlElement> adds = item.Find(".baseinfo"); IEnumerable <IHtmlElement> addsa = adds.Find("a"); string adess = ""; foreach (var addsaa in addsa) { adess += addsaa.InnerText(); } _class.Address = adess; string Timestr = MainWindow.GetN_value(item, ".time"); DateTime Dte = DateTime.Now; _class.FbTime = Convert.ToDateTime(Dte.Year.ToString() + "-" + Dte.Month.ToString() + "-" + Dte.Day.ToString()); Timestr = Timestr.Replace("更新于", string.Empty); Timestr = Timestr.Replace("前", string.Empty); if (Timestr != "今天") { #region MyRegion if (Timestr.IndexOf("分钟") > -1) { ret = IFthis_I(ret); _class.FbTime = Dte.AddMinutes(-(Convert.ToInt32(Timestr.Replace("分钟", string.Empty)))); } else if (Timestr.IndexOf("小时") > -1) { ret = IFthis_I(ret); _class.FbTime = Dte.AddHours(-(Convert.ToInt32(Timestr.Replace("小时", string.Empty)))); } else if (Timestr.IndexOf("天") > -1) { if (Timestr.Trim() == "昨天") { _class.FbTime = Dte.AddDays(-1); } else { if (Timestr.Replace("天", string.Empty).Trim().Length <= 0) { continue; } _class.FbTime = Dte.AddDays(-3); } } else { string[] strTime = Timestr.Split('-'); _class.FbTime = Convert.ToDateTime((_class.FbTime.Year - 1) + "-" + strTime[0] + "-" + strTime[1]); } if (_class.FbTime <= MaxTime) { if (ret >= 2) { break; } ret++; } else { ret = 0; } #endregion } else { var MaxT = ctx.T_FGJHtmlData.Where(x => x.HLName == _class.TextName && x.Address == _class.Address).DefaultIfEmpty().ToList(); if (MaxT[0] != null) { var tm = MaxT.Max(x => x.FbTime); var vtm = MaxT.Where(x => x.FbTime == tm).First(); //判断这条数据数 的时间是否是今天更新的 如果是 那么不进行操作 if (vtm.FbTime == DBtime) { continue; } } } _class.href = item.Exists(".title > a") ? item.FindFirst(".title>a").Attribute("href").Value() : string.Empty; _class.Quyu = "同城"; _class.PersonName = MainWindow.GetN_value(item, ".jjrname-outer"); _class.Laiyuan = "58"; _class.datetime = ""; _class.Image_Count = MainWindow.GetInt_value(item, ".picNum"); _class.Image_str = _class.Image_Count > 0 ? "有" : string.Empty; if (ret == 0) { L_Class.Add(_class); } r++; #endregion } #endregion this.Dispatcher.Invoke(new Action(() => { SUMcount.Text = L_Class.Count.ToString(); })); #region 查询完所有网站后执行 读取详细信息 for (i = 0; i < L_Class.Count; i++) { Thread.Sleep(6000); if (L_Class.Count == 0) { continue; } this.Dispatcher.Invoke(new Action(() => { ReadCount.Text = i.ToString(); })); this.Dispatcher.Invoke(new Action(() => { Yanzheng.Text = L_Class[i].href; })); string html = GetHTMLstr(L_Class[i].href); IHtmlDocument document_1 = new JumonyParser().Parse(html); IEnumerable <IHtmlElement> rl = document_1.Find("div"); IEnumerable <IHtmlElement> ss = rl.Find("p").Where(x => x.Identity() == "smallPicDescShow"); foreach (var rs in ss) { L_Class[i].bak = rs.InnerText(); } IEnumerable <IHtmlElement> ul_il = document_1.Find("ul").Where(p => p.Identity() == "leftImg"); IEnumerable <IHtmlElement> li = ul_il.Find("li"); foreach (var img in li) { //liImg.Add(); L_Class[i].Image_str = L_Class[i].Image_str.Length > 0 ? L_Class[i].Image_str + "---" + img.FindFirst("img").Attribute("src").Value() : img.FindFirst("img").Attribute("src").Value(); } IEnumerable <IHtmlElement> Phon = document_1.Find("div").Where(d => d.Identity() == "houseChatEntry"); IEnumerable <IHtmlElement> Phon_p = Phon.Find(".phone-num"); string phone = ""; foreach (var p in Phon_p) { phone = p.InnerText(); } //获取概况信息 IEnumerable <IHtmlElement> GKelement = rl.Where(x => x.Identity() == "generalSituation").Find(".c_000"); int ElementI = 0; foreach (var str in GKelement) { #region MyRegion if (GKelement.Count() > 6) { switch (ElementI) { case 0: L_Class[i].FwSumMoney = str.InnerText(); break; case 1: L_Class[i].FwHuXing = str.InnerText(); break; case 2: L_Class[i].FwMianji = str.InnerText(); break; case 3: L_Class[i].FwChaoxiang = str.InnerText(); break; case 4: L_Class[i].Loucheng = str.InnerText(); break; case 5: L_Class[i].FwZhuangxiu = str.InnerText(); break; case 6: L_Class[i].FwNianxian = str.InnerText(); break; default: ; break; } } else if (GKelement.Count() == 4) { switch (ElementI) { case 0: L_Class[i].FwSumMoney = str.InnerText(); break; case 1: L_Class[i].FwHuXing = str.InnerText(); break; case 2: L_Class[i].FwMianji = str.InnerText(); break; case 3: if (str.InnerText().IndexOf("层") > 0) { L_Class[i].FwLoucheng = str.InnerText(); } else { L_Class[i].FwZhuangxiu = str.InnerText(); } break; default: ; break; } } else { switch (ElementI) { case 0: L_Class[i].FwSumMoney = str.InnerText(); break; case 1: L_Class[i].FwHuXing = str.InnerText(); break; case 2: L_Class[i].FwMianji = str.InnerText(); break; case 3: L_Class[i].FwLoucheng = str.InnerText(); break; case 4: L_Class[i].FwZhuangxiu = str.InnerText(); break; case 5: L_Class[i].FwNianxian = str.InnerText(); break; default: ; break; } } #endregion ElementI++; } L_Class[i].photo = phone; if (i != 0) { List <newWORD.Class1> thisC = new List <newWORD.Class1>(); thisC.Add(L_Class[i - 1]); } } #endregion #region 读取完毕 开始数据库信息写入 SaveDataHTML(ctx, L_Class, cityItems); // ctx.SaveChanges(); #endregion } this.Dispatcher.Invoke(new Action(() => { LISTbox.Text = "完成更新————" + DateTime.Now.ToString(); })); } catch (Exception ex) { this.Dispatcher.Invoke(new Action(() => { LISTbox.Text = DateTime.Now.ToString() + ex.ToString(); })); } WhileBOOL1 = false; }
private void NewHTMLhreperGJ() { string url = ""; this.Dispatcher.Invoke(new Action(() => { url = UPURLganji.Text; })); int cityItems = 0; this.Dispatcher.Invoke(new Action(() => { cityItems = Convert.ToInt32(ganjicombc.SelectedValue); })); try { using (var ctx = new oaEntities()) { #region 加载首页 DateTime DBtime = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString()); DateTime ds = DateTime.Now; var ftdef = ctx.T_FGJHtmlData.DefaultIfEmpty().Where(x => x.FbTime != DBtime && x.Laiyuan == "赶集" && x.CityID == cityItems && x.FbTime <= ds).FirstOrDefault(); if (ftdef != null) { MaxTime = ctx.T_FGJHtmlData.DefaultIfEmpty().Where(x => x.FbTime != DBtime && x.Laiyuan == "赶集" && x.CityID == cityItems && x.FbTime <= ds).Max(x => x.FbTime); } string ALLhtml = GetHTMLstr_gj(url, ""); ALLhtml = ALLhtml.Replace("<!-- ", string.Empty); ALLhtml = ALLhtml.Replace(" -->", string.Empty); IHtmlDocument document = new JumonyParser().Parse(ALLhtml); IEnumerable <IHtmlElement> result1 = document.Find(".list-items"); L_Class_Ganji.Clear(); foreach (var item in result1) { #region MyRegion try { newWORD.Class1 GJclass = new newWORD.Class1(); IHtmlElement item_a = item.FindFirst("a"); //信息名称 GJclass.TextName = item.FindFirst(".house-name").InnerText().Trim(); #region 判断时间的方法 string Timestr = item.FindFirst(".house-pulishtime").InnerText().Trim(); DateTime Dte = DateTime.Now; GJclass.FbTime = Convert.ToDateTime(Dte.Year.ToString() + "-" + Dte.Month.ToString() + "-" + Dte.Day.ToString()); Timestr = Timestr.Replace("更新于", string.Empty); Timestr = Timestr.Replace("前", string.Empty); if (Timestr != "今天") { if (Timestr.IndexOf("分钟") > -1) { if (Timestr.Replace("分钟", string.Empty).Trim().Length <= 0) { continue; } GJclass.FbTime = Dte.AddMinutes(-(Convert.ToInt32(Timestr.Replace("分钟", string.Empty)))); } else if (Timestr.IndexOf("小时") > -1) { if (Timestr.Replace("小时", string.Empty).Trim().Length <= 0) { continue; } GJclass.FbTime = Dte.AddHours(-(Convert.ToInt32(Timestr.Replace("小时", string.Empty)))); } else if (Timestr.IndexOf("天") > -1) { if (Timestr.Trim() == "昨天") { GJclass.FbTime = Dte.AddDays(-1); } else if (Timestr.Trim() == "前天") { GJclass.FbTime = Dte.AddDays(-2); } else { if (Timestr.Replace("天", string.Empty).Trim().Length <= 0) { continue; } GJclass.FbTime = Dte.AddDays(-3); } } else if (Timestr.Trim() == "刚刚") { GJclass.FbTime = DateTime.Now; } else { string[] strTime_ = Timestr.Split('-'); GJclass.FbTime = Convert.ToDateTime((GJclass.FbTime.Year - 1) + "-" + strTime_[0] + "-" + strTime_[1]); } if (GJclass.FbTime <= MaxTime) { continue; } } #endregion //连接 GJclass.href = item_a.Attribute("href").Value().IndexOf("https") > -1 ? item_a.Attribute("href").Value() : "https://3g.ganji.com" + item_a.Attribute("href").Value(); //地址 GJclass.Address = item.FindFirst(".house-addr").FindFirst(".house-area").InnerText(); L_Class_Ganji.Add(GJclass); } catch (Exception ex) { } #endregion } #endregion this.Dispatcher.Invoke(new Action(() => { GJSUMcount.Text = L_Class_Ganji.Count().ToString(); })); #region 加载分页 for (int i = 0; i < L_Class_Ganji.Count; i++) { Thread.Sleep(3000); try { this.Dispatcher.Invoke(new Action(() => { GJReadCount.Text = i.ToString(); })); string this_html = GetHTMLstr_gj(L_Class_Ganji[i].href, ""); if (this_html.Trim().Length <= 0) { continue; } IHtmlDocument document_this = new JumonyParser().Parse(this_html); //金额 L_Class_Ganji[i].FwSumMoney = document_this.Exists(".house-price") ? document_this.FindFirst(".house-price").InnerText().Replace("算房贷", string.Empty).Trim() : string.Empty; var this_Image = document_this.Find(".slide-area>li>img"); L_Class_Ganji[i].Image_str = string.Empty; foreach (var img in this_Image) { L_Class_Ganji[i].Image_str = L_Class_Ganji[i].Image_str.Length > 0 ? L_Class_Ganji[i].Image_str + "---" + img.Attribute("data-big-image").Value() : "有---" + img.Attribute("data-big-image").Value(); } var list = document_this.Find(".house-type>span"); //电话 var php = document_this.Find(".tel"); foreach (var item in php) { if (item.Attribute("href").Value().Trim().Length > 0) { L_Class_Ganji[i].photo = item.Attribute("href").Value().Trim().Replace("tel:", string.Empty); } } //联系人 L_Class_Ganji[i].Laiyuan = "赶集"; L_Class_Ganji[i].PersonName = document_this.Exists(".broker") ? document_this.FindFirst(".broker").FindFirst("span").InnerText().Replace("(个人)", string.Empty) : string.Empty; foreach (var item in list) { if (item.InnerText().IndexOf("朝") > -1) { L_Class_Ganji[i].FwChaoxiang = PFUANDtext(item, "朝"); } else if (item.InnerText().IndexOf("室") > -1) { L_Class_Ganji[i].FwHuXing = PFUANDtext(item, "室"); } else if (item.InnerText().IndexOf("层") > -1) { L_Class_Ganji[i].FwLoucheng = PFUANDtext(item, "层"); } else if (item.InnerText().IndexOf("㎡") > -1) { L_Class_Ganji[i].FwMianji = PFUANDtext(item, "㎡"); } else if (item.InnerText().IndexOf("产权") > -1) { L_Class_Ganji[i].FwNianxian = PFUANDtext(item, "产权"); } else if (item.InnerText().IndexOf("毛") > -1) { L_Class_Ganji[i].FwZhuangxiu = PFUANDtext(item, "毛"); } else if (item.InnerText().IndexOf("装修") > -1) { L_Class_Ganji[i].FwZhuangxiu = PFUANDtext(item, "装修"); } } } catch (Exception e) { } } #endregion #region 进行数据存储 SaveDataHTML(ctx, L_Class_Ganji, cityItems); ctx.SaveChanges(); #endregion } this.Dispatcher.Invoke(new Action(() => { GJLISTbox.Text = "完成更新————" + DateTime.Now.ToString(); })); } catch (Exception e) { this.Dispatcher.Invoke(new Action(() => { Ertext.Text = DateTime.Now.ToString() + e.ToString(); })); WhileBOOL2 = false; } WhileBOOL2 = false; }
private void NewHTMLhreper58() { string url = ""; this.Dispatcher.Invoke(new Action(() => { url = up58nameurl.Text; })); string ALLhtml = GetHTMLstr(url); int cityItems = 0; this.Dispatcher.Invoke(new Action(() => { cityItems = Convert.ToInt32(up58city.SelectedValue); })); using (var ctx = new oaEntities()) { DateTime DBtime = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString()); var QZQtime = ctx.T_ChuZhuInfo.Count(); if (QZQtime <= 0) { } var timesdata = ctx.T_ChuZhuInfo.Where(x => x.LaiYuan == "58").DefaultIfEmpty(); var MaxTime = timesdata.First()!=null?(DateTime) timesdata.Max(x => x.FbTime) : new DateTime(2016, 12, 12); // MaxTime = QZQtime <= 0 ? new DateTime(2016, 12, 12) : times ; #region 开始读取网站列表信息 IHtmlDocument document = new JumonyParser().Parse(ALLhtml); IEnumerable<IHtmlElement> result = document.Find(".listBox"); IEnumerable<IHtmlElement> t = result.Find("li"); DateTime Ttdtime = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-1"); var TTimeData = ctx.T_ChuZhuInfo.Where(x => x.FbTime >= Ttdtime).DefaultIfEmpty(); //Dictionary<string, string> dir = new Dictionary<string, string>(); foreach (var item in t) { // DateTime uptime = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString()); // DateTime NOtime = DateTime.Now; // var drtme = ctx.T_FGJHtmlData.DefaultIfEmpty().Where(x => x.FbTime != uptime && x.Laiyuan == "58" && x.CityID == cityItems && x.FbTime <= NOtime).FirstOrDefault(); // MaxTime = drtme == null ? uptime.AddDays(-1) : ctx.T_FGJHtmlData.DefaultIfEmpty().Where(x => x.FbTime != uptime && x.Laiyuan == "58" && x.CityID == cityItems && x.FbTime <= NOtime).Max(x => x.FbTime); #region 开始读取网站列表信息 // IHtmlDocument document58 = new JumonyParser().Parse(ALLhtml); // IEnumerable<IHtmlElement> result58 = document58.Find(".house-list-wrap"); // IEnumerable<IHtmlElement> t58 = result.Find("li"); Dictionary<string, string> dir = new Dictionary<string, string>(); int ret = 0; #region MyRegion newWORD.Class1 _class = new newWORD.Class1(); IEnumerable<IHtmlElement> sendTime = item.Find(".sendTime"); string Timestr=""; foreach (var h1 in sendTime) { Timestr = h1.InnerText(); } DateTime Dte = DateTime.Now; _class.FbTime = Convert.ToDateTime(Dte.Year.ToString() + "-" + Dte.Month.ToString() + "-" + Dte.Day.ToString()); string timerss = Timestr.Replace(" ", ""); if (timerss.Length > 0) { Timestr = Timestr.Replace("更新于", string.Empty); Timestr = Timestr.Replace("前", string.Empty); if (Timestr != "今天") { #region MyRegion if (Timestr.IndexOf("分钟") > -1) { ret = IFthis_I(ret); _class.FbTime = Dte.AddMinutes(-(Convert.ToInt32(Timestr.Replace("分钟", string.Empty)))); } else if (Timestr.IndexOf("小时") > -1) { ret = IFthis_I(ret); _class.FbTime = Dte.AddHours(-(Convert.ToInt32(Timestr.Replace("小时", string.Empty)))); } else if (Timestr.IndexOf("天") > -1) { if (Timestr.Trim() == "昨天") { _class.FbTime = Dte.AddDays(-1); } else { if (Timestr.Replace("天", string.Empty).Trim().Length <= 0) { continue; } _class.FbTime = Dte.AddDays(-3); } } else { string[] strTime = Timestr.Split('-'); _class.FbTime = Convert.ToDateTime((_class.FbTime.Year - 1) + "-" + strTime[0] + "-" + strTime[1]); } if (_class.FbTime <= MaxTime) { if (ret >= 2) { break; } ret++; } else { ret = 0; } #endregion } } else { _class.FbTime = _class.FbTime.AddDays(-1); } IEnumerable<IHtmlElement> hname = item.Find("h2"); foreach (var h1 in hname) { _class.TextName= h1.InnerText(); } if (_class.TextName == null) { continue; } IEnumerable<IHtmlElement> tingshi = item.Find(".room"); foreach (var h1 in tingshi) { _class.FwHuXing = h1.InnerText(); } string pinx = _class.FwHuXing; pinx = pinx.Remove(0, pinx.IndexOf("卫") + 1).Replace("㎡", "").Replace(" ",""); _class.FwHuXing = _class.FwHuXing.Replace(pinx,""); _class.FwMianji = pinx.Remove(0, pinx.IndexOf(" ") + 1).Replace(" ", ""); IEnumerable<IHtmlElement> addess = item.Find(".add"); foreach (var h1 in addess) { _class.Address = h1.InnerText(); } IEnumerable<IHtmlElement> person = item.Find(".geren"); foreach (var h1 in person) { _class.PersonName = h1.InnerText(); } _class.PersonName = _class.PersonName.Replace("来自个人房源:", ""); IEnumerable<IHtmlElement> images = item.Find("img"); foreach (var h1 in images) { _class.Image_str= "---" + h1.Attribute("lazy_src").Value(); } IEnumerable<IHtmlElement> money = item.Find(".money>b"); foreach (var h1 in money) { _class.SumMoney = h1.InnerText(); } if (item.Exists("h2 > a")) { IEnumerable<IHtmlElement> href = item.Find("h2>a"); foreach (var h1 in href) { _class.href = h1.Attribute("href").Value(); } } _class.Laiyuan = "58"; r++; #endregion T_ChuZhuInfo tqzq = new T_ChuZhuInfo(); tqzq.ChuZhuName = _class.TextName; tqzq.Addess = _class.Address; int tmp; if (!int.TryParse(_class.SumMoney, out tmp)) { _class.SumMoney = "0"; } tqzq.Money = Convert.ToDecimal(_class.SumMoney); tqzq.LaiYuan = _class.Laiyuan; tqzq.Images = _class.Image_str; tqzq.FbTime = _class.FbTime; tqzq.PingMi = Convert.ToDecimal(_class.FwMianji.Replace(" ", "")); tqzq.LianXiPerson = _class.PersonName; tqzq.LianXiPhoto = _class.photo; tqzq.Bak = _class.bak; tqzq.ChuZhuHref = _class.href; tqzq.CityID = cityItems; var distic= TTimeData.Where(x => x.ChuZhuName == tqzq.ChuZhuName && x.Addess == tqzq.Addess && x.PingMi == tqzq.PingMi && x.Money == tqzq.Money).FirstOrDefault(); if (distic == null) { ctx.T_ChuZhuInfo.Add(tqzq); ctx.SaveChanges(); } this.Dispatcher.Invoke(new Action(() => { ADDC58.Text = r.ToString(); })); this.Dispatcher.Invoke(new Action(() => { ltextd58.Text = "更新一条数据————" + _class.TextName + "———" + DateTime.Now.ToString(); })); #endregion } #endregion } WhileBOOL58 = false; try { } catch (Exception ex) { this.Dispatcher.Invoke(new Action(() => { LISTbox.Text = DateTime.Now.ToString() + ex.ToString(); })); } }