终端一体化运控平台
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 

50 rindas
1.6 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?.FirstOrDefault(s => s == id) != null);
  29. if (res != null)
  30. {
  31. if (Global.userInfo.permission != res.permission)
  32. {
  33. BPASmartClient.Message.MessageLog.GetInstance.ShowDebugLog("NFC卡登录");
  34. LoginViewModel.NfcLogin(id);
  35. }
  36. }
  37. }
  38. }
  39. });
  40. NFCHelper.GetInstance.Init();
  41. }
  42. }
  43. }