using Dapper; using NetCore.Model.enums; using NetCore.Model.qw; using System; using System.Collections.Generic; using System.Data; using System.Linq; namespace NetCore.BLL { public class ww_message_bll { private string comcode; public ww_message_bll(string _comcode) { comcode = _comcode; } /// /// 获取数据源 /// /// /// /// /// /// /// public List GetList(string tablename, string corpid, int clearcount, int seq, int cusmsgdeedhg, DateTime checkdate) { using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode)) { if (cusmsgdeedhg == 0)//客户发得消息,不做合规 { string sql = string.Format(@"select seq,msgid,msgtype,action,fromer,tolist,roomid,ext,content,nfile,msgtime,ctime from wework_{0}.{1} b where seq>@seq and ctime>@checkdate and ctime<@checkdateNext and msgtype in('text','voice') and (roomid ='' or roomid is null) and exists(select 1 from hg_orderuser a where a.external_userid=b.tolist) and exists(select 1 from hg_jobuser a where a.corpid='{0}' and a.userid=b.fromer) order by seq asc limit @count", corpid, tablename);//过滤掉,只执行订单客服消息 return con.Query(sql, new { seq, count = clearcount, checkdate, checkdateNext = checkdate.AddDays(1) }, buffered: false).ToList(); } else { string sql = string.Format(@"select seq,msgid,msgtype,action,fromer,tolist,roomid,ext,content,nfile,msgtime,ctime from wework_{0}.{1} b where seq>@seq and ctime>@checkdate and ctime<@checkdateNext and msgtype in('text','voice') and (roomid ='' or roomid is null) and exists(select 1 from hg_orderuser a where a.external_userid=b.tolist or a.external_userid=b.fromer) order by seq asc limit @count", corpid, tablename);//过滤掉,只执行订单客服消息 return con.Query(sql, new { seq, count = clearcount, checkdate, checkdateNext = checkdate.AddDays(1) }, buffered: false).ToList(); } } } } }