void OnTimedEvent()
        {
            using (var ctx = new oaEntities())
            {
                //——————————————————————更新 时间大于

                var ftimes = DateTime.Now;
                var catemp = ctx.T_FGJHtmlData.Where(x => x.FbTime > ftimes).DefaultIfEmpty();
                if (catemp != null)
                {
                    if (catemp.Count() > 0)
                    {
                        foreach (var tp in catemp)
                        {
                            long id = tp.ID;
                            using (var Uptimes = new oaEntities())
                            {
                                var tps = Uptimes.T_FGJHtmlData.FirstOrDefault(z => z.ID == id);
                                tps.delflag = 1;
                                Uptimes.SaveChanges();
                            }
                        }
                    }
                }
                //————————————————————————————————————
                int Gint = 0;
                this.Dispatcher.Invoke(new Action(() =>
                {
                    Gint = Convert.ToInt32(TiaDay.Text);
                }));
                var         Zuijia = ctx.T_ZhuaiJiaBak.Where(x => x.DEL == 0).ToList();
                List <long> lit    = new List <long>();
                foreach (var a in Zuijia)
                {
                    lit.Add(Convert.ToInt64(a.FGJHTML_id));
                }
                var T_saverHtml = ctx.T_SaveHtmlData.Where(x => x.DelFlag == 0 && x.GongGong == 0 && !lit.Contains(x.HtmldataID)).ToList();
                for (int i = 0; i < T_saverHtml.Count(); i++)
                {
                    if (T_saverHtml[i].SaveTime.AddDays(Gint) < DateTime.Now)
                    {
                        long id = T_saverHtml[i].ID;
                        using (var newoa = new oaEntities())
                        {
                            var temp = newoa.T_SaveHtmlData.FirstOrDefault(x => x.ID == id);
                            temp.GongGong = 1;
                            //  newoa.Entry<T_SaveHtmlData>(temp).State = System.Data.EntityState.Modified;
                            newoa.SaveChanges();
                        }
                    }
                }
            }
        }
 private void tongcheCombx_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try {
         int strid = Convert.ToInt32(((System.Windows.Controls.Primitives.Selector)sender).SelectedValue.ToString());
         using (var City = new oaEntities())
         {
             var href = City.T_UpHerfCity.Where(x => x.Items == "58更新" && x.City_ID == strid).FirstOrDefault();
             UPURL58.Text = href == null ? "" : href.Href;
         }
     }
     catch (Exception err)
     {
         string ss = err.ToString();
     }
 }
        private void procombc_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            int strid = Convert.ToInt32(((System.Windows.Controls.Primitives.Selector)sender).SelectedValue.ToString());

            using (var City = new oaEntities())
            {
                var Mcity = City.T_City.Where(x => x.DelFlag == 0 && x.province_id == strid);
                ganjicombc.ItemsSource       = Mcity.ToList();
                ganjicombc.SelectedValuePath = "ID";
                ganjicombc.DisplayMemberPath = "City";
                ganjicombc.SelectedValue     = 1;
                int id   = Mcity.ToList()[0].ID;
                var href = City.T_UpHerfCity.Where(x => x.Items == "赶集更新" && x.City_ID == id).FirstOrDefault();
                UPURLganji.Text = href.Href;
            }
        }
 private void Button_Click_3(object sender, RoutedEventArgs e)
 {
     using (var ctx = new oaEntities())
     {
         var T = ctx.T_FGJHtmlData.DefaultIfEmpty().ToList();
         for (int i = 0; i < T.Count(); i++)
         {
             T_FGJHtmlData tf = T[i];
             tf.SumMoneyID = GetMoney(tf.FwSumMoney);
             tf.HuXingID   = GetHuxing(tf.FwHuXing);
             tf.MianjiID   = GeiMinji(tf.FwMianji);
             tf.Money_int  = GetMoney_int(tf.FwSumMoney);
             tf.Pingmi_int = GetPingmi_int(tf.FwMianji);
         }
         ctx.SaveChanges();
     }
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            using (var City = new oaEntities())
            {
                var prot = City.T_province.Where(x => x.ID > 0);
                tongchePro.ItemsSource       = prot.ToList();
                tongchePro.SelectedValuePath = "ID";
                tongchePro.DisplayMemberPath = "str";

                procombc.ItemsSource       = prot.ToList();
                procombc.SelectedValuePath = "ID";
                procombc.DisplayMemberPath = "str";

                var T_BoolItemService = City.T_BoolItem;
                var tbb = T_BoolItemService.Where(x => x.ID == 2).FirstOrDefault();
                TiaDay.Text = [email protected]();
            }
        }
Beispiel #6
0
        public void Updata()
        {
            #region MyRegion
            using (var ctx = new oaEntities())
            {
                var      obj    = (ctx as IObjectContextAdapter).ObjectContext;
                DateTime DBtime = Convert.ToDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" + DateTime.Now.Day.ToString());
                MaxTime = ctx.T_FGJHtmlData.DefaultIfEmpty().Where(x => x.FbTime != DBtime).Max(x => x.FbTime);

                // var tfdata = ctx.T_FGJHtmlData.DefaultIfEmpty<T_FGJHtmlData>().Where(x=>x.FbTime==DBtime);

                iqdata = ctx.T_FGJHtmlData.DefaultIfEmpty <T_FGJHtmlData>().Where(x => x.FbTime == DBtime);

                web1.LoadCompleted += new LoadCompletedEventHandler(webbrowserUpload);
                loadingS            = true; // 表示正在加载
                web1.Navigate("http://liaoyang.58.com/ershoufang/0");


                while (loadingS)
                {
                    System.Windows.Forms.Application.DoEvents(); // 等待本次加载完毕才执行下次循环.
                }

                #region 查询完所有网站后执行
                for (i = 0; i < L_Class.Count; i++)
                {
                    web1.LoadCompleted += new LoadCompletedEventHandler(web2_Navigated);;

                    loading = true;   // 表示正在加载
                    web1.Navigate(L_Class[i].href);
                    ChangeTextEvent("支目录条数已读取" + i + "条" + "-----主目录条数" + L_Class.Count());
                    while (loading)
                    {
                        System.Windows.Forms.Application.DoEvents(); // 等待本次加载完毕才执行下次循环.
                    }
                }
                //DPdg.ItemsSource = L_Class;
                #endregion

                foreach (var da in L_Class)
                {
                    T_FGJHtmlData tf = new T_FGJHtmlData();
                    //如果数据库中出现该名称并且 时间在当前时间那么  该信息不写入数据库

                    if (ctx.T_FGJHtmlData.FirstOrDefault(x => x.HLName == da.TextName) != null)
                    {
                        continue;
                    }
                    tf.HLName      = da.TextName;
                    tf.HLhref      = da.href;
                    tf.PersonName  = da.PersonName;
                    tf.Address     = da.Address;
                    tf.photo       = da.photo;
                    tf.FbTime      = da.FbTime;
                    tf.FwSumMoney  = da.FwSumMoney;
                    tf.FwHuXing    = da.FwHuXing;
                    tf.FwMianji    = da.FwMianji;
                    tf.FwLoucheng  = da.FwLoucheng;
                    tf.FwZhuangxiu = da.FwZhuangxiu;
                    tf.FwNianxian  = da.FwNianxian;
                    tf.FwChaoxiang = da.FwChaoxiang;
                    tf.bak         = da.bak;
                    tf.Id_count    = int.Parse(da.Id_count == null ? "0" : da.Id_count);
                    tf.Laiyuan     = da.Laiyuan;
                    tf.Image_str   = da.Image_str;

                    ctx.T_FGJHtmlData.Add(tf);
                }
                ctx.SaveChanges();
                ChangeTextEvent("完成更新————" + DateTime.Now.ToString() + ".OK");
            }
            #endregion

            this.Close();
        }
        private void SaveDataHTML(oaEntities ctx, List <newWORD.Class1> L_Class_, int p)
        {
            DAL.T_FGJHtmlDataDal Dti = new DAL.T_FGJHtmlDataDal();
            foreach (var da in L_Class_)
            {
                T_FGJHtmlData tf = new T_FGJHtmlData();

                tf.HLName     = da.TextName;
                tf.HLhref     = da.href;
                tf.PersonName = da.PersonName;
                tf.Address    = da.Address;
                tf.photo      = da.photo;
                tf.FbTime     = da.FbTime;
                tf.FbTime     = tf.FbTime > DateTime.Now ? new DateTime(2017, tf.FbTime.Month, tf.FbTime.Day, tf.FbTime.Hour, tf.FbTime.Minute, tf.FbTime.Second):tf.FbTime;
                if (da.FwSumMoney == null)
                {
                    continue;
                }
                else
                {
                    if (da.FwSumMoney.Trim().Length <= 0)
                    {
                        continue;
                    }
                }
                tf.FwSumMoney  = da.FwSumMoney;
                tf.FwHuXing    = da.FwHuXing;
                tf.FwMianji    = da.FwMianji;
                tf.FwLoucheng  = da.FwLoucheng;
                tf.FwZhuangxiu = da.FwZhuangxiu;
                tf.FwNianxian  = da.FwNianxian;
                tf.FwChaoxiang = da.FwChaoxiang;
                tf.bak         = da.bak;
                tf.Id_count    = int.Parse(da.Id_count == null ? "0" : da.Id_count);
                tf.Laiyuan     = da.Laiyuan;
                tf.Image_str   = da.Image_str;
                tf.CityID      = p;
                if (da.FwMianji != null)
                {
                    tf.MianjiID   = GeiMinji(da.FwMianji);
                    tf.Pingmi_int = GetPingmi_int(da.FwMianji);
                }
                if (da.FwSumMoney != null)
                {
                    tf.SumMoneyID = GetMoney(da.FwSumMoney);
                    tf.Money_int  = GetMoney_int(da.FwSumMoney);
                }
                if (da.FwHuXing != null)
                {
                    tf.HuXingID = GetHuxing(da.FwHuXing);
                }

                //如果数据库中出现该名称并且 时间在当前时间那么  该信息不写入数据库
                //如果有该数据那么修改数据库中的数据信息



                var isnull = Dti.LoadEntities(x => x.FwMianji == tf.FwMianji && x.photo == tf.photo).DefaultIfEmpty();

                if (isnull.ToList()[0] != null)
                {
                    var tm  = isnull.Max(x => x.FbTime);
                    var vtm = isnull.Where(x => x.FbTime == tm).First();
                    vtm.FbTime     = tf.FbTime;
                    vtm.Money_int  = tf.Money_int;
                    vtm.FwSumMoney = tf.FwSumMoney;
                    vtm.SumMoneyID = tf.SumMoneyID;
                    Dti.EditEntity(vtm);
                }
                else
                {
                    Dti.AddEntity(tf);
                }
            }
            Dti.SaveChanges();
        }
        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 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;
        }