Ejemplo n.º 1
0
        //  public bool Admn { get; set; }
        //  public int OrderPayedCount { get; set; }
        //      public Enums.OrderStatus stati { get; set; }

        //public OrderIndexVM() {
        //    //Search = new OrderSearchVM();
        //    //Search.ShowAll = false;
        //}

        public SearchIndexVM(IEnumerable <CacheUrlRecord> contents, SearchVM search, dynamic pager, CacheUrlSetting optionParameter = null)
        {
            ContentsIndexVM = contents.ToArray();
            Search          = search;
            Pager           = pager;
            Option          = optionParameter;
        }
        public void RefreshCachedRouteConfig()
        {
            var defaultMaxAge = _orchardServices.WorkContext.CurrentSite.As <CacheSettingsPart>().DefaultMaxAge;
            IRepository <CacheUrlRecord> _tmpcacheUrlRepository;

            _orchardServices.WorkContext.TryResolve <IRepository <CacheUrlRecord> >(out _tmpcacheUrlRepository);
            IRepository <CacheUrlSetting> _tmpcacheUrlSettingRepository;

            _orchardServices.WorkContext.TryResolve <IRepository <CacheUrlSetting> >(out _tmpcacheUrlSettingRepository);
            if (_tmpcacheUrlSettingRepository.Fetch(x => true).Count() == 0)
            {
                _tmpcacheUrlSettingRepository.Create(new CacheUrlSetting {
                    ActiveLog = false,
                    PreventDefaultAuthenticatedCache = false,
                    PreventDefaultNotContentItemAuthenticatedCache = false
                });
                _tmpcacheUrlSettingRepository.Flush();
            }
            _setting = _tmpcacheUrlSettingRepository.Fetch(x => true).FirstOrDefault();
            if (_tmpcacheUrlRepository.Fetch(x => x.CacheURL == "/private/").FirstOrDefault() == null)
            {
                _tmpcacheUrlRepository.Create(new CacheUrlRecord {
                    CacheDuration  = 0,
                    CacheGraceTime = 0,
                    Priority       = 10,
                    CacheURL       = "/private/",
                    CacheToken     = "{User.Id}"
                });
                _tmpcacheUrlRepository.Flush();
            }

            if (_tmpcacheUrlRepository.Fetch(x => x.CacheURL == "user+info").FirstOrDefault() == null)
            {
                _tmpcacheUrlRepository.Create(new CacheUrlRecord {
                    CacheDuration  = 0,
                    CacheGraceTime = 0,
                    Priority       = 10,
                    CacheURL       = "user+info",
                    CacheToken     = "{User.Id}"
                });
                _tmpcacheUrlRepository.Flush();
            }
            if (_tmpcacheUrlRepository.Fetch(x => x.CacheURL == "user info").FirstOrDefault() == null)
            {
                _tmpcacheUrlRepository.Create(new CacheUrlRecord {
                    CacheDuration  = 0,
                    CacheGraceTime = 0,
                    Priority       = 10,
                    CacheURL       = "user info",
                    CacheToken     = "{User.Id}"
                });
                _tmpcacheUrlRepository.Flush();
            }
            CachedRouteConfig = _tmpcacheUrlRepository.Table.OrderByDescending(y => y.Priority).Select(w => new CacheRouteConfig {
                Duration    = w.CacheDuration,
                GraceTime   = w.CacheGraceTime,
                Priority    = w.Priority,
                FeatureName = "CacheUrl",
                MaxAge      = defaultMaxAge,
                RouteKey    = w.CacheURL ?? "",
                Url         = w.CacheToken ?? ""
            }).ToList();
        }