Esempio n. 1
0
        /// <summary>
        /// 设置缓存
        /// </summary>
        /// <param name="cacheKey">缓存标识符</param>
        /// <param name="cacheObject">缓存object</param>
        /// <param name="dependencies">缓存依赖项:.Net中支持两种依赖:CacheDependency和SqlDependency(两者都是Dependency的子类)。从.Net2.0开始,CacheDependency不再是密封的,而是可以继承的。CacheDependency:表示对文件或者目录的依赖;SqlDependency:表示基于SQL数据库的依赖</param>
        /// <param name="absoluteExpiration">绝对过期时间:为特定时间点,类型为DateTime,如果不使用绝对过期时间,那么,使用System.Web.Caching.Cache.NoAbsoluteExpiration表示</param>
        /// <param name="slidingExpiration">滑动过期时间:最后一次访问的时间隔为一个事件间隔,类型为TimeSpan,如果不使用滑动过期时间,使用System.Web.Cacheing.NoSlidingExpiration或者TimeSpan.Zero表示</param>
        static public void SetBWJSCache(object cacheKey, object cacheObject, CacheDependency dependencies, object absoluteExpiration, TimeSpan slidingExpiration)
        {
            //HttpContext.Current.Response.Cache.SetExpires(ComPage.SafeToDateTime(absoluteExpiration));
            //HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.Public);

            System.Web.Caching.Cache objCache = HttpRuntime.Cache;
            objCache.Insert(SafeToString(cacheKey), cacheObject, dependencies, ComPage.SafeToDateTime(absoluteExpiration), slidingExpiration);
        }
Esempio n. 2
0
 /// <summary>
 /// 初始化绑定DropDownList
 /// </summary>
 public void InitDDL(DataTable dt, DropDownList ddl, object defaultText, object defaultValue, object bindText, object bindValue)
 {
     ddl.Items.Clear();
     if (defaultText != null && defaultValue != null)
     {
         ddl.Items.Add(new ListItem(defaultText.ToString(), defaultValue.ToString()));
     }
     if (dt != null && dt.Rows.Count > 0)
     {
         foreach (DataRow dr in dt.Rows)
         {
             ddl.Items.Add(new ListItem(ComPage.SafeToString(dr[bindText.ToString()]), ComPage.SafeToString(dr[bindValue.ToString()])));
         }
     }
 }