using DBHelper;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using WCS.Entity.Protocol;
namespace WCS.Service.Helpers
{
///
/// 系统设置
///
public class SystemConfigHelpers
{
///
/// 获取指定设备配置信息 true表示设备启用,false标识设备未启用
///
/// 设备编号
///
public static bool GetDeviceConfig(string DEVICECODE)
{
bool result = true;
DB.Do(db =>
{
var systemConfig = db.Default.Set().AsNoTracking().SingleOrDefault(p => p.DEVICECODE == DEVICECODE);
if (systemConfig != null) result = systemConfig.ENABLED;
});
return result;
}
///
public static bool GetDeviceEnabled(string CODE)
{
bool isError = false;
DB.Do(db =>
{
isError = db.Default.Set().AsNoTracking().Any(p => p.Code == CODE && p.ENABLED);
});
return isError;
}
public static bool GetDeviceIsUsed(string CODE)
{
bool result = false;
DB.Do(db =>
{
var systemConfig = db.Default.Set().AsNoTracking().SingleOrDefault(p => p.DEVICECODE == CODE);
if (systemConfig != null) result = systemConfig.ENABLED;
});
return result;
}
}
}