106 lines
3.1 KiB
C#
106 lines
3.1 KiB
C#
|
|
using Cowain.Preheat.Common.Core;
|
||
|
|
using Cowain.Preheat.Common.Enums;
|
||
|
|
using Cowain.Preheat.Model;
|
||
|
|
using System;
|
||
|
|
using System.Collections.Generic;
|
||
|
|
using System.Linq;
|
||
|
|
using System.Text;
|
||
|
|
using System.Threading.Tasks;
|
||
|
|
using Unity;
|
||
|
|
|
||
|
|
namespace Cowain.Preheat.BLL
|
||
|
|
{
|
||
|
|
public class DeviceConfigService : ServiceBase
|
||
|
|
{
|
||
|
|
public DeviceConfigService(IUnityContainer unityContainer) : base(unityContainer)
|
||
|
|
{
|
||
|
|
}
|
||
|
|
public List<TDeviceConfig> GetAll()
|
||
|
|
{
|
||
|
|
using (var Context = new PreheatEntities())
|
||
|
|
{
|
||
|
|
return Context.Set<TDeviceConfig>().ToList();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
public List<TDeviceConfig> GetDeviceByDesc(string parms)
|
||
|
|
{
|
||
|
|
using (var Context = new PreheatEntities())
|
||
|
|
{
|
||
|
|
return Context.Set<TDeviceConfig>().Where(p => p.Desc.Contains(parms)).ToList();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<TDeviceConfig> GetConfig(EDeviceType devType)
|
||
|
|
{
|
||
|
|
using (var Context = new PreheatEntities())
|
||
|
|
{
|
||
|
|
return Context.Set<TDeviceConfig>().Where(item => item.DType.ToLower() == devType.ToString().ToLower()).ToList(); //item.Enable == true &&
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public List<TDeviceConfig> GetConfig(EDeviceType devType, EDevName devName)
|
||
|
|
{
|
||
|
|
using (var Context = new PreheatEntities())
|
||
|
|
{
|
||
|
|
var ulist = Context.Set<TDeviceConfig>().Where(item => item.DType.ToLower() == devType.ToString().ToLower() &&
|
||
|
|
item.Name.ToLower().Contains(devName.ToString().ToLower())).ToList();
|
||
|
|
if (ulist.Count > 0)
|
||
|
|
{
|
||
|
|
return ulist;
|
||
|
|
}
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
public int UpdateStatus(int Id, bool status)
|
||
|
|
{
|
||
|
|
using (var Context = new PreheatEntities())
|
||
|
|
{
|
||
|
|
TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.Id == Id).FirstOrDefault();
|
||
|
|
|
||
|
|
if (null == conf)
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
conf.IsConnect = status;
|
||
|
|
CommonCoreHelper.BlockStatusColorItems.Add(conf); //生产者
|
||
|
|
|
||
|
|
return Context.SaveChanges();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
//public void UpdateMesJosn(string MesJosn)
|
||
|
|
//{
|
||
|
|
// using (var Context = new PreheatEntities())
|
||
|
|
// {
|
||
|
|
// TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.DType == "MES").FirstOrDefault();
|
||
|
|
|
||
|
|
// if (null == conf)
|
||
|
|
// {
|
||
|
|
// return;
|
||
|
|
// }
|
||
|
|
|
||
|
|
// conf.Json = MesJosn;
|
||
|
|
// Context.SaveChanges();
|
||
|
|
// }
|
||
|
|
//}
|
||
|
|
|
||
|
|
public int UpdateEnable(int Id, bool status)
|
||
|
|
{
|
||
|
|
using (var Context = new PreheatEntities())
|
||
|
|
{
|
||
|
|
TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.Id == Id).FirstOrDefault();
|
||
|
|
|
||
|
|
if (null == conf)
|
||
|
|
{
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
conf.Enable = status;
|
||
|
|
return Context.SaveChanges();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|