终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

46 line
1.4 KiB

  1. using BPASmartClient.CustomResource.Pages.ViewModel;
  2. using BPASmartClient.Nfc;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. namespace BPASmartClient.CustomResource.Pages.Model
  10. {
  11. public class NfcServer
  12. {
  13. private volatile static NfcServer _Instance;
  14. public static NfcServer GetInstance => _Instance ?? (_Instance = new NfcServer());
  15. private NfcServer() { }
  16. public bool EnableLogin { get; set; }
  17. public Action Update { get; set; }
  18. public void Init()
  19. {
  20. NFCHelper.GetInstance.Update = new Action(() =>
  21. {
  22. Update?.Invoke();
  23. if (!EnableLogin)
  24. {
  25. if (NFCHelper.GetInstance.GetReadResult?.CardNum.Length > 0)
  26. {
  27. string id = NFCHelper.GetInstance.GetReadResult?.CardNum;
  28. var res = Global.userManager.userInfos.FirstOrDefault(p => p.CardId == id) ;
  29. if (res != null)
  30. {
  31. BPASmartClient.Message.MessageLog.GetInstance.ShowDebugLog("NFC卡登录");
  32. LoginViewModel.NfcLogin(id);
  33. }
  34. }
  35. }
  36. });
  37. NFCHelper.GetInstance.Init();
  38. }
  39. }
  40. }