using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; using WX.CRM.BLL.Cache; using WX.CRM.BLL.Ord; using WX.CRM.BLL.Redis; using WX.CRM.BLL.Res; using WX.CRM.BLL.Soft; using WX.CRM.BLL.Util; using WX.CRM.Common; using WX.CRM.DAL.Redis; using WX.CRM.IBLL.RedisBL; using WX.CRM.Model.Entity; using WX.CRM.Model.EntitySync; using WX.CRM.Model.Redis; namespace WX.CRM.BLL.RedisBL { public class CUSTOMER_REDIS_BL : ICUSTOMER_REDIS { #region 测试redis连接是否有异常 private bool isHasException = false; //默认为无异常,正常连接redis private string isFromOracleDB = new CACHE_BL().GetValue_Parameter("Sys_IsFromOracleDB") == "true" ? "true" : "false";//默认为false:从redis库查询数据 //private string isFromOracleDB = "false"; public CUSTOMER_REDIS_BL() { //this.isHasException = isFromOracleDB == "false" ? TestRedisConnect() : Convert.ToBoolean(isFromOracleDB); isHasException = true; } private bool TestRedisConnect() { try { RedisHelper redis = new Redis.RedisHelper(); string rediskey = "gjs_customer:001"; string str = redis.Get(rediskey); return false; } catch (Exception ex) { LogHelper.Info("redis读写异常:" + ex.Message.ToString() + ex.StackTrace.ToString()); return true; } //isHasException = isFromOracleDB == "false" ? await TestRedisConnectAsync() : Convert.ToBoolean(isFromOracleDB); } private async Task TestRedisConnectAsync() { try { RedisHelper redis = new Redis.RedisHelper(); string rediskey = "gjs_customer:001"; await redis.GetAsync(rediskey); return false; } catch (Exception ex) { LogHelper.Error("redis读写异常:" + ex.ToString() + ex.StackTrace.ToString()); return true; } } #endregion #region res_customer模块 public RES_CUSTOMER GetInfo_Res_Customer(string resid, int IsTran = 1) { resid = String.Format("{0}", resid).Trim(); try { if (isHasException && IsTran != 1) return null; if (!isHasException) { 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; } else { var retModel = new RES_CUSTOMER_BL().getResCustomerByResId(resid); retModel.RES_CUSTOMERDETAIL = new RES_CUSTOMERDETAIL_BL().GetModel_RES_CUSTOMERDETAIL(resid); return retModel; } } catch (Exception ex) { return null; } } public List GetList_Res_Customer(string[] resids, int IsTran = 1) { List mlis = new List(); foreach (string s in resids) { var o = GetInfo_Res_Customer(s, IsTran); if (o != null) mlis.Add(o); } return mlis; } public bool AddRedis_Res_Customer(RES_CUSTOMER entity) { try { if (isHasException) { #region redis 添加到待打包表 REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); redisMoel1.TABLETYPE = "res_customer"; redisMoel1.KEYS = entity.RESID; redisMoel1.OPTYPE = "A"; redisMoel1.TIME = DateTime.Now; redisMoel1.LASTSYNCTIME = DateTime.Now; redisMoel1.ERRNUM = 0; redisMoel1.ERRMSG = ""; new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); #endregion return false; } string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.RESID); RedisHelper redis = new RedisHelper(); return redis.AddToCache(rediskey, entity); } catch (Exception ex) { return false; } } #endregion #region res_customerdetail模块 public RES_CUSTOMERDETAIL GetInfo_Res_CustomerDetail(string resid, int IsTran = 1) { resid = String.Format("{0}", resid).Trim(); try { if (isHasException && IsTran != 1) return null; if (!isHasException) { RedisHelper redis = new RedisHelper(); string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(resid); RES_CUSTOMERDETAIL model = redis.Get(rediskey); return model; } else { return new RES_CUSTOMERDETAIL_BL().GetModel_RES_CUSTOMERDETAIL(resid); } } catch (Exception ex) { return null; } } public bool AddRedis_Res_CustomerDetail(RES_CUSTOMERDETAIL entity) { try { if (isHasException) { #region redis 添加到待打包表 REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); redisMoel1.TABLETYPE = "res_customerdetail"; redisMoel1.KEYS = entity.RESID; redisMoel1.OPTYPE = "A"; redisMoel1.TIME = DateTime.Now; redisMoel1.LASTSYNCTIME = DateTime.Now; redisMoel1.ERRNUM = 0; redisMoel1.ERRMSG = ""; new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); #endregion return false; } string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.RESID); RedisHelper redis = new RedisHelper(); return redis.AddToCache(rediskey, entity); } catch (Exception ex) { return false; } } #endregion #region gjs_customer模块 //public GJS_CUSTOMER GetInfo_Gjs_Customer(string tradecode, int IsTran = 1) //{ // tradecode = String.Format("{0}", tradecode).Trim(); // try // { // if (isHasException && IsTran != 1) // return null; // if (!isHasException) // { // WX.CRM.BLL.Redis.RedisHelper redis = new Redis.RedisHelper(); // string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(tradecode); // GJS_CUSTOMER model = redis.Get(rediskey); // if (model != null) // model.GJS_CUSTOMERBOCE = new RedisBL.GJS_CUSTOMERBOCE_REDIS_BL().GetInfo(tradecode); // return model; // } // else // { // var retModel = new WX.CRM.BLL.Gjs.GJS_CUSTOMER_BL().getCustomerByTradecode(tradecode); // retModel.GJS_CUSTOMERBOCE = new WX.CRM.BLL.Gjs.GJS_CUSTOMER_BL().GetCustomerBoceByTradeCode(tradecode); // return retModel; // } // } // catch (Exception ex) // { // return null; // } //} //public List GetList_Gjs_Customer(string[] resids, int IsTran = 1) //{ // List list = new List(); // foreach (var resid in resids) // { // string[] tradecodes = new Gjs.GJS_CUSTOMER_BL().GetAllTradeCodeByResid(resid); // if (tradecodes != null && tradecodes.Count() > 0) // { // foreach (var tds in tradecodes) // { // GJS_CUSTOMER model = GetInfo_Gjs_Customer(tds, IsTran); // if (model != null) // list.Add(model); // } // } // } // return list; //} //public bool AddRedis_Gjs_Customer(GJS_CUSTOMER entity) //{ // try // { // if (isHasException) // { // #region redis 添加到待打包表 // REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); // redisMoel1.TABLETYPE = "gjs_customer"; // redisMoel1.KEYS = entity.TRADECODE; // redisMoel1.OPTYPE = "A"; // redisMoel1.TIME = DateTime.Now; // redisMoel1.LASTSYNCTIME = DateTime.Now; // redisMoel1.ERRNUM = 0; // redisMoel1.ERRMSG = ""; // new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); // #endregion // return false; // } // string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.TRADECODE); // RedisHelper redis = new RedisHelper(); // return redis.AddToCache(rediskey, entity); // } // catch (Exception ex) // { // LogHelper.Error("添加gjs_customer出错:" + entity.TRADECODE + ":" + ex.StackTrace.ToString()); // return false; // } //} #endregion #region gjs_customerboce模块 //public GJS_CUSTOMERBOCE GetInfo_Gjs_Customerboce(string tradecode, int IsTran = 1) //{ // tradecode = String.Format("{0}", tradecode).Trim(); // try // { // if (isHasException && IsTran != 1) // return null; // if (!isHasException) // { // WX.CRM.BLL.Redis.RedisHelper redis = new Redis.RedisHelper(); // string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(tradecode); // GJS_CUSTOMERBOCE model = redis.Get(rediskey); // return model; // } // else // return new WX.CRM.BLL.Gjs.GJS_CUSTOMER_BL().GetCustomerBoceByTradeCode(tradecode); // } // catch (Exception ex) // { // return null; // } //} //public bool AddRedis_Gjs_Customerboce(GJS_CUSTOMERBOCE entity) //{ // try // { // if (isHasException) // { // #region redis 添加到待打包表 // REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); // redisMoel1.TABLETYPE = "gjs_customerboce"; // redisMoel1.KEYS = entity.TRADECODE; // redisMoel1.OPTYPE = "A"; // redisMoel1.TIME = DateTime.Now; // redisMoel1.LASTSYNCTIME = DateTime.Now; // redisMoel1.ERRNUM = 0; // redisMoel1.ERRMSG = ""; // new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); // #endregion // return false; // } // string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.TRADECODE); // RedisHelper redis = new RedisHelper(); // return redis.AddToCache(rediskey, entity); // } // catch (Exception ex) // { // LogHelper.Error("添加gjs_customerboce出错:" + entity.TRADECODE + ":" + ex.StackTrace.ToString()); // return false; // } //} #endregion #region soft_user模块 public SOFT_USER GetInfo_Soft_User(string username, int IsTran = 1) { username = String.Format("{0}", username).Trim(); try { if (isHasException && IsTran != 1) return null; if (!isHasException) { RedisHelper redis = new Redis.RedisHelper(); string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(username); SOFT_USER model = redis.Get(rediskey); return model; } else { var retModel = new SOFT_USER_BL().GetUser_userName(username); return retModel; } } catch (Exception ex) { return null; } } public List GetList_Soft_User(string[] usernames, int IsTran = 1) { List list = new List(); foreach (string s in usernames) { var o = GetInfo_Soft_User(s, IsTran); if (o != null) list.Add(o); } return list; } public bool AddRedis_Soft_User(SOFT_USER entity) { try { if (isHasException) { #region redis 添加到待打包表 REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); redisMoel1.TABLETYPE = "soft_user"; redisMoel1.KEYS = entity.USERNAME; redisMoel1.OPTYPE = "A"; redisMoel1.TIME = DateTime.Now; redisMoel1.LASTSYNCTIME = DateTime.Now; redisMoel1.ERRNUM = 0; redisMoel1.ERRMSG = ""; new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); #endregion return false; } string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.USERNAME); RedisHelper redis = new RedisHelper(); return redis.AddToCache(rediskey, entity); } catch (Exception ex) { return false; } } #endregion #region res_customeruser_resid模块 public List GetList_Res_Customeruser_Resid(string resid, int IsTran = 1) { resid = String.Format("{0}", resid).Trim(); try { if (isHasException && IsTran != 1) return null; if (!isHasException) { string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(resid); RedisList redis = new RedisList(rediskey); List list = redis.Range().Distinct().ToList(); return list; } else { var list = new RES_CUSTOMERUSER_BL().GetModelByResId(resid); return list; } } catch (Exception ex) { return null; } } public List GetAll_Res_Customeruser_Resid(string[] resids, int IsTran = 1) { List list = new List(); foreach (string s in resids) { var o = GetList_Res_Customeruser_Resid(s, IsTran); if (o != null) list.AddRange(o); } return list; } public long AddRedis_Res_Customeruser_Resid(RES_CUSTOMERUSER entity) { try { if (isHasException) { #region redis 添加到待打包表 REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); redisMoel1.TABLETYPE = "res_customeruser_resid"; redisMoel1.KEYS = entity.RESID; redisMoel1.OPTYPE = "A"; redisMoel1.TIME = DateTime.Now; redisMoel1.LASTSYNCTIME = DateTime.Now; redisMoel1.ERRNUM = 0; redisMoel1.ERRMSG = ""; new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); #endregion return 0; } string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.RESID); RedisList redis = new RedisList(rediskey); return redis.LeftPush(entity); } catch (Exception ex) { return 0; } } #endregion #region res_customeruser_username模块 public List GetList_Res_Customeruser_Username(string username, int IsTran = 1) { username = String.Format("{0}", username).Trim(); try { if (isHasException && IsTran != 1) return null; if (!isHasException) { string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(username); RedisList redis = new RedisList(rediskey); List list = redis.Range().Distinct().ToList(); return list; } else { var list = new RES_CUSTOMERUSER_BL().GetListByUserName(username); return list; } } catch (Exception ex) { return null; } } public List GetAll_Res_Customeruser_Username(string[] usernames, int IsTran = 1) { List list = new List(); foreach (string s in usernames) { var o = GetList_Res_Customeruser_Username(s, IsTran); if (o != null) list.AddRange(o); } return list; } public long AddRedis_Res_Customeruser_Username(RES_CUSTOMERUSER entity) { try { if (isHasException) { #region redis 添加到待打包表 REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); redisMoel1.TABLETYPE = "res_customeruser_username"; redisMoel1.KEYS = entity.RESID; redisMoel1.OPTYPE = "A"; redisMoel1.TIME = DateTime.Now; redisMoel1.LASTSYNCTIME = DateTime.Now; redisMoel1.ERRNUM = 0; redisMoel1.ERRMSG = ""; new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); #endregion return 0; } string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.USERNAME); RedisList redis = new RedisList(rediskey); return redis.LeftPush(entity); } catch (Exception ex) { return 0; } } #endregion #region ord_memocontent模块 public ORD_MEMOCONTENT GetInfo_Ord_Memocontent(decimal contentid, int IsTran = 1) { try { if (isHasException && IsTran != 1) return null; if (!isHasException) { string content = double.Parse(contentid.ToString()).ToString(); string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(content); RedisClass redis = new RedisClass(rediskey, RedisConfig.Redis1); ORD_MEMOCONTENT model = redis.Get(); //RedisHash redis = new RedisHash(rediskey, RedisConfig.Redis1); //Dictionary dic = redis.GetALL(); //ORD_MEMOCONTENT model = new ORD_MEMOCONTENT(); //model.CONTENTID = Convert.ToDecimal(dic["CONTENTID"]); //model.STRCONTENT = dic["STRCONTENT"].ToString(); //model.CTIME = Convert.ToDateTime(dic["CTIME"]); return model; } else { var retModel = new ORD_MEMOCONTENT_BL().GetInfo_OrdMemoContent(contentid); return retModel; } } catch (Exception ex) { return null; } } public List GetList_Ord_Memocontent(decimal[] contentids, int IsTran = 1) { List list = new List(); foreach (decimal s in contentids) { var o = GetInfo_Ord_Memocontent(s, IsTran); if (o != null) list.Add(o); } return list; } public bool AddRedis_Ord_Memocontent(ORD_MEMOCONTENT entity) { try { if (isHasException) { #region redis 添加到待打包表 REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); redisMoel1.TABLETYPE = "ord_memocontent"; redisMoel1.KEYS = entity.CONTENTID.ToString(); redisMoel1.OPTYPE = "A"; redisMoel1.TIME = DateTime.Now; redisMoel1.LASTSYNCTIME = DateTime.Now; redisMoel1.ERRNUM = 0; redisMoel1.ERRMSG = ""; new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); #endregion return false; } string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.CONTENTID.ToString()); RedisClass redis = new RedisClass(rediskey, RedisConfig.Redis1); redis.Set(entity); return true; } catch (Exception ex) { LogHelper.Error("添加ord_memocontent_redis出错:" + entity.CONTENTID.ToString() + ":" + ex.StackTrace.ToString()); return false; } } public bool DeleteRedis_Ord_Memocontent(decimal contentid) { try { if (isHasException) { #region redis 添加到待打包表 REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); redisMoel1.TABLETYPE = "ord_memocontent"; redisMoel1.KEYS = contentid.ToString(); redisMoel1.OPTYPE = "D"; redisMoel1.TIME = DateTime.Now; redisMoel1.LASTSYNCTIME = DateTime.Now; redisMoel1.ERRNUM = 0; redisMoel1.ERRMSG = ""; new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); #endregion return false; } string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(contentid.ToString()); RedisHash redis = new RedisHash(rediskey, RedisConfig.Redis1); return redis.Del(); } catch (Exception ex) { return false; } } #endregion #region cache_ord_memo模块 public CACHE_ORD_MEMO GetList_CacheOrdMemo(decimal memoid, int IsTran = 1) { try { if (isHasException && IsTran != 1) return null; if (!isHasException) { string memo = double.Parse(memoid.ToString()).ToString(); string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(memo); RedisClass redis = new RedisClass(rediskey, RedisConfig.Redis1); CACHE_ORD_MEMO model = redis.Get(); //RedisHash redis = new RedisHash(rediskey, RedisConfig.Redis1); //Dictionary dic = redis.GetALL(); //CACHE_ORD_MEMO model = new CACHE_ORD_MEMO(); //model.MEMOID = Convert.ToDecimal(dic["MEMOID"]); //model.MTYPEID = Convert.ToDecimal(dic["MTYPEID"]); //model.RESID = dic["RESID"].ToString(); //model.MEMOSTYLEID = Convert.ToDecimal(dic["MEMOSTYLEID"]); //model.MEMOTYPEID = Convert.ToDecimal(dic["MEMOTYPEID"]); //model.MEMOSUBTYPEID = Convert.ToDecimal(dic["MEMOSUBTYPEID"]); //model.BUSINESSID = Convert.ToDecimal(dic["BUSINESSID"]); //model.MEMOCONTENTID = Convert.ToDecimal(dic["MEMOCONTENTID"]); //model.INNERUSERID = Convert.ToDecimal(dic["INNERUSERID"]); //model.CTIME = Convert.ToDateTime(dic["CTIME"]); //model.CALLTIME = Convert.ToDateTime(dic["CALLTIME"]); //model.CALLTIMEEND = Convert.ToDateTime(dic["CALLTIMEEND"]); //model.ISCHECKED = Convert.ToInt16(dic["ISCHECKED"]); //model.MEMOID = Convert.ToDecimal(redis.Get("MEMOID")); //model.MTYPEID = Convert.ToDecimal(redis.Get("MTYPEID")); //model.RESID = redis.Get("RESID"); //model.MEMOSTYLEID = Convert.ToDecimal(redis.Get("MEMOSTYLEID")); //model.MEMOTYPEID = Convert.ToDecimal(redis.Get("MEMOTYPEID")); //model.MEMOSUBTYPEID = Convert.ToDecimal(redis.Get("MEMOSUBTYPEID")); //model.BUSINESSID = Convert.ToDecimal(redis.Get("BUSINESSID")); //model.MEMOCONTENTID = Convert.ToDecimal(redis.Get("MEMOCONTENTID")); //model.INNERUSERID = Convert.ToDecimal(redis.Get("INNERUSERID")); //model.CTIME = Convert.ToDateTime(redis.Get("CTIME")); //model.CALLTIME = Convert.ToDateTime(redis.Get("CALLTIME")); //model.CALLTIMEEND = Convert.ToDateTime(redis.Get("CALLTIMEEND")); //model.ISCHECKED = Convert.ToInt16(redis.Get("ISCHECKED")); return model; } else { var retModel = new cache_ord_memo_bl().GetInfo(memoid); return retModel; } } catch (Exception ex) { LogHelper.Error("GetList_CacheOrdMemo:" + ex.ToString()); return null; } } private async Task GetList_CacheOrdMemoAsync(decimal memoid) { try { string memo = double.Parse(memoid.ToString()).ToString(); string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(memo); RedisClass redis = new RedisClass(rediskey, RedisConfig.Redis1); CACHE_ORD_MEMO model = await redis.GetAsync(); return model; } catch (Exception ex) { LogHelper.Error(ex); return null; } } public List GetAll_CacheOrdMemo(decimal[] memoids, int IsTran = 1) { List list = new List(); foreach (decimal s in memoids) { var o = GetList_CacheOrdMemo(s, IsTran); if (o != null) list.Add(o); } return list.OrderByDescending(m => m.CTIME).ToList(); } public bool AddRedis_CacheOrdMemo(CACHE_ORD_MEMO entity) { try { if (isHasException) { #region redis 添加到待打包表 REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); redisMoel1.TABLETYPE = "cache_ord_memo"; redisMoel1.KEYS = entity.MEMOID.ToString(); redisMoel1.OPTYPE = "A"; redisMoel1.TIME = DateTime.Now; redisMoel1.LASTSYNCTIME = DateTime.Now; redisMoel1.ERRNUM = 0; redisMoel1.ERRMSG = ""; new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); return false; #endregion } string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.MEMOID.ToString()); RedisClass redis = new RedisClass(rediskey, RedisConfig.Redis1); redis.Set(entity); //AddRedis_CacheOrdMemoAsync(entity); return true; } catch (Exception ex) { LogHelper.Error("添加cache_ord_memo_redis出错:" + entity.MEMOID.ToString() + ":" + ex.Message.ToString() + ex.StackTrace.ToString()); return false; } } private async void AddRedis_CacheOrdMemoAsync(CACHE_ORD_MEMO entity) { string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.MEMOID.ToString()); RedisClass redis = new RedisClass(rediskey, RedisConfig.Redis1); await redis.SetAsync(entity); } public bool DeleteRedis_CacheOrdMemo(decimal memoid) { try { if (isHasException) { #region redis 添加到待打包表 REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); redisMoel1.TABLETYPE = "cache_ord_memo"; redisMoel1.KEYS = memoid.ToString(); redisMoel1.OPTYPE = "D"; redisMoel1.TIME = DateTime.Now; redisMoel1.LASTSYNCTIME = DateTime.Now; redisMoel1.ERRNUM = 0; redisMoel1.ERRMSG = ""; new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); #endregion return false; } string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(memoid.ToString()); RedisHash redis = new RedisHash(rediskey, RedisConfig.Redis1); return redis.Del(); } catch (Exception ex) { return false; } } #endregion #region resid_memoid_redis模块 public List GetList_MemoID(string resid, int IsTran = 1) { resid = String.Format("{0}", resid).Trim(); try { if (isHasException && IsTran != 1) return null; if (!isHasException) { string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(resid.ToString()); RedisSet redis = new RedisSet(rediskey, RedisConfig.Redis1); List list = redis.Members().ToList(); return list; } else { var list = new cache_ord_memo_bl().GetList_Memoid(resid); return list; } } catch (Exception ex) { return null; } } public List GetAll_MemoId(string[] resids, int IsTran = 1) { List list = new List(); foreach (string s in resids) { var o = GetList_MemoID(s, IsTran); if (o != null) list.AddRange(o); } return list; } public bool AddRedis_Resid_Memoid(string resid, decimal memoid) { try { if (isHasException) { #region redis 添加到待打包表 REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); redisMoel1.TABLETYPE = "resid_memoid_redis"; redisMoel1.KEYS = memoid.ToString(); redisMoel1.OPTYPE = "A"; redisMoel1.TIME = DateTime.Now; redisMoel1.LASTSYNCTIME = DateTime.Now; redisMoel1.ERRNUM = 0; redisMoel1.ERRMSG = ""; new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); #endregion return false; } string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(resid); RedisSet redis = new RedisSet(rediskey, RedisConfig.Redis1); return redis.Add(memoid.ToString()); } catch (Exception ex) { LogHelper.Error("添加resid_memoid_redis出错:" + resid + " - " + memoid.ToString() + ":" + ex.StackTrace.ToString()); return false; } } public bool DeleteRedis_Resid_Memoid(string resid, decimal memoid) { try { if (isHasException) { #region redis 添加到待打包表 REDIS_CACHE_SSODATASYNC redisMoel1 = new REDIS_CACHE_SSODATASYNC(); redisMoel1.TABLETYPE = "resid_memoid_redis"; redisMoel1.KEYS = memoid.ToString(); redisMoel1.OPTYPE = "D"; redisMoel1.TIME = DateTime.Now; redisMoel1.LASTSYNCTIME = DateTime.Now; redisMoel1.ERRNUM = 0; redisMoel1.ERRMSG = ""; new REDIS_CACHE_SSODATASYNC_BL().Create_RedisCacheSSODataSYNC(redisMoel1); #endregion return false; } string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(resid); RedisSet redis = new RedisSet(RedisConfig.Redis1); return redis.Remove(rediskey, memoid.ToString()); } catch (Exception ex) { return false; } } #endregion #region 出局资源 public bool AddRedis_Res_CallOutCustomer(RES_CALLOUTCUSTOMER entity) { try { if (isHasException) return false; string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(entity.RESID + "_" + entity.CALLOUTTYPE); RedisHelper redis = new RedisHelper(); return redis.AddToCache(rediskey, entity); } catch (Exception ex) { return false; } } public bool RemoveRedis_Res_CallOutCustomer(string key) { try { if (isHasException) return false; string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey(key); RedisHelper redis = new RedisHelper(); return redis.DeleteCache(rediskey); } catch (Exception ex) { return false; } } #endregion } }