EPLAN_PROD_Plugin/Sinvo.EplanHpD.Plugin.Service/DBHelper.cs

52 lines
1.7 KiB
C#
Raw Normal View History

using SqlSugar;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sinvo.EplanHpD.Plugin.Service
{
public class DBHelper
{
private static string _dbUser = "sa";
2025-01-23 09:04:38 +08:00
#if DEBUG
private static string _dbServer = "192.168.91.130";
private static string _dbPassword = "Sa1234";
#else
private static string _dbPassword = "SA@9512";
private static string _dbServer = "192.168.1.223";
2025-01-23 09:04:38 +08:00
#endif
private static string _dbName = "MotorData";
private static string _connectionString => $"Server={_dbServer};Database={_dbName};User Id={_dbUser};Password={_dbPassword};";
private static SqlSugarClient _db;
public static SqlSugarClient DB
{
get
{
_db = new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = _connectionString,
DbType = DbType.SqlServer,
IsAutoCloseConnection = true,
2024-12-23 11:56:17 +08:00
InitKeyType = InitKeyType.Attribute,
});
return _db;
}
}
2024-12-23 11:56:17 +08:00
public void CodeFirst()
{
DB.CodeFirst.InitTables(typeof(Model.MotorDataModel));
DB.CodeFirst.InitTables(typeof(Model.Motor));
DB.CodeFirst.InitTables(typeof(Model.CableLectotype));
DB.CodeFirst.InitTables(typeof(Model.LectotypeLine));
DB.CodeFirst.InitTables(typeof(Model.MultiCoreWireLecDBModel));
DB.CodeFirst.InitTables(typeof(Model.MultiWireCoreDataModel));
2024-12-23 11:56:17 +08:00
}
}
}