public static List <News> QueryLatestNewsForXml(int amount) { try { List <News> newss = new List <News>(); SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(NewsModel.newsSiteUrl, NewsModel.sayfalarListName, string.Format(NewsModel.newsLimitedCamlQuery, amount)); if (coll.Count > 0) { foreach (SP.ListItem item in coll) { News news = new News(); news.ID = Convert.ToInt32(item["ID"]); news.Created = Convert.ToDateTime(item["Created"]); news.Title = item["Title"].ToString().Replace("\u0003", " "); news.ListImage = HLP.TransformImgHtmlStringAndGetBase64(item["ListImage"].ToString()); newss.Add(news); } } return(newss.Take(amount).ToList()); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static List <Announcement> QueryLatestAnnouncementsForXml(int amount) { try { List <Announcement> anns = new List <Announcement>(); SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(AnnouncementModel.announcementsSiteUrl, AnnouncementModel.sayfalarListName, string.Format(AnnouncementModel.announcementsCamlQuery, amount)); if (coll.Count > 0) { foreach (SP.ListItem item in coll) { Announcement ann = new Announcement(); ann.ID = Convert.ToInt32(item["ID"]); ann.Created = Convert.ToDateTime(item["Created"]); ann.Title = item["Title"].ToString(); string imgUrl = HLP.GetImageUrlFromImgTag(item["ListImage"].ToString()); //string imgFileName = HLP.SaveFileToTempFolder(HLP.GetNetworkCredential(), DAT.DataStatics.saportHostURL+ imgUrl, System.Web.HttpContext.Current.Session.SessionID); //ann.ListImage = HLP.CreateImgTag(imgFileName); //ann.ListImage = HLP.TransformHtmlString(item["ListImage"].ToString()); ann.ListImage = HLP.RemoteImageUrlToBase64Converter(imgUrl, true); anns.Add(ann); } } return(anns); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static List <Banner> DeserializeXMLToBannersLightForGlobalAsax(string filefolder, string fileName, int amount) { try { string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName; List <Banner> bannersLight = new List <Banner>(); bannersLight = QueryLatestBannersForXml(amount); System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Banner>)); HLP.DeleteFile(filefolder, fileName); System.IO.FileStream file = System.IO.File.Create(fileLocation); writer.Serialize(file, bannersLight); file.Close(); return(bannersLight.Take(amount).ToList()); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static List <PostCategory> DeserializeXMLToPostCategories(string filefolder, string fileName) { try { string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName; List <PostCategory> categories = new List <PostCategory>(); if (HLP.CheckIfFileExists(fileLocation)) { System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <PostCategory>)); System.IO.FileStream file = System.IO.File.OpenRead(fileLocation); categories = (List <PostCategory>)writer.Deserialize(file); file.Close(); } else { categories = QueryPostCategories(PostModel.postsMainSiteUrl, PostModel.categoryListName, PostModel.getCategoriesCamlQuery); System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <PostCategory>)); System.IO.FileStream file = System.IO.File.Create(fileLocation); writer.Serialize(file, categories); file.Close(); } return(categories); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static List <News> QueryLatestNews() { try { List <News> newss = new List <News>(); SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(NewsModel.newsSiteUrl, NewsModel.sayfalarListName, NewsModel.newsCamlQuery); if (coll.Count > 0) { foreach (SP.ListItem item in coll) { News news = new News(); news.ID = Convert.ToInt32(item["ID"]); news.Created = Convert.ToDateTime(item["Created"]); news.Title = item["Title"].ToString(); news.ListImage = HLP.TransformHtmlString(item["ListImage"].ToString()); newss.Add(news); } } return(newss); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static List <Post> DeserializeXMLToPostsLightForGlobalAsax(string filefolder, string fileName) { try { string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName; List <Post> postsLight = new List <Post>(); postsLight = QueryAllLatestPostsLight(filefolder, fileName); System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Post>)); HLP.DeleteFile(filefolder, fileName); System.IO.FileStream file = System.IO.File.Create(fileLocation); writer.Serialize(file, postsLight); file.Close(); return(postsLight); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public bool CreateOrUpdateCategoriesXML(string fileLocation) { try { List <PostCategory> categories = QueryPostCategories(); if (HLP.CheckIfFileExists(fileLocation)) { System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <PostCategory>)); System.IO.FileStream file = System.IO.File.OpenWrite(fileLocation); writer.Serialize(file, categories); file.Close(); } else { System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <PostCategory>)); System.IO.FileStream file = System.IO.File.Create(fileLocation); writer.Serialize(file, categories); file.Close(); } return(true); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(false); } }
public static WeatherStatus DeserializeXMLToWeathers(string filefolder, string fileName, string cityName) { try { string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName; List <WeatherStatus> weatherStatuses = new List <WeatherStatus>(); WeatherStatus cityWeatherStatus = new WeatherStatus(); if (HLP.CheckIfFileExists(fileLocation)) { System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <WeatherStatus>)); System.IO.FileStream file = System.IO.File.OpenRead(fileLocation); weatherStatuses = (List <WeatherStatus>)writer.Deserialize(file); cityWeatherStatus = weatherStatuses.Single(x => x.City == cityName); file.Close(); } else { weatherStatuses = QueryAllWeatherStatusesForXml(); System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <WeatherStatus>)); System.IO.FileStream file = System.IO.File.Create(fileLocation); writer.Serialize(file, weatherStatuses); file.Close(); } return(weatherStatuses.Single(x => x.City == cityName)); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static News QueryNewsDetails(int newsId) { try { News news = new News(); Microsoft.SharePoint.Client.ListItemCollection coll = DAT.DataQuery.QueryListItems(NewsModel.newsSiteUrl, NewsModel.sayfalarListName, string.Format(NewsModel.newsDetailCamlQuery, newsId)); SP.ListItem item = coll[0]; news.ID = newsId; news.Modified = Convert.ToDateTime(item["Modified"]); news.Title = item["Title"].ToString(); string[] metaInfo = item["MetaInfo"].ToString().Split('\n'); foreach (var i in metaInfo) { if (i.Contains("vti_cachedcustomprops")) { continue; } if (i.Contains("PublishingPageContent:SW")) { news.PublishingPageContent = HLP.TransformHtmlString(i.Split('|')[1].Replace("\r", "")); } } return(news); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static List <Post> DeserializeXMLToPostsLight(string filefolder, string fileName, int amount) { try { string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName; List <Post> postsLight = new List <Post>(); if (HLP.CheckIfFileExists(fileLocation)) { System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Post>)); System.IO.FileStream file = System.IO.File.OpenRead(fileLocation); postsLight = (List <Post>)writer.Deserialize(file); file.Close(); } else { postsLight = QueryAllLatestPostsLight(); System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Post>)); System.IO.FileStream file = System.IO.File.Create(fileLocation); writer.Serialize(file, postsLight); file.Close(); } return(postsLight.Take(amount).ToList()); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static List <Banner> DeserializeXMLToBannersLight(string filefolder, string fileName, int amount) { try { string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName; List <Banner> bannersLight = new List <Banner>(); DateTime fileCreationDate = System.IO.File.GetCreationTime(fileLocation); bool isOld = fileCreationDate < DateTime.Now.AddDays(-1) ? true : false; if (HLP.CheckIfFileExists(fileLocation)) { System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Banner>)); System.IO.FileStream file = System.IO.File.OpenRead(fileLocation); bannersLight = (List <Banner>)writer.Deserialize(file); bannersLight = bannersLight.Take(amount).ToList(); file.Close(); } else { bannersLight = QueryLatestBannersForXml(amount); System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Banner>)); System.IO.FileStream file = System.IO.File.Create(fileLocation); writer.Serialize(file, bannersLight); file.Close(); } return(bannersLight.Take(amount).ToList()); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static List <Campaign> QueryLatestCampaignsForService(int amount) { try { List <Campaign> camps = new List <Campaign>(); SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(CampaignModel.campaignsSiteUrl, CampaignModel.sayfalarListName, string.Format(CampaignModel.campaignsCamlQueryForService, amount * 3)); if (coll.Count > 0) { foreach (SP.ListItem item in coll) { Campaign camp = new Campaign(); string[] metaInfo = item["MetaInfo"].ToString().Split('\n'); foreach (var i in metaInfo) { if (i.Contains("vti_cachedcustomprops")) { continue; } if (i.Contains("PublishingPageContent:SW")) { camp.PublishingPageContent = HLP.TransformHtmlStringForMobile(i.Split('|')[1].Replace("\r", "")); } if (i.Contains("CampaignEndDate")) { camp.CampaignEndDate = Convert.ToDateTime(i.Split('|')[1].Replace("\r", "")); } if (i.Contains("ListImage")) { if (camp.CampaignEndDate != null && camp.CampaignEndDate >= DateTime.Now) { camp.ListImage = DAT.DataStatics.saportHostURL + HLP.TransformHtmlStringAndGetFileUrl(i.Split('|')[1].Replace("\r", "")); break; } } } if (camp.CampaignEndDate >= DateTime.Now) { if (camp.ListImage != string.Empty) { camp.ListImage = "/mobile/" + HLP.ResizeAndSaveFileToMobileFolder(HLP.GetNetworkCredential(), camp.ListImage); } camp.ID = Convert.ToInt32(item["ID"]); camp.Title = item["Title"].ToString(); camps.Add(camp); } } } return(camps.Take(amount).ToList()); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static string SaveRemoteImageToTemp(string imageUrl) { try { string imageBase64 = HLP.RemoteImageUrlToBase64Converter(imageUrl, false); return(imageBase64); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static List <Advert> QueryLatestCategoryAdvertsForXml(int amount, string category) { try { List <Advert> adverts = new List <Advert>(); SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(BillBoardModel.advertsSiteUrl, BillBoardModel.sayfalarListName, string.Format(BillBoardModel.categoryAdvertsLimitedCamlQuery, category, amount)); if (coll.Count > 0) { foreach (SP.ListItem item in coll) { Advert adv = new Advert(); adv.Category = category; adv.ID = Convert.ToInt32(item["ID"]); adv.Title = item["Title"].ToString(); string imgUrl = item["DefaultImage"] != null ? item["DefaultImage"].ToString() : ""; if (imgUrl == string.Empty) { adv.DefaultImage = BillBoardModel.defaultImageBase64; } else if (imgUrl.Contains("/tr-tr/ilanpanosu/") && !imgUrl.Contains("x.com")) { adv.DefaultImage = HLP.RemoteImageUrlToBase64Converter(Data.DataStatics.saportHostURL + imgUrl, true); } else if (imgUrl.Contains("x.com")) { adv.DefaultImage = HLP.RemoteImageUrlToBase64Converter(imgUrl, true); } else { adv.DefaultImage = HLP.RemoteImageUrlToBase64Converter(string.Format(BillBoardModel.thumbnailImageRemoteUrl, Convert.ToInt32(item["ID"]), imgUrl), true); } if (adv.DefaultImage.Length == 0 || adv.DefaultImage == null) { adv.DefaultImage = BillBoardModel.defaultImageBase64; } adverts.Add(adv); } } return(adverts); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
//public static string GetMobileImageUrl(string imageUrl, string context) //{ // try // { // imageUrl = bannersListUrl + imageUrl; // imageUrl = "/mobile/" + HLP.SaveFileForMobile(HLP.GetNetworkCredential(), imageUrl, context ); // return imageUrl; // } // catch (Exception ex) // { // EXP.RedirectToErrorPage(ex.Message); // return null; // } //} public static string GetImageUrl(string imageUrl) { try { //imageUrl = "/temp/" + HLP.SaveFileToTempFolderForBanners(HLP.GetNetworkCredential(), imageUrl); imageUrl = HLP.RemoteImageUrlToBase64Converter(imageUrl, false); return(imageUrl); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static List <Campaign> QueryLatestCampaignsForXml(int amount) { try { List <Campaign> camps = new List <Campaign>(); SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(CampaignModel.campaignsSiteUrl, CampaignModel.sayfalarListName, string.Format(CampaignModel.campaignsLimitedCamlQuery, amount * 3)); if (coll.Count > 0) { foreach (SP.ListItem item in coll) { Campaign camp = new Campaign(); string[] metaInfo = item["MetaInfo"].ToString().Split('\n'); foreach (var i in metaInfo) { if (i.Contains("vti_cachedcustomprops")) { continue; } if (i.Contains("CampaignEndDate")) { camp.CampaignEndDate = Convert.ToDateTime(i.Split('|')[1].Replace("\r", "")); } if (i.Contains("ListImage")) { if (camp.CampaignEndDate != null && camp.CampaignEndDate >= DateTime.Now) { camp.ListImage = HLP.TransformImgHtmlStringAndGetBase64(i.Split('|')[1].Replace("\r", "")); //camp.ListImage = "../temp/" + HLP.TransformHtmlStringAndGetFileName(i.Split('|')[1].Replace("\r", "")); break; } } } if (camp.CampaignEndDate >= DateTime.Now) { camp.ID = Convert.ToInt32(item["ID"]); camp.Title = item["Title"].ToString(); camps.Add(camp); } } } return(camps.Take(amount).ToList()); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { string category = string.Empty; int advertId = 0; advertId = Request.QueryString["AdvertId"] != null?Convert.ToInt32(Request.QueryString["AdvertId"]) : 0; category = Request.QueryString["Cat"] != null ? Request.QueryString["Cat"].ToString() : ""; if (advertId > 0 && !string.IsNullOrEmpty(category)) { #region Load Advert Images List <string> imageServerUrls = DAT.DataQuery.QueryFolderFileUrls(BillBoardModel.advertsSiteUrl, BillBoardModel.goruntulerListName, advertId.ToString()); if (imageServerUrls.Count > 0) { foreach (var item in imageServerUrls) { ltrAnnouncementImages2.Text = ltrAnnouncementImages.Text += string.Format(AnnouncementModel.announcementDetailImageHtml, HLP.ResizeAndSaveRemoteImageToLocal(item.ToString(), HttpContext.Current.Session.SessionID, true, 200, 100, 14)); } } else { ltrAnnouncementImages.Text += "<img src=\"data:image/png;base64," + BillBoardModel.defaultImageBase64 + "\"/>"; } #endregion #region Load Advert Info BillBoardModel.Advert advert = BillBoardService.QueryAdvertDetails(advertId)[0]; ltrTitle.Text = advert.Title; ltrCategory.Text = category; ltrDateCreated.Text = HLP.GetDateTurkishCulture(advert.Created); ltrDetails.Text = advert.Detail; ltrPrice.Text = advert.Price.ToString(); ltrSpotText.Text = advert.Description; #endregion } } } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message + " - " + ex.Source + " - " + ex.Data); } }
public static Announcement QueryAnnouncementDetails(int announcementId) { try { Announcement ann = new Announcement(); Microsoft.SharePoint.Client.ListItemCollection coll = DAT.DataQuery.QueryListItems(AnnouncementModel.announcementsSiteUrl, AnnouncementModel.sayfalarListName, string.Format(AnnouncementModel.announcementDetailCamlQuery, announcementId)); SP.ListItem item = coll[0]; ann.ID = announcementId; ann.Created = Convert.ToDateTime(item["Created"]); ann.Title = item["Title"].ToString(); ann.PublishingPageContent = HLP.TransformHtmlString(item["PublishingPageContent"].ToString()); return(ann); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static List <Advert> QueryAdvertDetailForService(int id, string category) { try { List <Advert> adverts = new List <Advert>(); SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(BillBoardModel.advertsSiteUrl, BillBoardModel.sayfalarListName, string.Format(BillBoardModel.advertDetailForServiceCamlQuery, category, id)); if (coll.Count > 0) { var item = coll[0]; Advert adv = new Advert(); adv.Category = category; adv.ID = id; adv.Title = item["Title"].ToString(); adv.Price = Convert.ToDecimal(item["Price"]); adv.Created = Convert.ToDateTime(item["Created"]); adv.Description = item["GenericDescription"].ToString(); adv.Detail = item["GenericDetail"].ToString(); // Retrieve Images List <string> imageServerUrls = DAT.DataQuery.QueryFolderFileUrls(BillBoardModel.advertsSiteUrl, BillBoardModel.goruntulerListName, id.ToString()); if (imageServerUrls.Count > 0) { List <string> urlPaths = new List <string>(); foreach (var imgUrl in imageServerUrls) { urlPaths.Add(HLP.ResizeAndSaveRemoteImageToLocalForService(imgUrl, 200, 100, 14, adv.GetType().Name.ToString() + id)); } adv.ImageUrls = urlPaths; } adverts.Add(adv); } return(adverts); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static Campaign QueryCampaignDetails(int campaignId) { try { System.Net.ServicePointManager.ServerCertificateValidationCallback = delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return(true); }; // To avouid SSL Security - Certificate Error SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(CampaignModel.campaignsSiteUrl, CampaignModel.sayfalarListName, string.Format(CampaignModel.campaignDetailCamlQuery, campaignId)); SP.ListItem item = coll[0]; Campaign camp = new Campaign(); string[] metaInfo = item["MetaInfo"].ToString().Split('\n'); foreach (var i in metaInfo) { if (i.Contains("vti_cachedcustomprops")) { continue; } if (i.Contains("PublishingPageContent:SW")) { camp.PublishingPageContent = HLP.TransformHtmlString(i.Split('|')[1].Replace("\r", "")); } if (i.Contains("CampaignEndDate:SW")) { camp.CampaignEndDate = Convert.ToDateTime(i.Split('|')[1].Replace("\r", "")); } if (i.Contains("CampaignStartDate:SW")) { camp.CampaignStartDate = Convert.ToDateTime(i.Split('|')[1].Replace("\r", "")); } } camp.ID = Convert.ToInt32(item["ID"]); camp.Title = item["Title"].ToString(); camp.PublishingPageContent = HttpUtility.HtmlDecode(camp.PublishingPageContent); return(camp); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static void DeserializeXMLToAnnouncementsForGlobalAsax(string filefolder, string fileName) { try { string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName; List <Announcement> anns = new List <Announcement>(); anns = QueryLatestAnnouncementsForXml(100); System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Announcement>)); HLP.DeleteFile(filefolder, fileName); System.IO.FileStream file = System.IO.File.Create(fileLocation); writer.Serialize(file, anns); file.Close(); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); } }
public static Campaign QueryCampaignDetailForService(int campaignId) { try { SP.ListItemCollection coll = DAT.DataQuery.QueryListItems(CampaignModel.campaignsSiteUrl, CampaignModel.sayfalarListName, string.Format(CampaignModel.campaignDetailCamlQuery, campaignId)); SP.ListItem item = coll[0]; Campaign camp = new Campaign(); string[] metaInfo = item["MetaInfo"].ToString().Split('\n'); foreach (var i in metaInfo) { if (i.Contains("vti_cachedcustomprops")) { continue; } if (i.Contains("PublishingPageContent:SW")) { camp.PublishingPageContent = HLP.TransformHtmlStringForMobile(i.Split('|')[1].Replace("\r", "")); } if (i.Contains("CampaignEndDate:SW")) { camp.CampaignEndDate = Convert.ToDateTime(i.Split('|')[1].Replace("\r", "")); } if (i.Contains("CampaignStartDate:SW")) { camp.CampaignStartDate = Convert.ToDateTime(i.Split('|')[1].Replace("\r", "")); } } camp.ID = Convert.ToInt32(item["ID"]); camp.Title = item["Title"].ToString(); return(camp); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); return(null); } }
public static void DeserializeXMLToAdvertsForGlobalAsax(string filefolder, string fileName, int amount, string category) { try { string fileLocation = AppDomain.CurrentDomain.BaseDirectory + "\\" + filefolder + "\\" + fileName; List <Advert> advsLight = new List <Advert>(); advsLight = QueryLatestCategoryAdvertsForXml(amount, category); System.Xml.Serialization.XmlSerializer writer = new System.Xml.Serialization.XmlSerializer(typeof(List <Advert>)); if (System.IO.File.Exists(fileLocation)) { HLP.DeleteFile(filefolder, fileName); } System.IO.FileStream file = System.IO.File.Create(fileLocation); writer.Serialize(file, advsLight); file.Close(); } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); } }
public static Post QueryPostDetail(string postTitle, string category) { try { Post post = new Post(); Microsoft.SharePoint.Client.ListItemCollection coll = DAT.DataQuery.QueryListItems(string.Format(PostModel.postsSiteUrl, category), PostModel.postsListName, string.Format(PostModel.postDetailCamlQueryByTitle, postTitle)); if (coll.Count > 0 && coll[0] != null) { SP.ListItem item = coll[0]; post.Id = Convert.ToInt32(item["ID"]); SP.FieldUserValue author = (SP.FieldUserValue)item["Author"]; post.Author = author.LookupValue.ToString(); post.Title = postTitle; post.Body = HLP.TransformHtmlStringForGlobalAsax(item["Body"].ToString()); post.PublishedDate = Convert.ToDateTime(item["PublishedDate"]); post.CategoryName = category; } return(post); } catch (Exception) { throw; } }
protected void Page_Load(object sender, EventArgs e) { try { string literalString = ""; #region (!Page.IsPostBack) if (!Page.IsPostBack) { #region Load Category Links List <PostModel.PostCategory> allCats = PostService.DeserializeXMLToPostCategories(PostModel.postCategoriesSaveFolder, PostModel.postCategoriesSaveFileName); foreach (var cat in allCats) { ltrBlogCategories.Text += string.Format(PostModel.htmlForPostCategories, string.Format(PostModel.postCategoryDetailUrl, cat.CategoryName), cat.CategoryTitle); } #endregion List <PostModel.Post> allPostsLight = PostService.DeserializeXMLToPostsLight(PostModel.postsLightSaveFolder, PostModel.postsLightFileName); PostModel.Post post = new PostModel.Post(); if (Request.QueryString["PostCat"] == null) // If there is no Category selection { #region First 3 Post of All Categories int i = 0; #region Modify Box Title boxTitle.InnerHtml = "Köşe Yazıları"; #endregion foreach (var item in allPostsLight) { post = PostService.QueryPostDetail(item.Id, item.CategoryName); string redirectUrlCategory = string.Format(PostModel.postCategoryDetailUrl, post.CategoryName); string redirectUrlCampItem = string.Format(PostModel.postDetailUrl, item.Id, post.CategoryName); ltrMain.Text += string.Format(PostModel.htmlForPostsPage, redirectUrlCampItem, post.Title, post.Author, redirectUrlCategory, post.CategoryTitle, HLP.GetDateTurkishCulture(post.PublishedDate), post.Body, redirectUrlCampItem); i++; if (i == 3) { ViewState.Add("LastPostId", post.Id.ToString()); ViewState.Add("LastPostCat", post.CategoryName.ToString()); break; } } #endregion } else // If there's a Category selected { #region First 3 Post of Specific Category int i = 0; string catName = Request.QueryString["PostCat"].ToString(); #region Modify Box Title boxTitle.InnerHtml = "Köşe Yazıları - " + PostService.GetCategoryTitleByCategoryName(catName); #endregion var categoriedPosts = allPostsLight.Where(x => x.CategoryName == catName).Take(3).ToList(); foreach (var item in categoriedPosts) { post = PostService.QueryPostDetail(item.Id, item.CategoryName); ltrMain.Text += string.Format(PostModel.htmlForCategoryPostsPage, string.Format(PostModel.postDetailUrl, post.Id, post.CategoryName), post.Title, post.Author, post.PublishedDate.ToShortDateString(), post.Body); i++; if (i == 3) { ViewState.Add("LastPostId", post.Id.ToString()); break; } } #endregion } } #endregion ltrMain.Text += literalString; } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); } }
protected void Button1_Click(object sender, EventArgs e) { try { #region Load Mode Button'u click olursa int lastPostId = Convert.ToInt32(ViewState["LastPostId"]); string lastPostCat = ViewState["LastPostCat"] != null ? ViewState["LastPostCat"].ToString() : (Request.QueryString["PostCat"] != null ? Request.QueryString["PostCat"] : ""); List <PostModel.Post> sessionPosts = PostService.DeserializeXMLToPostsLight(PostModel.postsLightSaveFolder, PostModel.postsLightFileName); if (sessionPosts != null) { #region Disable LoadMore Button if no more posts exist PostModel.Post last = null; if (Request.QueryString["PostCat"] != null) { last = sessionPosts.Where(x => x.CategoryName == Request.QueryString["PostCat"].ToString()).Last(); } if ((Request.QueryString["PostCat"] == null && sessionPosts[sessionPosts.Count - 1].Id == lastPostId) || (Request.QueryString["PostCat"] != null && last.Id == lastPostId)) { Button1.Visible = false; #endregion } else { var lastPost = sessionPosts.Where(x => x.Id == lastPostId && x.CategoryName == lastPostCat).ToList(); int index = sessionPosts.IndexOf((PostModel.Post)lastPost[0]); index++; if (Request.QueryString["PostCat"] == null) { #region Load One More Post From Any Category PostModel.Post addPost = PostService.QueryPostDetail(sessionPosts[index].Id, sessionPosts[index].CategoryName); string redirectUrlCategory = string.Format(PostModel.postCategoryDetailUrl, addPost.CategoryName); string redirectUrlCampItem = string.Format(PostModel.postDetailUrl, addPost.Id, addPost.CategoryName); ltrMain.Text += string.Format(PostModel.htmlForPostsPage, redirectUrlCampItem, addPost.Title, addPost.Author, redirectUrlCategory, addPost.CategoryTitle, HLP.GetDateTurkishCulture(addPost.PublishedDate), addPost.Body, redirectUrlCampItem); ViewState.Add("LastPostId", addPost.Id); ViewState.Add("LastPostCat", addPost.CategoryName); #endregion } else { #region Load One More Post From Specific Category string postCat = Request.QueryString["PostCat"].ToString(); while (sessionPosts[index].CategoryName != postCat) { index++; if (index == sessionPosts.Count) { index = 0; break; } } if (index > 0) { PostModel.Post addPost = PostService.QueryPostDetail(sessionPosts[index].Id, sessionPosts[index].CategoryName); ltrMain.Text += string.Format(PostModel.htmlForCategoryPostsPage, string.Format(PostModel.postDetailUrl, addPost.Id, addPost.CategoryName), addPost.Title, addPost.Author, HLP.GetDateTurkishCulture(addPost.PublishedDate), addPost.Body); ViewState.Add("LastPostId", addPost.Id); } #endregion } } } #endregion } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { #region Load Portalfeeds List <PortalFeedsModel.PortalFeed> allFeeds = PortalFeedsService.DeserializeXMLToPortalFeedsLight(PortalFeedsModel.portalFeedsSaveFolder, PortalFeedsModel.portalFeedSavedFileName, 50); int i = 0; foreach (var item in allFeeds) { i++; ltrMain.Text += string.Format(PortalFeedsModel.htmlForPortalFeedsPage, item.IconCode, PortalFeedsService.GetRedirectUrl(item.Category.ToString(), item.Id), HLP.GetDateTurkishCulture(Convert.ToDateTime(item.Created)), item.Title); if (i == allFeeds.Count) { ViewState.Add("LastPortalFeedId", item.Id.ToString()); ViewState.Add("LastPortalFeedCategory", item.Category.ToString()); } } #endregion } } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); } }
protected void Button1_Click(object sender, EventArgs e) { try { int lastPortalFeedId = Convert.ToInt32(ViewState["LastPortalFeedId"]); string lastPortalFeedCat = ViewState["LastPortalFeedCategory"] != null ? ViewState["LastPortalFeedCategory"].ToString() : ""; List <PortalFeedsModel.PortalFeed> sessionPortalFeeds = PortalFeedsService.DeserializeXMLToPortalFeedsLight(PortalFeedsModel.portalFeedsSaveFolder, PortalFeedsModel.portalFeedSavedFileName); if (sessionPortalFeeds != null) { var lastPortalFeed = sessionPortalFeeds.Where(x => x.Id == lastPortalFeedId && x.Category == lastPortalFeedCat).ToList(); int index = sessionPortalFeeds.IndexOf((PortalFeedsModel.PortalFeed)lastPortalFeed[0]); if (index + 10 < sessionPortalFeeds.Count - 1) { index++; int lastIndex = index + 4; // adding 5 more portalfeeds while (index <= lastIndex) { ltrMain.Text += string.Format(PortalFeedsModel.htmlForPortalFeedsPage, sessionPortalFeeds[index].IconCode, PortalFeedsService.GetRedirectUrl(sessionPortalFeeds[index].Category.ToString(), sessionPortalFeeds[index].Id), HLP.GetDateTurkishCulture(Convert.ToDateTime(sessionPortalFeeds[index].Created)), sessionPortalFeeds[index].Title); index++; } ViewState.Add("LastPortalFeedId", sessionPortalFeeds[lastIndex].Id.ToString()); ViewState.Add("LastPortalFeedCategory", sessionPortalFeeds[lastIndex].Category.ToString()); } else { Button1.Visible = false; } } } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message); } }
protected void Page_Load(object sender, EventArgs e) { try { if (!Page.IsPostBack) { #region Load Posts List <PostModel.Post> homePosts = PostService.DeserializeXMLToPostsLight(PostModel.postsLightSaveFolder, PostModel.postsLightFileName, 4); if (homePosts.Count > 0) { foreach (var item in homePosts) { string postDetailUrl = string.Format(PostModel.postDetailUrl, item.Id, item.CategoryName); ltrPosts.Text += string.Format(PostModel.htmlDivPostsForHomePage, postDetailUrl, postDetailUrl, item.Title); } } #endregion #region Load Campaigns List <CampaignModel.Campaign> homeCamps = CampaignService.DeserializeXMLToCampsLight(CampaignModel.campaignsSaveFolder, CampaignModel.campaignsSaveFileName, 6); if (homeCamps.Count == 0) { homeCamps.Clear(); homeCamps = CampaignService.QueryLastSixCampaigns(); foreach (var item in homeCamps) { item.Title = item.Title.Length > 30 ? item.Title.Substring(0, 29) + "..." : item.Title; ltrCampaigns.Text += string.Format(CampaignModel.htmlDivForHomePage2, item.ListImage, item.RedirectPage, item.RedirectPage, item.Title); } } else { foreach (var item in homeCamps) { item.Title = item.Title.Length > 30 ? item.Title.Substring(0, 29) + "..." : item.Title; ltrCampaigns.Text += string.Format(CampaignModel.htmlDivForHomePage, item.ListImage, item.RedirectPage, item.RedirectPage, item.Title); } } if (homeCamps.Count <= 3) { divCampaigns.Attributes.Add("style", "min-height:180px"); } #endregion #region Load Portal Feeds List <PortalFeedsModel.PortalFeed> homeFeeds = PortalFeedsService.DeserializeXMLToPortalFeedsLight("temp", "PortalFeeds.xml", 10); if (homeFeeds.Count > 0) { foreach (var item in homeFeeds) { string redirectUrl = string.Empty; switch (item.Category) { case "Announcement": redirectUrl = string.Format(PortalFeedsModel.redirectToAnnouncementDetailUrl, item.Id); break; case "Campaign": redirectUrl = string.Format(PortalFeedsModel.redirectToCampaignDetailUrl, item.Id); break; case "News": redirectUrl = string.Format(PortalFeedsModel.redirectToNewsDetailUrl, item.Id); break; } ltrPortalFeeds.Text += string.Format(PortalFeedsModel.htmlForHomePage, item.IconCode, redirectUrl, item.Title, item.Title); } } #endregion #region Load Banners List <BannerModel.Banner> activeBanners = BannerService.DeserializeXMLToBannersLight(BannerModel.announcementsSaveFolder, BannerModel.announcementsSaveFileName, 5); if (activeBanners.Count > 0) { foreach (var item in activeBanners) { //ltrBanners.Text += string.Format(BannerModel.wrapTextForHomePage, item.RedirectPage, BannerService.GetRemoteImageAsBase64(item.ImageUrl)); ltrBanners.Text += string.Format(BannerModel.wrapTextForHomePage, item.RedirectPage, HLP.SaveFileToTempFolderForBanners(HLP.GetNetworkCredential(), item.ImageUrl)); } } #endregion } } catch (Exception ex) { EXP.RedirectToErrorPage(ex.Message + ex.StackTrace.ToString()); } }