/// <summary>
 /// 执行前读取站点配置信息
 /// </summary>
 /// <param name="filterContext"></param>
 protected override void OnActionExecuting(ActionExecutingContext filterContext)
 {
     this.Config = CacheHelper.GetCache(Constant.CacheKey.SiteConfigCacheKey) as SiteConfig;
     if (this.Config == null)
     {
         this.Config = siteConfigService.LoadConfig(Constant.SiteConfigPath);
         CacheHelper.SetCache(Constant.CacheKey.SiteConfigCacheKey, Config);
     }
 }
        protected virtual string GetCurrentTheme()
        {
            string     theme  = "";
            SiteConfig config = CacheHelper.GetCache(Constant.CacheKey.SiteConfigCacheKey) as SiteConfig;

            if (config == null)
            {
                ISiteConfigService siteConfigService = IocHelper.AutofacResolveNamed <ISiteConfigService>("SiteConfigService");
                config = siteConfigService.LoadConfig(Constant.SiteConfigPath);
                CacheHelper.SetCache(Constant.CacheKey.SiteConfigCacheKey, config);
            }
            theme = config.SiteTheme;
            //Debug.WriteLine("theme:" + theme);
            return(theme);
        }
Exemple #3
0
        /// <summary>
        /// 执行前读取站点配置信息
        /// </summary>
        /// <param name="filterContext"></param>
        protected override void OnActionExecuting(ActionExecutingContext filterContext)
        {
            CacheObj obj = cacheService.Get(Constant.CacheKey.SiteConfigCacheKey);

            this.Config = (obj != null && obj.value != null) ? (obj.value as SiteConfig) : null;
            if (this.Config == null)
            {
                this.Config = siteConfigService.LoadConfig(Constant.SiteConfigPath);
                cacheService.Add(Constant.CacheKey.SiteConfigCacheKey,
                                 new CacheObj()
                {
                    value = Config,
                    AbsoluteExpiration = new TimeSpan(1, 0, 0, 0)
                });
            }
            if (this.Config != null)
            {
                ViewData["_SiteConfig"] = this.Config;
            }
        }
Exemple #4
0
        protected virtual string GetCurrentTheme()
        {
            string theme = "";
            //SiteConfig config = CacheHelper.GetCache(Constant.CacheKey.SiteConfigCacheKey) as SiteConfig;
            CacheObj   obj    = cacheService.Get(Constant.CacheKey.SiteConfigCacheKey);
            SiteConfig config = (obj != null && obj.value != null) ? (obj.value as SiteConfig) : null;

            if (config == null)
            {
                config = siteConfigService.LoadConfig(Constant.SiteConfigPath);
                cacheService.Add(Constant.CacheKey.SiteConfigCacheKey,
                                 new CacheObj()
                {
                    value = config,
                    AbsoluteExpiration = new DateTimeOffset(DateTime.Now).AddDays(1)
                });
                //CacheHelper.SetCache(Constant.CacheKey.SiteConfigCacheKey, config);
            }
            theme = config.SiteTheme;
            return(theme);
        }