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.

61 lines
1.8 KiB

1 month ago
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Forms;
  7. using ShenTun.IcCard.Common;
  8. using ShenTun.IcCard.Instance;
  9. namespace ShenTun.IcCard
  10. {
  11. public class IcCardClient
  12. {
  13. public async Task<string> getReadCardAsync(RequestIcCardInterface req)
  14. {
  15. return await Task.Run(() => ReadCard(req));
  16. }
  17. private string ReadCard(RequestIcCardInterface req)
  18. {
  19. IDCardInfo info = new IDCardInfo();
  20. Response res = new Response()
  21. {
  22. code = -100,
  23. message = "",
  24. };
  25. try
  26. {
  27. IReadCard iReadCard = null;
  28. if (req.IcCardInterface.Equals(1))
  29. {
  30. iReadCard = new ReadCardByYT100();
  31. }
  32. else if (req.IcCardInterface.Equals(2))
  33. {
  34. iReadCard = new ReadCardByDCT10D();
  35. }
  36. else if (req.IcCardInterface.Equals(3))
  37. {
  38. iReadCard = new ReadCardByIDR210();
  39. }
  40. else if (req.IcCardInterface.Equals(4))
  41. {
  42. iReadCard = new ReadCardByHXFDX3S();
  43. }
  44. if (BaseData.nList.Count == 0) BaseData.CreateNationList();
  45. if (BaseData.sList.Count == 0) BaseData.CreateSexList();
  46. res = iReadCard.GetReadCard();
  47. }
  48. catch (Exception err)
  49. {
  50. res.code = -100;
  51. res.message = "系统级错误,读卡失败";
  52. MessageBox.Show(err.Message);
  53. }
  54. return JsonHelper.SerializeObject(res);
  55. }
  56. }
  57. }