解决刷卡登录问题
This commit is contained in:
@@ -82,14 +82,16 @@ namespace JinYuan.Helper
|
|||||||
}
|
}
|
||||||
private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)
|
private int KeyboardHookProc(int nCode, Int32 wParam, IntPtr lParam)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
EventMsg msg = (EventMsg)Marshal.PtrToStructure(lParam, typeof(EventMsg));
|
EventMsg msg = (EventMsg)Marshal.PtrToStructure(lParam, typeof(EventMsg));
|
||||||
codes.Add(msg);
|
codes.Add(msg);
|
||||||
if (ScanerEvent != null && msg.message == 13 && msg.paramH > 0 && !string.IsNullOrEmpty(codes.Result))
|
if (ScanerEvent != null && msg.message == 13 && msg.paramH > 0 && !string.IsNullOrEmpty(codes.Result))
|
||||||
{
|
{
|
||||||
ScanerEvent(codes);
|
ScanerEvent(codes);
|
||||||
|
|
||||||
|
// 返回一个非零值,阻断键盘消息继续向下传递
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
|
return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam);
|
||||||
}
|
}
|
||||||
public class ScanerCodes
|
public class ScanerCodes
|
||||||
|
|||||||
@@ -207,6 +207,11 @@ namespace LargeSquareOne
|
|||||||
idleTimer.Interval = 1000;
|
idleTimer.Interval = 1000;
|
||||||
idleTimer.Tick += (s, e) =>
|
idleTimer.Tick += (s, e) =>
|
||||||
{
|
{
|
||||||
|
if (CommonMethods.LoginOut)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if ((DateTime.Now - lastActivityTime).TotalMinutes >= 1)
|
if ((DateTime.Now - lastActivityTime).TotalMinutes >= 1)
|
||||||
{
|
{
|
||||||
idleTimer.Stop();
|
idleTimer.Stop();
|
||||||
@@ -220,10 +225,15 @@ namespace LargeSquareOne
|
|||||||
|
|
||||||
private void btn_logOut_Click(object sender, EventArgs e)
|
private void btn_logOut_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
idleTimer.Stop();
|
//idleTimer.Stop();
|
||||||
|
|
||||||
// 处理用户超时
|
// 处理用户超时
|
||||||
this.BeginInvoke(new Action(() => LoginLocalOut()));
|
this.BeginInvoke(new Action(() => {
|
||||||
|
LoginLocalOut();
|
||||||
|
|
||||||
|
// 为了取消当前按钮的焦点
|
||||||
|
avMesicon.Focus();
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void FrmNewMain_Load(object sender, EventArgs e)
|
private async void FrmNewMain_Load(object sender, EventArgs e)
|
||||||
@@ -533,11 +543,14 @@ namespace LargeSquareOne
|
|||||||
}
|
}
|
||||||
|
|
||||||
CommonMethods.IsLoginOk = true;
|
CommonMethods.IsLoginOk = true;
|
||||||
|
CommonMethods.LoginOut = false;
|
||||||
//存储用户对象
|
//存储用户对象
|
||||||
CommonMethods.currentAdmin = sysAdmin;
|
CommonMethods.currentAdmin = sysAdmin;
|
||||||
|
|
||||||
//1.设置登录用户
|
//1.设置登录用户
|
||||||
this.lbl_LoginLevel.Text = CommonMethods.currentAdmin?.LoginLevel;
|
this.lbl_LoginLevel.Text = CommonMethods.currentAdmin?.LoginLevel;
|
||||||
this.lbl_LoginName.Text = CommonMethods.currentAdmin?.LoginName;
|
this.lbl_LoginName.Text = CommonMethods.currentAdmin?.LoginName;
|
||||||
|
this.lbl_LoginName.Visible = true;
|
||||||
//登录日志
|
//登录日志
|
||||||
CommonMethods.AddOPLog(false, "登录成功,登录用户".Translated() + $":{CommonMethods.currentAdmin?.LoginName}," + "权限".Translated() + $":{CommonMethods.currentAdmin?.LoginLevel}");
|
CommonMethods.AddOPLog(false, "登录成功,登录用户".Translated() + $":{CommonMethods.currentAdmin?.LoginName}," + "权限".Translated() + $":{CommonMethods.currentAdmin?.LoginLevel}");
|
||||||
|
|
||||||
@@ -678,13 +691,13 @@ namespace LargeSquareOne
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 登录状态:只在状态变化时更新
|
// 登录状态:只在状态变化时更新
|
||||||
bool isSwipeCardMode = CommonMethods.sysConfig.SwipeCardMode && !CommonMethods.IsLoginOk;
|
//bool isSwipeCardMode = CommonMethods.sysConfig.SwipeCardMode && !CommonMethods.IsLoginOk;
|
||||||
if (lbl_LoginName.Visible == isSwipeCardMode)
|
//if (lbl_LoginName.Visible == isSwipeCardMode)
|
||||||
{
|
//{
|
||||||
lbl_LoginName.Visible = !isSwipeCardMode;
|
// lbl_LoginName.Visible = !isSwipeCardMode;
|
||||||
if (isSwipeCardMode)
|
// if (isSwipeCardMode)
|
||||||
lbl_LoginLevel.Text = "未登录";
|
// lbl_LoginLevel.Text = "未登录";
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
System.Diagnostics.Debug.Print("ShowButtonEven_Run end at " + DateTime.Now.ToString("HH:mm:ss.fff"));
|
System.Diagnostics.Debug.Print("ShowButtonEven_Run end at " + DateTime.Now.ToString("HH:mm:ss.fff"));
|
||||||
@@ -1311,6 +1324,8 @@ namespace LargeSquareOne
|
|||||||
LogHelper.Instance.WriteLog("用户".Translated() + $":{CommonMethods.currentAdmin?.LoginName} - " + "退出".Translated());
|
LogHelper.Instance.WriteLog("用户".Translated() + $":{CommonMethods.currentAdmin?.LoginName} - " + "退出".Translated());
|
||||||
CommonMethods.LoginOut = true;
|
CommonMethods.LoginOut = true;
|
||||||
CommonMethods.IsLoginOk = false;
|
CommonMethods.IsLoginOk = false;
|
||||||
|
this.lbl_LoginName.Visible = false;
|
||||||
|
lbl_LoginLevel.Text = "未登录";
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user