public static async Task <string> generateATOM(ApplicationDbContext context, VideoEntity Entity, string url) { var str = new StringBuilder(); str.AppendLine("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"); str.AppendLine("<feed xmlns=\"http://www.w3.org/2005/Atom\">\n"); str.AppendLine("<title type=\"text\">" + Jugnoon.Settings.Configs.GeneralSettings.website_title + "</title>\n"); str.AppendLine("<subtitle type=\"html\">" + Jugnoon.Settings.Configs.GeneralSettings.website_description + "</subtitle>"); str.AppendLine("<id>tag:" + Config.GetUrl() + "," + DateTime.Now.Year + ":3</id>"); str.AppendLine("<link rel=\"alternate\" type=\"text/html\" hreflang=\"en\" href=\"" + Config.GetUrl("videos/?type=atom") + "\"/>"); str.AppendLine("<link rel=\"self\" type=\"application/atom+xml\" href=\"" + url + "\"/>"); str.AppendLine("<rights>" + Jugnoon.Settings.Configs.GeneralSettings.website_title + "</rights>"); str.AppendLine("<generator uri=\"" + Config.GetUrl("videos/") + "\" version=\"1.0\">"); str.AppendLine(Jugnoon.Settings.Configs.GeneralSettings.website_title + " (" + Assembly.GetEntryAssembly().GetName().Version + ")"); str.AppendLine("</generator>"); var _lst = await VideoBLL.LoadItems(context, Entity); foreach (var Item in _lst) { string title_url = VideoUrlConfig.PrepareUrl(Item); string body = WebUtility.HtmlEncode(UtilityBLL.StripHTML_v2(Item.description)); str.AppendLine("<entry>"); str.AppendLine("<title type=\"text\">" + Item.title + "</title>"); str.AppendLine("<link rel=\"alternate\" type=\"text/html\" href=\"" + title_url + "\"/>"); str.AppendLine("<id>tag:" + Config.GetUrl() + "," + Item.created_at.Year + ":3." + Item.id + "</id>\n"); str.AppendLine("<updated>" + String.Format("{0:R}", Item.created_at) + "</updated>\n"); str.AppendLine("<published>" + String.Format("{0:R}", Item.created_at) + "</published>\n"); str.AppendLine("<author>\n"); str.AppendLine("<name>" + Item.userid + "</name>\n"); str.AppendLine("<uri>" + Config.GetUrl("videos/") + "</uri>\n"); str.AppendLine("</author>\n"); str.AppendLine("<content type=\"html\">" + body + "</content>\n"); str.AppendLine("</entry>\n"); } str.AppendLine("</feed>"); return(str.ToString()); }
public static async Task <string> GenerateBingSitemap(ApplicationDbContext context, VideoEntity Entity) { var str = new StringBuilder(); str.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); str.AppendLine("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"); var _lst = await VideoBLL.LoadItems(context, Entity); foreach (var Item in _lst) { str.AppendLine("<url>"); str.AppendLine("<loc>" + VideoUrlConfig.PrepareUrl(Item) + "</loc>"); str.Append("</url>"); } str.AppendLine("</urlset>"); return(str.ToString()); }
public static async Task <string> generateGoogleSitemap(ApplicationDbContext context, VideoEntity Entity) { var str = new StringBuilder(); str.AppendLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); str.AppendLine("<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\""); str.AppendLine(" xmlns:image=\"http://www.google.com/schemas/sitemap-image/1.1\""); str.AppendLine(" xmlns:video=\"http://www.google.com/schemas/sitemap-video/1.1\">"); var _lst = await VideoBLL.LoadItems(context, Entity); foreach (var Item in _lst) { string mediaUrl = ""; if (Item.type == 1) { mediaUrl = VideoUrlConfig.Return_MP3_Audio_Url(Item.pub_url, Item.userid) + "/" + Item.videofilename; } else { mediaUrl = VideoUrlConfig.Return_FLV_Video_Url(Item.pub_url, Item.userid) + "/" + Item.videofilename; } string thumburl = VideoUrlConfig.Return_Video_Thumb_Url(Item.thumb_url, Item.userid) + "/" + Item.thumbfilename; str.AppendLine("<url>"); str.AppendLine("<loc>" + VideoUrlConfig.PrepareUrl(Item) + "</loc>"); str.AppendLine("<image:image>"); str.AppendLine("<image:loc>" + thumburl + "</image:loc>"); str.AppendLine("<image:caption>" + Item.title + "</image:caption>"); str.AppendLine("</image:image>"); str.AppendLine("<video:video>"); str.AppendLine("<video:content_loc>"); str.AppendLine(mediaUrl); str.AppendLine("</video:content_loc>"); str.AppendLine("<video:thumbnail_loc>"); str.AppendLine(thumburl); str.AppendLine("</video:thumbnail_loc>"); str.AppendLine("<video:title>" + Item.title + "</video:title>"); if (Item.description != "") { str.AppendLine("<video:description>"); str.AppendLine(Item.description); str.AppendLine("</video:description>"); } str.AppendLine("</video:video>"); str.AppendLine("</url>"); } str.AppendLine("</urlset>"); return(str.ToString()); }
private static IQueryable <VideoQueryEntity> prepareQuery(ApplicationDbContext context, VideoEntity entity) { return(context.JGN_Videos .Join(context.AspNetusers, video => video.userid, user => user.Id, (video, user) => new { video, user }) .Join(context.JGN_CategoryContents, video => video.video.id, video_category => video_category.contentid, (video, video_category) => new { video, video_category }) .Join(context.JGN_Categories, video_category => video_category.video_category.categoryid, category => category.id, (video_category, category) => new VideoQueryEntity { video = video_category.video.video, video_category = video_category.video_category, category = category, user = video_category.video.user }) .Where(VideoBLL.returnWhereClause(entity))); }
private static Task <List <JGN_Videos> > Load_Raw(ApplicationDbContext context, VideoEntity entity) { return(VideoBLL.processOptionalConditions(prepareQuery(context, entity), entity) .Select(VideoBLL.prepareSummaryList()).ToListAsync()); }
public static Task <int> Count(ApplicationDbContext context, VideoEntity entity) { return(prepareQuery(context, entity).CountAsync()); }
public static async Task <List <JGN_Videos> > LoadItems(ApplicationDbContext context, VideoEntity entity) { if (!entity.iscache || Jugnoon.Settings.Configs.GeneralSettings.cache_duration == 0 || entity.pagenumber > Jugnoon.Settings.Configs.GeneralSettings.max_cache_pages) { return(await Load_Raw(context, entity)); } else { string key = VideoBLL.GenerateKey("lg_video_cat_", entity); var data = new List <JGN_Videos>(); if (!SiteConfig.Cache.TryGetValue(key, out data)) { data = await Load_Raw(context, entity); var cacheEntryOptions = new MemoryCacheEntryOptions() // Keep in cache for this time, reset time if accessed. .SetSlidingExpiration(TimeSpan.FromSeconds(3600)); // Save data in cache. SiteConfig.Cache.Set(key, data, cacheEntryOptions); } else { data = (List <JGN_Videos>)SiteConfig.Cache.Get(key); } return(data); } }
private static IQueryable <VideoQueryEntity> prepareQuery(ApplicationDbContext context, VideoEntity entity) { return(context.JGN_Videos .Join(context.AspNetusers, video => video.userid, user => user.Id, (video, user) => new { video, user }) .Join(context.JGN_AbuseReports, video => video.video.id, abusereports => abusereports.contentid, (video, abusereports) => new VideoQueryEntity { video = video.video, user = video.user, abusereports = abusereports }) .Where(VideoBLL.returnWhereClause(entity))); }
private static IQueryable <VideoQueryEntity> prepareQuery(ApplicationDbContext context, VideoEntity entity) { return(context.JGN_Videos .Join(context.AspNetusers, video => video.userid, user => user.Id, (video, user) => new { video, user }) .Join(context.JGN_User_Ratings, video => video.video.id, rating => rating.itemid, (video, rating) => new VideoQueryEntity { video = video.video, user = video.user, rating = rating }) .Where(VideoBLL.returnWhereClause(entity))); }
private static IQueryable <VideoQueryEntity> prepareQuery(ApplicationDbContext context, VideoEntity entity) { return(context.JGN_Videos .Join(context.AspNetusers, video => video.userid, user => user.Id, (video, user) => new { video, user }) .Join(context.JGN_Favorites, video => video.video.id, favorite => favorite.contentid, (video, favorite) => new VideoQueryEntity { video = video.video, user = video.user, favorite = favorite }) .Where(VideoBLL.returnWhereClause(entity))); }
private static IQueryable <VideoQueryEntity> prepareQuery(ApplicationDbContext context, VideoEntity entity) { return(context.JGN_Videos .Join(context.AspNetusers, video => video.userid, user => user.Id, (video, user) => new { video, user }) .Join(context.JGN_Playlist_Videos, video => video.video.id, playlist => playlist.contentid, (video, playlist) => new VideoQueryEntity { video = video.video, user = video.user, playlist = playlist }) .Where(VideoBLL.returnWhereClause(entity))); }