Ejemplo n.º 1
0
        /// <summary>
        /// 获取缓存中Mac地址匹配的列表
        /// </summary>
        /// <param name="keyword"></param>
        /// <returns></returns>
        public static List <MacInfo> GetMacList(string keyword)
        {
            List <MacInfo> list = null;

            if (HttpContext.Current.Cache["CacheMac"] == null)
            {
                list = new MacDAL().GetNoMacList();
                HttpContext.Current.Cache.Insert("CacheMac", list, null, DateTime.Now.AddHours(5), TimeSpan.Zero);
                Logger.writeLog(list.Count.ToString());
            }
            else
            {
                list = (List <MacInfo>)HttpContext.Current.Cache["CacheMac"];
            }

            if (!string.IsNullOrEmpty(keyword))
            {
                IEnumerable <MacInfo> IEList = list;
                IEList = IEList.Where(m => m.COLLECTION_EQUIPMENT_ID.Contains(keyword)).Take(10);
                if (IEList.ToList().Count() > 0)
                {
                    return(IEList.ToList());
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 缓存未使用的Mac地址集合
 /// </summary>
 public static void GetCacheMac(bool isReset)
 {
     if (HttpContext.Current.Cache["CacheMac"] == null || isReset)
     {
         List <MacInfo> list = new MacDAL().GetNoMacList();
         HttpContext.Current.Cache.Insert("CacheMac", list, null, DateTime.Now.AddHours(5), TimeSpan.Zero);
     }
 }