12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using CP.Cache;
- using CP.Model;
- namespace CP.Business
- {
- public class AreaBLL
- {
- /// <summary>
- /// 缓存
- /// </summary>
- static WMCache cache = WMCache.GetCacheService();
- /// <summary>
- /// 获取
- /// </summary>
- /// <returns></returns>
- public List<Area> GetAreaList()
- {
- string key = CacheKeys.ares;
- List<Area> list = cache.GetObject<List<Area>>(key);
- if (list == null)
- {
- var dc = new DataConnect();
- list = dc.db.Fetch<Area>("order by seq asc");
- cache.AddObject(key, list, (int)CacheTime.System);
- }
-
- return list;
-
- }
- /// <summary>
- /// 获取
- /// </summary>
- /// <returns></returns>
- public static List<Cz> GetCzByareaid(int areaid)
- {
- string key = string.Format(CacheKeys.ares_id, areaid);
- List<Cz> list = cache.GetObject<List<Cz>>(key);
- if (list == null)
- {
- list = new List<Cz>();
- var dc = new DataConnect();
- string sql = string.Format(" where areaid={0} order by seq asc", areaid);
- var query = dc.db.Fetch<AreaCz>(sql);
- for (int i = 0; i < query.Count; i++)
- {
- var listcz = CzBll.GetCz(query[i].cid);
- if (listcz != null)
- {
- if (listcz.cid != 0)
- list.Add(listcz);
- }
-
- }
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- return list;
- }
- /// <summary>
- /// 获取
- /// </summary>
- /// <returns></returns>
- public static Area GetAreaByname(string ename)
- {
- string key = string.Format(CacheKeys.ares_name, ename);
- Area list = cache.GetObject<Area>(key);
- if (list == null)
- {
- var dc = new DataConnect();
- string sql = string.Format(" where ename='{0}' ", ename);
- list = dc.db.Fetch<Area>(sql).FirstOrDefault();
- cache.AddObject(key, list, (int)CacheTime.System);
- }
- return list;
- }
- }
- }
|