// Read Action page html Content public List<DataContent> ReadActionHtmlContent() { List<DataContent> ListDC = new List<DataContent>(); SqlDateTime SqlDtTime = new SqlDateTime(); CMSHelper ObjCMSHelper = null; try { string PdfFileUrl = string.Empty; string RetPageContent = string.Empty; string ContentFileFullPath = string.Empty; string HtmlPageFullPath = string.Empty; string HtmlPageName = string.Empty; HtmlDocument document = null; string ContentSummary = string.Empty; string ContentTitle = string.Empty; string ContentDate = string.Empty; string ImgUrl = string.Empty; string ContentPageUrl = string.Empty; string UserEmailID = string.Empty; string DatabaseLanguage = string.Empty; string UserName = string.Empty; string CurrentDbLangCode = string.Empty; string CountentUrl = string.Empty; string ArticleTags = string.Empty; //get name of news html page HtmlPageName = this.ActionHtmlFilenamePrefix + ".html"; document = new HtmlDocument(); // create html page full path HtmlPageFullPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.DiorgContent, HtmlPageName); if (!File.Exists(HtmlPageFullPath)) { return ListDC; } // load html page document.Load(HtmlPageFullPath); // Targets a specific node(since all the page contains parent table tag with width 700) HtmlNode content_wrapper = document.DocumentNode.SelectNodes("//table[@width='700']").FirstOrDefault(); // get html news collection HtmlNodeCollection search_results = content_wrapper.SelectNodes("//td[@class='news_space']"); //itterate through loop foreach (HtmlNode result in search_results) { DataContent Content = new DataContent(); // get title of news if (result.SelectNodes(".//p//span[@class='header']") != null && !string.IsNullOrEmpty(result.SelectNodes(".//p//span[@class='header']").FirstOrDefault().InnerText)) { ContentTitle = result.SelectNodes(".//p//span[@class='header']").FirstOrDefault().InnerText.Trim(); } else if (result.SelectNodes(".//span//strong//a") != null && !string.IsNullOrEmpty(result.SelectNodes(".//span//strong//a").FirstOrDefault().InnerText)) { ContentTitle = result.SelectNodes(".//span//strong//a").FirstOrDefault().InnerText.Trim(); } else if (result.SelectNodes(".//p//a//strong") != null && !string.IsNullOrEmpty(result.SelectNodes(".//p//a//strong").FirstOrDefault().InnerText.Trim())) { ContentTitle = result.SelectNodes(".//p//a//strong").FirstOrDefault().InnerText.Trim(); } else if (result.SelectNodes(".//p//strong//a") != null && !string.IsNullOrEmpty(result.SelectNodes(".//p//strong//a").FirstOrDefault().InnerText.Trim())) { ContentTitle = result.SelectNodes(".//p//strong//a").FirstOrDefault().InnerText.Trim(); } else if (result.SelectNodes(".//p//a") != null && !string.IsNullOrEmpty(result.SelectNodes(".//p//a").FirstOrDefault().InnerText)) { ContentTitle = result.SelectNodes(".//p//a").FirstOrDefault().InnerText.Trim(); } else if (result.SelectNodes(".//p//strong") != null && !string.IsNullOrEmpty(result.SelectNodes(".//p//strong").FirstOrDefault().InnerText)) { ContentTitle = result.SelectNodes(".//p//strong").FirstOrDefault().InnerText.Trim(); } // get summary of news if (result.SelectNodes(".//td[@width='71%']//tr/td") != null) { ContentSummary = result.SelectNodes(".//td[@width='71%']//tr/td").ElementAt(1).InnerText.Trim().ToString(); } // get date created of news if (result.SelectSingleNode(".//span[@class='adaptation_italic']") != null) { ContentDate = result.SelectSingleNode(".//span[@class='adaptation_italic']").InnerText.Replace("(", "").Replace(")", "").Trim(); } // get Thumbnail url of news if (result.SelectNodes(".//img[@class='reflect ropacity30']") != null) { ImgUrl = result.SelectNodes(".//img[@class='reflect ropacity30']").FirstOrDefault().GetAttributeValue("src", "").ToString(); } else if (result.SelectNodes(".//td//a//img[@width='140']") != null) { ImgUrl = result.SelectNodes(".//td//a//img[@width='140']").FirstOrDefault().GetAttributeValue("src", "").ToString(); } else if (result.SelectNodes(".//img[@class='reflect ropacity30 ']") != null) { ImgUrl = result.SelectNodes(".//img[@class='reflect ropacity30 ']").FirstOrDefault().GetAttributeValue("src", "").ToString(); } if (ImgUrl.Contains("diorg/")) { ImgUrl = ImgUrl.Replace("diorg/", "../libraries/aspx/diorg/"); } // get content page of url if (result.SelectNodes(".//td[@width='29%']//a") != null) { ContentPageUrl = result.SelectNodes(".//td[@width='29%']//a").FirstOrDefault().GetAttributeValue("href", "").ToString(); } else if (result.SelectNodes(".//td[@width='29%']//tr/td//a") != null) { ContentPageUrl = result.SelectNodes(".//td[@width='29%']//tr/td//a").FirstOrDefault().GetAttributeValue("href", "").ToString(); } else if (result.SelectNodes(".//td[@width='28%']//a") != null) { ContentPageUrl = result.SelectNodes(".//td[@width='28%']//a").FirstOrDefault().GetAttributeValue("href", "").ToString(); } //get content of inner html page if (ContentPageUrl.Contains("diorg/")) { // create full path of inner html page ContentFileFullPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.DiorgContent, Global.SplitString(ContentPageUrl, "diorg/")[1].ToString().Replace(@"/", "\\")); // check if file exist if (File.Exists(ContentFileFullPath)) { // call method to get content of html page //get pdfurl as out parameter RetPageContent = GetInnerContentNPdfUrl(ContentFileFullPath, out PdfFileUrl); } } // Initlize object of class cmshelper ObjCMSHelper = new CMSHelper(); // remove space and ;nbsp from date ContentDate = ObjCMSHelper.RemoveExtraCharsFromDate(ContentDate); // get created date of news SqlDtTime = new SqlDateTime(ObjCMSHelper.GetSqlDataTimeFromInptDate(ContentDate)); // get user email id from session if (!string.IsNullOrEmpty(HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUserNId].ToString())) { UserEmailID = Global.Get_User_EmailId_ByAdaptationURL(HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUserNId].ToString()); } // get user name from session if (!string.IsNullOrEmpty(HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUser].ToString())) { UserName = HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUser].ToString(); } // Create url from title CountentUrl = ObjCMSHelper.CreateUrlFromInputString(ContentTitle); //Get language of current database CurrentDbLangCode = Global.GetDefaultLanguageCode(); // innitlize of members of class Content Content.MenuCategory = "Action"; Content.Date = SqlDtTime; Content.DateAdded = new SqlDateTime(DateTime.Now); Content.DateModified = new SqlDateTime(DateTime.Now); Content.Description = RetPageContent; Content.Title = ContentTitle; Content.PDFUpload = PdfFileUrl; Content.Summary = ContentSummary; Content.Thumbnail = ImgUrl; Content.URL = CountentUrl; Content.Archived = false; Content.UserNameEmail = UserName + " " + UserEmailID; Content.LngCode = CurrentDbLangCode; Content.ArticleTagID = -1; Content.IsDeleted = false; Content.IsDeleted = false; // all class Content to list ListDC.Add(Content); } } catch (Exception Ex) { Global.CreateExceptionString(Ex, null); } // return list containing all html pages return ListDC; }
// Read facts page html content public List<DataContent> ReadFactsHtmlContent() { List<DataContent> ListDC = new List<DataContent>(); string PdfFileUrl = string.Empty; string RetPageContent = string.Empty; string NewsContentFullPath = string.Empty; string HtmlPageFullPath = string.Empty; string HtmlPageName = string.Empty; HtmlDocument document = null; string NewsSummary = string.Empty; string NewsTitle = string.Empty; string NewsContentDate = string.Empty; string ImgUrl = string.Empty; string ContentPageUrl = string.Empty; string UserEmailID = string.Empty; string DatabaseLanguage = string.Empty; string UserName = string.Empty; string CurrentDbLangCode = string.Empty; string NewsUrl = string.Empty; string ArticleTags = string.Empty; SqlDateTime SqlDtTime; // Initlize object of class cmshelper CMSHelper ObjCMSHelper = null; try { //get name of news html page HtmlPageName = this.FactsHtmlFilenamePrefix + ".html"; document = new HtmlDocument(); // create html page full path HtmlPageFullPath = Path.Combine(HttpContext.Current.Request.PhysicalApplicationPath, Constants.FolderName.DiorgContent, HtmlPageName); if (!File.Exists(HtmlPageFullPath)) { return ListDC; } // load html page document.Load(HtmlPageFullPath); // Targets a specific node(since all the page contains parent table tag with width 700) HtmlNode content_wrapper = document.DocumentNode.SelectNodes("//table[@width='700']//tr//td[@height='450']").FirstOrDefault(); // get html news collection if (content_wrapper.SelectNodes("//table[@width='700']//tr//td") != null) { HtmlNodeCollection SplitString = content_wrapper.SelectNodes("//div[@class='goal']"); foreach (HtmlNode HtmlNodResult in SplitString) { //HtmlNodResult.se DataContent Content = new DataContent(); // Initlize object of class cmshelper ObjCMSHelper = new CMSHelper(); // remove space and ;nbsp from date NewsContentDate = ObjCMSHelper.RemoveExtraCharsFromDate(NewsContentDate); // get created date of news SqlDtTime = new SqlDateTime(ObjCMSHelper.GetSqlDataTimeFromInptDate(NewsContentDate)); // get user email id from session if (!string.IsNullOrEmpty(HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUserNId].ToString())) { UserEmailID = Global.Get_User_EmailId_ByAdaptationURL(HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUserNId].ToString()); } // get user name from session if (!string.IsNullOrEmpty(HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUser].ToString())) { UserName = HttpContext.Current.Session[Constants.SessionNames.LoggedAdminUser].ToString(); } // Create url from title NewsUrl = ObjCMSHelper.CreateUrlFromInputString(NewsTitle); //Get language of current database CurrentDbLangCode = Global.GetDefaultLanguageCode(); // innitlize of members of class Content Content.Date = SqlDtTime; Content.DateAdded = new SqlDateTime(DateTime.Now); Content.DateModified = new SqlDateTime(DateTime.Now); Content.Description = RetPageContent; Content.Title = NewsTitle; Content.PDFUpload = PdfFileUrl; Content.Summary = NewsSummary; Content.Thumbnail = ImgUrl; Content.URL = NewsUrl; Content.Archived = false; Content.UserNameEmail = UserName + " " + UserEmailID; Content.LngCode = CurrentDbLangCode; Content.ArticleTagID = -1; // all class Content to list ListDC.Add(Content); } } } catch (Exception Ex) { Global.CreateExceptionString(Ex, null); } // return list containing all html pages return ListDC; }