コード例 #1
0
ファイル: FeereportBLL.cs プロジェクト: JerryForNet/wuye
        /// <summary>
        /// 获取列表(缓存保存1个小时)
        /// </summary>
        /// <param name="queryJson">查询参数</param>
        /// <returns>返回列表</returns>
        public IEnumerable <ChargeModel> GetChargeListJson(string queryJson)
        {
            #region 使用缓存的方法提高查询速度 不建议使用
            var    queryParam = queryJson.ToJObject();
            string userStatus = queryParam["UserStatues"].ToString();
            string floornum   = queryParam["FloorNum"].ToString();
            string propertyId = queryParam["propertyID"].ToString();
            string year       = queryParam["YearNum"].ToString();
            string month      = queryParam["MonthNum"].ToString();
            string feeitem    = queryParam["feeitem"].ToString();

            string cacheKey = CacheFactory.CacheKey().Charge(userStatus, floornum, propertyId, year, month, feeitem);

            IList <ChargeModel> cache = CacheFactory.Cache().GetCache <List <ChargeModel> >(cacheKey);
            if (cache == null)
            {
                IEnumerable <ChargeModel> list = service.GetChargeListJson(queryJson);
                if (list != null)
                {
                    CacheFactory.Cache().WriteCache <IList <ChargeModel> >(list.ToList(), cacheKey, DateTime.Now.AddHours(1));
                }
            }

            return(CacheFactory.Cache().GetCache <List <ChargeModel> >(cacheKey));

            #endregion

            //return service.GetChargeListJson(queryJson);
        }