Exemple #1
0
        public ActionResult NewsAdd(WriterModel model)
        {
            if (ModelState.IsValid)
            {
                List <Gallery> fotoList = new List <Gallery>();
                News           AddNew   = new News();
                AddNew.NewsContent = RemoveHtml.Delete(model.NewsContent);
                AddNew.CreateDate  = DateTime.Now;
                AddNew.CategoryId  = model.News.CategoryId;
                AddNew.NewsTitle   = model.NewsTitle;
                AddNew.UserId      = 2;
                news.Add(AddNew);
                foreach (HttpPostedFileBase file in model.files)
                {
                    //Checking file is available to save.
                    if (file != null)
                    {
                        var     InputFileName  = Path.GetFileName(file.FileName);
                        var     ServerSavePath = Path.Combine(Server.MapPath("~/Assets/img/") + InputFileName);
                        Gallery newPage        = new Gallery();
                        newPage.ImagePath = "Assets/img/" + InputFileName;
                        newPage.NewsId    = news.GetAll().Select(x => x.NewsId).LastOrDefault();
                        fotoList.Add(newPage);
                        gallery.Add(newPage);
                        //Save file to server folder
                        file.SaveAs(ServerSavePath);
                    }
                }
            }

            ViewBag.Kayit = "Kaydedildi";
            return(RedirectToAction("Writer", "Login", null));
        }
Exemple #2
0
        protected override void Handle(Page page)
        {
            var totalPageElement = page.Selectable().SelectList(Selectors.XPath(".//div[@class='nlc_details']")).Nodes();

            List <Housing> results = new List <Housing>();

            foreach (var housingElement in totalPageElement)
            {
                var housingModel = new Housing();
                {
                    housingModel.Village = RemoveHtml.RemoveHTMLTags(housingElement.Select(Selectors.XPath("./div[@class='house_value clearfix']/div[@class='nlcd_name']/a")).GetValue());
                    //小区名称
                    housingModel.Village = RemoveHtml.RemoveHTMLTags(housingElement.Select(Selectors.XPath("./div[@class='house_value clearfix']/div[@class='nlcd_name']/a")).GetValue());
                    //备注
                    housingModel.Remark = RemoveHtml.RemoveHTMLTags(housingElement.Select(Selectors.XPath("./div[@class='house_type clearfix']")).GetValue()).Replace("\n", "");

                    // 联系方式
                    housingModel.Contact = RemoveHtml.RemoveHTMLTags(housingElement.Select(Selectors.XPath("./div[@class='relative_message clearfix']/div[@class='tel']/p")).GetValue());
                    //每平方米价格
                    //housingModel.Per_Price = RemoveHtml.RemoveHTMLTags(housingElements.Select(Selectors.XPath("./div[@class='nhouse_price']")).GetValue());
                    housingModel.Per_Price = RemoveHtml.RemoveHTMLTags(housingElement.Select(Selectors.XPath("./div[5]")).GetValue());
                    //具体位置
                    housingModel.Location = RemoveHtml.RemoveHTMLTags(housingElement.Select(Selectors.XPath("./div[@class='relative_message clearfix']/div[@class='address']/a")).GetValue());
                    //爬虫房源类型
                    housingModel.House_SpiderType = "newhouse";
                    housingModel.City             = "石家庄";
                    //小区名称
                    housingModel.Title = null;
                    //装饰
                    housingModel.Decoration = null;
                    //总金额
                    housingModel.Total_Price = null;
                    // 住房类型
                    housingModel.House_Type = null;
                    //面积
                    housingModel.House_Area = null;

                    //楼层
                    housingModel.Floor = null;
                    //方位
                    housingModel.Direcation = null;
                };
                var result = DataInput.Service.HousingService.Instance.AddHousingPrice(housingModel);
                results.Add(housingModel);
            }
            page.AddResultItem("LinesResult", results);
        }
Exemple #3
0
        protected override void Handle(Page page)
        {
            var            totalPageElements = page.Selectable().SelectList(Selectors.XPath(".//dl[@class='clearfix']")).Nodes();
            List <Housing> results           = new List <Housing>();

            foreach (var housingElements in totalPageElements)
            {
                var HousingModel = new Housing();
                // 标题
                HousingModel.Title = housingElements.Select(Selectors.XPath("./dd[1]/h4/a/span")).GetValue().Replace(" ", "");
                //小区名称
                HousingModel.Village = RemoveHtml.RemoveHTMLTags(housingElements.Select(Selectors.XPath("./dd[1]/p[2]/a/text()")).GetValue());
                //装饰
                HousingModel.Decoration = RemoveHtml.RemoveHTMLTags(housingElements.Select(Selectors.XPath("./dd[1]/p[3]")).GetValue());
                //总金额
                HousingModel.Total_Price = RemoveHtml.RemoveHTMLTags(housingElements.Select(Selectors.XPath("./dd[2]/span[1]")).GetValue());
                //每平方米价格
                HousingModel.Per_Price = housingElements.Select(Selectors.XPath("./dd[2]/span[2]")).GetValue().Replace(" ", "");

                // 住房类型
                HousingModel.House_Type = RemoveHtml.RemoveHTMLTags(housingElements.Select(Selectors.XPath("./dd[1]/p[1]/text()[1]")).GetValue());
                //面积
                HousingModel.House_Area = housingElements.Select(Selectors.XPath("./dd[1]/p[1]/text()[2]")).GetValue().Replace(" ", "");
                //楼层
                HousingModel.Floor = housingElements.Select(Selectors.XPath("./dd[1]/p[1]/text()[3]")).GetValue().Replace(" ", "");
                //方位
                HousingModel.Direcation = housingElements.Select(Selectors.XPath("./dd[1]/p[1]/text()[4]")).GetValue().Replace(" ", "");
                //具体位置
                HousingModel.Location = housingElements.Select(Selectors.XPath("./dd[1]/p[2]/span")).GetValue().Replace(" ", "");

                //爬虫房源类型
                HousingModel.House_SpiderType = "esf";
                var result = DataInput.Service.HousingService.Instance.AddHousingPrice(HousingModel);

                results.Add(HousingModel);
            }
            page.AddResultItem("LinesResult", results);
        }
 /// <summary>
 /// 获取content中80个字符的内容
 /// </summary>
 /// <param name="str"></param>
 /// <returns></returns>
 public string substr(string str)
 {
     return(RemoveHtml.substr(str));
 }