public static GetRequestDomain ( ) : string | ||
Résultat | string |
public static void ResetSite() { string RequestDomain = Globals.GetRequestDomain(); string CacheKey = $"{CacheKeys.Site.ToString()}-{RequestDomain}"; RemoveCache(CacheKey); }
public static string GetSidebar() { string Result = ""; // TODOXXX DatabaseCache.GetSidebars(); if (Result == null) { string RequestDomain = Globals.GetRequestDomain(); using (ApplicationDbContext DB = new ApplicationDbContext()) { // Get site side bar var Site = DB.Sites.SingleOrDefault(x => x.Domain == RequestDomain); if (Site != null) { Result += Site.Sidebar; } // Get global side bar(s) foreach (var Sidebar in Site.GlobalSidebars) { Result += Sidebar.Html; } } if (Result == null) { Result = ""; } // TODOXXX DatabaseCache.AddSidebars(Result); } return(Result); }
public static void ResetPages() { string RequestDomain = Globals.GetRequestDomain(); RemoveCache($"{CacheKeys.Pages.ToString()}-{RequestDomain}"); RemoveCacheMulti($"{CacheKeys.NavMenuItems.ToString()}-{RequestDomain}-"); }
public static long GetTimestamp(string path) { string RequestDomain = Globals.GetRequestDomain(); string CacheKey = $"{CacheKeys.Timestamp.ToString()}-{path}"; long?Result = GetCache <long?>(CacheKey); if (Result == null) { Result = File.GetLastWriteTimeUtc(path).ToFileTime(); SetCacheAbsolute(CacheKey, Result); } return(Convert.ToInt64(Result)); }
public static List <SiteBlogPost> GetBlogPosts() { string RequestDomain = Globals.GetRequestDomain(); string CacheKey = $"{CacheKeys.BlogPosts.ToString()}-{RequestDomain}"; List <SiteBlogPost> Result = GetCache <List <SiteBlogPost> >(CacheKey); if (Result == null) { using (ApplicationDbContext DB = new ApplicationDbContext()) { Result = DB.SiteBlogPosts.Where(x => x.Site.Domain == RequestDomain).ToList(); if (Result != null) { SetCacheSliding(CacheKey, Result); } } } return(Result); }
public static Site GetSite() { string RequestDomain = Globals.GetRequestDomain(); string CacheKey = $"{CacheKeys.Site.ToString()}-{RequestDomain}"; Site Result = GetCache <Site>(CacheKey); if (Result == null) { using (ApplicationDbContext DB = new ApplicationDbContext()) { Result = DB.Sites.SingleOrDefault(x => x.Domain == RequestDomain); if (Result != null) { SetCacheSliding(CacheKey, Result); } } } return(Result); }
public static List <SitePage> GetPages() { string RequestDomain = Globals.GetRequestDomain(); string CacheKey = $"{CacheKeys.Pages.ToString()}-{RequestDomain}"; List <SitePage> Result = GetCache <List <SitePage> >(CacheKey); if (Result == null) { using (ApplicationDbContext DB = new ApplicationDbContext()) { Result = DB.SitePages.Include("Children").Include("Parent").Where(x => x.Site.Domain == RequestDomain).ToList(); if (Result != null) { SetCacheSliding(CacheKey, Result); } } } return(Result); }
public static List <NavMenuItem> GetNavMenuItems(bool isAdmin, bool rightAlign) { string RequestDomain = Globals.GetRequestDomain(); string CacheKey = $"{CacheKeys.NavMenuItems.ToString()}-{RequestDomain}-{isAdmin}-{rightAlign}"; List <NavMenuItem> Result = GetCache <List <NavMenuItem> >(CacheKey); if (Result == null) { Result = new List <NavMenuItem>(); using (ApplicationDbContext DB = new ApplicationDbContext()) { // Get nav menu var TopLevelPages = GetPages().Where(x => x.ShowInMenu && (x.ParentId == null) && (isAdmin || !x.RequireAdmin) && (x.RightAlign == rightAlign)).OrderBy(x => x.DisplayOrder).ThenBy(x => x.LinkText).ToArray(); foreach (var TopLevelPage in TopLevelPages) { // Build the menu item NavMenuItem NewMenuItem = new NavMenuItem(TopLevelPage.Id, TopLevelPage.LinkText, TopLevelPage.Slug); // Determine if we have children if (TopLevelPage.Children.Count > 0) { NewMenuItem.Children = new List <NavMenuItem>(); foreach (var ChildPage in TopLevelPage.Children) { NewMenuItem.Children.Add(new NavMenuItem(ChildPage.Id, ChildPage.LinkText, ChildPage.Slug)); } } Result.Add(NewMenuItem); } } SetCacheSliding(CacheKey, Result); } return(Result); }
public static string GetSiteTitle() { return(GetSite()?.Title ?? Globals.GetRequestDomain()); }