TG.WXCRM.V4/BLL/Wx/WX_MESSAGECOMPLIANCE_BL.cs

118 lines
4.8 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using WX.CRM.BLL.Util;
using WX.CRM.Common;
using WX.CRM.DAL.Wx;
using WX.CRM.IBLL.Wx;
using WX.CRM.Model.Entity;
using WX.CRM.Model.MAP;
namespace WX.CRM.BLL.Wx
{
public class WX_MESSAGECOMPLIANCE_BL : DbContextRepository<WX_MESSAGECOMPLIANCE>, IWX_MESSAGECOMPLIANCE
{
WX_Message_DAL dal = new WX_Message_DAL();
public List<WX_MESSAGECOMPLIANCE_Extend> GetList(ref Pager pager, decimal? groupId, decimal? innerUserId, string[] customerUserNames, string jobUserName, string bigType, string subType, string stime, string etime)
{
using (var db = new crmContext())
{
var queryData = db.WX_MESSAGECOMPLIANCE.AsQueryable();
if (customerUserNames != null && customerUserNames.Length > 0)
{
queryData = queryData.Where(m => customerUserNames.Contains(m.USERNAME));
}
if (!string.IsNullOrWhiteSpace(jobUserName))
{
jobUserName = jobUserName.Trim();
queryData = queryData.Where(m => m.JOBUSERNAME == jobUserName);
}
if (!string.IsNullOrWhiteSpace(stime))
{
DateTime time1 = Convert.ToDateTime(stime);
queryData = queryData.Where(m => m.CTIME >= time1);
}
if (!string.IsNullOrWhiteSpace(etime))
{
DateTime time2 = Convert.ToDateTime(etime).AddDays(1);
queryData = queryData.Where(m => m.CTIME < time2);
}
//只要userid选中了就按userid查询
if (innerUserId.HasValue && innerUserId.Value > 0)
{
queryData = queryData.Where(m => m.INNERUSERID == innerUserId);
}
//当选择了组然后userid没选中的话按用户组查询
else if (groupId.HasValue && groupId.Value > 0)
{
decimal g = groupId.Value;
var returnData = (from a in queryData
join b in db.BAS_INNERUSERGROUP on a.INNERUSERID equals b.INNERUSERID
where b.GID == g
select a);
queryData = returnData;
}
if (!string.IsNullOrWhiteSpace(bigType) && bigType != "0")
{
queryData = queryData.Where(m => m.BIGTYPE == bigType);
}
if (!string.IsNullOrWhiteSpace(subType) && subType != "0")
{
queryData = queryData.Where(m => m.SUBTYPE == subType);
}
var queryData2 = db.WX_WORKACCOUNT.AsQueryable().Where(m => m.USERNAME != null);
var resultData = (from a in queryData
join b in queryData2 on a.JOBUSERNAME equals b.USERNAME into tmp0
from ab in tmp0.DefaultIfEmpty()
select new WX_MESSAGECOMPLIANCE_Extend
{
wx_MessageCompliance = a,
Alias = ab.ALIAS
});
resultData = resultData.OrderByDescending(m => m.wx_MessageCompliance.CTIME);
PagerUtil.SetPager<WX_MESSAGECOMPLIANCE_Extend>(ref resultData, ref pager);
return resultData.ToList();
}
}
public DataSet CountMessageCompliance(string stime, string etime)
{
return dal.CountMessageCompliance(stime, etime);
}
public DataSet CountMessageComplianceList(string typeCode, string stime, string etime)
{
return dal.CountMessageComplianceList(typeCode, stime, etime);
}
public List<WX_MESSAGECOMPLIANCE> GetList(ref Pager pager, decimal type)
{
using (var db = new crmContext())
{
var queryData = db.WX_MESSAGECOMPLIANCE.AsQueryable();
queryData = queryData.Where(m => m.TYPE == type);
queryData = queryData.OrderBy(m => m.CTIME);
PagerUtil.SetPager<WX_MESSAGECOMPLIANCE>(ref queryData, ref pager);
return queryData.ToList();
}
}
public bool DeleteMessage(ref ValidationErrors errors, decimal id)
{
return dal.DeleteMessage(ref errors, id);
}
public void DeleteMessageIsIllegal(string tableName, string userName, string msgSvrid)
{
dal.DeleteMessageIsIllegal(tableName, userName, msgSvrid);
}
}
}