|
|
|
|
|
using SlnMesnac.RfidUpload.NLog;
|
|
|
using SqlSugar;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text;
|
|
|
|
|
|
#region << 版 本 注 释 >>
|
|
|
/*--------------------------------------------------------------------
|
|
|
* 版权所有 (c) 2024 WenJY 保留所有权利。
|
|
|
* CLR版本:4.0.30319.42000
|
|
|
* 机器名称:T14-GEN3-7895
|
|
|
* 命名空间:slnmesnac.rfidupload.Repository
|
|
|
* 唯一标识:af6b459e-40d9-4e83-97e6-0b17f28044e5
|
|
|
*
|
|
|
* 创建者:WenJY
|
|
|
* 电子邮箱:
|
|
|
* 创建时间:2024-12-06 9:01:34
|
|
|
* 版本:V1.0.0
|
|
|
* 描述:
|
|
|
*
|
|
|
*--------------------------------------------------------------------
|
|
|
* 修改人:
|
|
|
* 时间:
|
|
|
* 修改说明:
|
|
|
*
|
|
|
* 版本:V1.0.0
|
|
|
*--------------------------------------------------------------------*/
|
|
|
#endregion << 版 本 注 释 >>
|
|
|
namespace slnmesnac.rfidupload.Repository
|
|
|
{
|
|
|
internal class SqlSugarHelper
|
|
|
{
|
|
|
#region 连接字符串
|
|
|
/**
|
|
|
* Sqlite:获取debug路径下的数据库文件,不建议直接写死路径
|
|
|
* private static string sqliteConnStr = $"Data Source={Path.GetFullPath("data\\data.db")};Version=3";
|
|
|
*/
|
|
|
private static string sqliteConnStr = "Data Source=Z:\\Desktop\\日常代码\\HighWayIot\\HighWayIot\\bin\\Debug\\data\\data.db;Version=3";
|
|
|
|
|
|
/**
|
|
|
* Mysql
|
|
|
*/
|
|
|
private static string mysqlConnStr = "Data Source=124.70.63.37;Port=6000;Initial Catalog=ry-cloud;uid=root;pwd=haiwei@123;Charset=utf8mb4;SslMode=none";
|
|
|
|
|
|
private static string oracleConnStr = "Data Source=175.27.215.92/helowin;User ID=aucma_mes;Password=aucma";
|
|
|
#endregion
|
|
|
|
|
|
private static LogHelper logHelper = LogHelper.Instance;
|
|
|
|
|
|
//如果是固定多库可以传 new SqlSugarScope(List<ConnectionConfig>,db=>{}) 文档:多租户
|
|
|
//如果是不固定多库 可以看文档Saas分库
|
|
|
|
|
|
//用单例模式
|
|
|
public static SqlSugarScope Db = new SqlSugarScope(new List<ConnectionConfig>()
|
|
|
{
|
|
|
new ConnectionConfig()
|
|
|
{
|
|
|
ConfigId = "sqlite",
|
|
|
ConnectionString = sqliteConnStr,
|
|
|
DbType = DbType.Sqlite,
|
|
|
InitKeyType = InitKeyType.Attribute,
|
|
|
IsAutoCloseConnection = true
|
|
|
}
|
|
|
},
|
|
|
db =>
|
|
|
{
|
|
|
//(A)全局生效配置点
|
|
|
//调试SQL事件,可以删掉
|
|
|
db.Aop.OnLogExecuting = (sql, pars) =>
|
|
|
{
|
|
|
//logHelper.SqlLog($"{sql};参数:{jsonChange.ModeToJson(pars)}");
|
|
|
};
|
|
|
});
|
|
|
|
|
|
}
|
|
|
} |