SystemConfigHelpers.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using DBHelper;
  2. using Microsoft.EntityFrameworkCore;
  3. using System.Linq;
  4. using WCS.Entity.Protocol;
  5. namespace WCS.Service.Helpers
  6. {
  7. /// <summary>
  8. /// 系统设置
  9. /// </summary>
  10. public class SystemConfigHelpers
  11. {
  12. /// <summary>
  13. /// 获取指定设备配置信息 true表示设备启用,false标识设备未启用
  14. /// </summary>
  15. /// <param name="DEVICECODE">设备编号</param>
  16. /// <returns></returns>
  17. public static bool GetDeviceConfig(string DEVICECODE)
  18. {
  19. bool result = true;
  20. DB.Do(db =>
  21. {
  22. var systemConfig = db.Default.Set<WCS_SystemConfig>().AsNoTracking().SingleOrDefault(p => p.DEVICECODE == DEVICECODE);
  23. if (systemConfig != null) result = systemConfig.ENABLED;
  24. });
  25. return result;
  26. }
  27. /// <returns></returns>
  28. public static bool GetDeviceEnabled(string CODE)
  29. {
  30. bool isError = false;
  31. DB.Do(db =>
  32. {
  33. isError = db.Default.Set<WCS_SystemConfig>().AsNoTracking().Any(p => p.Code == CODE && p.ENABLED);
  34. });
  35. return isError;
  36. }
  37. public static bool GetDeviceIsUsed(string CODE)
  38. {
  39. bool result = false;
  40. DB.Do(db =>
  41. {
  42. var systemConfig = db.Default.Set<WCS_SystemConfig>().AsNoTracking().SingleOrDefault(p => p.DEVICECODE == CODE);
  43. if (systemConfig != null) result = systemConfig.ENABLED;
  44. });
  45. return result;
  46. }
  47. }
  48. }