DotNet.Business/DataAccess/Manager/BaseItemDetailsManager.Web.cs

(开头部分) 5KB

这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。

//-----------------------------------------------------------------
// All Rights Reserved , Copyright (C) 2014 , Hairihan TECH, Ltd. 
//-----------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Caching;

namespace DotNet.Business
{
    using DotNet.Utilities;

    /// <remarks>
    /// BaseItemDetailsManager
    /// 选项管理
    /// 
    /// 修改纪录
    /// 
    ///	版本:1.0 2012.12.13    JiRiGaLa    选项管理从缓存读取,通过编号显示名称的函数完善。
    ///	
    /// <author>  
    ///		<name>JiRiGaLa</name>
    ///		<date>2012.12.13</date>
    /// </author> 
    /// </remarks>
    public partial class BaseItemDetailsManager
    {
        #region private static List<BaseItemDetailsEntity> GetEntities(string tableName) 获取选项表明细,从缓存读取
        /// <summary>
        /// 获取选项表明细,从缓存读取
        /// </summary>
        private static List<BaseItemDetailsEntity> GetEntities(string tableName)
        {
            if (HttpContext.Current.Session == null || HttpContext.Current.Cache[tableName] == null)
            {
                lock (BaseSystemInfo.UserLock)
                {
                    if (HttpContext.Current.Session == null || HttpContext.Current.Cache[tableName] == null)
                    {
                        // 读取目标表中的数据
                        List<BaseItemDetailsEntity> entityList = null;
                        BaseItemDetailsManager manager = new DotNet.Business.BaseItemDetailsManager(tableName);
                        entityList = manager.GetList<BaseItemDetailsEntity>();
                        // 这个是没写过期时间的方法
                        // HttpContext.Current.Cache[tableName] = entityList;
                        // 设置过期时间为8个小时,第2天若有不正常的自动就可以正常了
                        HttpContext.Current.Cache.Add(tableName, entityList, null, DateTime.Now.AddHours(8), TimeSpan.Zero, CacheItemPriority.Normal, null);
                    }
                }
            }
            return HttpContext.Current.Cache[tableName] as List<BaseItemDetailsEntity>;
        }
        #endregion

        #region public static string GetItemNameByCode(string tableName, string itemCode) 通过编号获取选项的显示内容
        /// <summary>
        /// 通过编号获取选项的显示内容
        /// 这里是进行了内存缓存处理,减少数据库的I/O处理,提高程序的运行性能,
后面还有 49 行代码,购买后查看完整代码

24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明

AI 解读

登录后可用,每次 10 积分,解读结果公开显示在下面。

还没有人解读过这个文件。