终端一体化运控平台
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.
 
 
 

47 line
1.4 KiB

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