64 lines
2.4 KiB
C#
64 lines
2.4 KiB
C#
using Dapper;
|
|
using NetCore.Model.enums;
|
|
using NetCore.Model.wx;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
|
|
namespace NetCore.BLL.wx
|
|
{
|
|
public class wx_message_bll
|
|
{
|
|
private string comcode;
|
|
public wx_message_bll(string _comcode)
|
|
{
|
|
comcode = _comcode;
|
|
}
|
|
/// <summary>
|
|
/// 获取数据源(已兼容)
|
|
/// </summary>
|
|
/// <param name="tablename"></param>
|
|
/// <param name="corpid"></param>
|
|
/// <param name="clearcount"></param>
|
|
/// <param name="seq"></param>
|
|
/// <param name="cusmsgdeedhg"></param>
|
|
/// <returns></returns>
|
|
public List<wx_message> GetList(string tablename, int clearcount, int pkid, int cusmsgdeedhg, DateTime checkdate)
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.wxContext, comcode))
|
|
{
|
|
string contype = con.GetType().Name.ToLower();
|
|
string sql = string.Empty;
|
|
if (contype.Contains("sqlconnection"))
|
|
{
|
|
|
|
sql = string.Format(@"SELECT top {0} pkid,msgid,msgsvrid,status,issend,createtime,talker,imgpath,username,nickname,ctime,msgtype,msgcontent FROM WxMessage.dbo.{1} b
|
|
where pkid>@pkid
|
|
and ctime>@checkdate
|
|
and ctime<@checkdateNext
|
|
and msgtype in(1,34)
|
|
{2}
|
|
and exists(select 1 from hg_orderuser a where a.username=b.talker)
|
|
and exists(select 1 from hg_jobalias a where a.jobusername=b.username)
|
|
order by pkid asc", clearcount, tablename, (cusmsgdeedhg == 0 ? "and issend=1" : ""));//过滤掉,只执行订单客服消息
|
|
}
|
|
else if (contype.Contains("mysql"))
|
|
{
|
|
|
|
sql = string.Format(@"SELECT pkid,msgid,msgsvrid,status,issend,createtime,talker,imgpath,username,nickname,ctime,msgtype,msgcontent FROM WxMessage.{1} b
|
|
where pkid>@pkid
|
|
and ctime>@checkdate
|
|
and ctime<@checkdateNext
|
|
and msgtype in(1,34)
|
|
{2}
|
|
and exists(select 1 from hg_orderuser a where a.username=b.talker)
|
|
and exists(select 1 from hg_jobalias a where a.jobusername=b.username)
|
|
order by pkid asc limit {0} ", clearcount, tablename, (cusmsgdeedhg == 0 ? "and issend=1" : ""));//过滤掉,只执行订单客服消息
|
|
}
|
|
return con.Query<wx_message>(sql, new { pkid, checkdate, checkdateNext = checkdate.AddDays(1) }, buffered: false).ToList();
|
|
|
|
}
|
|
}
|
|
}
|
|
} |