using BPASmartClient.CustomResource.Pages.ViewModel; using BPASmartClient.Nfc; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; namespace BPASmartClient.CustomResource.Pages.Model { public class NfcServer { private volatile static NfcServer _Instance; public static NfcServer GetInstance => _Instance ?? (_Instance = new NfcServer()); private NfcServer() { } public bool EnableLogin { get; set; } public Action Update { get; set; } public void Init() { NFCHelper.GetInstance.Update = new Action(() => { Update?.Invoke(); if (!EnableLogin) { if (NFCHelper.GetInstance.GetReadResult?.CardNum.Length > 0) { string id = NFCHelper.GetInstance.GetReadResult?.CardNum; var res = Global.userManager.userInfos.FirstOrDefault(p => p.CardId == id) ; if (res != null) { BPASmartClient.Message.MessageLog.GetInstance.ShowDebugLog("NFC卡登录"); LoginViewModel.NfcLogin(id); } } } }); NFCHelper.GetInstance.Init(); } } }