public static void CleanSettingsRepository() { LS.Cache.Remove("SettingsAll"); foreach (Settings item in RP.GetSettingsRepositoryList()) { LS.Cache.Remove("CurrentSettingsMultiDomain_" + item.Domain + "_" + item.LanguageCode); LS.Cache.Remove("CurrentSettings_" + item.LanguageCode); } LS.Cache.Remove("CurrentSettingsMultiDomain_" + SF.GetCurrentDomain() + "_" + SF.GetLangCodeThreading()); LS.CurrentHttpContext.Session["AdminCurrentSettingsRepository"] = null; }
public override string GetVaryByCustomString(HttpContext context, string arg) { if (arg == "LangCode") { return(SF.GetLangCodeThreading()); } else if (arg == "CleanCacheGuid") { string Token = "CleanCacheGuid"; object o = context.Application[Token]; if (o == null) { o = Guid.NewGuid(); context.Application[Token] = o; } return(o.ToString()); } else if (arg == "LangCodeAndCleanCacheGuid") { string CurrentCulture = SF.GetLangCodeThreading(); string Token = string.Format("CleanCacheGuid_{0}", CurrentCulture); object o = context.Application[Token]; if (o == null) { o = CurrentCulture + Guid.NewGuid(); context.Application[Token] = o; } return(o.ToString()); } else if (arg == "LangCodeDomainAndCleanCacheGuid") { string Domain = SF.GetCurrentDomain(); string CurrentCulture = SF.GetLangCodeThreading(); string Token = string.Format("LangCodeDomainAndCleanCacheGuid_{0}_{1}", CurrentCulture, Domain); object o = context.Application[Token]; if (o == null) { o = Guid.NewGuid(); context.Application[Token] = o; } return(o.ToString()); } return(base.GetVaryByCustomString(context, arg)); }
public static Uco.Models.Settings GetCurrentSettings() { if (LS.CurrentEntityContext == null) { return new Settings() { AdminEmail = "*****@*****.**", Domain = "localhost", LanguageCode = "en-US", Roles = "", } } ; if (SF.UseMultiDomain() == false) { string Token = "CurrentSettings_" + SF.GetLangCodeThreading(); if (LS.Cache[Token] == null) { lock (s_lock) { Settings s = GetSettingsRepositoryList().FirstOrDefault(); if (s == null) { return(null); } string LangCodeThreading = SF.GetLangCodeThreading(); if (SF.GetLangCodeWebconfig() != LangCodeThreading) { LanguagePage l = _db.LanguagePages.FirstOrDefault(r => r.DomainID == s.ID && r.LanguageCode == LangCodeThreading); if (l != null) { s.LanguageCode = l.LanguageCode; //s.LanguageRTL = l.ShowOnMainPage; s.HeaderHtml = l.Text2; s.FotterHtml = l.Text3; } } LS.Cache[Token] = s; } } return((Uco.Models.Settings)LS.Cache[Token]); } else { string Domain = SF.GetCurrentDomain(); if (LS.CurrentHttpContext.Request.IsLocal) { string TokenAdmin = "AdminCurrentSettingsRepository"; if (LS.CurrentHttpContext.Session[TokenAdmin] != null) { return((Uco.Models.Settings)LS.CurrentHttpContext.Session[TokenAdmin]); } else { string Token = string.Format("CurrentSettingsMultiDomain_{0}_{1}", Domain, SF.GetLangCodeThreading()); if (LS.Cache[Token] == null) { lock (s_lock) { Settings s = GetSettingsRepositoryList().FirstOrDefault(); if (s == null) { return(null); } string LangCodeThreading = SF.GetLangCodeThreading(); if (SF.GetLangCodeWebconfig() != LangCodeThreading) { LanguagePage l = _db.LanguagePages.FirstOrDefault(r => r.DomainID == s.ID && r.LanguageCode == LangCodeThreading); if (l != null) { s.LanguageCode = l.LanguageCode; //s.LanguageRTL = l.ShowOnMainPage; s.HeaderHtml = l.Text2; s.FotterHtml = l.Text3; } } LS.Cache[Token] = s; } } return((Uco.Models.Settings)LS.Cache[Token]); } } else { string Token = string.Format("CurrentSettingsMultiDomain_{0}_{1}", Domain, SF.GetLangCodeThreading()); if (LS.Cache[Token] == null) { lock (s_lock) { Settings s = GetSettingsRepositoryList().FirstOrDefault(r => r.Domain == Domain); if (s == null) { return(null); } string LangCodeThreading = SF.GetLangCodeThreading(); if (SF.GetLangCodeWebconfig() != LangCodeThreading) { LanguagePage l = _db.LanguagePages.FirstOrDefault(r => r.DomainID == s.ID && r.LanguageCode == LangCodeThreading); if (l != null) { s.LanguageCode = l.LanguageCode; //s.LanguageRTL = l.ShowOnMainPage; s.HeaderHtml = l.Text2; s.FotterHtml = l.Text3; } } LS.Cache[Token] = s; } } return((Uco.Models.Settings)LS.Cache[Token]); } } }