首次提交:添加src文件夹代码
This commit is contained in:
131
Cowain.Bake.BLL/DeviceConfigService.cs
Normal file
131
Cowain.Bake.BLL/DeviceConfigService.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using Cowain.Bake.Common.Core;
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using Cowain.Bake.Model;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Bake.BLL
|
||||
{
|
||||
public class DeviceConfigService : ServiceBase
|
||||
{
|
||||
public DeviceConfigService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
}
|
||||
public List<TDeviceConfig> GetAll()
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
return Context.Set<TDeviceConfig>().OrderBy(x=>x.Id).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TDeviceConfig> GetUnEnableAll()
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
return Context.Set<TDeviceConfig>().Where(x=>x.Enable == false).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
public List<TDeviceConfig> GetDeviceByDesc(string parms)
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
return Context.Set<TDeviceConfig>().Where(p => p.Desc.Contains(parms)).ToList();
|
||||
}
|
||||
}
|
||||
public TDeviceConfig GetConfig(int stationId)
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
return (from s in Context.Set<TStation>()
|
||||
join d in Context.Set<TDeviceConfig>() on s.DeviceId equals d.Id
|
||||
where s.Id == stationId
|
||||
select d).FirstOrDefault();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public List<TDeviceConfig> GetConfig(EDeviceType devType)
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
return Context.Set<TDeviceConfig>().Where(item => item.Type == (int)devType).ToList(); //item.Enable == true &&
|
||||
}
|
||||
}
|
||||
|
||||
public List<TDeviceConfig> GetConfig(EDeviceType devType, EDeviceName devName)
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
var ulist = Context.Set<TDeviceConfig>().Where(item => item.Type == (int)devType &&
|
||||
item.Name.ToLower().Contains(devName.ToString().ToLower())).ToList();
|
||||
if (ulist.Count > 0)
|
||||
{
|
||||
return ulist;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public List<TDeviceConfig> GetConfig(EDeviceType devType, string subDevName)
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
return Context.Set<TDeviceConfig>().Where(item => item.Type == (int)devType &&
|
||||
item.Name.ToLower().Contains(subDevName.ToLower())).ToList();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public int UpdateStatus(int Id, bool status)
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.Id == Id).FirstOrDefault();
|
||||
|
||||
if (null == conf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
conf.IsConnect = status;
|
||||
CommonCoreHelper.Instance.BlockStatusColor.Add(conf); //生产者
|
||||
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
//public void UpdateMesJosn(string MesJosn)
|
||||
//{
|
||||
// using (var Context = new BakingEntities())
|
||||
// {
|
||||
// TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.Type == (int)EDeviceType.MES).FirstOrDefault();
|
||||
|
||||
// if (null == conf)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// conf.Json = MesJosn;
|
||||
// Context.SaveChanges();
|
||||
// }
|
||||
//}
|
||||
|
||||
public int UpdateEnable(int Id, bool status)
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
TDeviceConfig conf = Context.Set<TDeviceConfig>().Where(x => x.Id == Id).FirstOrDefault();
|
||||
|
||||
if (null == conf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
conf.Enable = status;
|
||||
return Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user