66 lines
2.2 KiB
C#
66 lines
2.2 KiB
C#
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 bas_config_bll
|
|
{
|
|
private string comcode;
|
|
public bas_config_bll(string _comcode)
|
|
{
|
|
comcode = _comcode;
|
|
}
|
|
/// <summary>
|
|
/// 获取配置
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public bas_config GetConfig(BasConfigEnum config)
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode, false))
|
|
{
|
|
return con.QueryFirstOrDefault<bas_config>("select code,value from bas_config where code=@code", new { code = config.ToString() });
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取需要补充的关键字数据
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public int GetIntConfig(BasConfigEnum config)
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode, false))
|
|
{
|
|
bas_config co = con.QueryFirstOrDefault<bas_config>("select code,value from bas_config where code=@code", new { code = config.ToString() });
|
|
return co == null ? 0 : Convert.ToInt32(co.value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取当前消息库的消息表列表
|
|
/// </summary>
|
|
/// <param name="corpid"></param>
|
|
/// <returns></returns>
|
|
public List<corptable> GetCorpTable(string corpid)
|
|
{
|
|
using (IDbConnection con = ConnectionFactory.CreateConnection(ContextType.qwContext, comcode, false))
|
|
{
|
|
string sql = @"select TABLE_NAME table_name from information_schema.`TABLES`
|
|
where table_schema=@dbname
|
|
and table_name REGEXP'^ww_message_[0-9]{6}'
|
|
and table_name<=@nowtablename
|
|
order by TABLE_NAME ASC";
|
|
return con.Query<corptable>(sql, new
|
|
{
|
|
dbname = string.Format("wework_{0}", corpid),
|
|
nowtablename = string.Format("ww_message_{0}", DateTime.Now.ToString("yyyyMM"))
|
|
}, buffered: false).ToList();
|
|
}
|
|
}
|
|
}
|
|
} |