protected void btn_slug_click(object sender, EventArgs e) { NewsGroupBSO newsGroupBSO = new NewsGroupBSO(); CateNewsGroupBSO _catenewsgroupBSO = new CateNewsGroupBSO(); CateNewsBSO _catenewsBSO = new CateNewsBSO(); NewsGroup newsGroup = new NewsGroup(); DataTable table = newsGroupBSO.GetNewsGroupAll(Language.language); if (table.Rows.Count > 0) { for (int i = 0; i < table.Rows.Count; i++) { newsGroup = newsGroupBSO.GetNewsGroupById(Convert.ToInt32(table.Rows[i]["NewsGroupID"].ToString())); newsGroup.Slug = GetString(newsGroup.Title); newsGroup.Tags = _catenewsBSO.GetCateNewsById(newsGroup.CateNewsID).CateNewsName.Replace(",", ""); newsGroup.Tags += "," + _catenewsgroupBSO.GetCateNewsGroupByGroupCate(newsGroup.GroupCate, Language.language).CateNewsGroupName.Replace(",", ""); newsGroup.Keyword = _catenewsBSO.GetCateNewsById(newsGroup.CateNewsID).CateNewsName.Replace(",", ""); newsGroup.Keyword += "," + _catenewsgroupBSO.GetCateNewsGroupByGroupCate(newsGroup.GroupCate, Language.language).CateNewsGroupName.Replace(",", ""); newsGroupBSO.UpdateNewsGroup(newsGroup); } clientview.Text = "Xử lý OK"; ViewNewsGroup(-1); } }
protected void btn_img2_click(object sender, EventArgs e) { NewsGroupBSO newsGroupBSO = new NewsGroupBSO(); NewsGroup newsGroup = new NewsGroup(); DataTable table = newsGroupBSO.GetNewsGroupAll(Language.language); //newsGroup = newsGroupBSO.GetNewsGroupById(7202); //string filename = FetchLinksFromSource(newsGroup.FullDescribe); if (table.Rows.Count > 0) { for (int i = 0; i < table.Rows.Count; i++) { newsGroup = newsGroupBSO.GetNewsGroupById(Convert.ToInt32(table.Rows[i]["NewsGroupID"].ToString())); //newsGroup.ShortDescribe = newsGroup.ShortDescribe.Replace("href=\"images/stories/", "href=\"/UserFile/images/stories/"); newsGroup.FullDescribe = newsGroup.FullDescribe.Replace("src=\"/upload/image/", "src=\"/UserFile/images/"); //newsGroup.ImageThumb = FetchLinksFromSource(newsGroup.FullDescribe); //newsGroup.ImageLarge = FetchLinksFromSource(newsGroup.FullDescribe); newsGroupBSO.UpdateNewsGroup(newsGroup); } clientview.Text = "Xử lý OK"; ViewNewsGroup(-1); } }
//Strip font HTML protected void btn_html_click(object sender, EventArgs e) { NewsGroupBSO newsGroupBSO = new NewsGroupBSO(); NewsGroup newsGroup = new NewsGroup(); DataTable table = newsGroupBSO.GetNewsGroupAll(Language.language); if (table.Rows.Count > 0) { for (int i = 0; i < table.Rows.Count; i++) { newsGroup = newsGroupBSO.GetNewsGroupById(Convert.ToInt32(table.Rows[i]["NewsGroupID"].ToString())); //if (newsGroup.FullDescribe.IndexOf("<!--more-->") != -1) //{ // newsGroup.ShortDescribe = newsGroup.FullDescribe.Substring(0, newsGroup.FullDescribe.IndexOf("<!--more-->")); //} //newsGroup.FullDescribe = newsGroup.FullDescribe.Replace("^<p> </p>", ""); //string regex = @"<p[^>]*>(\s|& nbsp;)*</p>"; //string regex = @" "; //newsGroup.FullDescribe = Regex.Replace(newsGroup.FullDescribe, regex, "").Trim(); //newsGroup.FullDescribe = Regex.Match(newsGroup.FullDescribe, "^<p> </p>").ToString(); //newsGroup.ShortDescribe = Regex.Replace(newsGroup.ShortDescribe, regex, "").Trim(); // string text = x; string patternfont = @"font-size\s*?:.*?(;|(?=""|'|;))"; string cleanedHtmlfontFull = Regex.Replace(newsGroup.FullDescribe, patternfont, string.Empty); //cleanedHtmlfontFull = Regex.Replace(cleanedHtmlfontFull, "(line-height|font-family|font-size)\\s:.*?;?", String.Empty); cleanedHtmlfontFull = Regex.Replace(cleanedHtmlfontFull, @"font-family\s*?:.*?(;|(?=""|'|;))", String.Empty); newsGroup.FullDescribe = cleanedHtmlfontFull; string cleanedHtmlfontDes = Regex.Replace(newsGroup.ShortDescribe, patternfont, string.Empty); cleanedHtmlfontDes = Regex.Replace(cleanedHtmlfontDes, @"font-family\s*?:.*?(;|(?=""|'|;))", String.Empty); newsGroup.ShortDescribe = cleanedHtmlfontDes; //newsGroup.ShortDescribe = Tool.StripTagsCharArray(newsGroup.ShortDescribe); newsGroupBSO.UpdateNewsGroup(newsGroup); } clientview.Text = "Xử lý OK"; ViewNewsGroup(-1); } }
protected void btn_img_click(object sender, EventArgs e) { NewsGroupBSO newsGroupBSO = new NewsGroupBSO(); NewsGroup newsGroup = new NewsGroup(); DataTable table = newsGroupBSO.GetNewsGroupAll(Language.language); if (table.Rows.Count > 0) { for (int i = 0; i < table.Rows.Count; i++) { newsGroup = newsGroupBSO.GetNewsGroupById(Convert.ToInt32(table.Rows[i]["NewsGroupID"].ToString())); // newsGroup.ShortDescribe = newsGroup.ShortDescribe.Replace("src=\"/Portals/0/", "src=\"/UserFile/images/"); newsGroup.FullDescribe = newsGroup.FullDescribe.Replace("src=\"/upload/image/", "src=\"/UserFile/images/"); newsGroupBSO.UpdateNewsGroup(newsGroup); } clientview.Text = "Xử lý OK"; ViewNewsGroup(-1); } }
protected void btn_img1_click(object sender, EventArgs e) { NewsGroupBSO newsGroupBSO = new NewsGroupBSO(); NewsGroup newsGroup = new NewsGroup(); DataTable table = newsGroupBSO.GetNewsGroupAll(Language.language); if (table.Rows.Count > 0) { for (int i = 0; i < table.Rows.Count; i++) { newsGroup = newsGroupBSO.GetNewsGroupById(Convert.ToInt32(table.Rows[i]["NewsGroupID"].ToString())); newsGroup.ShortDescribe = newsGroup.ShortDescribe.Replace("[img src", "<br/><img src"); newsGroup.FullDescribe = newsGroup.FullDescribe.Replace("[img src", "<br/><img src"); newsGroup.ShortDescribe = newsGroup.ShortDescribe.Replace("\"]", "\"/><br/>"); newsGroup.FullDescribe = newsGroup.FullDescribe.Replace("\"]", "\"/><br/>"); newsGroupBSO.UpdateNewsGroup(newsGroup); } clientview.Text = "Xử lý OK"; ViewNewsGroup(-1); } }
protected void btn_down_thumb_click(object sender, EventArgs e) { NewsGroupBSO newsGroupBSO = new NewsGroupBSO(); NewsGroup newsGroup = new NewsGroup(); DataTable table = newsGroupBSO.GetNewsGroupAll(Language.language); //newsGroup = newsGroupBSO.GetNewsGroupById(9163); //string filename = FetchLinksFromSource(newsGroup.FullDescribe); if (table.Rows.Count > 0) { for (int i = 0; i < table.Rows.Count; i++) //for (int i = 0; i < 1000; i++) { newsGroup = newsGroupBSO.GetNewsGroupById(Convert.ToInt32(table.Rows[i]["NewsGroupID"].ToString())); //newsGroup.ShortDescribe = newsGroup.ShortDescribe.Replace("href=\"images/stories/", "href=\"/UserFile/images/stories/"); //newsGroup.FullDescribe = newsGroup.FullDescribe.Replace("href=\"images/stories/", "href=\"/UserFile/images/stories/"); //newsGroup = newsGroupBSO.GetNewsGroupById(8960); string fileurl = newsGroup.ImageThumb; if (fileurl != "") { string strRealname = Path.GetFileName(fileurl); string exts = Path.GetExtension(fileurl); WebClient webClient = new WebClient(); string url1 = "http://*****:*****@"\", "/") + "Upload/NewsGroup/Gets/" + newsGroup.NewsGroupID + "-" + GetString(Tool.SubString(Tool.StripTagsCharArray(newsGroup.Title), 50)) + exts)) { try { webClient.DownloadFile(url1, Request.PhysicalApplicationPath.Replace(@"\", "/") + "Upload/NewsGroup/Gets/" + newsGroup.NewsGroupID + "-" + GetString(Tool.SubString(Tool.StripTagsCharArray(newsGroup.Title), 50)) + exts); } catch { } newsGroup.ImageThumb = newsGroup.NewsGroupID + "-" + GetString(Tool.SubString(Tool.StripTagsCharArray(newsGroup.Title), 50)) + exts; newsGroup.ImageLarge = newsGroup.NewsGroupID + "-" + GetString(Tool.SubString(Tool.StripTagsCharArray(newsGroup.Title), 50)) + exts; newsGroupBSO.UpdateNewsGroup(newsGroup); } } //string fileurl = GetSource(newsGroup.FullDescribe); //if (fileurl != "") //{ // string strRealname = Path.GetFileName(fileurl); // string exts = Path.GetExtension(fileurl); // WebClient webClient = new WebClient(); // //webClient.DownloadFile(Request.PhysicalApplicationPath.Replace(@"\", "/") + fileurl, Request.PhysicalApplicationPath.Replace(@"\", "/") + "Upload/NewsGroup/Gets/" + strRealname + exts); // string url1 = ""; // if (fileurl.IndexOf("http://") == -1) // { // url1 = "http://ussh.vnu.edu.vn/" + fileurl.Replace(@"UserFile/Images/News/img/", "wp-content/uploads/"); // url1 = url1.Replace(@"UserFile/images/News/img/", "wp-content/uploads/"); // url1 = url1.Replace("//wp-content", "/wp-content"); // url1 = url1.Replace("//uploads", "/wp-content/uploads"); // url1 = url1.Replace("[siteurl]/", ""); // url1 = url1.Replace("http://ussh.vnu.edu.vn//UserFile", "http://203.190.160.247:8321/UserFile"); // } // else // url1 = fileurl; // //string url1 = Request.PhysicalApplicationPath.Replace(@"\", "/") + fileurl; // //if (!File.Exists(Request.PhysicalApplicationPath.Replace(@"\", "/") + "Upload/NewsGroup/Gets/" + newsGroup.NewsGroupID + "-" + GetString(Tool.SubString(Tool.StripTagsCharArray(newsGroup.Title), 50)) + exts)) // //{ // //Stream mystream; // //HttpWebRequest wreq; // //HttpWebResponse wresp; // //wreq = (HttpWebRequest)WebRequest.Create(url1); // //wreq.AllowWriteStreamBuffering = true; // //wreq.Timeout = 6000; // =6s //set timeout download images from server other // //wresp = (HttpWebResponse)wreq.GetResponse(); // //if ((mystream = wresp.GetResponseStream()) != null) // //{ // if (!File.Exists(Request.PhysicalApplicationPath.Replace(@"\", "/") + "Upload/NewsGroup/Gets/" + newsGroup.NewsGroupID + "-" + GetString(Tool.SubString(Tool.StripTagsCharArray(newsGroup.Title), 50)) + exts)) // { // webClient.DownloadFile(url1, Request.PhysicalApplicationPath.Replace(@"\", "/") + "Upload/NewsGroup/Gets/" + newsGroup.NewsGroupID + "-" + GetString(Tool.SubString(Tool.StripTagsCharArray(newsGroup.Title), 50)) + exts); // newsGroup.ImageThumb = newsGroup.NewsGroupID + "-" + GetString(Tool.SubString(Tool.StripTagsCharArray(newsGroup.Title), 50)) + exts; // newsGroup.ImageLarge = newsGroup.NewsGroupID + "-" + GetString(Tool.SubString(Tool.StripTagsCharArray(newsGroup.Title), 50)) + exts; // newsGroupBSO.UpdateNewsGroup(newsGroup); // } // //} // //} //} } clientview.Text = "Xử lý OK"; ViewNewsGroup(-1); } }