123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- using Lottomat.Application.Busines;
- using Lottomat.Application.Busines.SystemManage;
- using Lottomat.Application.Entity.SystemManage.ViewModel;
- using Lottomat.Cache.Factory;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Lottomat.Application.Code;
- using Lottomat.Application.Entity.SystemManage;
- namespace Lottomat.Application.Cache
- {
-
-
-
-
-
-
-
- public class DataItemCache
- {
- private DataItemDetailBLL busines = new DataItemDetailBLL();
-
-
-
- public static DataItemBLL dataItemBll = new DataItemBLL();
-
-
-
-
- public IEnumerable<DataItemModel> GetDataItemList()
- {
- string key = "";
- IEnumerable<DataItemModel> cacheList = CacheFactory.Cache().GetCache<IEnumerable<DataItemModel>>(busines.cacheKey);
- if (cacheList == null)
- {
- cacheList = busines.GetDataItemList();
- CacheFactory.Cache().WriteCache(cacheList, busines.cacheKey);
- }
- return cacheList;
- }
-
-
-
-
-
- public DataItemEntity GetDataItemEntityByCode(string code)
- {
- if (!string.IsNullOrEmpty(code))
- {
- DataItemEntity entity = CacheFactory.Cache().GetCache<DataItemEntity>("__" + code + "__");
- if (entity == null)
- {
- entity = dataItemBll.GetEntityByCode(code);
- CacheFactory.Cache().WriteCache(entity, "__" + code + "__");
- }
- return entity;
- }
- return default(DataItemEntity);
- }
-
-
-
-
-
- public DataItemDetailEntity GetDataItemEntityById(string id)
- {
- if (!string.IsNullOrEmpty(id))
- {
- DataItemDetailEntity entity = CacheFactory.Cache().GetCache<DataItemDetailEntity>("__" + id + "__");
- if (entity == null)
- {
- entity = busines.GetEntityById(id);
- CacheFactory.Cache().WriteCache(entity, "__" + id + "__");
- }
- return entity;
- }
- return default(DataItemDetailEntity);
- }
-
-
-
-
-
- public List<DataItemDetailEntity> GetDataItemListById(string id)
- {
- if (!string.IsNullOrEmpty(id))
- {
- List<DataItemDetailEntity> entity = CacheFactory.Cache().GetCache<List<DataItemDetailEntity>>("__" + id + "__DATA__ITEM__LIST__");
- if (entity == null)
- {
- entity = busines.GetDataItemListById(id);
- CacheFactory.Cache().WriteCache(entity, "__" + id + "__DATA__ITEM__LIST__");
- }
- return entity;
- }
- return default(List<DataItemDetailEntity>);
- }
-
-
-
-
-
- public List<DataItemModel> GetDataItemList(string EnCode)
- {
- string[] codeArr = EnCode.Split("|".ToArray());
- return this.GetDataItemList().Where(t => codeArr.Contains(t.EnCode) && t.EnabledMark == (int)EnabledMarkEnum.Enabled).ToList();
- }
-
-
-
-
-
-
- public IEnumerable<DataItemModel> GetSubDataItemList(string EnCode, string ItemValue)
- {
- IEnumerable<DataItemModel> data = this.GetDataItemList().Where(t => t.EnCode == EnCode);
- IEnumerable<DataItemModel> dataItemModels = data as DataItemModel[] ?? data.ToArray();
- string itemDetailId = dataItemModels.First(t => t.ItemValue == ItemValue).ItemDetailId;
- return dataItemModels.Where(t => t.ParentId == itemDetailId);
- }
-
-
-
-
-
- public DataItemModel GetItemDetailByItemValue(string ItemValue)
- {
- DataItemModel data = this.GetDataItemList().First(t => t.ItemValue == ItemValue);
- return data;
- }
-
-
-
-
-
-
- public string ToItemName(string EnCode, string ItemValue)
- {
- IEnumerable<DataItemModel> data = this.GetDataItemList().Where(t => t.EnCode == EnCode);
- return data.First(t => t.ItemValue == ItemValue).ItemName;
- }
- }
- }
|