查状态时间间隔设置100ms
homeWindowViewModel构造函数添加 _socketHelper.dateTime=DateTime.Now;
This commit is contained in:
parent
b1974bd1a5
commit
24b5d6257b
|
@ -877,10 +877,10 @@ namespace DM_Weight.ViewModels
|
|||
return;
|
||||
}
|
||||
_socketHelper.OpenStatus = true;
|
||||
Thread.Sleep(200);
|
||||
int i = 40;
|
||||
Thread.Sleep(100);
|
||||
int i = 80;
|
||||
int iException = 0;
|
||||
new PromiseUtil<int>().taskAsyncLoop(200, 0, async (options, next, stop) =>
|
||||
new PromiseUtil<int>().taskAsyncLoop(100, 0, async (options, next, stop) =>
|
||||
{
|
||||
|
||||
_socketHelper.IsMultiThread = true;
|
||||
|
@ -900,7 +900,7 @@ namespace DM_Weight.ViewModels
|
|||
if (i == 0)
|
||||
{
|
||||
ModbusHelper.SpeakAsync("请及时关闭药箱");
|
||||
i = 40;
|
||||
i = 80;
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
|
|
@ -376,6 +376,7 @@ namespace DM_Weight.ViewModels
|
|||
_container = container;
|
||||
this._eventAggregator = eventAggregator;
|
||||
_socketHelper = socketHelper;
|
||||
_socketHelper.dateTime=DateTime.Now;
|
||||
//timerNew = new DispatcherTimer();
|
||||
//int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
|
||||
//if (autoExit > 0)
|
||||
|
@ -411,49 +412,7 @@ namespace DM_Weight.ViewModels
|
|||
// };
|
||||
// timerNew.Start();
|
||||
//}
|
||||
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
|
||||
if (autoExit > 0)
|
||||
{
|
||||
int interval= autoExit * 1000;
|
||||
new PromiseUtil<int>().taskAsyncLoop(interval, 0, async (options, next, stop) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_socketHelper.OpenStatus)
|
||||
{
|
||||
// 无人操作鼠标键盘
|
||||
if ((DateTime.Now - _socketHelper.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
|
||||
{
|
||||
logger.Info($"设备内无人操作,用户【{Operator?.Nickname}】自动退出登录");
|
||||
Operator = null;
|
||||
Reviewer = null;
|
||||
//Application.Current.Dispatcher.Invoke(() =>
|
||||
//{
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
{
|
||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
}));
|
||||
//});
|
||||
stop();
|
||||
//timer.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
next();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_socketHelper.dateTime = DateTime.Now;
|
||||
next();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Info($"自动退出异常:{ex.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public DelegateCommand<string> OpenFingerDialog
|
||||
|
@ -678,7 +637,7 @@ namespace DM_Weight.ViewModels
|
|||
// //WDTimer.AutoReset = true;
|
||||
// //WDTimer.Enabled = true;
|
||||
//}
|
||||
|
||||
|
||||
#endregion
|
||||
//if (stopRecord > 0)
|
||||
//{
|
||||
|
@ -699,6 +658,57 @@ namespace DM_Weight.ViewModels
|
|||
////获取录像机的时间
|
||||
//_chkFunction.HIK_DVR_TIME();
|
||||
//_chkFunction.HIKStartDVRRecord();
|
||||
|
||||
int autoExit = Convert.ToInt32(ConfigurationManager.AppSettings["autoExit"] ?? "0");
|
||||
if (autoExit > 0)
|
||||
{
|
||||
//int interval = autoExit * 1000;
|
||||
new PromiseUtil<int>().taskAsyncLoop(1000, 0, async (options, next, stop) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!_socketHelper.OpenStatus)
|
||||
{
|
||||
// 无人操作鼠标键盘
|
||||
if ((DateTime.Now - _socketHelper.dateTime).TotalSeconds > autoExit && CheckComputerFreeState.GetLastInputTime() > autoExit)
|
||||
{
|
||||
logger.Info($"设备内无人操作,用户【{Operator?.Nickname}】自动退出登录.autoExit:{autoExit};socketTime:{_socketHelper.dateTime};totalSeconds:{(DateTime.Now - _socketHelper.dateTime).TotalSeconds}{_socketHelper.dateTime};LastInputTime:{CheckComputerFreeState.GetLastInputTime()}");
|
||||
Operator = null;
|
||||
Reviewer = null;
|
||||
//Application.Current.Dispatcher.Invoke(() =>
|
||||
//{
|
||||
stop();
|
||||
System.Windows.Application.Current.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.Send, new Action(() =>
|
||||
{
|
||||
_regionManager.RequestNavigate("MainRegion", "LoginWindow");
|
||||
}));
|
||||
//});
|
||||
//timer.Dispose();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Operator == null)
|
||||
{
|
||||
stop();
|
||||
}
|
||||
else
|
||||
{
|
||||
next();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_socketHelper.dateTime = DateTime.Now;
|
||||
next();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Info($"自动退出异常:{ex.Message}");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//每次导航的时候,该实列用不用重新创建,true是不重新创建,false是重新创建
|
||||
|
|
|
@ -709,10 +709,10 @@ namespace DM_Weight.ViewModels
|
|||
// stop();
|
||||
// }
|
||||
//});
|
||||
Thread.Sleep(200);
|
||||
int i = 40;
|
||||
Thread.Sleep(100);
|
||||
int i = 80;
|
||||
int iException = 0;
|
||||
new PromiseUtil<int>().taskAsyncLoop(200, 0, async (options, next, stop) =>
|
||||
new PromiseUtil<int>().taskAsyncLoop(100, 0, async (options, next, stop) =>
|
||||
{
|
||||
_socketHelper.IsMultiThread = true;
|
||||
try
|
||||
|
@ -732,7 +732,7 @@ namespace DM_Weight.ViewModels
|
|||
if (i == 0)
|
||||
{
|
||||
ModbusHelper.SpeakAsync("请及时关闭药箱");
|
||||
i = 40;
|
||||
i = 80;
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue