yangw
nodyang@aliyun.com 2 months ago
parent 66869df649
commit 9fbb4ad5d9

@ -101,11 +101,14 @@
<ItemGroup>
<Compile Include="DbCommandInterceptor.cs" />
<Compile Include="DbFactory.cs" />
<Compile Include="Entity\Log.cs" />
<Compile Include="Entity\Point.cs" />
<Compile Include="Entity\Role.cs" />
<Compile Include="Entity\User.cs" />
<Compile Include="MappingHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SystemEntityTypeBuilder.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>
<ProjectReference Include="..\Tool\Tool.csproj">
<Project>{a49bc7e3-39b7-4f68-8780-fb4da3461aff}</Project>

@ -23,7 +23,7 @@ namespace DB
return conn;
});
context.Options.ConvertToLowercase = false;
context.Options.ConvertToLowercase = true;
return context;
}
}

@ -0,0 +1,24 @@
namespace DB.Entity
{
public class Log:BaseChimsDb
{
public string LogLevel { get; set; }
public string Msg { get; set; }
/// <summary>
/// 1到100 系统功能日志
/// 400 系统错误日志
///
/// </summary>
public short LogType { get; set; }
}
public class LogMapper : SystemEntityTypeBuilder<Log>
{
public LogMapper() : base("Log")
{
}
}
}

@ -0,0 +1,27 @@
namespace DB.Entity
{
public class Point:BaseChimsDb
{
/// <summary>
/// plc 点位名称
/// </summary>
public string PointName { get; set; }
/// <summary>
/// plc 点位地址
/// </summary>
public string PointAddress { get; set; }
/// <summary>
/// plc 数据类型 bool float int bit
/// </summary>
public string DataType { get; set; }
}
public class PointMapper : SystemEntityTypeBuilder<Point>
{
public PointMapper() : base("Point")
{
}
}
}

@ -0,0 +1,19 @@
namespace DB.Entity
{
public class Role:BaseChimsDb
{
public string RoleName { get; set; }
public short RoleLevel { get; set; }
}
public class RoleMapper : SystemEntityTypeBuilder<Role>
{
public RoleMapper() : base("role")
{
}
}
}

@ -0,0 +1,17 @@
namespace DB.Entity
{
public class User:BaseChimsDb
{
public string UserName { get; set; }
public string Pwd { get; set; }
public long RoleId { get; set; }
}
public class UserMapper : SystemEntityTypeBuilder<User>
{
public UserMapper() : base("user")
{
}
}
}

@ -34,11 +34,11 @@ namespace DB
/// <summary>
/// </summary>
public int IsEnable { get; set; } = 1;
public short IsEnable { get; set; } = 1;
/// <summary>
/// </summary>
public int IsDelete { get; set; } = 0;
public short IsDelete { get; set; } = 0;
@ -50,11 +50,13 @@ namespace DB
/// <summary>
/// </summary>
[UpdateIgnore]
public string CreateUserId { get; set; } = "";
/// <summary>
/// </summary>
[UpdateIgnore]
public string CreateUserName { get; set; } = "";
/// <summary>
@ -69,6 +71,6 @@ namespace DB
/// </summary>
public string LastModifyUserName { get; set; } = "";
public int SortCode { get; set; } = 0;
}
}

@ -23,25 +23,37 @@
#region Windows 窗体设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容。
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(662, 241);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(137, 97);
this.button1.TabIndex = 0;
this.button1.Text = "初始化数据库";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1180, 553);
this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
this.ClientSize = new System.Drawing.Size(1770, 830);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
private System.Windows.Forms.Button button1;
#endregion
}
}

@ -9,7 +9,12 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Chloe.PostgreSQL.DDL;
using Chloe.RDBMS.DDL;
using DB;
using DB.Entity;
using NewLife.Data;
using NewLife.Log;
using Tool;
namespace RfidWeb
@ -22,20 +27,48 @@ namespace RfidWeb
{
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
AppContext.SetSwitch("Npgsql.DisableDateTimeInfinityConversions", true);
InitializeComponent();
// 如果所有的日志在记录之前需要在控制台显示出来
logNet.BeforeSaveToFile += (object sender, HslEventArgs e) =>
{
Console.WriteLine(e.HslMessage.ToString());
};
logNet.ConsoleOutput = true;
logNet.WriteInfo("nihao");
}
// 如果所有的日志在记录之前需要在控制台显示出来
logNet.BeforeSaveToFile += (object sender, HslEventArgs e) =>
private void button1_Click(object sender, EventArgs e)
{
Console.WriteLine(e.HslMessage.ToString());
};
DbInfo.Init(typeof(RoleMapper).Assembly);
var dbContext = DbFactory.GetContext;
new PostgreSQLTableGenerator(dbContext).CreateTables(TableCreateMode.CreateNew);
dbContext.Insert(new Role()
{
ID = SnowflakeFactory.NewId,
RoleName = "管理层",
RoleLevel = 1
});
dbContext.Insert(new Role()
{
ID = SnowflakeFactory.NewId,
RoleName = "设备层",
RoleLevel = 2
});
dbContext.Insert(new Role()
{
ID = SnowflakeFactory.NewId,
RoleName = "使用层",
RoleLevel = 3
});
}
}
}

@ -13,7 +13,7 @@ namespace Tool
[Config("Core")]
public class RfidSetting : Config<RfidSetting>
{
public string Db { get; set; } = "server=127.0.0.1;database=postgres;uid=postgres;pwd=yangwei";
public string Db { get; set; } = "server=127.0.0.1;database=gaosu;uid=postgres;pwd=123456";
public string PlcIp { get; set; } = "127.0.0.1";

@ -0,0 +1,11 @@
using NewLife.Data;
namespace Tool
{
public class SnowflakeFactory
{
private static readonly Snowflake GetInstance = new Snowflake();
public static long NewId => GetInstance.NewId();
}
}

@ -64,6 +64,7 @@
<Compile Include="RfidSetting.cs" />
<Compile Include="PlcConnect.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SnowflakeFactory.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Loading…
Cancel
Save