79 lines
2.7 KiB
C#
79 lines
2.7 KiB
C#
using System;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Base;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.IBLL.Res;
|
|
|
|
namespace WX.CRM.BLL.Res
|
|
{
|
|
public class RES_APPLY_BL : IRES_APPLY
|
|
{
|
|
string clientid = Utility.GetSettingByKey("CRMClientKey");
|
|
WX.CRM.IBLL.Util.ISecurityHelper sHelper = new SecurityHelper();
|
|
CACHE_BL _cache = new CACHE_BL();
|
|
|
|
ValidationErrors errors = new ValidationErrors();
|
|
public bool Create(ref ValidationErrors errors, WX.CRM.Model.Entity.RES_APPLY model)
|
|
{
|
|
//try
|
|
//{
|
|
// var url = _cache.GetValue_Parameter("UserCenterAccountUrl");
|
|
// if (!string.IsNullOrEmpty(url))
|
|
// {
|
|
// var rsp = Utility.HttpPostData(url, "mobile=" + model.MOBILE, Encoding.UTF8);
|
|
// var ret = JsonConvert.DeserializeAnonymousType(rsp, new { ret = 0, msg = string.Empty, list = new List<AccountInfo>() { } });
|
|
|
|
// foreach (var item in ret.list)
|
|
// {
|
|
// if (item.appid.EndsWith("_1"))
|
|
// {
|
|
// model.SOURCETYPE = 4;
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// LogHelper.Error("验证资源是否企微客户:" + ex.ToString());
|
|
//}
|
|
|
|
try
|
|
{
|
|
using (WX.CRM.Model.Entity.crmContext db = new WX.CRM.Model.Entity.crmContext())
|
|
{
|
|
var entry = db.RES_APPLY.FirstOrDefault(m => m.PKID == model.PKID);
|
|
if (entry != null)
|
|
{
|
|
errors.Add("该编码已经被占用!");
|
|
return false;
|
|
}
|
|
model.PKID = new SEQUENCES_BL().Seq_base_get();
|
|
model.CTIME = DateTime.Now;
|
|
model.ENMOBILE = Utility.NumberFormat(model.MOBILE);
|
|
model.MOBILE = sHelper.encyptData(clientid, model.MOBILE);
|
|
db.RES_APPLY.Add(model);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
errors.Add(ex.Message);
|
|
LogHelper.Error(ex.Message + "|" + ex.StackTrace);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private class AccountInfo
|
|
{
|
|
public string appid { get; set; }
|
|
public string appuserid { get; set; }
|
|
public int uid { get; set; }
|
|
public string mobile { get; set; }
|
|
public string unionid { get; set; }
|
|
public string ctime { get; set; }
|
|
}
|
|
|
|
}
|
|
}
|