public IHttpActionResult GetDetail(long newsID)
        {
            NewsPublishEntity newsPublishEntity = NewsPublished.NP_TinChiTiet(newsID, true);

            if (newsPublishEntity == null)
            {
                return(NotFound());
            }
            return(Ok(newsPublishEntity));
        }
Beispiel #2
0
        public List <NewsPublishEntity> GetRelation(string News_ID, int ImgWidth)
        {
            if (!string.IsNullOrEmpty(News_ID))
            {
                string key = String.Format("NP_Tin_Lien_Quan-{0}", News_ID);
                var    lst = Utils.Get_MemCache <List <NewsPublishEntity> >(key) ?? Utils.GetFromCache <List <NewsPublishEntity> >(key);
                if (lst == null || lst.Count == 0)
                {
                    lst = new List <NewsPublishEntity>();
                    DataTable da;
                    using (var db = new MainDB())
                    {
                        da = db.StoredProcedures.NP_Tin_Lien_Quan(News_ID);
                    }

                    int iCount = da != null ? da.Rows.Count : 0;
                    if (da != null)
                    {
                        for (int i = 0; i < iCount; i++)
                        {
                            var row = da.Rows[i];
                            var npe = new NewsPublishEntity();
                            npe.NEWS_TITLE       = Utils.GetObj <string>(row["NEWS_TITLE"]);
                            npe.NEWS_INITCONTENT = Utils.GetObj <string>(row["NEWS_INITCONTENT"]);
                            npe.NEWS_ID          = Convert.ToInt64(row["NEWS_ID"]);
                            npe.NEWS_PUBLISHDATE = Utils.GetObj <DateTime>(row["NEWS_PUBLISHDATE"]);
                            npe.URL = Utils.BuildLinkDetail(Convert.ToInt32(row["Cat_ParentID"]), Convert.ToInt32(row["Cat_ID"]), npe.NEWS_ID, npe.NEWS_TITLE);

                            string img = Utils.GetObj <string>(row["NEWS_Image"]);
                            if (img.Trim().Length > 0)
                            {
                                npe.Imgage = new ImageEntity(ImgWidth, img);
                            }

                            lst.Add(npe);
                        }
                    }
                    if (!Utils.Add_MemCache(key, lst))
                    {
                        Utils.SaveToCacheDependency(TableName.DATABASE_NAME, TableName.NEWSPUBLISHED, key, lst);
                    }
                }
                return(lst);
            }
            else
            {
                return(new List <NewsPublishEntity>());
            }
        }
Beispiel #3
0
        public static string[] GetTopNewsestCommentByCatID(int Top, int CatID, int cat_parentid)
        {
            string key = String.Format("GetTopNewsestCommentByCatID_{0}_{1}", Top, CatID);

            string[] temp = Utils.GetFromCache <string[]>(key);
            if (temp != null)
            {
                return(temp);
            }
            temp = new string[2] {
                "", ""
            };
            string            Item1    = "<div class=\"gridItem\">{0}<p style='padding-top:0px;'><span><a>{1} : </a></span>{2}</p></div>";
            string            Item     = "<div class=\"gridItem\">{0}<h3><a href=\"{1}\">{4}</a></h3><h5>{5}</h5><p><span><a>{2} : </a></span>{3}</p></div>";
            string            DIV      = "<div class=\"chude_khac_col\">{0}</div>";
            string            DIV_Khac = "<li><a href=\"{0}\">{1}</a></li>";
            NewsPublishEntity nep      = new NewsPublishEntity();
            DataTable         tbl;

            using (MainDB db = new MainDB())
            {
                tbl = db.StoredProcedures.GetTopNewestCommentByCatID(Top, CatID);
            }

            if (tbl != null && tbl.Rows.Count > 0)
            {
                if (!tbl.Columns.Contains("Image"))
                {
                    tbl.Columns.Add("Image");
                }
                if (!tbl.Columns.Contains("CommentAvatar"))
                {
                    tbl.Columns.Add("CommentAvatar");
                }
                if (!tbl.Columns.Contains("NewsIcon"))
                {
                    tbl.Columns.Add("NewsIcon");
                }

                ImageEntity _newsImage     = null;
                ImageEntity _commentAvatar = null;
                ImageEntity _icon          = null;
                Hashtable   htb            = new Hashtable();

                DataRow _row = null;

                string _newsUrl  = "";
                string temp1     = "";
                int    realCount = 0;
                for (int i = 0; i < tbl.Rows.Count; i++)
                {
                    temp1 = "";
                    _row  = tbl.Rows[i];

                    if (htb.Contains(_row["News_ID"].ToString()))
                    {
                        continue;
                    }
                    htb.Add(_row["News_ID"].ToString(), _row["News_ID"].ToString());
                    if (realCount <= 1)
                    {
                        if (_row["News_Image"] != null && _row["News_Image"].ToString() != "")
                        {
                            _newsImage    = new ImageEntity(78, _row["News_Image"].ToString());
                            _row["Image"] = "<img src=\"" + _newsImage.ImageUrl + "\" width=\"78px\" onerror=\"LoadImage(this,'" + _newsImage.OnError + "');\">";
                        }
                        else
                        {
                            _row["Image"] = DBNull.Value;
                        }

                        if (_row["Avatar"] != null && _row["Avatar"].ToString() != "")
                        {
                            _commentAvatar        = new ImageEntity(78, _row["Avatar"].ToString());
                            _row["CommentAvatar"] = "<img src=\"" + _commentAvatar.ImageUrl + "\" width=\"78px\" onerror=\"LoadImage(this,'" + _commentAvatar.OnError + "');\">";
                        }
                        else
                        {
                            _row["CommentAvatar"] = DBNull.Value;
                        }

                        if (_row["Icon"] != null && _row["Icon"].ToString() != "")
                        {
                            _icon            = new ImageEntity(78, _row["Icon"].ToString());
                            _row["NewsIcon"] = "<img src=\"" + _icon.ImageUrl + "\" width=\"78px\" onerror=\"LoadImage(this,'" + _icon.OnError + "');\">";
                        }
                        else
                        {
                            _row["NewsIcon"] = DBNull.Value;
                        }


                        nep            = new NewsPublishEntity();
                        nep.NEWS_ID    = Convert.ToInt64(_row["News_ID"]);
                        nep.NEWS_TITLE = _row["News_Title"].ToString();

                        cat_parentid = Convert.ToInt32(_row["Cat_ParentID"]);
                        CatID        = Convert.ToInt32(_row["Cat_ID"]);

                        _newsUrl = NewsPublished.BuildLink(cat_parentid, CatID, nep);
                        temp1   += String.Format(Item, "<a href=\"" + _newsUrl + "\">" + _row["Image"].ToString() + "</a>", _newsUrl, _row["News_SubTitle"].ToString(), Utils.CatSapo(_row["News_InitContent"].ToString(), 30), _row["News_Title"].ToString(), Convert.ToDateTime(_row["News_PublishDate"]).ToString("dd/MM/yyyy HH:mm"));
                        temp1   += String.Format(Item1, _row["CommentAvatar"] != DBNull.Value ? "<a href=\"" + _newsUrl + "\">" + _row["CommentAvatar"].ToString() + "</a>" : "", _row["Comment_User"].ToString(), Utils.CatSapo(_row["Comment_Content"].ToString(), 30));
                        temp[0] += String.Format(DIV, temp1);
                    }
                    else
                    {
                        nep            = new NewsPublishEntity();
                        nep.NEWS_ID    = Convert.ToInt64(_row["News_ID"]);
                        nep.NEWS_TITLE = _row["News_Title"].ToString();

                        cat_parentid = Convert.ToInt32(_row["Cat_ParentID"]);
                        CatID        = Convert.ToInt32(_row["Cat_ID"]);

                        _newsUrl = NewsPublished.BuildLink(cat_parentid, CatID, nep);

                        temp[1] += String.Format(DIV_Khac, _newsUrl, _row["News_Title"].ToString());
                    }
                    realCount++;
                }
                Utils.SaveToCacheDependency(TableName.DATABASE_NAME, new string[] { TableName.COMMENT, TableName.NEWSPUBLISHED }, key, temp);
            }


            return(temp);
        }
Beispiel #4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            NewsPublishEntity ne = NewsPublished.NP_TinChiTiet(Lib.QueryString.NewsID, true);

            if (ne != null)
            {
                if (Request.QueryString["move301"] != null)
                {
                    Utils.Move301(ne.URL);
                    return;
                }

                string htmlMobile2        = BOAdv.GetAdvItemById(Lib.Object2Integer(31), Lib.QueryString.CategoryID);
                string htmlMobile2Extend  = BOAdv.GetAdvItemById(Lib.Object2Integer(47), Lib.QueryString.CategoryID);
                string htmlMobile2Perfect = BOAdv.GetAdvItemById(Lib.Object2Integer(55), Lib.QueryString.CategoryID);
                string htmlMobile6Adpruce = BOAdv.GetAdvEmbedScriptItemById(Lib.Object2Integer(38), Lib.QueryString.CategoryID); //live id = 38, sua dong duoi nua
                string htmlVideoMobile    = BOAdv.GetAdvEmbedScriptItemById(Lib.Object2Integer(39), Lib.QueryString.CategoryID); //live id = 39
                string mobile8            = BOAdv.GetAdvEmbedScriptItemById(Lib.Object2Integer(40), Lib.QueryString.CategoryID); //live id = 39

                string adsContent        = "";
                string adsContentExtend  = "";
                string adsContentPerfect = "";

                if (!String.IsNullOrWhiteSpace(htmlMobile2))
                {
                    adsContent = Environment.NewLine + "<script>" + String.Format("var zone{0}_{2} = new RunBanner({1}, \"zone{0}_{2}_Adv\"); zone{0}_{2}.Show();", Lib.QueryString.CategoryID, htmlMobile2.Replace("\\n", " ").Replace("\\t", " "), 31).Replace("INSERT_RANDOM_NUMBER_HERE", DateTime.Now.ToFileTime().ToString()) + "</script>" + Environment.NewLine;
                    //adsContent = Environment.NewLine + "<div class=\"stickyads\"><a  href=\"https://www.toshiba.com.vn/san-pham/tivi/pro-theatre-series/pro-theatre-l36-series\" target=\"_blank\"><img alt=\"\" src=\"http://static.netlife.vn/2016/06/04/07/41/Left-x2300x600.png\" style=\"width: 300px; height: 600px;\"></a></div>" + Environment.NewLine;
                }
                if (!String.IsNullOrWhiteSpace(htmlMobile2Extend))
                {
                    adsContentExtend = Environment.NewLine + "<script>" + String.Format("var zone{0}_{2} = new RunBanner({1}, \"zone{0}_{2}_Adv\"); zone{0}_{2}.Show();", Lib.QueryString.CategoryID, htmlMobile2Extend.Replace("\\n", " ").Replace("\\t", " "), 47).Replace("INSERT_RANDOM_NUMBER_HERE", DateTime.Now.ToFileTime().ToString()) + "</script>" + Environment.NewLine;
                }
                if (!String.IsNullOrWhiteSpace(htmlMobile2Perfect))
                {
                    adsContentPerfect = Environment.NewLine + "<script>" + String.Format("var zone{0}_{2} = new RunBanner({1}, \"zone{0}_{2}_Adv\"); zone{0}_{2}.Show();", Lib.QueryString.CategoryID, htmlMobile2Perfect.Replace("\\n", " ").Replace("\\t", " "), 47).Replace("INSERT_RANDOM_NUMBER_HERE", DateTime.Now.ToFileTime().ToString()) + "</script>" + Environment.NewLine;
                }



                ltrTitle.Text = ne.NEWS_TITLE;

                var    content   = ne.NEWS_CONTENT;
                string pattern   = @"(?<start><a[^>]*)(?<end>>)";
                string repl      = @"${start} target=""_blank"" ${end}";
                string newString = Regex.Replace(content, pattern, repl);
                //ltrContent.Text = newString.Replace("src=\"/Uploaded/", "src=\"http://static.netlife.vn/Uploaded/").Replace("<div id=\"vmcbackground\"></div>", string.Format("<div id=\"vmcbackground\"><center>{0}</center></div>", adsContent)).Replace("<div id=\"vmcbackgroundExtend\"></div>", string.Format("<div id=\"vmcbackground\"><center>{0}</center></div>", adsContentExtend));
                ltrContent.Text = newString.Replace("src=\"/Uploaded/", "src=\"http://static.netlife.vn/Uploaded/").Replace("<div id=\"vmcbackground\"></div>", string.Format("<div id=\"vmcbackground_1\"><center>{0}</center></div>", adsContent)).Replace("<div id=\"vmcbackgroundExtend\"></div>", string.Format("<div id=\"vmcbackground\"><center>{0}</center></div>", adsContentExtend)).Replace("<div id=\"vmcbackgroundPerfect\"></div>", string.Format("<div id=\"vmcbackground\"><center>{0}</center></div>", adsContentPerfect));
                //ltrContent.Text = newString.Replace("src=\"/Uploaded/", "src=\"http://static.netlife.vn/Uploaded/").Replace("<div id=\"vmcbackground\"></div>", string.Format("<div id=\"vmcbackground1\" class=\"vmcbackground_1\"><center>{0}</center></div>", adsContent)).Replace("<div id=\"vmcbackgroundExtend\"></div>", string.Format("<div id=\"vmcbackground\" class=\"vmcbackground_2\"><center>{0}</center></div>", adsContentExtend)).Replace("<div id=\"vmcbackgroundPerfect\"></div>", string.Format("<div id=\"vmcbackground\" class=\"vmcbackground_3\"><center>{0}</center></div>", adsContentPerfect));
                //ltrContent.Text = newString.Replace("src=\"/Uploaded/", "src=\"http://static.netlife.vn/Uploaded/").Replace("<div id=\"vmcbackground\"></div>", string.Format("{0}", adsContent)).Replace("<div id=\"vmcbackgroundExtend\"></div>", string.Format("<div id=\"vmcbackground\"><center>{0}</center></div>", adsContentExtend));

                //ltrContent.Text = newString.Replace("<div id=\"vmcbackgroundExtend\"></div>", string.Format("<div id=\"vmcbackground1\"><center>{0}</center></div>", adsContentExtend));
                //ltrContent.Text = ltrContent.Text.Replace("jpg\"", "jpg?maxwidth=480\"");
                ltrContent.Text = ltrContent.Text.Replace("jpg\"", "jpg?maxwidth=480\"" + " alt=\"" + ne.NEWS_TITLE + "\"");
                //ltrContent.Text = ltrContent.Text.Replace("<div id=\"abde\">", "<div id=\"abdad\"> <script type=\"text/javascript\"> var _ase  = _ase || []; /* load placement for account: Netlife, site: http://m.netlife.vn, zone size : 640x1280 */ _ase.push(['1464661938','1491064202']); </script> <script src=\"http://static.gammaplatform.com/js/ad-exchange.js\" type=\"text/javascript\"></script> </div><div id=\"abde\">");
                if (!String.IsNullOrWhiteSpace(htmlMobile6Adpruce) && htmlMobile6Adpruce.Length > 2)
                {
                    ltrContent.Text += Environment.NewLine;
                    ltrContent.Text += htmlMobile6Adpruce;
                }
                //if (htmlVideoMobile.Length > 2) //add ad video 7
                //{
                //    if (htmlVideoMobile.Contains("ambient")) //ambient
                //    {
                //        ltrContent.Text += Environment.NewLine;
                //        ltrContent.Text += htmlVideoMobile;
                //    }
                //    else if (htmlVideoMobile.Contains("Ebound")) //ebound
                //    {
                //        String[] part = htmlVideoMobile.Split('@');
                //        ltrContent.Text += Environment.NewLine;
                //        ltrContent.Text = ltrContent.Text.Replace("<video", part[0] + "<video").Replace("video>", "video>" + part[1]);
                //    }
                if (!String.IsNullOrWhiteSpace(htmlVideoMobile))
                {
                    ltrContent.Text += Environment.NewLine;
                    ltrContent.Text += htmlVideoMobile;
                }


                //}
                // mobile 8
                //if (!String.IsNullOrWhiteSpace(mobile8))
                //{
                //    ltrContent.Text += "<a href=\"http://idp.vn/lif/vi\" target=\"_blank\"><div class=\"video_Sticky\"><video id=\"myVideo\"   autoplay height=\"80\" ><source src=\"" + mobile8 + "\"></source></video></div></a>";
                //}

                ltrContent.Text = ltrContent.Text.Replace("595px", "device-width");// chinh lai do rong cua the de fit voi content
                if (!ltrContent.Text.Contains("people_write"))
                {
                    ltrContent.Text += "<div class=\"people_write hide\" itemprop=\"author\" itemscope=\"\" itemtype=\"https://schema.org/Person\"> <b><span itemprop=\"name\" class=\"icon_author\">Tổng hợp</span>/ Theo google</b><br></div> </div> </div>";
                }
                ltrDate.Text  = ne.NEWS_PUBLISHDATE.ToString("dd/MM/yyyy");
                ltrTime.Text  = ne.NEWS_PUBLISHDATE.ToString("hh:mm");
                ltrDes.Text   = ne.NEWS_INITCONTENT;
                ltrAthor.Text = ne.NEWS_ATHOR;

                if (!String.IsNullOrEmpty(ne.Keywrods))
                {
                    ltrKeyword.Text = ne.Keywrods;
                }
                var catId = 0;

                if (Lib.QueryString.ParentCategoryID == 0)
                {
                    catId = Lib.QueryString.CategoryID;
                }
                else
                {
                    catId = Lib.QueryString.ParentCategoryID;
                }
                CategoryEntity cat = BOCategory.GetCategory(catId);
                if (cat != null)
                {
                    //ltrCatName.Text = cat.Cat_Name;

                    ltrCattxt.Text = string.Format(txtCat, (String.Format("/{0}.html", cat.Cat_DisplayURL.ToLower().Trim())), cat.Cat_Name);
                    CategoryEntity catParent = BOCategory.GetCategory(cat.Cat_ParentID);

                    //ltrCatParentMenu.Text=
                    if (cat.Cat_ParentID != null && cat.Cat_ParentID != 0)
                    {
                        ltrCatParentMenu.Text = string.Format(txtCat, (String.Format("/{0}.html", catParent.Cat_DisplayURL.ToLower().Trim())), catParent.Cat_Name);
                    }
                }


                if (Lib.QueryString.ParentCategoryID > 0)
                {
                    catId = Lib.QueryString.CategoryID;
                    CategoryEntity cat1 = BOCategory.GetCategory(catId);
                    ltrCatParent.Text = string.Format(txtCatPr,
                                                      (String.Format("/{0}.html", cat1.Cat_DisplayURL.ToLower().Trim())), cat1.Cat_Name);
                }



                Utils.SetPageHeader(this.Page, ne.NEWS_TITLE, ne.NEWS_INITCONTENT, Utils.RemoveHTMLTag(ne.Keywrods));
                Utils.SetFaceBookSEO(this.Page, ne.NEWS_TITLE, ne.NEWS_INITCONTENT, ne.Imgage.StorageUrl, Request.RawUrl);

                string GOOGLE =
                    @"  <meta itemprop=""datePublished"" content=""{4}"" />
                                        <meta itemprop=""sourceOrganization"" content=""NetLife"" />
                                        <meta itemprop=""url"" property=""og:url"" content=""{0}"" />
                                        <meta itemprop=""articleSection"" content=""{1}"" />
                                        <meta itemprop=""image"" content=""{3}"" />
                                        <div style=""display: none !important"" itemscope itemtype=""http://schema.org/Recipe"">
                                            <span itemprop=""name"">{2}</span>
                                            <img itemprop=""image"" src=""{3}"" />                                             
                                        </div>";

                ltrTitle.Text += string.Format(GOOGLE, ne.URL.StartsWith("http") ? ne.URL : "http://netlife.com.vn" + ne.URL, cat.Cat_Name, ne.NEWS_TITLE, !String.IsNullOrEmpty(ne.Imgage.StorageUrl) && ne.Imgage.StorageUrl.StartsWith("http") ? ne.Imgage.StorageUrl : Utils.ImagesThumbUrl + "/" + ne.Imgage.StorageUrl, ne.NEWS_PUBLISHDATE);
            }
            if (ne.NEWS_RELATION.Count > 0)
            {
                //Tin_lien_quan1.DataEntity = nep.NEWS_RELATION;
                var abc = ne.NEWS_RELATION; //.Take(ne.NEWS_RELATION.Count < 5 ? ne.NEWS_RELATION.Count : 5).ToList();
                dataEntity = abc;
                NewsPublishEntity nep;
                int iCount = dataEntity != null ? dataEntity.Count : 0;
                for (int i = 0; i < (iCount > 6 ? 6 : iCount); i++)
                {
                    nep = dataEntity[i];
                    //ltrListRelate.Text += String.Format(itemRelate, nep.URL, nep.NEWS_TITLE, nep.URL_IMG);

                    ltrListRelate.Text += String.Format(itemRelate, nep.URL, nep.NEWS_TITLE, nep.Imgage.ImageUrl, countTime(nep.NEWS_PUBLISHDATE));
                }
                //ltrListRelate.Text = ltrListRelate.Text.Replace("img", "img width=\"60\" height=\"50\"");
            }
            else
            {
                relate.Visible = false;
            }

            //var otherNews = NewsPublished.NP_Select_Tin_Khac(Lib.QueryString.ParentCategoryID, Lib.QueryString.CategoryID, Lib.QueryString.NewsID, 10);
            var otherNews = NewsPublished.NP_Xem_Nhieu_Nhat(10, 213, Lib.QueryString.CategoryID);

            if (otherNews != null)
            {
                NewsPublishEntity nep;
                int iCount = otherNews != null ? otherNews.Count : 0;
                for (int i = 0; i < iCount; i++)
                {
                    nep            = otherNews[i];
                    ltrOther.Text += String.Format(itemRelate, nep.URL, nep.NEWS_TITLE, nep.Imgage.ImageUrl, countTime(nep.NEWS_PUBLISHDATE));
                }
            }
            var newsHot = NewsPublished.NoiBatTrangChu(5, 50);

            if (newsHot != null)
            {
                NewsPublishEntity nep;
                int iCount = newsHot != null ? newsHot.Count : 0;
                for (int i = 0; i < iCount; i++)
                {
                    nep          = newsHot[i];
                    ltrHot.Text += String.Format(itemHot, nep.URL, nep.NEWS_TITLE);
                }
            }
            var listNew = NewsPublished.NP_Tin_Moi_Trong_Ngay(10, 60);

            if (listNew != null)
            {
                NewsPublishEntity nep;
                int iCount = listNew != null ? listNew.Count : 0;
                for (int i = 0; i < iCount; i++)
                {
                    nep          = listNew[i];
                    ltrNew.Text += String.Format(itemRelate, nep.URL, nep.NEWS_TITLE, nep.Imgage.ImageUrl, countTime(nep.NEWS_PUBLISHDATE));
                }
            }


            var sameCategorys = NewsPublished.NP_Select_Tin_Khac(Lib.QueryString.ParentCategoryID, Lib.QueryString.CategoryID, Lib.QueryString.NewsID, 10);

            if (sameCategorys != null)
            {
                NewsPublishEntity nep;
                int iCount = sameCategorys != null ? sameCategorys.Count : 0;
                for (int i = 0; i < iCount; i++)
                {
                    nep = sameCategorys[i];
                    ltsameCategorys.Text += String.Format(itemRelate, nep.URL, nep.NEWS_TITLE, nep.Imgage.ImageUrl, countTime(nep.NEWS_PUBLISHDATE));
                }
            }
        }
Beispiel #5
0
        public NewsPublishEntity GetNewsById(long News_ID)
        {
            int               cat_parentid;
            int               cat_id;
            string            key = String.Format(ATVCommon.Constants.CACHE_NAME_NEWS_DETAIL, News_ID);
            NewsPublishEntity npe = Utils.Get_MemCache <NewsPublishEntity>(key) ?? Utils.GetFromCache <NewsPublishEntity>(key);

            if (npe == null)
            {
                DataTable tbl = new DataTable();

                using (MainDB db = new MainDB())
                {
                    tbl = db.StoredProcedures.NP_TinChiTiet(News_ID);
                }

                int iCount = tbl != null ? tbl.Rows.Count : 0;
                npe = new NewsPublishEntity();
                if (iCount > 0)
                {
                    DataRow row;
                    row = tbl.Rows[0];
                    npe.NEWS_INITCONTENT = Utils.GetObj <string>(row["NEWS_INITCONTENT"]);
                    npe.NEWS_PUBLISHDATE = Utils.GetObj <DateTime>(row["NEWS_PUBLISHDATE"]);
                    npe.NEWS_SUBTITLE    = Utils.GetObj <string>(row["NEWS_SUBTITLE"]);
                    npe.NEWS_IMAGESNOTE  = Utils.GetObj <string>(row["News_ImageNote"]);
                    npe.NEWS_TITLE       = Utils.GetObj <string>(row["NEWS_TITLE"]);
                    npe.NEWS_ID          = Convert.ToInt64(row["NEWS_ID"]);
                    npe.ICON             = Utils.GetObj <string>(row["ICON"]);
                    npe.News_Rate        = Utils.GetObj <Int32>(row["NEWS_Rate"]);
                    npe.Cat_Id           = cat_id = Utils.GetObj <Int32>(row["Cat_Id"]);
                    npe.Cat_ParentId     = cat_parentid = Utils.GetObj <Int32>(row["Cat_ParentId"]);
                    npe.URL    = Utils.BuildLinkDetail(Convert.ToInt32(row["Cat_ParentID"]), Convert.ToInt32(row["Cat_ID"]), npe.NEWS_ID, npe.NEWS_TITLE);
                    npe.Imgage = new ImageEntity(100, Utils.GetObj <string>(row["NEWS_IMAGE"]));
                    string content = Utils.GetObj <string>(row["News_Content"]).Replace("//<![CDATA[", "").Replace("//]]>", "");

                    var lstDomain = LBDomain.Split('|');

                    if (npe.NEWS_PUBLISHDATE < new DateTime(2010, 7, 8, 23, 59, 00) && lstDomain.Length > 0)
                    {
                        content = content.Replace("img.2sao.vietnamnet.vn", lstDomain[0]);
                    }
                    else if (npe.NEWS_PUBLISHDATE < DateTime.Now.AddDays(-3) && lstDomain.Length > 1)
                    {
                        content = content.Replace("img.2sao.vietnamnet.vn", lstDomain[1]);
                    }

                    npe.NEWS_CONTENT  = content;
                    npe.Keywrods      = Utils.GetObj <string>(row["Extension3"]);
                    npe.NEWS_RELATION = GetRelation(Utils.GetObj <string>(row["NEWS_RELATION"]), 200);

                    var tmpKeyword = new List <string>();
                    try
                    {
                        tmpKeyword = NGramKeyword.GetNGramKeyword(npe.NEWS_TITLE, npe.NEWS_INITCONTENT, npe.NEWS_CONTENT, 10);
                    }
                    catch
                    {
                        tmpKeyword = new List <string>();
                    }


                    npe.Keywrods = string.Concat(npe.Keywrods, " ", String.Join(", ", tmpKeyword.ToArray()));


                    if (npe.Keywrods.Length > 0)
                    {
                        string[] arStrings = npe.Keywrods.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                        for (int i = 0; i < arStrings.Length; i++)
                        {
                            arStrings[i] = String.Format("<a title=\"{2}\" href=\"http://sao.tintuconline.com.vn/{0}.search\">{1}</a>", arStrings[i].Trim().Replace(" ", "-"), HttpUtility.HtmlEncode(arStrings[i].Trim()), HttpUtility.HtmlEncode(arStrings[i].Trim()));
                        }

                        npe.Keywrods = String.Join(", ", arStrings);
                    }

                    string news_otherCat = Utils.GetObj <String>(row["News_OtherCat"]);
                    if (news_otherCat.Length > 0)
                    {
                        string[] otherCat = news_otherCat.Split(',');
                        foreach (var s in otherCat)
                        {
                            if (Utils.IsNumber(s))
                            {
                                npe.NEWS_OTHERCAT.Add(Convert.ToInt32(s));
                            }
                        }
                    }
                }

                bool isSuccess = Utils.Add_MemCache(key, npe);

                if (!isSuccess)
                {
                    Utils.SaveToCacheDependency(TableName.DATABASE_NAME, TableName.NEWSPUBLISHED, key, npe);
                }

                return(npe);
            }
            return(npe);
        }
Beispiel #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var tbl = BOCategory.GetCategoryByParent(CatID);

            if (tbl != null && tbl.Rows.Count > 0)
            {
                foreach (System.Data.DataRow row in tbl.Rows)
                {
                    Literal1.Text += String.Format(childCat, (String.Format("/{0}.html", row["Cat_DisplayUrl"].ToString())), row["Cat_Name"].ToString(), row["Cat_ID"]);
                }
            }


            NewsPublishEntity ne = NewsPublished.NP_TinChiTiet(Lib.QueryString.NewsID, false);

            if (ne != null)
            {
                if (Request.QueryString["move301"] != null)
                {
                    Utils.Move301(ne.URL);
                    return;
                }
                string htmlMobile2 = BOAdv.GetAdvItemById(Lib.Object2Integer(48), Lib.QueryString.CategoryID);
                string adsContent  = "";

                if (!String.IsNullOrWhiteSpace(htmlMobile2))
                {
                    adsContent = Environment.NewLine + "<script>" + String.Format("var zone{0}_{2} = new RunBanner({1}, \"zone{0}_{2}_Adv\"); zone{0}_{2}.Show();", Lib.QueryString.CategoryID, htmlMobile2.Replace("\\n", " ").Replace("\\t", " "), 48).Replace("INSERT_RANDOM_NUMBER_HERE", DateTime.Now.ToFileTime().ToString()) + "</script>" + Environment.NewLine;
                }

                ltrTitle.Text = ne.NEWS_TITLE;

                var    content   = ne.NEWS_CONTENT;
                string pattern   = @"(?<start><a[^>]*)(?<end>>)";
                string repl      = @"${start} target=""_blank"" ${end}";
                string newString = Regex.Replace(content, pattern, repl);
                ltrContent.Text = newString.Replace("src=\"/Uploaded/", "src=\"http://static.netlife.vn/Uploaded/").Replace("<div id=\"vmcbackground\"></div>", string.Format("<div id=\"vmcbackground\"><center>{0}</center></div>", adsContent));
                ltrContent.Text = ltrContent.Text.Replace("jpg\"", "jpg?maxwidth=480\"" + " alt=\"" + ne.NEWS_TITLE + "\"");

                //jwplayer
                ltrContent.Text += "";



                string html = BOAdv.GetAdvEmbedScriptItemById(Lib.Object2Integer(37), Lib.Object2Integer(Lib.QueryString.CategoryID));
                if (html.Length > 2) //add ad video 7
                {
                    //if (html.Contains("ambient")) //ambient
                    //{
                    ltrContent.Text += Environment.NewLine;
                    ltrContent.Text += html;
                    //}
                    //else if (html.Contains("ebound")) //ebound
                    //{
                    //    String[] part = html.Split('@');
                    //    ltrContent.Text += Environment.NewLine;
                    //    ltrContent.Text = ltrContent.Text.Replace("<video", part[0] + "<video").Replace("video>", "video>" + part[1]);
                    //}
                }
                if (!ltrContent.Text.Contains("people_write"))
                {
                    ltrContent.Text += "\n<table class=\"tplCaption\"><div class=\"people_write hide\" itemprop=\"author\" itemscope=\"\" itemtype=\"https://schema.org/Person\"> <b><span itemprop=\"name\" class=\"icon_author\">Tổng hợp</span>/ Theo google</b><br></div> </div> </div></table>";
                }



                ltrDate.Text  = ne.NEWS_PUBLISHDATE.ToString("dd/MM/yyyy");
                ltrTime.Text  = ne.NEWS_PUBLISHDATE.ToString("hh:mm");
                ltrDes.Text   = ne.NEWS_INITCONTENT;
                ltrAthor.Text = ne.NEWS_ATHOR;

                if (!String.IsNullOrEmpty(ne.Keywrods))
                {
                    ltrKeyword.Text = ne.Keywrods;
                }
                else
                {
                    tags.Visible = false;
                }
                var catId = 0;

                if (Lib.QueryString.ParentCategoryID == 0)
                {
                    catId = Lib.QueryString.CategoryID;
                }
                else
                {
                    catId = Lib.QueryString.ParentCategoryID;
                }
                CategoryEntity cat = BOCategory.GetCategory(catId);
                if (cat != null)
                {
                    ltrCatName.Text = cat.Cat_Name;

                    ltrCattxt.Text = string.Format(txtCat, cat.Cat_DisplayURL.ToLower(), cat.Cat_Name);
                }
                if (Lib.QueryString.ParentCategoryID > 0)
                {
                    catId = Lib.QueryString.CategoryID;
                    CategoryEntity cat1 = BOCategory.GetCategory(catId);
                    ltrCatParent.Text = string.Format(txtCatPr, cat1.Cat_Description, cat1.Cat_Name);
                }



                Utils.SetPageHeader(this.Page, ne.NEWS_TITLE, ne.NEWS_INITCONTENT, Utils.RemoveHTMLTag(ne.Keywrods));
                Utils.SetFaceBookSEO(this.Page, ne.NEWS_TITLE, ne.NEWS_INITCONTENT, ne.Imgage.StorageUrl, Request.RawUrl);

                string GOOGLE =
                    @"  <meta itemprop=""datePublished"" content=""{4}"" />
                                        <meta itemprop=""sourceOrganization"" content=""NetLife"" />
                                        <meta itemprop=""url"" property=""og:url"" content=""{0}"" />
                                        <meta itemprop=""articleSection"" content=""{1}"" />
                                        <meta itemprop=""image"" content=""{3}"" />
                                        <div style=""display: none !important"" itemscope itemtype=""http://schema.org/Recipe"">
                                            <span itemprop=""name"">{2}</span>
                                            <img itemprop=""image"" src=""{3}"" />                                             
                                        </div>";

                ltrTitle.Text += string.Format(GOOGLE, ne.URL.StartsWith("http") ? ne.URL : "http://netlife.vn" + ne.URL, cat.Cat_Name, ne.NEWS_TITLE, !String.IsNullOrEmpty(ne.Imgage.StorageUrl) && ne.Imgage.StorageUrl.StartsWith("http") ? ne.Imgage.StorageUrl : Utils.ImagesThumbUrl + "/" + ne.Imgage.StorageUrl, ne.NEWS_PUBLISHDATE);
            }
            //if (ne != null && ne.NEWS_RELATION.Count > 0)
            {
                var abc = ne.NEWS_RELATION.Count > 2 ? ne.NEWS_RELATION.Skip(2).Take(6).ToList() : ne.NEWS_RELATION; // Edit Take(8) -> Take(6)  edit 20160525
                dataEntity = abc;
                NewsPublishEntity nep;
                int iCount = dataEntity != null ? dataEntity.Count : 0;
                for (int i = 0; i < (iCount > 6 ? 6 : iCount); i++) //(int i = 0; i < iCount; i++)
                {
                    nep        = dataEntity[i];
                    nep.Imgage = new ImageEntity(300, nep.Imgage.ImageUrl);
                    if (i < 3) //Gia tri cu la 4, thay doi vi ly do giam muc xuong con 6 bai, thay vi 8 bai nhu cu
                    {
                        ltrListRelate.Text += String.Format(itemRelateNews, nep.URL, nep.NEWS_TITLE, nep.URL_IMG);
                    }
                    else
                    {
                        ltrListRelate2.Text += String.Format(itemRelateNews, nep.URL, nep.NEWS_TITLE, nep.URL_IMG);
                        relatenews.Visible   = true;
                    }
                    // "Tin Cung Chuyen Muc"
                    if (relatedNewsId == null || relatedNewsId == "")
                    {
                        relatedNewsId = nep.NEWS_ID.ToString();
                    }
                    else
                    {
                        relatedNewsId = relatedNewsId + "," + nep.NEWS_ID.ToString();
                    }
                }

                for (int i = 0; i < (iCount > 3 ? 3 : iCount); i++) //Gia tri cu la 4, thay doi vi ly do giam muc xuong con 6 bai, thay vi 8 bai nhu cu
                {
                    nep             = dataEntity[i];
                    ltrRelate.Text += String.Format(itemOtherNews, nep.URL, nep.NEWS_TITLE, nep.URL_IMG);
                }
            }
            //else
            //{
            //    lienquan.Visible = false;

            //}

            //ltrVideo

            var video = NewsPublished.NP_Danh_Sach_Tin(0, 134, 4, 1, 300);

            if (video != null)
            {
                NewsPublishEntity nep;
                int iCount = video != null ? video.Count : 0;
                for (int i = 0; i < iCount; i++)
                {
                    nep = video[i];

                    ltrVideo.Text += String.Format(itemRelate, nep.URL, nep.NEWS_TITLE, nep.URL_IMG);
                }
            }

            {
                if (relatedNewsId.Length == 0)
                {
                    relatedNewsId = "20170427093838540";
                }
                var otherNews = NewsPublished.NP_Select_Tin_Cung_Chuyen_Muc(Lib.QueryString.ParentCategoryID, Lib.QueryString.CategoryID, Lib.QueryString.NewsID, 6, relatedNewsId);
                if (otherNews != null)
                {
                    NewsPublishEntity nep;
                    int iCount = otherNews != null ? otherNews.Count : 0;

                    for (int i = 0; i < (iCount > 6 ? 6 : iCount); i++) //(int i = 0; i < iCount; i++)
                    {
                        nep        = otherNews[i];
                        nep.Imgage = new ImageEntity(300, nep.Imgage.ImageUrl);
                        /*Chinh muc tin cung chuyen muc hien thi tuong tu Muc tin lien quan*/
                        if (i < 3) //Gia tri cu la 4, thay doi vi ly do giam muc xuong con 6 bai, thay vi 8 bai nhu cu
                        {
                            LiteralOther1.Text += String.Format(itemOther, nep.URL, nep.NEWS_TITLE, nep.URL_IMG);
                        }
                        else
                        {
                            LiteralOther2.Text += String.Format(itemOther, nep.URL, nep.NEWS_TITLE, nep.URL_IMG);
                            othernews.Visible   = true;
                        }
                    }
                }
                else
                {
                    cungchuyenmuc.Visible = false;
                }
            }
            {
                var listNews = NewsPublished.NP_Tin_Moi_Trong_Ngay(10, 60);
                if (listNews != null)
                {
                    NewsPublishEntity nep;
                    int iCount = listNews != null ? listNews.Count : 0;
                    //for (int i = 0; i < iCount; i++)
                    //{
                    //    nep = otherNews[i];
                    //    nep.Imgage = new ImageEntity(40, nep.Imgage.ImageUrl);
                    //    ltrOther.Text += String.Format(itemOther, nep.URL, nep.NEWS_TITLE, nep.URL_IMG);
                    //}
                    for (int i = 0; i < (iCount > 6 ? 6 : iCount); i++) //(int i = 0; i < iCount; i++)
                    {
                        nep        = listNews[i];
                        nep.Imgage = new ImageEntity(300, nep.Imgage.ImageUrl);
                        /* EDIT: Chinh muc tin cung chuyen muc hien thi tuong tu Muc tin lien quan*/
                        if (i < 3) //Gia tri cu la 4, thay doi vi ly do giam muc xuong con 6 bai, thay vi 8 bai nhu cu
                        {
                            LiteralNews1.Text += String.Format(itemNews, nep.URL, nep.NEWS_TITLE, nep.URL_IMG);
                        }
                        else
                        {
                            LiteralNews2.Text += String.Format(itemNews, nep.URL, nep.NEWS_TITLE, nep.URL_IMG);
                            listnews.Visible   = true;
                        }
                    }
                }
            }
        }