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.
167 lines
4.2 KiB
C#
167 lines
4.2 KiB
C#
using Chloe.PostgreSQL.DDL;
|
|
using Chloe.RDBMS.DDL;
|
|
|
|
using DB;
|
|
using DB.Entity;
|
|
|
|
using HslCommunication;
|
|
using HslCommunication.LogNet;
|
|
|
|
using NewLife.Threading;
|
|
|
|
using System;
|
|
using System.Drawing;
|
|
using System.Web.UI;
|
|
using System.Windows.Forms;
|
|
using RfidWeb.Frm;
|
|
using Tool;
|
|
|
|
namespace RfidWeb
|
|
{
|
|
public partial class FrmMain : Form
|
|
{
|
|
private ILogNet logNet = ILogNetFactory.GetLogNet;
|
|
|
|
TimerX _timer;
|
|
|
|
public FrmMain()
|
|
{
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
_timer= new TimerX(TimeState, null, 10 , 1000);
|
|
// 如果所有的日志在记录之前需要在控制台显示出来
|
|
logNet.BeforeSaveToFile += (object sender, HslEventArgs e) =>
|
|
{
|
|
Console.WriteLine(e.HslMessage.ToString());
|
|
};
|
|
logNet.ConsoleOutput = true;
|
|
logNet.WriteInfo("nihao");
|
|
Init();
|
|
}
|
|
|
|
|
|
/// <summary>移除过期的缓存项</summary>
|
|
void TimeState(Object state)
|
|
{
|
|
var dataTime = DateTime.Now;
|
|
this.Invoke(() =>
|
|
{
|
|
|
|
label1.Text = dataTime.ToString("yyyy'/'MM'/'dd");
|
|
label2.Text = dataTime.ToString("HH:mm:ss");
|
|
});
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
}
|
|
|
|
panel6.Dock = DockStyle.Fill;
|
|
this.panel6.Controls.Add(new UserMain());
|
|
|
|
|
|
|
|
//// 当前写入操作的代码 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);
|
|
//}
|
|
|
|
|
|
// this.panel6.Controls.Add(new UserControl1());
|
|
|
|
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
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
|
|
});
|
|
}
|
|
|
|
private void button4_Click(object sender, EventArgs e)
|
|
{
|
|
SetBackGroupImage(btnMain);
|
|
this.panel6.Controls.Clear();
|
|
// this.panel6.Controls.Add(new UserControl1());
|
|
}
|
|
|
|
private void button3_Click(object sender, EventArgs e)
|
|
{
|
|
SetBackGroupImage(btnArgument);
|
|
|
|
this.panel6.Controls.Clear();
|
|
// this.panel6.Controls.Add(new UserControl2());
|
|
}
|
|
|
|
private void SetBackGroupImage(Button button)
|
|
{
|
|
var imageOld = Properties.Resources.btn;
|
|
btnMain.BackgroundImage=imageOld;
|
|
btnArgument.BackgroundImage = imageOld;
|
|
|
|
var imageNew = Properties.Resources.btn_sel1;
|
|
if (button != null)
|
|
{
|
|
button.BackgroundImage=imageNew;
|
|
}
|
|
}
|
|
|
|
private void btnExit_Click(object sender, EventArgs e)
|
|
{
|
|
Application.Exit();
|
|
}
|
|
|
|
private void button3_Click_1(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void button4_Click_1(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|