登录用户超时注销、登录日志记录
This commit is contained in:
@@ -94,6 +94,11 @@ namespace LargeSquareOne
|
||||
}
|
||||
};
|
||||
|
||||
Application.AddMessageFilter(new InputMessageFilter(() =>
|
||||
{
|
||||
lastActivityTime = DateTime.Now;
|
||||
}));
|
||||
|
||||
// 双缓冲全覆盖
|
||||
this.DoubleBuffered = true;
|
||||
InitializeOptimizedControlStyles();
|
||||
@@ -178,6 +183,9 @@ namespace LargeSquareOne
|
||||
}
|
||||
}
|
||||
|
||||
private DateTime lastActivityTime;
|
||||
private System.Windows.Forms.Timer idleTimer;
|
||||
|
||||
// 定时器初始化优化
|
||||
private void InitializeTimersOptimized()
|
||||
{
|
||||
@@ -192,6 +200,21 @@ namespace LargeSquareOne
|
||||
storeTimer.Elapsed += StoreTimer_Elapsed;
|
||||
storeTimer.AutoReset = true;
|
||||
storeTimer.Start();
|
||||
|
||||
// 定时退出当前用户
|
||||
idleTimer = new System.Windows.Forms.Timer();
|
||||
idleTimer.Interval = 1000;
|
||||
idleTimer.Tick += (s, e) =>
|
||||
{
|
||||
if ((DateTime.Now - lastActivityTime).TotalMinutes >= 1)
|
||||
{
|
||||
idleTimer.Stop();
|
||||
|
||||
// 处理用户超时
|
||||
this.BeginInvoke(new Action(() => LoginLocalOut()));
|
||||
}
|
||||
};
|
||||
idleTimer.Start();
|
||||
}
|
||||
|
||||
|
||||
@@ -902,6 +925,9 @@ namespace LargeSquareOne
|
||||
updateTimer?.Dispose();
|
||||
storeTimer?.Dispose();
|
||||
|
||||
idleTimer?.Stop();
|
||||
storeTimer?.Dispose();
|
||||
|
||||
if (ControlCenter.Instance != null)
|
||||
{
|
||||
ControlCenter.Instance.DisconnectAllPlcs(); // 假设存在断开PLC的方法
|
||||
@@ -1266,6 +1292,7 @@ namespace LargeSquareOne
|
||||
CommonMethods.AddOPLog(false, "退出成功".Translated() + "," + "退出用户".Translated() + $":{CommonMethods.currentAdmin?.LoginName}," + "权限".Translated() + $":{CommonMethods.currentAdmin?.LoginLevel}");
|
||||
LogHelper.Instance.WriteLog("用户".Translated() + $":{CommonMethods.currentAdmin?.LoginName} - " + "退出".Translated());
|
||||
CommonMethods.LoginOut = true;
|
||||
CommonMethods.IsLoginOk = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user