protected void Page_Load(object sender, EventArgs e) { try { string strCode = Request["Code"]; int Code; Int32.TryParse(strCode, out Code); BOLNews NewsBOL = new BOLNews(); NewsList1.ShowNewsByCatCode(Code, null); string strPageNo = Request["PageNo"]; int PageNo = Convert.ToInt32(strPageNo); if (PageNo == 0) { PageNo = 1; } IBaseBOL <DataTable> HardCodeBOL = new BOLHardCode(); HardCodeBOL.QueryObjName = "HCResourceSitesCats"; DataTable dtCurCat = HardCodeBOL.GetDetails(Code); if (dtCurCat.Rows.Count == 1) { ltrHeader.Text = "آخرین خبرهای " + dtCurCat.Rows[0]["Name"].ToString() + " صفحه " + Tools.ChangeEnc(PageNo); Page.Title = " آخرین خبرهای " + dtCurCat.Rows[0]["Name"].ToString() + " صفحه " + Tools.ChangeEnc(PageNo); } } catch (Exception err) { BOLErrorLogs ErrorLogsBOL = new BOLErrorLogs(); ErrorLogsBOL.Insert(err.Message, DateTime.Now, Request.Url.AbsolutePath, "NewsByCatCode::Load"); } }
void ListNews(int privateSiteCode, string privateNewsUrl, string privateNewsTitle, string privateREDetail, string privateREImage, string privateREVideo, int Count, string LinkDomainName, int EncodingTypeCode) { ReqUtils gn = new ReqUtils(); string NewsContentHtml = ""; string FullStory = ""; string ImageSource = ""; string VideoSource = ""; string TextTitle = ""; string NewsCode = ""; System.Text.Encoding enc = System.Text.Encoding.UTF8; if (EncodingTypeCode != 1) { IBaseBOL <DataTable> BolHardCode = new BOLHardCode(); BolHardCode.QueryObjName = "HCEncodingTypes"; DataTable dt = BolHardCode.GetDetails(EncodingTypeCode); enc = System.Text.Encoding.GetEncoding(dt.Rows[0]["Description"].ToString()); } privateNewsUrl = privateNewsUrl.Replace("//", "/"); privateNewsUrl = privateNewsUrl.Replace("http:/", "http://"); privateNewsUrl = privateNewsUrl.Replace("https:/", "https://"); if (privateREDetail.Length > 0) { NewsContentHtml = gn.GetHTML(privateNewsUrl, enc); if (privateREDetail != null && privateREDetail != "") { FullStory = gn.GetREGroup(NewsContentHtml, privateREDetail, "CONTENT"); } if (privateREImage != null && privateREImage != "") { ImageSource = gn.GetREGroup(NewsContentHtml, privateREImage, "IMAGE"); } if (privateREVideo != null && privateREVideo != "") { VideoSource = gn.GetREGroup(NewsContentHtml, privateREVideo, "VIDEO"); } if (!ImageSource.StartsWith("http://") && !ImageSource.StartsWith("https://") && ImageSource != "") { ImageSource = LinkDomainName + ImageSource; } if (!VideoSource.StartsWith("http://") && VideoSource != "") { VideoSource = LinkDomainName + VideoSource; } FullStory = gn.RemoveTags(FullStory, "br"); FullStory = FullStory.Replace("'", ""); FullStory = FullStory.Replace("\"", ""); FullStory = FullStory.Replace("\r", ""); FullStory = FullStory.Replace("\t", ""); FullStory = FullStory.Replace(" ", ""); ImageSource = ImageSource.Replace("[", "%5B"); ImageSource = ImageSource.Replace("]", "%5D"); VideoSource = VideoSource.Replace("[", "%5B"); VideoSource = VideoSource.Replace("]", "%5D"); if (ImageSource != "") //Save News File { try { int SlashPos = ImageSource.LastIndexOf("/"); string FileName = ImageSource.Substring(SlashPos + 1, ImageSource.Length - SlashPos - 1); WebClient WebCl = new WebClient(); string FName = Server.MapPath("~/Files/News/" + Tools.GetRandomFileName(FileName)); //WebCl.DownloadFile(ImageSource, FName); } catch { } } } TextTitle = gn.RemoveTags(privateNewsTitle); string ImageTag = ""; if (ImageSource != "") { ImageSource = "<img src=\"" + ImageSource + "\">"; } string outStr = string.Format("<table border=\"1\" class=\"cNews\" dir=\"rtl\" width=\"100%\" ><tr><td>{0}</td><td >{1}</td><td>{2}</td><td>{3}</td><td>{4}</td><td>{5}</td></tr></table>", Count, TextTitle, FullStory.Length, ImageSource, VideoSource, privateNewsUrl); Response.Write(outStr); Response.Flush(); gn.Dispose(); }
public void GetSingleSite(int privateSiteCode, int privateLimitCount) { int Count = 1; string NewsTitle = ""; string HtmlContent = ""; string EditedNewsTitle = ""; string NewsTextTitle = ""; ReqUtils gn; string SelectStatement = ""; BOLResourseSiteCats ResourceSiteCatsBOL = new BOLResourseSiteCats(1); vResourseSiteCats SingleSite = ResourceSiteCatsBOL.GetSingleSite(privateSiteCode); int SiteCode = SingleSite.Code; string SiteName = SingleSite.Name; string SiteUrl = SingleSite.Url; int? EncodingTypeCode = SingleSite.HCEncodingTypeCode; string BaseURL = SingleSite.BaseURL; string RELink = SingleSite.RELink; string REDetail = SingleSite.REDetail; string REImage = SingleSite.REImage; string REVideo = SingleSite.REVideo; ArrayList NewList = new ArrayList(); gn = new ReqUtils(); System.Text.Encoding enc = System.Text.Encoding.UTF8; if (EncodingTypeCode != 1) { IBaseBOL <DataTable> BolHardCode = new BOLHardCode(); BolHardCode.QueryObjName = "HCEncodingTypes"; DataTable dt = BolHardCode.GetDetails((int)EncodingTypeCode); enc = System.Text.Encoding.GetEncoding(dt.Rows[0]["Description"].ToString()); } int LastSlash = SiteUrl.LastIndexOf("/"); string LinkDomainName; if (BaseURL != null && BaseURL != "") { LinkDomainName = BaseURL; } else { LinkDomainName = SiteUrl.Substring(0, LastSlash + 1); } if (!(bool)SingleSite.RssIsActive) { HtmlContent = gn.GetHTML(SiteUrl, enc); NewList = gn.ExtractNewsLinks(HtmlContent, RELink, LinkDomainName); } else { NewList = GetNewsList(SingleSite.RssUrl); } IEnumerator NewENum = NewList.GetEnumerator(); gn = new ReqUtils(); while (NewENum.MoveNext()) { NewsTitle = NewENum.Current.ToString(); NewsTextTitle = gn.RemoveTags(NewsTitle); BOLNews NewsBOl = new BOLNews(); if (!NewsBOl.CheckNewsExists(NewsTextTitle, SiteCode)) { string RealLink = gn.ExtractLink(NewsTitle); string outStr = ""; //outStr = string.Format("<table width=100% ><tr><td class=\"cNews\">{1}</td><td>{0}</td></tr></table>", Count, NewsTitle); //Response.Write(outStr); //Response.Flush(); ListNews(SiteCode, RealLink, NewsTitle, REDetail, REImage, REVideo, Count, LinkDomainName, (int)EncodingTypeCode); } Count++; if (privateLimitCount != 0) { if (privateLimitCount == Count) { break; } } } }