2024-12-03 11:50:36 +08:00
|
|
|
|
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
|
2025-01-13 17:12:53 +08:00
|
|
|
|
private static string _dbPassword = "SA@9512";
|
|
|
|
|
private static string _dbServer = "192.168.1.223";
|
2025-01-23 09:04:38 +08:00
|
|
|
|
#endif
|
2024-12-03 11:50:36 +08:00
|
|
|
|
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,
|
|
|
|
|
|
2024-12-03 11:50:36 +08:00
|
|
|
|
});
|
|
|
|
|
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));
|
2025-04-24 14:22:46 +08:00
|
|
|
|
DB.CodeFirst.InitTables(typeof(Model.MultiCoreWireLecDBModel));
|
2025-05-06 11:06:39 +08:00
|
|
|
|
DB.CodeFirst.InitTables(typeof(Model.MultiWireCoreDataModel));
|
2024-12-23 11:56:17 +08:00
|
|
|
|
}
|
2024-12-03 11:50:36 +08:00
|
|
|
|
}
|
|
|
|
|
}
|