MachineForQrCodeDbconn.cs 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using MySystem.Models.Main;
  5. namespace MySystem
  6. {
  7. public class MachineForQrCodeDbconn
  8. {
  9. public readonly static MachineForQrCodeDbconn Instance = new MachineForQrCodeDbconn();
  10. #region 获取单个字段
  11. public MachineForQrCode Get(string DataId)
  12. {
  13. WebCMSEntities db = new WebCMSEntities();
  14. MachineForQrCode order = db.MachineForQrCode.FirstOrDefault(m => m.DataId == DataId);
  15. if (order != null)
  16. {
  17. }
  18. return order;
  19. }
  20. #endregion
  21. #region 获取列表
  22. public List<MachineForQrCode> GetList(int MerchantId, int pageNum = 1, int pageSize = 10)
  23. {
  24. // string key = "MachineForQrCodeList:" + MerchantId;
  25. // List<MachineForQrCode> list = new List<MachineForQrCode>();
  26. // if (RedisDbconn.Instance.Exists(key))
  27. // {
  28. // list = RedisDbconn.Instance.GetList<MachineForQrCode>(key, pageNum, pageSize);
  29. // if (list.Count > 0)
  30. // {
  31. // return list;
  32. // }
  33. // }
  34. WebCMSEntities db = new WebCMSEntities();
  35. List<MachineForQrCode> newlist = new List<MachineForQrCode>();
  36. var mysqllist = db.MachineForQrCode.Where(m => m.MerchantId == MerchantId && m.SnNo != m.MachineSnNo).ToList();
  37. if (mysqllist.Count > 0)
  38. {
  39. foreach (MachineForQrCode sub in mysqllist)
  40. {
  41. newlist.Add(sub);
  42. }
  43. // RedisDbconn.Instance.Clear(key);
  44. // foreach (MachineForQrCode sub in newlist)
  45. // {
  46. // RedisDbconn.Instance.AddRightList(key, sub);
  47. // }
  48. // RedisDbconn.Instance.SetExpire(key, Library.function.get_Random(1800, 5400));
  49. }
  50. db.Dispose();
  51. return newlist;
  52. }
  53. #endregion
  54. }
  55. }