ComplianceServer/oldcode/BLL/RedisBL/RES_CUSTOMER_REDIS_BL.cs

72 lines
2.5 KiB
C#

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<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;
string rediskey = WX.CRM.Model.Redis.KeysDic.GetKey<RES_CUSTOMER>(resid);
RedisString<RES_CUSTOMER> redis = new RedisString<RES_CUSTOMER>(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<RES_CUSTOMER> GetList(string[] resids, int IsTran = 1)
{
List<RES_CUSTOMER> mlis = new List<RES_CUSTOMER>();
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<RES_CUSTOMER>(entity.RESID);
RedisHelper redis = new RedisHelper();
return redis.AddToCache(rediskey, entity);
}
catch (Exception ex)
{
return false;
}
}
}
}