Files
FATrace/FATrace.WPLApp/Services/SysRunService.cs
2025-10-29 11:42:58 +08:00

89 lines
2.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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;
}
}
}