using HH.WCS.Hexafluo.util;
|
using HH.WCS.SJML.Dto;
|
using HH.WCS.ZCQTJ.Entitys;
|
using Newtonsoft.Json;
|
using SqlSugar;
|
using System;
|
|
namespace HH.WCS.ZCQTJ.util
|
{
|
public class SqlServerList
|
{
|
public OperateResult SqlConnect(string ConfigId)
|
{
|
var oop = SqlSugarHelper.conn;
|
if (oop.FindAll(e => e.ConfigId.ToString() == ConfigId).Count == 0)
|
{
|
//查询表 然后加入到连接池里
|
var Alone = SqlSugarHelper.Db.Queryable<SqlCountEntitys>().Where(e => e.ConfigId == ConfigId)?.First();
|
if (Alone != null)
|
{
|
SqlSugarHelper.conn.Add(new ConnectionConfig()
|
{
|
ConfigId = Alone.ConfigId,
|
DbType = DbType.SqlServer,
|
ConnectionString = Alone.ConnectionString,
|
IsAutoCloseConnection = true,
|
InitKeyType = InitKeyType.Attribute
|
});
|
}
|
}
|
|
return OperateResult.Succeed();
|
}
|
/// <summary>
|
/// 初始化
|
/// </summary>
|
/// <returns></returns>
|
public OperateResult SqlConnectC()
|
{
|
var Alone = SqlSugarHelper.Db.Queryable<SqlCountEntitys>().ToList();
|
foreach (var item in Alone)
|
{
|
SqlSugarHelper.conn.Add(new ConnectionConfig()
|
{
|
ConfigId = item.ConfigId,
|
DbType = DbType.SqlServer,
|
ConnectionString = item.ConnectionString,
|
IsAutoCloseConnection = true,
|
InitKeyType = InitKeyType.Attribute
|
});
|
}
|
foreach (var item in SqlSugarHelper.conn)
|
{
|
Console.WriteLine($"sql连接池 {JsonConvert.SerializeObject(item)}");
|
}
|
//查询表 然后吧sql语句加到连接池中
|
return OperateResult.Succeed();
|
}
|
}
|
}
|