945 lines
37 KiB
C#
945 lines
37 KiB
C#
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<string>(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<bool> TestRedisConnectAsync()
|
||
{
|
||
try
|
||
{
|
||
RedisHelper redis = new Redis.RedisHelper();
|
||
string rediskey = "gjs_customer:001";
|
||
await redis.GetAsync<string>(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<RES_CUSTOMER>(resid);
|
||
RES_CUSTOMER model = redis.Get<RES_CUSTOMER>(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<RES_CUSTOMER> GetList_Res_Customer(string[] resids, int IsTran = 1)
|
||
{
|
||
List<RES_CUSTOMER> mlis = new List<RES_CUSTOMER>();
|
||
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<RES_CUSTOMER>(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<RES_CUSTOMERDETAIL>(resid);
|
||
RES_CUSTOMERDETAIL model = redis.Get<RES_CUSTOMERDETAIL>(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<RES_CUSTOMERDETAIL>(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<GJS_CUSTOMER>(tradecode);
|
||
// GJS_CUSTOMER model = redis.Get<GJS_CUSTOMER>(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<GJS_CUSTOMER> GetList_Gjs_Customer(string[] resids, int IsTran = 1)
|
||
//{
|
||
// List<GJS_CUSTOMER> list = new List<GJS_CUSTOMER>();
|
||
|
||
// 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<GJS_CUSTOMER>(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<GJS_CUSTOMERBOCE>(tradecode);
|
||
// GJS_CUSTOMERBOCE model = redis.Get<GJS_CUSTOMERBOCE>(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<GJS_CUSTOMERBOCE>(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<SOFT_USER>(username);
|
||
SOFT_USER model = redis.Get<SOFT_USER>(rediskey);
|
||
return model;
|
||
}
|
||
else
|
||
{
|
||
var retModel = new SOFT_USER_BL().GetUser_userName(username);
|
||
return retModel;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return null;
|
||
}
|
||
}
|
||
|
||
public List<SOFT_USER> GetList_Soft_User(string[] usernames, int IsTran = 1)
|
||
{
|
||
List<SOFT_USER> list = new List<SOFT_USER>();
|
||
|
||
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<SOFT_USER>(entity.USERNAME);
|
||
RedisHelper redis = new RedisHelper();
|
||
return redis.AddToCache(rediskey, entity);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region res_customeruser_resid模块
|
||
public List<RES_CUSTOMERUSER> 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<RES_CUSTOMERUSER_RESID>(resid);
|
||
RedisList<RES_CUSTOMERUSER> redis = new RedisList<RES_CUSTOMERUSER>(rediskey);
|
||
List<RES_CUSTOMERUSER> 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<RES_CUSTOMERUSER> GetAll_Res_Customeruser_Resid(string[] resids, int IsTran = 1)
|
||
{
|
||
List<RES_CUSTOMERUSER> list = new List<RES_CUSTOMERUSER>();
|
||
|
||
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<RES_CUSTOMERUSER_RESID>(entity.RESID);
|
||
RedisList<RES_CUSTOMERUSER> redis = new RedisList<RES_CUSTOMERUSER>(rediskey);
|
||
return redis.LeftPush(entity);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return 0;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region res_customeruser_username模块
|
||
public List<RES_CUSTOMERUSER> 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<RES_CUSTOMERUSER_USERNAME>(username);
|
||
RedisList<RES_CUSTOMERUSER> redis = new RedisList<RES_CUSTOMERUSER>(rediskey);
|
||
List<RES_CUSTOMERUSER> 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<RES_CUSTOMERUSER> GetAll_Res_Customeruser_Username(string[] usernames, int IsTran = 1)
|
||
{
|
||
List<RES_CUSTOMERUSER> list = new List<RES_CUSTOMERUSER>();
|
||
|
||
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<RES_CUSTOMERUSER_USERNAME>(entity.USERNAME);
|
||
RedisList<RES_CUSTOMERUSER> redis = new RedisList<RES_CUSTOMERUSER>(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<ORD_MEMOCONTENT>(content);
|
||
RedisClass<ORD_MEMOCONTENT> redis = new RedisClass<ORD_MEMOCONTENT>(rediskey, RedisConfig.Redis1);
|
||
ORD_MEMOCONTENT model = redis.Get();
|
||
//RedisHash<string> redis = new RedisHash<string>(rediskey, RedisConfig.Redis1);
|
||
//Dictionary<string, string> dic = redis.GetALL<string>();
|
||
//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<ORD_MEMOCONTENT> GetList_Ord_Memocontent(decimal[] contentids, int IsTran = 1)
|
||
{
|
||
List<ORD_MEMOCONTENT> list = new List<ORD_MEMOCONTENT>();
|
||
|
||
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<ORD_MEMOCONTENT>(entity.CONTENTID.ToString());
|
||
RedisClass<ORD_MEMOCONTENT> redis = new RedisClass<ORD_MEMOCONTENT>(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<ORD_MEMOCONTENT>(contentid.ToString());
|
||
RedisHash<ORD_MEMOCONTENT> redis = new RedisHash<ORD_MEMOCONTENT>(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<CACHE_ORD_MEMO>(memo);
|
||
RedisClass<CACHE_ORD_MEMO> redis = new RedisClass<CACHE_ORD_MEMO>(rediskey, RedisConfig.Redis1);
|
||
CACHE_ORD_MEMO model = redis.Get();
|
||
|
||
//RedisHash<string> redis = new RedisHash<string>(rediskey, RedisConfig.Redis1);
|
||
//Dictionary<string, string> dic = redis.GetALL<string>();
|
||
//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<string>("MEMOID"));
|
||
//model.MTYPEID = Convert.ToDecimal(redis.Get<string>("MTYPEID"));
|
||
//model.RESID = redis.Get<string>("RESID");
|
||
//model.MEMOSTYLEID = Convert.ToDecimal(redis.Get<string>("MEMOSTYLEID"));
|
||
//model.MEMOTYPEID = Convert.ToDecimal(redis.Get<string>("MEMOTYPEID"));
|
||
//model.MEMOSUBTYPEID = Convert.ToDecimal(redis.Get<string>("MEMOSUBTYPEID"));
|
||
//model.BUSINESSID = Convert.ToDecimal(redis.Get<string>("BUSINESSID"));
|
||
//model.MEMOCONTENTID = Convert.ToDecimal(redis.Get<string>("MEMOCONTENTID"));
|
||
//model.INNERUSERID = Convert.ToDecimal(redis.Get<string>("INNERUSERID"));
|
||
//model.CTIME = Convert.ToDateTime(redis.Get<string>("CTIME"));
|
||
//model.CALLTIME = Convert.ToDateTime(redis.Get<string>("CALLTIME"));
|
||
//model.CALLTIMEEND = Convert.ToDateTime(redis.Get<string>("CALLTIMEEND"));
|
||
//model.ISCHECKED = Convert.ToInt16(redis.Get<string>("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<CACHE_ORD_MEMO> GetList_CacheOrdMemoAsync(decimal memoid)
|
||
{
|
||
try
|
||
{
|
||
string memo = double.Parse(memoid.ToString()).ToString();
|
||
string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey<CACHE_ORD_MEMO>(memo);
|
||
RedisClass<CACHE_ORD_MEMO> redis = new RedisClass<CACHE_ORD_MEMO>(rediskey, RedisConfig.Redis1);
|
||
CACHE_ORD_MEMO model = await redis.GetAsync();
|
||
return model;
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
LogHelper.Error(ex);
|
||
return null;
|
||
}
|
||
}
|
||
public List<CACHE_ORD_MEMO> GetAll_CacheOrdMemo(decimal[] memoids, int IsTran = 1)
|
||
{
|
||
List<CACHE_ORD_MEMO> list = new List<CACHE_ORD_MEMO>();
|
||
|
||
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<CACHE_ORD_MEMO>(entity.MEMOID.ToString());
|
||
RedisClass<CACHE_ORD_MEMO> redis = new RedisClass<CACHE_ORD_MEMO>(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<CACHE_ORD_MEMO>(entity.MEMOID.ToString());
|
||
RedisClass<CACHE_ORD_MEMO> redis = new RedisClass<CACHE_ORD_MEMO>(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<CACHE_ORD_MEMO>(memoid.ToString());
|
||
RedisHash<CACHE_ORD_MEMO> redis = new RedisHash<CACHE_ORD_MEMO>(rediskey, RedisConfig.Redis1);
|
||
return redis.Del();
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region resid_memoid_redis模块
|
||
public List<decimal> 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_MEMOID_REDIS>(resid.ToString());
|
||
RedisSet<decimal> redis = new RedisSet<decimal>(rediskey, RedisConfig.Redis1);
|
||
List<decimal> list = redis.Members().ToList<decimal>();
|
||
return list;
|
||
}
|
||
else
|
||
{
|
||
var list = new cache_ord_memo_bl().GetList_Memoid(resid);
|
||
return list;
|
||
}
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return null;
|
||
}
|
||
}
|
||
|
||
public List<decimal> GetAll_MemoId(string[] resids, int IsTran = 1)
|
||
{
|
||
List<decimal> list = new List<decimal>();
|
||
|
||
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_MEMOID_REDIS>(resid);
|
||
RedisSet<string> redis = new RedisSet<string>(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_MEMOID_REDIS>(resid);
|
||
RedisSet<string> redis = new RedisSet<string>(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<RES_CALLOUTCUSTOMER>(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<RES_CALLOUTCUSTOMER>(key);
|
||
RedisHelper redis = new RedisHelper();
|
||
return redis.DeleteCache(rediskey);
|
||
}
|
||
catch (Exception ex)
|
||
{
|
||
return false;
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
}
|