You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
4.1 KiB
C#
142 lines
4.1 KiB
C#
using ConsoleApp;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using SlnMesnac.Model.domain;
|
|
using SlnMesnac.Repository.service;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Linq;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace SlnMesnac.WPF.ViewModel
|
|
{
|
|
public class HandOverViewModel : INotifyPropertyChanged
|
|
{
|
|
//private HidUtils hidUtils = new HidUtils();
|
|
private IBaseStaffService _baseStaffService;
|
|
private int times;
|
|
|
|
/// <summary>
|
|
/// 按钮文字转换事件
|
|
/// </summary>
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
|
|
public HandOverViewModel()
|
|
{
|
|
Init();
|
|
_baseStaffService = App.ServiceProvider.GetService<IBaseStaffService>();
|
|
}
|
|
|
|
#region
|
|
|
|
/// <summary>
|
|
/// 员工id
|
|
/// </summary>
|
|
private string staffIdText;
|
|
public string StaffIdText
|
|
{
|
|
get { return staffIdText; }
|
|
set { staffIdText = value; OnPropertyChanged("StaffIdText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 员工名称
|
|
/// </summary>
|
|
private string staffNameText;
|
|
public string StaffNameText
|
|
{
|
|
get { return staffNameText; }
|
|
set { staffNameText = value; OnPropertyChanged("StaffNameText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 员工类型
|
|
/// </summary>
|
|
private string staffTypeText;
|
|
public string StaffTypeText
|
|
{
|
|
get { return staffTypeText; }
|
|
set { staffTypeText = value; OnPropertyChanged("StaffTypeText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 班组编号
|
|
/// </summary>
|
|
private string teamCodeText;
|
|
public string TeamCodeText
|
|
{
|
|
get { return teamCodeText; }
|
|
set { teamCodeText = value; OnPropertyChanged("TeamCodeText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 提示信息
|
|
/// </summary>
|
|
private string hintText;
|
|
public string HintText
|
|
{
|
|
get { return hintText; }
|
|
set { hintText = value; OnPropertyChanged("HintText"); }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 信息
|
|
/// </summary>
|
|
private string messageText;
|
|
public string MessageText
|
|
{
|
|
get { return messageText; }
|
|
set { messageText = value; OnPropertyChanged("MessageText"); }
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 初始化
|
|
/// </summary>
|
|
private void Init()
|
|
{
|
|
var hidUtils = EmployeeLoginViewModel.hidUtils;
|
|
// hidUtils.Initial();
|
|
hidUtils.StartScan();
|
|
hidUtils.pushReceiveDataEvent += (bytes, str) =>
|
|
{
|
|
if (times < 2)
|
|
{
|
|
str = str.ToString().Replace(" ", "");
|
|
BaseStaffInfo user = _baseStaffService.GetStaffInfoByCardId(str);
|
|
if (user != null)
|
|
{
|
|
string staffType = user.StaffType;
|
|
if (staffType == "1")
|
|
{
|
|
//显示记录
|
|
StaffIdText = user.StaffId;
|
|
StaffNameText = user.StaffName;
|
|
StaffTypeText = user.StaffType;
|
|
TeamCodeText = user.TeamCode;
|
|
//数量+1
|
|
times++;
|
|
}
|
|
else
|
|
{
|
|
HintText = "打卡人员非班长,打卡无效!";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
HintText = "没有匹配的员工,打卡失败!";
|
|
}
|
|
}
|
|
};
|
|
}
|
|
|
|
public void OnPropertyChanged([CallerMemberName] string propertyName = "")
|
|
{
|
|
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
|
}
|
|
}
|
|
}
|