You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/RfidWeb/FrmMain.cs

105 lines
2.7 KiB
C#

2 months ago
using HslCommunication.LogNet;
using System;
3 months ago
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
2 months ago
using Chloe.PostgreSQL.DDL;
using Chloe.RDBMS.DDL;
using DB;
using DB.Entity;
using NewLife.Data;
using NewLife.Log;
3 months ago
using Tool;
1 month ago
using HslCommunication;
3 months ago
namespace RfidWeb
{
1 month ago
public partial class FrmMain : Form
3 months ago
{
2 months ago
private ILogNet logNet = ILogNetFactory.GetLogNet;
1 month ago
public FrmMain()
3 months ago
{
2 months ago
1 month ago
3 months ago
InitializeComponent();
1 month ago
2 months ago
// 如果所有的日志在记录之前需要在控制台显示出来
logNet.BeforeSaveToFile += (object sender, HslEventArgs e) =>
{
Console.WriteLine(e.HslMessage.ToString());
};
2 months ago
logNet.ConsoleOutput = true;
logNet.WriteInfo("nihao");
1 month ago
Init();
}
private void Init()
{
//if (this.FormBorderStyle == FormBorderStyle.None)
//{
// this.FormBorderStyle = FormBorderStyle.FixedSingle;
// this.WindowState = FormWindowState.Normal;
//}
//else
//{
// this.FormBorderStyle = FormBorderStyle.None;
// this.WindowState = FormWindowState.Maximized;
//}
// 当前写入操作的代码 The code for the current write operation
OperateResult write = PlcConnect.Instance.Write("A1", short.Parse("4"));
if (write.IsSuccess)
{
Console.WriteLine("Write [A1] success");
}
else
{
Console.WriteLine("Write [A1] failed: " + write.Message);
}
2 months ago
}
2 months ago
2 months ago
private void button1_Click(object sender, EventArgs e)
{
DbInfo.Init(typeof(RoleMapper).Assembly);
2 months ago
2 months ago
var dbContext = DbFactory.GetContext;
new PostgreSQLTableGenerator(dbContext).CreateTables(TableCreateMode.CreateNew);
2 months ago
2 months ago
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
});
3 months ago
}
}
}