private DataTable getRSS() { DataTable dtRSS = new DataTable(); dtRSS.Columns.Add("title"); dtRSS.Columns.Add("url"); dtRSS.Columns.Add("date"); dtRSS.Columns.Add("IdCatalogy"); dtRSS.Columns.Add("urlRss"); DataTable dt = _db.get_all_LoaiTin_UrlNotNull(); if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { string url = BaseView.GetStringFieldValue(dr, "url"); string urlct = BaseView.GetStringFieldValue(dr, "urlct"); if (!String.IsNullOrEmpty(url)) { try { var web = new HtmlWeb(); var doc = web.Load(url); var links = from lnk in doc.DocumentNode.Descendants() where lnk.Name == "a" && lnk.Attributes["href"] != null && lnk.InnerText.Trim().Length > 30 select new { link = lnk.Attributes["href"].Value, text = lnk.InnerText.Replace(" ", "") }; foreach (var l in links) { DataRow r = dtRSS.NewRow(); r[0] = l.text; string[] A = l.link.Split('/'); r[1] = urlct + A[A.Length - 1]; r[2] = ToSQL.SQLToDateRic(BaseView.getDateTimeNow()); r[3] = BaseView.GetStringFieldValue(dr, "id"); r[4] = BaseView.GetStringFieldValue(dr, "url"); dtRSS.Rows.Add(r); } } catch { } } } } return(dtRSS); }
private void Post(string url, string tt, string des, string datepost, string content, string img, string url_f, string maloai) { //try //{ if (checkNews(url) == 0) { if (img.Length >= 200) { img = img.Substring(0, 200); } if (url_f.Length > 50) { url_f = url_f.Substring(0, 50); } url_f = url_f + ".html"; if (BaseView.CheckImg(img) == false) { img = "Nha-khoa-thuan-kieu.png"; } if (content.Trim().Length > 100) { _db.OnInsert_Update_Delete_News(0, url, tt, des, getKeyWord(url), tt, ToSQL.SQLToDateRic(BaseView.getDateTimeNow()), des, content, true, img, ToSQL.SQLToInt(maloai), url_f, "", "", 0, 0, "", ToSQL.SQLToDateRic(BaseView.getDateTimeNow()), "", "", "insert"); } } //} //catch { } }
private void autoPost(string urlRss, string url, string tieude, string description, string content, string img, string code_url_friendly, int idLoai) { try { if (checkNews(url) == 0) { //Do(tieude, "http://lamdep123.org/" + code_url_friendly, img, tieude, description); if (code_url_friendly.Length > 50) { code_url_friendly = code_url_friendly.Substring(0, 50); } if (code_url_friendly.Trim().Length == 0) { code_url_friendly = BaseView.convertToUnSign2(tieude); code_url_friendly = BaseView.repalce_UrlFriendly(code_url_friendly.Trim()) + ".html"; } else { if (code_url_friendly.IndexOf(".html") == -1) { code_url_friendly = code_url_friendly + ".html"; } } if (BaseView.CheckImg(img) == false) { img = "noImg.png"; } if (content.Trim().Length > 200) { DataRow rowL = _db.get_info_loai(idLoai); if (rowL != null) { //string idBlog = BaseView.GetStringFieldValue(rowL, "idBlog"); //DataRow infoBlog = _db.get_info_blog(idBlog); //if (infoBlog != null) //{ //int q= sendPostToBlogspot(idBlog, BaseView.GetStringFieldValue(infoBlog, "user_name"), BaseView.GetStringFieldValue(infoBlog, "pass_word"), tieude, content, BaseView.GetStringFieldValue(infoBlog, "tag")); //if (q == 1) //{ _db.OnInsert_Update_Delete_News(0, url, tieude, description, getKeyWord(urlRss), tieude, ToSQL.SQLToDateRic(BaseView.getDateTimeNow()), description, content, true, img, idLoai, code_url_friendly, "", "", 0, 0, "", null, "", "", "insert"); //} //} } } } } catch { } }
private int Post(string urlRss, string url, string tieude, string description, string datePost, string content, string img, string code_url_friendly, int idLoai) { try { if (checkNews(url) == 0) { if (img.Length >= 200) { img = img.Substring(0, 200); } if (code_url_friendly.Length > 50) { code_url_friendly = code_url_friendly.Substring(0, 50); } if (BaseView.CheckImg(img) == false) { img = "Nha-khoa-thuan-kieu.png"; } if (content.Trim().Length > 200) { _db.OnInsert_Update_Delete_News(0, url, tieude, description, getKeyWord(urlRss), tieude, ToSQL.SQLToDateRic(datePost), description, content, true, img, idLoai, code_url_friendly, "", "", 0, 0, "", ToSQL.SQLToDateRic(datePost).AddMonths(12), "", "", "insert"); } return(1); } else { return(0); } } catch { return(0); } }
private int SavePost(string url_from_rss, string tieude, string description, string content, string img, string code_url_friendly, int idLoai) { try { DBClass _db = new DBClass(); if (checkNews(url_from_rss) == 0) { if (code_url_friendly.Length > 50) { code_url_friendly = code_url_friendly.Substring(0, 50); } if (code_url_friendly.Trim().Length == 0) { code_url_friendly = BaseView.RemoveKiTuDacBietVaKhoangTrang(tieude.ToLower()) + ".html"; } else { if (code_url_friendly.IndexOf(".html") == -1) { code_url_friendly = code_url_friendly + ".html"; } } if (content.Trim().Length > 200) { DataRow rowL = _db.get_info_loai(idLoai); if (rowL != null) { _db.OnInsert_Update_Delete_News(0, url_from_rss, tieude, description, "", tieude, ToSQL.SQLToDateRic(BaseView.getDateTimeNow()), description, content, true, img, idLoai, code_url_friendly, "", "", 0, 0, "", null, "", "", "insert"); // ltHome.Text +="<img src='"+ img+ "'/></br>"; return(1); } } } return(0); } catch { return(0); } }