创建了PLC相关的文件
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace PMSWPF.Data
|
||||
{
|
||||
internal class DbContext
|
||||
public class DbContext
|
||||
{
|
||||
private static SqlSugarClient _db;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace PMSWPF.Data
|
||||
{
|
||||
if (_db == null)
|
||||
{
|
||||
string connectionString = "server=127.0.0.1;port=3306;user=root;password=Pgw15221236646; database=PMS;";
|
||||
string connectionString = "server=127.0.0.1;port=3306;user=root;password=Pgw15221236646; database=pmswpf;";
|
||||
_db = new SqlSugarClient(new ConnectionConfig()
|
||||
{
|
||||
ConnectionString = connectionString,
|
||||
|
||||
64
Data/Entities/PLC.cs
Normal file
64
Data/Entities/PLC.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
using PMSWPF.Enums;
|
||||
using SqlSugar;
|
||||
using SqlSugar.DbConvert;
|
||||
|
||||
namespace PMSWPF.Data.Entities
|
||||
{
|
||||
public class PLC
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]//数据库是自增才配自增
|
||||
public int id { get; set; }
|
||||
/// <summary>
|
||||
/// PLC名称
|
||||
/// </summary>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// PLC品牌
|
||||
/// </summary>
|
||||
/// //新版本:存储字符串 SqlSugar 5.1.4.66-preview02
|
||||
[SugarColumn(ColumnDataType = "varchar(30)", SqlParameterDbType = typeof(EnumToStringConvert))]
|
||||
public PlcBrand PlcBrand { get; set; }
|
||||
/// <summary>
|
||||
/// PLC类型
|
||||
/// </summary>
|
||||
public int CpuType { get; set; }
|
||||
/// <summary>
|
||||
/// PLC节点ID
|
||||
/// </summary>
|
||||
public string NodeID { get; set; }
|
||||
/// <summary>
|
||||
/// PLC IP地址
|
||||
/// </summary>
|
||||
public string IP { get; set; }
|
||||
/// <summary>
|
||||
/// PLC状态
|
||||
/// </summary>
|
||||
public string Status { get; set; }
|
||||
/// <summary>
|
||||
/// PLC连接类型
|
||||
/// </summary>
|
||||
public string ConnType { get; set; }
|
||||
/// <summary>
|
||||
/// PLC连接时间
|
||||
/// </summary>
|
||||
public DateTime ConnTime { get; set; }
|
||||
/// <summary>
|
||||
/// 是否启用
|
||||
/// </summary>
|
||||
public bool IsEnable { get; set; }
|
||||
|
||||
public PLC()
|
||||
{
|
||||
|
||||
}
|
||||
public PLC(string name = "", string nodeID = "", string ip = "", string status = "", string connType = "")
|
||||
{
|
||||
this.Name = name;
|
||||
this.NodeID = nodeID;
|
||||
this.IP = ip;
|
||||
this.Status = status;
|
||||
this.ConnType = connType;
|
||||
this.ConnTime = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
21
Data/Repositories/PlcRepositories.cs
Normal file
21
Data/Repositories/PlcRepositories.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using PMSWPF.Data.Entities;
|
||||
using SqlSugar;
|
||||
|
||||
namespace PMSWPF.Data.Repositories
|
||||
{
|
||||
internal class PlcRepositories
|
||||
{
|
||||
private SqlSugarClient _db;
|
||||
|
||||
public PlcRepositories()
|
||||
{
|
||||
|
||||
_db = DbContext.GetInstance();
|
||||
var tabExist = _db.DbMaintenance.IsAnyTable(nameof(PLC), false);
|
||||
if (tabExist)
|
||||
{
|
||||
_db.CodeFirst.InitTables<PLC>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user