add-添加打印日志
parent
58815381fe
commit
a16bc8d39f
@ -1,20 +1,47 @@
|
|||||||
|
using Microsoft.AspNetCore.Components;
|
||||||
using PrintBarCode.Business;
|
using PrintBarCode.Business;
|
||||||
using PrintBarCode.Helper;
|
using PrintBarCode.Helper;
|
||||||
using PrintBarCode.Model;
|
using PrintBarCode.Model;
|
||||||
using SlnMesnac.Redis;
|
using SlnMesnac.Redis;
|
||||||
|
using static PrintBarCode.MessageClient;
|
||||||
|
|
||||||
namespace PrintBarCode
|
namespace PrintBarCode
|
||||||
{
|
{
|
||||||
public partial class MainForm : Form
|
public partial class MainForm : Form
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
public MainForm()
|
public MainForm()
|
||||||
{
|
{
|
||||||
|
MessageClient.addLogEvent += addLog;
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
|
addLog("启动监听打印服务成功......");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void addLog(string logInfo)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
|
||||||
|
// 如果当前调用线程不是创建窗体的线程,使用 Invoke
|
||||||
|
if (this.logList.InvokeRequired)
|
||||||
|
{
|
||||||
|
this.logList.Invoke(new Action<string>(addLog), logInfo);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.logList.Items.Add($"{DateTime.Now}==>{logInfo}");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue