diff --git a/JinYuan.Helper/InputMessageFilter.cs b/JinYuan.Helper/InputMessageFilter.cs
new file mode 100644
index 0000000..0f8968e
--- /dev/null
+++ b/JinYuan.Helper/InputMessageFilter.cs
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace JinYuan.Helper
+{
+ public class InputMessageFilter : IMessageFilter
+ {
+ private Action onActivity;
+
+ public InputMessageFilter(Action onActivity)
+ {
+ this.onActivity = onActivity;
+ }
+
+ public bool PreFilterMessage(ref Message m)
+ {
+ // 鼠标移动(0x0200)、鼠标按下(0x0201)、键盘按下(0x0100)等
+ if (m.Msg == 0x0200 || m.Msg == 0x0201 || m.Msg == 0x0204
+
+ || m.Msg == 0x0100 || m.Msg == 0x0101)
+ {
+ onActivity?.Invoke();
+ }
+ return false; // 不拦截消息,继续传递
+ }
+ }
+}
diff --git a/JinYuan.Helper/JinYuan.Helper.csproj b/JinYuan.Helper/JinYuan.Helper.csproj
index 0a35936..81bdf67 100644
--- a/JinYuan.Helper/JinYuan.Helper.csproj
+++ b/JinYuan.Helper/JinYuan.Helper.csproj
@@ -140,6 +140,7 @@
+
diff --git a/JinYuan.MES/MesDataProcess.cs b/JinYuan.MES/MesDataProcess.cs
index dded582..2e49910 100644
--- a/JinYuan.MES/MesDataProcess.cs
+++ b/JinYuan.MES/MesDataProcess.cs
@@ -530,7 +530,7 @@ namespace JinYuan.MES
ProcessGradeResponse(mesResponse, listCode, ref message, ref materialGrades); // 处理返回结果
//resJson = $"{nowDate.ToString("yyyy-MM-dd HH:mm:ss.fff")}:调用查询电芯档位接口:{url},请求数据为:{postcontent},\n{nowDate.AddMilliseconds(sw.ElapsedMilliseconds).ToString("yyyy-MM-dd HH:mm:ss.fff")}:接口耗时:{sw.ElapsedMilliseconds}ms,返回结果:{result}";
//TxtHelper.WriteTxt($@"D:\APILog\Logs\MesLogs\{nowDate.ToString("yyyyMMdd")}\查询电芯档位\{nowDate.ToString("HH")}.txt", resJson);
- if (success)
+ if (success && mesResType == MesResType.D)
{
message = $"查询电芯档位成功,共获取 {materialGrades.Count} 个档位信息";
TxtHelper.WriteTxt($@"D:\APILog\Logs\MesLogs\{nowDate.ToString("yyyyMMdd")}\查询电芯档位\{nowDate.ToString("HH")}.txt", message);
diff --git a/JinYuan.Models/ConstValue.cs b/JinYuan.Models/ConstValue.cs
new file mode 100644
index 0000000..7a8720b
--- /dev/null
+++ b/JinYuan.Models/ConstValue.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JinYuan.Models
+{
+ public class ConstValue
+ {
+ #region 日志文件夹名称
+ ///
+ /// 操作日志存储
+ ///
+ public const string USER_LOG = "OperaLog";
+ #endregion
+ }
+}
diff --git a/JinYuan.Models/JinYuan.Models.csproj b/JinYuan.Models/JinYuan.Models.csproj
index 2f74d2a..5709973 100644
--- a/JinYuan.Models/JinYuan.Models.csproj
+++ b/JinYuan.Models/JinYuan.Models.csproj
@@ -85,6 +85,7 @@
+
diff --git a/JinYuan.Models/SysConfig/PlcGroupConfig.cs b/JinYuan.Models/SysConfig/PlcGroupConfig.cs
index 90fec0e..c958bfa 100644
--- a/JinYuan.Models/SysConfig/PlcGroupConfig.cs
+++ b/JinYuan.Models/SysConfig/PlcGroupConfig.cs
@@ -138,6 +138,5 @@
}
-
}
}
diff --git a/JinYuan.VirtualDataLibrary/MesConfig.cs b/JinYuan.VirtualDataLibrary/MesConfig.cs
index 3241df6..fec28ae 100644
--- a/JinYuan.VirtualDataLibrary/MesConfig.cs
+++ b/JinYuan.VirtualDataLibrary/MesConfig.cs
@@ -227,11 +227,11 @@ namespace JinYuan.VirtualDataLibrary
private Dictionary> userPLCAddr_Mapping = new Dictionary>()
{
{ "1-1", new Dictionary {{"user", "D22"}, {"right", "D21"}} },
- { "1-2", new Dictionary {{"user", "D22"}, {"right", "D21"}} },
- { "1-3", new Dictionary {{"user", "D22"}, {"right", "D21"}} },
- { "2-1", new Dictionary {{"user", "D22"}, {"right", "D21"}} },
- { "2-2", new Dictionary {{"user", "D22"}, {"right", "D21"}} },
- { "2-3", new Dictionary {{"user", "D22"}, {"right", "D21"}} },
+ { "1-2", new Dictionary {{"user", "D24" }, {"right", "D23" } } },
+ { "1-3", new Dictionary {{"user", "D26" }, {"right", "D25" } } },
+ { "2-1", new Dictionary {{"user", "D22" }, {"right", "D21" } } },
+ { "2-2", new Dictionary {{"user", "D24" }, {"right", "D23" } } },
+ { "2-3", new Dictionary {{"user", "D26" }, {"right", "D25" } } },
};
public Dictionary GetHMIUserRightAddr()
diff --git a/LargeSquareOne/FrmAlarmLog.cs b/LargeSquareOne/FrmAlarmLog.cs
index 06ba51c..fd7b216 100644
--- a/LargeSquareOne/FrmAlarmLog.cs
+++ b/LargeSquareOne/FrmAlarmLog.cs
@@ -101,8 +101,9 @@ namespace LargeSquareOne
// AlarmType = isError ? "错误".Translated() : "信息".Translated(),
// Operater = CommonMethods.currentAdmin.LoginName
//});
-
-
+ string opeType = isError ? "错误" : "信息";
+ string logInfo = $"操作时间: {CurrentTime}, 操作类型: {opeType}, 操作信息: {info}";
+ LogHelper.Instance.WriteLog(logInfo, ConstValue.USER_LOG);
}
///
diff --git a/LargeSquareOne/FrmMain.cs b/LargeSquareOne/FrmMain.cs
index 772715b..0ae6e61 100644
--- a/LargeSquareOne/FrmMain.cs
+++ b/LargeSquareOne/FrmMain.cs
@@ -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;
}
///