예제 #1
0
        public List <ActionPower> GetBusPower(string userNo, byte issupper)
        {
            string             conn            = ConfigurationManager.ConnectionStrings["Gungnir_AlwaysOnRead"].ConnectionString;
            IConnectionManager connManager     = new ConnectionManager(SecurityHelp.IsBase64Formatted(conn) ? SecurityHelp.DecryptAES(conn) : conn);
            IDBScopeManager    dbscope         = new DBScopeManager(connManager);
            PowerHandle        pHandle         = new PowerHandle(dbscope);
            List <ActionPower> actionPowerList = new List <ActionPower>();

            try
            {
                //var cache = CacheFactory.Create(CacheType.CouchBase);
                //var key = EnOrDeHelper.GetMd5(userNo + "power!@#$", Encoding.UTF8);
                //cache.TryGet(key, out actionPowerList);

                //if (actionPowerList != null && actionPowerList.Count != 0)
                //    return actionPowerList;
                var key = EnOrDeHelper.GetMd5(userNo + "power!@#$", Encoding.UTF8);
                using (var client = CacheHelper.CreateCacheClient("Setting"))
                {
                    return((client.GetOrSet(key, () => pHandle.GetBusPower(userNo, issupper),
                                            new TimeSpan(1, 0, 0)))?.Value ?? new List <ActionPower>());
                }
            }
            catch
            {
                actionPowerList = pHandle.GetBusPower(userNo, issupper);
            }
            return(actionPowerList);
        }
예제 #2
0
        /// <summary>
        /// 获得region表里面所有的数据
        /// </summary>
        /// <param name="connection"></param>
        /// <returns></returns>
        public List <Region> SelectAllRegions()
        {
            var           key = EnOrDeHelper.GetMd5("Yewu/Shop/YeWuAllRegions", Encoding.UTF8);
            List <Region> resultList;

            using (CacheClient client = CacheHelper.CreateCacheClient("Cache_GetRegions"))
            {
                resultList = client.GetOrSet <List <Region> >(key, () => {
                    return(GetRegionAllData());
                }).Value;
            }
            return(resultList);
        }