using System; using System.Collections.Generic; using WX.CRM.BLL.Redis; using WX.CRM.BLL.Res; using WX.CRM.DAL.Redis; using WX.CRM.IBLL.RedisBL; using WX.CRM.Model.Entity; namespace WX.CRM.BLL.RedisBL { public class RES_CUSTOMER_REDIS_BL : IRES_CUSTOMER_REDIS { public RES_CUSTOMER GetInfo(string resid, int IsTran = 1) { resid = String.Format("{0}", resid).Trim(); try { //resid = String.Format("{0}", resid).Trim(); //WX.CRM.BLL.Redis.RedisHelper redis = new Redis.RedisHelper(); //string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(resid); //RES_CUSTOMER model = redis.Get(rediskey); //if (model != null) // model.RES_CUSTOMERDETAIL = new RES_CUSTOMERDETAIL_REDIS_BL().GetInfo(resid); //return model; string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(resid); RedisString redis = new RedisString(rediskey); RES_CUSTOMER model = redis.Get(); if (model != null) model.RES_CUSTOMERDETAIL = new RES_CUSTOMERDETAIL_REDIS_BL().GetInfo(resid); return model; } catch (Exception ex) { if (IsTran == 1) { var retModel = new RES_CUSTOMER_BL().getResCustomerByResId(resid); retModel.RES_CUSTOMERDETAIL = new RES_CUSTOMERDETAIL_BL().GetModel_RES_CUSTOMERDETAIL(resid); return retModel; } else return null; } } public List GetList(string[] resids, int IsTran = 1) { List mlis = new List(); foreach (string s in resids) { var o = GetInfo(s, IsTran); if (o != null) mlis.Add(o); } return mlis; } public bool AddRedis(RES_CUSTOMER entity) { try { string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.RESID); RedisHelper redis = new RedisHelper(); return redis.AddToCache(rediskey, entity); } catch (Exception ex) { return false; } } } }