109 lines
3.3 KiB
C#
109 lines
3.3 KiB
C#
using System;
|
|
using System.Data.Entity.Validation;
|
|
using System.Linq;
|
|
using WX.CRM.BLL.Base;
|
|
using WX.CRM.BLL.Util;
|
|
using WX.CRM.Common;
|
|
using WX.CRM.DAL.Wx;
|
|
using WX.CRM.Model.Entity;
|
|
|
|
namespace WX.CRM.BLL.Wx
|
|
{
|
|
public class WX_DBRECIVE_BL : IWX_DBRECIVE
|
|
{
|
|
public bool Create(WX_DBRECIVE model)
|
|
{
|
|
try
|
|
{
|
|
using (crmContext db = new crmContext())
|
|
{
|
|
SEQUENCES_BL pkidBll = new SEQUENCES_BL();
|
|
model.PKID = pkidBll.Seq_base_get();
|
|
db.WX_DBRECIVE.Add(model);
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
}
|
|
catch (DbEntityValidationException ex)
|
|
{
|
|
string msg = "";
|
|
foreach (var validationErrors in ex.EntityValidationErrors)
|
|
{
|
|
msg += validationErrors.Entry.Entity.ToString();
|
|
foreach (var validationError in validationErrors.ValidationErrors)
|
|
{
|
|
msg += string.Format("。Property:{0} Error:{1}", validationError.PropertyName, validationError.ErrorMessage) + Environment.NewLine;
|
|
}
|
|
}
|
|
LogHelper.Error(ex);
|
|
LogHelper.Error(msg);
|
|
return false;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogHelper.Error(ex);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public WX_DBRECIVE GetNoHandler()
|
|
{
|
|
try
|
|
{
|
|
using (crmContext db = new crmContext())
|
|
{
|
|
return db.WX_DBRECIVE.Where(obj => obj.STATUS == 0).OrderBy(obj => obj.CTIME).Take(1).FirstOrDefault();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.Message + ex.StackTrace);
|
|
LogHelper.Error(ex);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public bool UpdateStatus(decimal pkid, int status)
|
|
{
|
|
try
|
|
{
|
|
using (crmContext db = new crmContext())
|
|
{
|
|
var model = db.WX_DBRECIVE.FirstOrDefault(obj => obj.PKID == pkid);
|
|
if (null != model)
|
|
{
|
|
model.STATUS = status;
|
|
return db.SaveChanges().GetResult();
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Console.WriteLine(ex.Message + ex.StackTrace);
|
|
LogHelper.Error(ex);
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public bool ImportWxBizInfo(decimal pkid, out string errmsg)
|
|
{
|
|
return new WX_DBRECIVE_DAL().ImportWxBizInfo(pkid, out errmsg);
|
|
}
|
|
|
|
public bool ImportWxRContact(decimal pkid, out string errmsg)
|
|
{
|
|
return new WX_DBRECIVE_DAL().ImportWxRContact(pkid, out errmsg);
|
|
}
|
|
|
|
public bool ImportWxMessage(decimal pkid, out string errmsg)
|
|
{
|
|
return new WX_DBRECIVE_DAL().ImportWxMessage(pkid, out errmsg);
|
|
}
|
|
|
|
public bool ImportWxJobBizInfo(decimal pkid, out string errmsg)
|
|
{
|
|
return new WX_DBRECIVE_DAL().ImportWxJobBizInfo(pkid, out errmsg);
|
|
}
|
|
}
|
|
}
|