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 GetAll() { using (var Context = new PreheatEntities()) { return Context.Set().ToList(); } } public List GetDeviceByDesc(string parms) { using (var Context = new PreheatEntities()) { return Context.Set().Where(p => p.Desc.Contains(parms)).ToList(); } } public List GetConfig(EDeviceType devType) { using (var Context = new PreheatEntities()) { return Context.Set().Where(item => item.DType.ToLower() == devType.ToString().ToLower()).ToList(); //item.Enable == true && } } public List GetConfig(EDeviceType devType, EDevName devName) { using (var Context = new PreheatEntities()) { var ulist = Context.Set().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().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().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().Where(x => x.Id == Id).FirstOrDefault(); if (null == conf) { return 0; } conf.Enable = status; return Context.SaveChanges(); } } } }