public PartialViewResult GetMoreTFC20Content(int? pageSize, int page = 0) { List<HomepageFeatureItem> jfi = null; List<HomepageFeatureItem> obj = null; string jsonString = String.Empty; var registDt = DateTime.Now; int size = 12; int skipSize = 0; try { if (pageSize != null) size = (int)pageSize; skipSize = size * page; string CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy(); var cache = DataCache.Cache; string cacheKey = "T20BFC:O:" + GlobalConfig.TFC20BayaningFilipinoCategoryId; try { jsonString = (string)cache[cacheKey]; } catch (Exception) { } if (String.IsNullOrEmpty(jsonString)) { var context = new IPTV2Entities(); var episodeIds = context.EpisodeCategories1.Where(e => e.CategoryId == GlobalConfig.TFC20BayaningFilipinoCategoryId).Select(e => e.EpisodeId); var episodes = context.Episodes.Where(e => episodeIds.Contains(e.EpisodeId)); if (episodes != null) { jfi = new List<HomepageFeatureItem>(); foreach (var item in episodes) { if (item.OnlineStatusId == GlobalConfig.Visible && item.OnlineStartDate < registDt && item.OnlineEndDate > registDt) { string img = String.IsNullOrEmpty(item.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, item.EpisodeId, item.ImageAssets.ImageVideo); HomepageFeatureItem j = new HomepageFeatureItem() { id = item.EpisodeId, description = item.Description, name = item.EpisodeName, airdate = (item.DateAired != null) ? item.DateAired.Value.ToString("MMMM d, yyyy") : "", imgurl = img, blurb = HttpUtility.HtmlEncode(item.Synopsis), slug = MyUtility.GetSlug(item.EpisodeName) }; jfi.Add(j); } } jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(jfi); cache.Put(cacheKey, jsonString, DataCache.CacheDuration); } } else jfi = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomepageFeatureItem>>(jsonString); if (jfi != null) obj = jfi.Skip(skipSize).Take(size).ToList(); } catch (Exception e) { MyUtility.LogException(e); } ViewBag.pageSize = size; ViewBag.page = page + 1; return PartialView(obj); }
public ActionResult LoadMoreItems(int id, string sectionTitle, string containerId, int? pageSize, int page = 0, string featureType = "episode", bool removeShowAll = false, CelebrityContentType contentType = CelebrityContentType.SHOWS) { List<HomepageFeatureItem> jfi = null; List<HomepageFeatureItem> obj = null; string jsonString = String.Empty; var registDt = DateTime.Now; int size = GlobalConfig.FeatureItemsPageSize; int skipSize = 0; try { if (pageSize != null) size = (int)pageSize; skipSize = size * page; string CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy(); var cache = DataCache.Cache; string cacheKey = "BCSLS:C:" + id.ToString(); if (contentType == CelebrityContentType.MOVIES) cacheKey = "BCSLS:M:" + id.ToString(); else if (contentType == CelebrityContentType.EPISODES) cacheKey = "BCSLS:E:" + id.ToString(); try { jsonString = (string)cache[cacheKey]; } catch (Exception) { } if (String.IsNullOrEmpty(jsonString)) { var context = new IPTV2Entities(); var celebrity = context.Celebrities.FirstOrDefault(c => c.CelebrityId == id); if (celebrity != null) { if (contentType == CelebrityContentType.EPISODES) { var episodes = celebrity.EpisodeCelebrityRoles.Select(c => c.Episode); if (episodes != null) { jfi = new List<HomepageFeatureItem>(); foreach (var episode in episodes) { if (episode.OnlineStatusId == GlobalConfig.Visible && episode.OnlineStartDate < registDt && episode.OnlineEndDate > registDt) { var ShowListBasedOnCountryCode = ContextHelper.GetAllShowsBasedOnCountryCode(context, CountryCode, true); EpisodeCategory epCategory = episode.EpisodeCategories.FirstOrDefault(e => ShowListBasedOnCountryCode.Contains(e.CategoryId)); Show show = epCategory.Show; string img = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); HomepageFeatureItem j = new HomepageFeatureItem() { id = show.CategoryId, name = show.Description, blurb = HttpUtility.HtmlEncode(show.Blurb), imgurl = img, slug = MyUtility.GetSlug(show.Description) }; jfi.Add(j); } } jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(jfi); cache.Put(cacheKey, jsonString, DataCache.CacheDuration); } } else { var shows = celebrity.ShowCelebrityRoles.Select(c => c.Show); if (shows != null) { jfi = new List<HomepageFeatureItem>(); foreach (var show in shows) { if (contentType == CelebrityContentType.SHOWS) { if (show.StatusId == GlobalConfig.Visible && !(show is Movie) && show.StartDate < registDt && show.EndDate > registDt) { string img = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); HomepageFeatureItem j = new HomepageFeatureItem() { id = show.CategoryId, name = show.Description, blurb = HttpUtility.HtmlEncode(show.Blurb), imgurl = img, slug = MyUtility.GetSlug(show.Description) }; jfi.Add(j); } } else if (contentType == CelebrityContentType.MOVIES) { if (show.StatusId == GlobalConfig.Visible && show is Movie && show.StartDate < registDt && show.EndDate > registDt) { string img = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); HomepageFeatureItem j = new HomepageFeatureItem() { id = show.CategoryId, name = show.Description, blurb = HttpUtility.HtmlEncode(show.Blurb), imgurl = img, slug = MyUtility.GetSlug(show.Description) }; jfi.Add(j); } } } jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(jfi); cache.Put(cacheKey, jsonString, DataCache.CacheDuration); } } } } else jfi = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomepageFeatureItem>>(jsonString); ViewBag.FeatureType = featureType; ViewBag.SectionTitle = sectionTitle; ViewBag.id = id; ViewBag.containerId = containerId; ViewBag.pageSize = size; ViewBag.RemoveShowAll = removeShowAll; ViewBag.ContentType = contentType; if (jfi != null) obj = jfi.Skip(skipSize).Take(size).ToList(); } catch (Exception e) { MyUtility.LogException(e); } return PartialView("BuildSection", obj); }
public JsonResult GetSection(int id, int? pageSize, int page = 0) { List<HomepageFeatureItem> jfi = null; List<HomepageFeatureItem> obj = null; string jsonString = String.Empty; var registDt = DateTime.Now; int size = GlobalConfig.FeatureItemsPageSize; int skipSize = 0; try { if (pageSize != null) size = (int)pageSize; skipSize = size * page; string CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy(); var cache = DataCache.Cache; string cacheKey = "JRGL:O:" + id.ToString() + ";C:" + CountryCode; try { jsonString = (string)cache[cacheKey]; } catch (Microsoft.ApplicationServer.Caching.DataCacheException) { DataCache.Refresh(); } catch (Exception) { } var context = new IPTV2Entities(); var feature = context.Features.FirstOrDefault(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible); if (feature != null) { if (String.IsNullOrEmpty(jsonString)) { string assetBaseUrl = GlobalConfig.AssetsBaseUrl; string episodeImgPath = GlobalConfig.EpisodeImgPath; string showImgPath = GlobalConfig.ShowImgPath; string celebrityImgPath = GlobalConfig.CelebrityImgPath; try { assetBaseUrl = assetBaseUrl.Replace("http:", ""); episodeImgPath = episodeImgPath.Replace("http:", ""); showImgPath = showImgPath.Replace("http:", ""); celebrityImgPath = celebrityImgPath.Replace("http:", ""); } catch (Exception) { } var featureItems = context.FeatureItems.Where(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible).OrderByDescending(f => f.FeatureItemId); jfi = new List<HomepageFeatureItem>(); foreach (var f in featureItems) { if (f is EpisodeFeatureItem) { if (((EpisodeFeatureItem)f).Episode != null) { var episode = ((EpisodeFeatureItem)f).Episode; if (episode.OnlineStartDate < registDt && episode.OnlineEndDate > registDt && episode.OnlineStatusId == GlobalConfig.Visible) { EpisodeCategory epCategory = null; if (GlobalConfig.UseServiceOfferingWhenCheckingEpisodeParentCategory) { var ShowListBasedOnCountryCode = ContextHelper.GetAllShowsBasedOnCountryCode(context, CountryCode, true); epCategory = episode.EpisodeCategories.FirstOrDefault(e => ShowListBasedOnCountryCode.Contains(e.CategoryId)); } else { var excludedCategoryIds = MyUtility.StringToIntList(GlobalConfig.ExcludedCategoryIdsForDisplay); epCategory = episode.EpisodeCategories.FirstOrDefault(e => !excludedCategoryIds.Contains(e.CategoryId)); } if (epCategory != null) { Show show = epCategory.Show; if (show != null) { string img = String.IsNullOrEmpty(episode.ImageAssets.ImageVideo) ? assetBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", episodeImgPath, episode.EpisodeId.ToString(), episode.ImageAssets.ImageVideo); string showImg = String.IsNullOrEmpty(show.ImagePoster) ? assetBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", showImgPath, show.CategoryId.ToString(), show.ImagePoster); HomepageFeatureItem j = new HomepageFeatureItem() { id = episode.EpisodeId, description = episode.Description, name = episode.EpisodeName, airdate = (episode.DateAired != null) ? episode.DateAired.Value.ToString("MMMM d, yyyy") : "", show_id = show.CategoryId, show_name = String.Compare(episode.EpisodeName, episode.EpisodeCode) == 0 ? show.CategoryName : episode.EpisodeName, imgurl = img, show_imgurl = showImg, blurb = HttpUtility.HtmlEncode(episode.Synopsis), slug = MyUtility.GetSlug(episode.IsLiveChannelActive == true ? episode.Description : String.Format("{0} {1}", show.Description, episode.DateAired.Value.ToString("MMMM d yyyy"))) }; jfi.Add(j); } } } } } else if (f is ShowFeatureItem) { Show show = ((ShowFeatureItem)f).Show; string img = String.IsNullOrEmpty(show.ImagePoster) ? assetBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", showImgPath, show.CategoryId.ToString(), show.ImagePoster); HomepageFeatureItem j = new HomepageFeatureItem() { id = show.CategoryId, name = show.Description, blurb = HttpUtility.HtmlEncode(show.Blurb), imgurl = img, slug = MyUtility.GetSlug(show.Description) }; jfi.Add(j); } else if (f is CelebrityFeatureItem) { Celebrity person = ((CelebrityFeatureItem)f).Celebrity; string img = String.IsNullOrEmpty(person.ImageUrl) ? assetBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", celebrityImgPath, person.CelebrityId.ToString(), person.ImageUrl); HomepageFeatureItem j = new HomepageFeatureItem() { name = person.FullName, id = person.CelebrityId, imgurl = img, blurb = HttpUtility.HtmlEncode(person.Description), slug = MyUtility.GetSlug(person.FullName) }; jfi.Add(j); } } jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(jfi); cache.Put(cacheKey, jsonString, DataCache.CacheDuration); } else jfi = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomepageFeatureItem>>(jsonString); } try { if (jfi != null) obj = pageSize == null ? jfi : jfi.Take(size).ToList(); } catch (Exception) { obj = jfi; } } catch (Exception e) { MyUtility.LogException(e); } return this.Json(obj, JsonRequestBehavior.AllowGet); }
public PartialViewResult BuildSection(int id, string sectionTitle, string containerId, int? pageSize, int page = 0, string featureType = "episode", bool removeShowAll = true, bool isFeature = false, bool ShowAllItems = false, string partialViewName = "") { List<HomepageFeatureItem> jfi = null; List<HomepageFeatureItem> obj = null; string jsonString = String.Empty; var registDt = DateTime.Now; int size = GlobalConfig.FeatureItemsPageSize; int skipSize = 0; try { if (pageSize != null) size = (int)pageSize; skipSize = size * page; string CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy(); var cache = DataCache.Cache; string cacheKey = "JRAIR:O:" + id.ToString() + ";C:" + CountryCode; try { jsonString = (string)cache[cacheKey]; } catch (Microsoft.ApplicationServer.Caching.DataCacheException) { DataCache.Refresh(); } catch (Exception) { } ViewBag.FeatureType = featureType; ViewBag.SectionTitle = sectionTitle; ViewBag.id = id; ViewBag.containerId = containerId; ViewBag.pageSize = size; ViewBag.RemoveShowAll = removeShowAll; ViewBag.IsFeature = isFeature; var context = new IPTV2Entities(); if (String.IsNullOrEmpty(jsonString)) { //get movie parent category var movie_category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == id); if (movie_category != null) { var movieCategoryIds = ContextHelper.GetAllShowsBasedOnCountryCode(context, CountryCode, false, null, null, (Category)movie_category); //remove online premiere & adult content try { var onlinepremiere_category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == GlobalConfig.OnlinePremiereCategoryId); if (onlinepremiere_category != null) movieCategoryIds = movieCategoryIds.Except(ContextHelper.GetAllShowsBasedOnCountryCode(context, CountryCode, false, null, null, (Category)onlinepremiere_category)); var adultcontent_category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == GlobalConfig.AdultContentCategoryId); if (adultcontent_category != null) movieCategoryIds = movieCategoryIds.Except(ContextHelper.GetAllShowsBasedOnCountryCode(context, CountryCode, false, null, null, (Category)adultcontent_category)); } catch (Exception) { } //get all movies int[] setofMovies = movieCategoryIds.ToArray(); var list = context.CategoryClasses.Where(c => setofMovies.Contains(c.CategoryId) && c.StartDate <= registDt && c.EndDate >= registDt && c.StatusId == GlobalConfig.Visible).OrderBy(c => Guid.NewGuid()).Take((int)pageSize).ToList(); jfi = new List<HomepageFeatureItem>(); foreach (var item in list) { Show show = (Show)item; string img = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); HomepageFeatureItem j = new HomepageFeatureItem() { id = show.CategoryId, name = show.Description, blurb = HttpUtility.HtmlEncode(show.Blurb), imgurl = img, slug = MyUtility.GetSlug(show.Description) }; jfi.Add(j); } jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(jfi); cache.Put(cacheKey, jsonString, DataCache.CacheDuration); } } else jfi = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomepageFeatureItem>>(jsonString); ViewBag.LinkSlug = String.Empty; obj = jfi; } catch (Exception e) { MyUtility.LogException(e); } if (!String.IsNullOrEmpty(partialViewName)) return PartialView(partialViewName, obj); return PartialView(obj); }
public PartialViewResult BuildSectionShow(int id, string sectionTitle, string containerId, int? pageSize = 4, int page = 0, string featureType = "episode", bool removeShowAll = true, bool isFeature = false, bool ShowAllItems = false, string partialViewName = "") { List<HomepageFeatureItem> obj = new List<HomepageFeatureItem>(); string jsonString = String.Empty; var registDt = DateTime.Now; int size = GlobalConfig.FeatureItemsPageSize; try { ViewBag.FeatureType = featureType; ViewBag.SectionTitle = sectionTitle; ViewBag.id = id; ViewBag.containerId = containerId; ViewBag.pageSize = size; ViewBag.RemoveShowAll = removeShowAll; ViewBag.IsFeature = isFeature; string assetBaseUrl = GlobalConfig.AssetsBaseUrl; string episodeImgPath = GlobalConfig.EpisodeImgPath; string showImgPath = GlobalConfig.ShowImgPath; string celebrityImgPath = GlobalConfig.CelebrityImgPath; var context = new IPTV2Entities(); var category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == id); var show = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == id && c.StatusId == GlobalConfig.Visible); if (pageSize != null) size = (int)pageSize; if (show != null) { if (show is Show) { string CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy(); var MEPacMayCountryCodeList = GlobalConfig.MEPacMayAllowedCountryCodes.Split(','); bool IncludeTVC = MEPacMayCountryCodeList.Contains(CountryCode); //Get all episode numbers var episode_list = context.EpisodeCategories1.Where(e => e.Show.CategoryId == ((Show)show).CategoryId).Select(e => e.EpisodeId); //var episodes = ((Show)show).Episodes.Where(e => e.Episode.OnlineStatusId == GlobalConfig.Visible).OrderByDescending(e => e.Episode.DateAired).Select((item, index) => new { Item = item, Position = index }).ToList(); var episodes = context.Episodes.Where(e => episode_list.Contains(e.EpisodeId) && e.OnlineStatusId == GlobalConfig.Visible && e.OnlineStartDate < registDt && e.OnlineEndDate > registDt).OrderByDescending(e => e.IsLiveChannelActive).OrderByDescending(e => e.DateAired).ThenByDescending(e => e.EpisodeId).Take(size); ViewBag.sCount = episodes.Count(); int epCount = episodes.Count(); foreach (var episode in episodes) { string img = String.IsNullOrEmpty(episode.ImageAssets.ImageVideo) ? assetBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", episodeImgPath, episode.EpisodeId.ToString(), episode.ImageAssets.ImageVideo); string showImg = String.IsNullOrEmpty(show.ImagePoster) ? assetBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", showImgPath, show.CategoryId.ToString(), show.ImagePoster); string EpLength = ""; if (!(episode.EpisodeLength == null)) { TimeSpan span = new TimeSpan(0, 0, Convert.ToInt32(episode.EpisodeLength) * 60); EpLength = String.Format("{0}:{1}:{2}", span.Hours.ToString().PadLeft(2, '0'), span.Minutes.ToString().PadLeft(2, '0'), span.Seconds.ToString().PadLeft(2, '0')); } HomepageFeatureItem j = new HomepageFeatureItem() { id = episode.EpisodeId, description = episode.Description, name = episode.EpisodeName, airdate = (episode.DateAired != null) ? episode.DateAired.Value.ToString("MMMM d, yyyy") : "", show_id = show.CategoryId, show_name = String.Compare(episode.EpisodeName, episode.EpisodeCode) == 0 ? show.CategoryName : episode.EpisodeName, imgurl = img, show_imgurl = showImg, blurb = HttpUtility.HtmlEncode(episode.Synopsis), slug = MyUtility.GetSlug(episode.IsLiveChannelActive == true ? episode.Description : String.Format("{0} {1}", show.Description, episode.DateAired.Value.ToString("MMMM d yyyy"))) }; if (episode.EpisodeId == GlobalConfig.PacMayTVCEpisodeId) { if (IncludeTVC) obj.Add(j); } else obj.Add(j); epCount--; } } } } catch (Exception e) { MyUtility.LogException(e); } if (!String.IsNullOrEmpty(partialViewName)) return PartialView(partialViewName, obj); return PartialView(obj); }
public PartialViewResult LoadMoreItems(int id, int page, int? pageSize, string featureType = "episode") { List<HomepageFeatureItem> jfi = null; List<HomepageFeatureItem> obj = null; string jsonString = String.Empty; var registDt = DateTime.Now; int size = GlobalConfig.FeatureItemsPageSize; int skipSize = 0; try { if (pageSize != null) size = (int)pageSize; skipSize = size * page; string CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy(); var cache = DataCache.Cache; string cacheKey = "BSCL:O:" + id.ToString() + ";C:" + CountryCode; try { jsonString = (string)cache[cacheKey]; } catch (Exception) { } if (String.IsNullOrEmpty(jsonString)) { var context = new IPTV2Entities(); var category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == id && c.StatusId == GlobalConfig.Visible); if (category != null) { if (category is Category) { var offering = context.Offerings.Find(GlobalConfig.offeringId); var service = offering.Services.FirstOrDefault(o => o.PackageId == GlobalConfig.serviceId); var showIds = service.GetAllOnlineShowIds(CountryCode, (Category)category); if (showIds.Count() > 0) { var shows = context.CategoryClasses.Where(c => showIds.Contains(c.CategoryId)); if (shows != null) { jfi = new List<HomepageFeatureItem>(); foreach (var cat in shows) { if (cat is Show) { if (cat.StatusId == GlobalConfig.Visible && cat.StartDate < registDt && cat.EndDate > registDt) { Show show = (Show)cat; string img = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); HomepageFeatureItem j = new HomepageFeatureItem() { id = show.CategoryId, name = show.Description, blurb = HttpUtility.HtmlEncode(show.Blurb), imgurl = img, slug = MyUtility.GetSlug(show.Description) }; jfi.Add(j); } } } jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(jfi); cache.Put(cacheKey, jsonString, DataCache.CacheDuration); } } } } } else jfi = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomepageFeatureItem>>(jsonString); ViewBag.page = page + 1; ViewBag.FeatureType = featureType; ViewBag.id = id; ViewBag.pageSize = size; if (jfi != null) obj = jfi.Skip(skipSize).Take(size).ToList(); } catch (Exception e) { MyUtility.LogException(e); } return PartialView(obj); }
public ActionResult BuildSectionCategory(int id, string sectionTitle, string containerId, string partialViewName, int? pageSize, int page = 0, string featureType = "episode", bool removeShowAll = false) { List<HomepageFeatureItem> jfi = null; List<HomepageFeatureItem> obj = null; string jsonString = String.Empty; var registDt = DateTime.Now; int size = GlobalConfig.FeatureItemsPageSize; int skipSize = 0; try { if (pageSize != null) size = (int)pageSize; skipSize = size * page; string CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy(); var cache = DataCache.Cache; string cacheKey = "BSCL:O:" + id.ToString() + ";C:" + CountryCode; try { jsonString = (string)cache[cacheKey]; } catch (Exception) { } var context = new IPTV2Entities(); var category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == id && c.StatusId == GlobalConfig.Visible); if (String.IsNullOrEmpty(jsonString)) { if (category != null) { if (category is Category) { if (String.IsNullOrEmpty(containerId)) { try { char[] arr = sectionTitle.ToCharArray(); arr = Array.FindAll<char>(arr, (c => (char.IsLetterOrDigit(c) || char.IsWhiteSpace(c) || c == '-'))); containerId = String.Format("{0}_section", new string(arr)); } catch (Exception) { containerId = String.Format("{0}_section", category.Description.Substring(0, 4)); } } var offering = context.Offerings.Find(GlobalConfig.offeringId); var service = offering.Services.FirstOrDefault(o => o.PackageId == GlobalConfig.serviceId); var showIds = service.GetAllOnlineShowIds(CountryCode, (Category)category).ToList(); showIds = showIds.Union(MyUtility.getIncludedShowIDsForMenu(category.CategoryId)).ToList(); if (showIds.Count() > 0) { var shows = context.CategoryClasses.Where(c => showIds.Contains(c.CategoryId)); if (shows != null) { shows = shows.OrderBy(s => s.Description); // order alphabetically jfi = new List<HomepageFeatureItem>(); foreach (var cat in shows) { if (cat is Show) { if (cat.StatusId == GlobalConfig.Visible && cat.StartDate < registDt && cat.EndDate > registDt) { Show show = (Show)cat; if (show.IsOnlineAllowed(CountryCode)) { string img = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); HomepageFeatureItem j = new HomepageFeatureItem() { id = show.CategoryId, name = show.Description, blurb = HttpUtility.HtmlEncode(show.Blurb), imgurl = img, slug = MyUtility.GetSlug(show.Description) }; jfi.Add(j); } } } } jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(jfi); cache.Put(cacheKey, jsonString, DataCache.CacheDuration); } } } } } else jfi = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomepageFeatureItem>>(jsonString); ViewBag.FeatureType = featureType; if (String.IsNullOrEmpty(sectionTitle)) sectionTitle = category.Description; ViewBag.SectionTitle = sectionTitle; ViewBag.id = id; ViewBag.containerId = containerId; ViewBag.pageSize = size; ViewBag.RemoveShowAll = removeShowAll; ViewBag.CategoryClass = category; //if (jfi != null) // obj = jfi.Skip(skipSize).Take(size).ToList(); obj = jfi; } catch (Exception e) { MyUtility.LogException(e); } if (!String.IsNullOrEmpty(partialViewName)) return PartialView(partialViewName, obj); return PartialView("BuildSection", obj); }
public PartialViewResult GetFeatures(int id, string containerId, bool IsActive = false) { List<HomepageFeatureItem> jfi = null; string jsonString = String.Empty; var registDt = DateTime.Now; try { ViewBag.containerId = containerId; ViewBag.IsActive = IsActive; string CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy(); var cache = DataCache.Cache; string cacheKey = "JRGL:O:" + id.ToString() + ";C:" + CountryCode; try { jsonString = (string)cache[cacheKey]; } catch (Exception) { } if (String.IsNullOrEmpty(jsonString)) { var context = new IPTV2Entities(); var feature = context.Features.FirstOrDefault(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible); if (feature != null) { var featureItems = context.FeatureItems.Where(f => f.FeatureId == id && f.StatusId == GlobalConfig.Visible).OrderByDescending(f => f.AuditTrail.UpdatedOn); jfi = new List<HomepageFeatureItem>(); foreach (var f in featureItems) { if (f is EpisodeFeatureItem) { if (((EpisodeFeatureItem)f).Episode != null) { var episode = ((EpisodeFeatureItem)f).Episode; if (episode.OnlineStartDate < registDt && episode.OnlineEndDate > registDt && episode.OnlineStatusId == GlobalConfig.Visible) { EpisodeCategory epCategory = null; if (GlobalConfig.UseServiceOfferingWhenCheckingEpisodeParentCategory) { var ShowListBasedOnCountryCode = ContextHelper.GetAllShowsBasedOnCountryCode(context, CountryCode, true); epCategory = episode.EpisodeCategories.FirstOrDefault(e => ShowListBasedOnCountryCode.Contains(e.CategoryId)); } else { var excludedCategoryIds = MyUtility.StringToIntList(GlobalConfig.ExcludedCategoryIdsForDisplay); epCategory = episode.EpisodeCategories.FirstOrDefault(e => !excludedCategoryIds.Contains(e.CategoryId)); } if (epCategory != null) { Show show = epCategory.Show; if (show != null) { string img = String.IsNullOrEmpty(episode.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, episode.EpisodeId.ToString(), episode.ImageAssets.ImageVideo); string showImg = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); HomepageFeatureItem j = new HomepageFeatureItem() { id = episode.EpisodeId, description = episode.Description, name = episode.EpisodeName, airdate = (episode.DateAired != null) ? episode.DateAired.Value.ToString("MMMM d, yyyy") : "", show_id = show.CategoryId, show_name = String.Compare(episode.EpisodeName, episode.EpisodeCode) == 0 ? show.CategoryName : episode.EpisodeName, imgurl = img, show_imgurl = showImg, blurb = HttpUtility.HtmlEncode(episode.Synopsis), slug = MyUtility.GetSlug(episode.EpisodeName) }; jfi.Add(j); } } } } } else if (f is ShowFeatureItem) { Show show = ((ShowFeatureItem)f).Show; string img = String.IsNullOrEmpty(show.ImagePoster) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.ShowImgPath, show.CategoryId.ToString(), show.ImagePoster); HomepageFeatureItem j = new HomepageFeatureItem() { id = show.CategoryId, name = show.Description, blurb = HttpUtility.HtmlEncode(show.Blurb), imgurl = img, slug = MyUtility.GetSlug(show.Description) }; jfi.Add(j); } else if (f is CelebrityFeatureItem) { Celebrity person = ((CelebrityFeatureItem)f).Celebrity; string img = String.IsNullOrEmpty(person.ImageUrl) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.CelebrityImgPath, person.CelebrityId.ToString(), person.ImageUrl); HomepageFeatureItem j = new HomepageFeatureItem() { name = person.FullName, id = person.CelebrityId, imgurl = img, blurb = HttpUtility.HtmlEncode(person.Description), slug = MyUtility.GetSlug(person.FullName) }; jfi.Add(j); } } jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(jfi); cache.Put(cacheKey, jsonString, DataCache.CacheDuration); } } else jfi = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomepageFeatureItem>>(jsonString); } catch (Exception e) { MyUtility.LogException(e); } return PartialView(jfi); }
public PartialViewResult LoadMoreGames(int id, int? pageSize, int page = 0) { List<HomepageFeatureItem> jfi = null; List<HomepageFeatureItem> obj = null; string jsonString = String.Empty; var registDt = DateTime.Now; int size = GlobalConfig.FeatureItemsPageSize; int skipSize = 0; try { if (pageSize != null) size = (int)pageSize; skipSize = size * page; string CountryCode = MyUtility.GetCountryCodeViaIpAddressWithoutProxy(); var cache = DataCache.Cache; string cacheKey = "UAAPGTGES:O:" + id.ToString() + ";C:" + CountryCode; try { jsonString = (string)cache[cacheKey]; } catch (Exception) { } ViewBag.id = id; ViewBag.page = page + 1; ViewBag.pageSize = pageSize; if (String.IsNullOrEmpty(jsonString)) { var context = new IPTV2Entities(); var celebrity = context.Celebrities.FirstOrDefault(c => c.CelebrityId == id); if (celebrity != null) { var categoryIds = celebrity.ShowCelebrityRoles.Select(s => s.CategoryId); var episodeIds = context.EpisodeCategories1.Where(e => categoryIds.Contains(e.CategoryId)).Select(e => e.EpisodeId); var episodes = context.Episodes.Where(e => episodeIds.Contains(e.EpisodeId) && e.OnlineStatusId == GlobalConfig.Visible && e.OnlineStartDate < registDt && e.OnlineEndDate > registDt); if (episodes != null) { jfi = new List<HomepageFeatureItem>(); foreach (var episode in episodes) { string img = String.IsNullOrEmpty(episode.ImageAssets.ImageVideo) ? GlobalConfig.AssetsBaseUrl + GlobalConfig.BlankGif : String.Format("{0}{1}/{2}", GlobalConfig.EpisodeImgPath, episode.EpisodeId.ToString(), episode.ImageAssets.ImageVideo); HomepageFeatureItem j = new HomepageFeatureItem() { id = episode.EpisodeId, description = episode.Description, name = episode.EpisodeName, airdate = (episode.DateAired != null) ? episode.DateAired.Value.ToString("MMMM d, yyyy") : "", imgurl = img, blurb = HttpUtility.HtmlEncode(episode.Synopsis), slug = MyUtility.GetSlug(episode.EpisodeName) }; jfi.Add(j); } jsonString = Newtonsoft.Json.JsonConvert.SerializeObject(jfi); cache.Put(cacheKey, jsonString, DataCache.CacheDuration); } } } else jfi = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomepageFeatureItem>>(jsonString); if (jfi != null) obj = jfi.Skip(skipSize).Take(size).ToList(); } catch (Exception e) { MyUtility.LogException(e); } return PartialView(obj); }
public PartialViewResult BuildReviews(int id) { List<HomepageFeatureItem> jfi = null; string jsonString = String.Empty; var registDt = DateTime.Now; try { var cache = DataCache.Cache; string cacheKey = "UXBREV:O:" + id.ToString(); try { jsonString = (string)cache[cacheKey]; } catch (Exception) { } if (String.IsNullOrEmpty(jsonString)) { var context = new IPTV2Entities(); var category = context.CategoryClasses.FirstOrDefault(c => c.CategoryId == id); if (category != null) { var subcategories = category.CategoryClassSubCategories.Select(c => c.SubCategory); if (subcategories != null) { jfi = new List<HomepageFeatureItem>(); int ctr = 0; foreach (var item in subcategories) { var obj = new HomepageFeatureItem() { blurb = item.Blurb }; jfi.Add(obj); ctr = ctr + 1; if (ctr > 2) break; } } } } else jfi = Newtonsoft.Json.JsonConvert.DeserializeObject<List<HomepageFeatureItem>>(jsonString); } catch (Exception e) { MyUtility.LogException(e); } return PartialView(jfi); }