예제 #1
0
        /// <summary>
        /// 根据门店编号获取门店信息
        /// </summary>
        /// <param name="shopId"></param>
        /// <returns></returns>
        ShopInfo IShopCache.GetshopInfoByShopId(int shopId)
        {
            ShopInfo result = null;

            if (shopId == 0)
            {
                throw new ArgumentNullException("Shop Id can not be zero");
            }

            string         key  = string.Format("DB_SI_{0}_*", shopId);
            IList <string> keys = Session.Current.ScanAllKeys(key);

            if (keys != null && keys.Count > 0)
            {
                result = Session.Current.Get <ShopInfo>(keys[0]);
            }
            else
            {
                //从数据库获取数据
                IList <ShopInfo> shopinfolist = DBConnectionManager.Instance.Reader.Select <ShopInfo>(new ShopSelectSpefication(shopId.ToString(), 0).Satifasy());

                if (shopinfolist != null && shopinfolist.Count > 0)
                {
                    result = shopinfolist[0];
                    //同步缓存
                    Session.Current.Set(result.GetKeyName(), result);
                }
            }
            return(result);
        }
예제 #2
0
        /// <summary>
        /// 设置门店禁用
        /// </summary>
        /// <param name="shopId"></param>
        /// <param name="enable"></param>
        /// <returns></returns>
        bool IShopCache.SetShopInfoEnable(int shopId, bool enable)
        {
            if (shopId == 0)
            {
                throw new ArgumentNullException("shopId can not be zero");
            }
            bool result = false;

            string key = string.Format("DB_SI_{0}_*", shopId);

            ShopInfo       updateinfo = null;
            IList <string> keys       = Session.Current.ScanAllKeys(key);

            if (keys != null && keys.Count > 0)
            {
                updateinfo = Session.Current.Get <ShopInfo>(keys[0]);
            }
            if (updateinfo != null)
            {
                updateinfo.Enable = enable;
                result            = Session.Current.Set(updateinfo.GetKeyName(), updateinfo);
            }
            return(result);
        }