251029
This commit is contained in:
88
FATrace.WPLApp/Services/SysRunService.cs
Normal file
88
FATrace.WPLApp/Services/SysRunService.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
using FATrace.WPLApp.Models;
|
||||
using Prism.Events;
|
||||
using Prism.Mvvm;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace FATrace.WPLApp.Services
|
||||
{
|
||||
public class SysRunService : BindableBase
|
||||
{
|
||||
public SysRunService(IEventAggregator eventAggregator)
|
||||
{
|
||||
// 创建一个定时器,设置间隔时间为2000毫秒(即2秒)
|
||||
CurTimer = new System.Timers.Timer(5000);
|
||||
CurTimer.AutoReset = true;
|
||||
// 设置Elapsed事件处理程序
|
||||
CurTimer.Elapsed += CurTimer_Elapsed;
|
||||
// 启动定时器
|
||||
CurTimer.Start();
|
||||
|
||||
}
|
||||
|
||||
private string? _CurUser;
|
||||
/// <summary>
|
||||
/// 当前的用户
|
||||
/// </summary>
|
||||
public string? CurUser
|
||||
{
|
||||
get { return _CurUser; }
|
||||
set
|
||||
{
|
||||
if (_CurUser != value)
|
||||
{
|
||||
_CurUser = value;
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
IsLogin = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
IsLogin = true;
|
||||
}
|
||||
RaisePropertyChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool _IsLogin;
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
public bool IsLogin
|
||||
{
|
||||
get { return _IsLogin; }
|
||||
set { _IsLogin = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 运行状态
|
||||
/// </summary>
|
||||
public SysRunState SysRunState { get; set; } = new SysRunState();
|
||||
|
||||
/// <summary>
|
||||
/// 定时器
|
||||
/// </summary>
|
||||
private System.Timers.Timer CurTimer { get; set; }
|
||||
|
||||
private DateTime _CurDateTime;
|
||||
/// <summary>
|
||||
/// 当前时间信息
|
||||
/// </summary>
|
||||
public DateTime CurDateTime
|
||||
{
|
||||
get { return _CurDateTime; }
|
||||
set { _CurDateTime = value; RaisePropertyChanged(); }
|
||||
}
|
||||
|
||||
private void CurTimer_Elapsed(object? sender, System.Timers.ElapsedEventArgs e)
|
||||
{
|
||||
CurDateTime = DateTime.Now;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user