示例#1
0
        public void AddUserSelectCriteria(string cacheKey, DetachedCriteria selectCriteria, DetachedCriteria selectCountCriteria, IDictionary <string, string> alias)
        {
            if (_page.Session["SelectCriteriaCache"] == null)
            {
                _page.Session["SelectCriteriaCache"] = new Dictionary <string, CachedSelectCriteria>();
            }

            IDictionary <string, CachedSelectCriteria> selectCriteriaCache = (IDictionary <string, CachedSelectCriteria>)_page.Session["SelectCriteriaCache"];

            if (!selectCriteriaCache.ContainsKey(cacheKey) && selectCriteriaCache.Count > UserSelectCriteriaCacheSize)
            {
                //CacheÇå³ý×îÔçµÄUserSelectCriteria
                DateTime lastestTime = DateTime.Now;
                string   lastestkey  = string.Empty;
                foreach (string key in selectCriteriaCache.Keys)
                {
                    CachedSelectCriteria cache = selectCriteriaCache[key];
                    if (lastestTime > cache.LastAccessTime)
                    {
                        lastestkey = key;
                    }
                }
                selectCriteriaCache.Remove(lastestkey);
            }

            if (selectCriteriaCache.ContainsKey(cacheKey))
            {
                selectCriteriaCache[cacheKey] = new CachedSelectCriteria(DateTime.Now, selectCriteria, selectCountCriteria, alias);
            }
            else
            {
                selectCriteriaCache.Add(cacheKey, new CachedSelectCriteria(DateTime.Now, selectCriteria, selectCountCriteria, alias));
            }
        }
        public void AddUserSelectCriteria(string cacheKey, DetachedCriteria selectCriteria, DetachedCriteria selectCountCriteria, IDictionary<string, string> alias)
        {
            if (_page.Session["SelectCriteriaCache"] == null)
            {
                _page.Session["SelectCriteriaCache"] =  new Dictionary<string, CachedSelectCriteria>();
            }

            IDictionary<string, CachedSelectCriteria> selectCriteriaCache = (IDictionary<string, CachedSelectCriteria>)_page.Session["SelectCriteriaCache"];
            if (!selectCriteriaCache.ContainsKey(cacheKey) && selectCriteriaCache.Count > UserSelectCriteriaCacheSize) 
            {
                //CacheÇå³ý×îÔçµÄUserSelectCriteria
                DateTime lastestTime = DateTime.Now;
                string lastestkey = string.Empty;
                foreach (string key in selectCriteriaCache.Keys)
                {
                    
                    CachedSelectCriteria cache = selectCriteriaCache[key];
                    if (lastestTime > cache.LastAccessTime)
                    {
                        lastestkey = key;
                    }
                }
                selectCriteriaCache.Remove(lastestkey);
            }

            if (selectCriteriaCache.ContainsKey(cacheKey))
            {
                selectCriteriaCache[cacheKey] = new CachedSelectCriteria(DateTime.Now, selectCriteria, selectCountCriteria, alias);
            }
            else
            {
                selectCriteriaCache.Add(cacheKey, new CachedSelectCriteria(DateTime.Now, selectCriteria, selectCountCriteria, alias));
            }
        }
示例#3
0
        public DetachedCriteria GetUserSelectCountCriteria(string cacheKey)
        {
            if (_page.Session["SelectCriteriaCache"] != null)
            {
                IDictionary <string, CachedSelectCriteria> selectCriteriaCache = (IDictionary <string, CachedSelectCriteria>)_page.Session["SelectCriteriaCache"];
                if (selectCriteriaCache.ContainsKey(cacheKey))
                {
                    CachedSelectCriteria cache = selectCriteriaCache[cacheKey];
                    cache.LastAccessTime = DateTime.Now;

                    return(cache.SelectCountCriteria);
                }
            }

            return(null);
        }