|
|
|
|
using GalaSoft.MvvmLight;
|
|
|
|
|
using GalaSoft.MvvmLight.Command;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using SlnMesnac.Business.business;
|
|
|
|
|
using SlnMesnac.Common;
|
|
|
|
|
using SlnMesnac.Repository.service;
|
|
|
|
|
using SlnMesnac.Repository.service.Impl;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Input;
|
|
|
|
|
|
|
|
|
|
namespace SlnMesnac.WPF.ViewModel
|
|
|
|
|
{
|
|
|
|
|
public class EmployeeLoginViewModel : ViewModelBase,INotifyPropertyChanged
|
|
|
|
|
{
|
|
|
|
|
private readonly RfidHandleBusniess rfidHandle;
|
|
|
|
|
private readonly ILogger<EmployeeLoginViewModel> _logger;
|
|
|
|
|
private IBaseStaffService baseStaffService;
|
|
|
|
|
public string _isCheckInButtonEnabled;
|
|
|
|
|
private string _isCheckOutButtonEnabled;
|
|
|
|
|
private string _checkInButtonColor;
|
|
|
|
|
private string _checkOutButtonColor = "#009999";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 按钮文字转换事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 上班命令
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ICommand CheckInCommand { get; private set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下班命令
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ICommand CheckOutCommand { get; private set; }
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 结束命令
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ICommand OverCommand { get; private set; }
|
|
|
|
|
private string _checkInButtonText = "上班打卡";
|
|
|
|
|
private string _checkOutButtonText = "下班打卡";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 上班打卡文本
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string CheckInButtonText
|
|
|
|
|
{
|
|
|
|
|
get { return _checkInButtonText; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_checkInButtonText = value;
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CheckInButtonText)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 上班打卡
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string IsCheckInButtonEnabled
|
|
|
|
|
{
|
|
|
|
|
get { return _isCheckInButtonEnabled; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isCheckInButtonEnabled = value;
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsCheckInButtonEnabled)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///下班打卡文本
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string CheckOutButtonText
|
|
|
|
|
{
|
|
|
|
|
get { return _checkOutButtonText; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_checkOutButtonText = value;
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CheckOutButtonText)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下班打卡
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string IsCheckOutButtonEnabled
|
|
|
|
|
{
|
|
|
|
|
get { return _isCheckOutButtonEnabled; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_isCheckOutButtonEnabled = value;
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(IsCheckOutButtonEnabled)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 上班打卡按钮颜色
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string CheckInButtonColor
|
|
|
|
|
{
|
|
|
|
|
get { return _checkInButtonColor; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_checkInButtonColor = value;
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CheckInButtonColor)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下班打卡按钮颜色
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string CheckOutButtonColor
|
|
|
|
|
{
|
|
|
|
|
get { return _checkOutButtonColor; }
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_checkOutButtonColor = value;
|
|
|
|
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(nameof(CheckOutButtonColor)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public EmployeeLoginViewModel()
|
|
|
|
|
{
|
|
|
|
|
CheckInCommand = new RelayCommand(CheckIn);
|
|
|
|
|
CheckOutCommand = new RelayCommand(CheckOut);
|
|
|
|
|
OverCommand = new RelayCommand(Over);
|
|
|
|
|
rfidHandle = App.ServiceProvider.GetService<RfidHandleBusniess>();
|
|
|
|
|
baseStaffService = App.ServiceProvider.GetService<IBaseStaffService>();
|
|
|
|
|
IsCheckInButtonEnabled = "True";
|
|
|
|
|
IsCheckOutButtonEnabled = "True";
|
|
|
|
|
CheckInButtonColor = "#009999";
|
|
|
|
|
CheckOutButtonColor = "#009999";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 上班打卡事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void CheckIn()
|
|
|
|
|
{
|
|
|
|
|
if (CheckInButtonText == "上班打卡")
|
|
|
|
|
{
|
|
|
|
|
// 执行上班打卡逻辑
|
|
|
|
|
CheckInButtonText = "结束打卡";
|
|
|
|
|
IsCheckOutButtonEnabled = "False"; // Disable CheckOutButton
|
|
|
|
|
CheckOutButtonColor = "Gray";
|
|
|
|
|
rfidHandle.CheckIn();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 执行结束打卡逻辑
|
|
|
|
|
CheckInButtonText = "上班打卡";
|
|
|
|
|
IsCheckOutButtonEnabled = "True"; // Enable CheckOutButton
|
|
|
|
|
CheckOutButtonColor = "#009999";
|
|
|
|
|
rfidHandle.CloseRfid();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 下班打卡事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void CheckOut()
|
|
|
|
|
{
|
|
|
|
|
if (CheckOutButtonText == "下班打卡")
|
|
|
|
|
{
|
|
|
|
|
// 执行下班打卡逻辑
|
|
|
|
|
CheckOutButtonText = "结束打卡";
|
|
|
|
|
IsCheckInButtonEnabled = "False"; // Disable CheckInButton
|
|
|
|
|
//IsCheckOutButtonEnabled = "True";
|
|
|
|
|
CheckInButtonColor = "Gray";
|
|
|
|
|
rfidHandle.CheckOut();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// 执行结束打卡逻辑
|
|
|
|
|
CheckOutButtonText = "下班打卡";
|
|
|
|
|
IsCheckInButtonEnabled = "True"; // Enable CheckInButton
|
|
|
|
|
//IsCheckOutButtonEnabled="False";
|
|
|
|
|
CheckInButtonColor = "#009999";
|
|
|
|
|
rfidHandle.CloseRfid();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 结束打卡事件
|
|
|
|
|
/// </summary>
|
|
|
|
|
private void Over()
|
|
|
|
|
{
|
|
|
|
|
// 执行结束打卡的逻辑
|
|
|
|
|
CheckInButtonText = "上班打卡";
|
|
|
|
|
CheckOutButtonText = "下班打卡";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|