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 { /// /// 缓存 /// static WMCache cache = WMCache.GetCacheService(); /// /// 获取 /// /// public List GetAreaList() { string key = CacheKeys.ares; List list = cache.GetObject>(key); if (list == null) { var dc = new DataConnect(); list = dc.db.Fetch("order by seq asc"); cache.AddObject(key, list, (int)CacheTime.System); } return list; } /// /// 获取 /// /// public static List GetCzByareaid(int areaid) { string key = string.Format(CacheKeys.ares_id, areaid); List list = cache.GetObject>(key); if (list == null) { list = new List(); var dc = new DataConnect(); string sql = string.Format(" where areaid={0} order by seq asc", areaid); var query = dc.db.Fetch(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; } /// /// 获取 /// /// public static Area GetAreaByname(string ename) { string key = string.Format(CacheKeys.ares_name, ename); Area list = cache.GetObject(key); if (list == null) { var dc = new DataConnect(); string sql = string.Format(" where ename='{0}' ", ename); list = dc.db.Fetch(sql).FirstOrDefault(); cache.AddObject(key, list, (int)CacheTime.System); } return list; } } }