Esempio n. 1
0
 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); }
 }
Esempio n. 2
0
 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 { }
 }
Esempio n. 3
0
    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 { }
    }
Esempio n. 4
0
    private int Post(string url, string hinhdaidien, int idRSSGroup)
    {
        try
        {
            DBClass      _db = new DBClass();
            string       title = "", description = "", content = "";
            HtmlWeb      hw  = new HtmlWeb();
            HtmlDocument doc = hw.Load(url);

            DataRow rowNode = _db.sqlGetDataRow("select * from RssGroups where id  = " + idRSSGroup + "");// get tag </> form Group
            if (rowNode != null)
            {
                string             titleNode      = BaseView.GetStringFieldValue(rowNode, "Tagtitle");
                HtmlNodeCollection nodetitle_news = doc.DocumentNode.SelectNodes("//" + titleNode);
                title = "";
                foreach (var item in nodetitle_news)
                {
                    title += item.InnerText + Environment.NewLine;
                }
                string             nodeDesc        = BaseView.GetStringFieldValue(rowNode, "TagDesc");
                HtmlNodeCollection nodeshort_intro = doc.DocumentNode.SelectNodes("//" + nodeDesc);
                description = "";

                foreach (var item in nodeshort_intro)
                {
                    description += item.InnerText + Environment.NewLine;
                }
                content = "";
                string nodeContent = BaseView.GetStringFieldValue(rowNode, "TagContent");

                HtmlNodeCollection node = doc.DocumentNode.SelectNodes("//" + nodeContent);
                foreach (var item in node)
                {
                    string sHtml = BaseView.RemoveLinks(item.InnerHtml) + Environment.NewLine;
                    content += sHtml;
                }

                // Process Images
                int    beginIndex = content.IndexOf("src=");
                string ctSub      = "";
                try
                {
                    ctSub = content.Substring(beginIndex, content.Length - beginIndex);
                }
                catch { }

                int endIndex = ctSub.IndexOf(".jpg");
                if (endIndex == -1)
                {
                    endIndex = ctSub.IndexOf(".gif");
                }
                if (endIndex == -1)
                {
                    endIndex = ctSub.IndexOf(".png");
                }
                if (endIndex == -1)
                {
                    endIndex = ctSub.IndexOf(".jpeg");
                }

                string hinhDaiDien = "";
                try
                {
                    hinhDaiDien = ctSub.Substring(5, ((endIndex) - (5)) + 4);
                }
                catch
                {
                }
                // Process link
                string[] a = url.Split('/');
                if (a.Length > 2)
                {
                    content += "<div class='nguon'> Nguồn: " + a[2] + "</div>";
                }

                string url_friendly = a[a.Length - 1];

                if (BaseView.CheckImg(hinhdaidien) == false)
                {
                    hinhdaidien = hinhDaiDien;
                }
                if (BaseView.CheckImg(hinhdaidien) == false)
                {
                    hinhdaidien = "noImg.png";
                }
                // Save to database
                return(SavePost(url, title, description, content, hinhdaidien, url_friendly));
            }
            return(0);
        }
        catch { return(0); }
    }