首次提交:添加src文件夹代码
This commit is contained in:
103
Cowain.Bake.BLL/StationService.cs
Normal file
103
Cowain.Bake.BLL/StationService.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using Cowain.Bake.Model.Models;
|
||||
using Cowain.Bake.Common.Core;
|
||||
using Cowain.Bake.Model;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Unity;
|
||||
using System.Data.Entity;
|
||||
|
||||
namespace Cowain.Bake.BLL
|
||||
{
|
||||
public class StationService : ServiceBase
|
||||
{
|
||||
private readonly List<TStation> _station;
|
||||
public StationService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
_station = Context.Set<TStation>().OrderBy(x => x.Id).ToList();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取工位列表信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<TStation> GetAll()
|
||||
{
|
||||
return _station;
|
||||
}
|
||||
|
||||
public List<string> GetInfo(int deviceId)
|
||||
{
|
||||
var stations = _station.Where(m => m.DeviceId == deviceId).ToList();
|
||||
return stations.Select(x => x.Id.ToString()).ToList();
|
||||
}
|
||||
|
||||
public List<TStation> GetStaions(int deviceId)
|
||||
{
|
||||
return _station.Where(m => m.DeviceId == deviceId).ToList();
|
||||
}
|
||||
public List<TStation> GetStationsByType(int type)
|
||||
{
|
||||
return _station.Where(x => x.Type == type).OrderBy(x => x.Id).ToList();
|
||||
}
|
||||
|
||||
public TStation GetStationByCavityId(int cavityId)
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
return (from s in Context.Set<TStation>()
|
||||
join c in Context.Set<TCavityInfo>() on s.Id equals c.StationId
|
||||
where c.Id == cavityId
|
||||
select s).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
public void UpdateEnableStatus(TStation machineModel)
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
var pi = (from ts in Context.Set<TStation>()
|
||||
where ts.Id == machineModel.Id
|
||||
select ts).FirstOrDefault();
|
||||
pi.Enable = machineModel.Enable;
|
||||
Context.SaveChanges();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取工位明细列表信息
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public List<TCavityInfo> GetAllStationDetailList()
|
||||
//{
|
||||
// using (var Context = new BakingEntities())
|
||||
// {
|
||||
// var dataList = Context.Set<TCavityInfo>().OrderBy(x => x.StationId).ThenBy(s => s.Layer).ToList();
|
||||
// return dataList;
|
||||
// }
|
||||
//}
|
||||
|
||||
public TStation GetStation(int stationId)
|
||||
{
|
||||
return _station.Where(p => p.Id == stationId).FirstOrDefault();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改工位明细信息
|
||||
/// </summary>
|
||||
/// <param name="stationDetail"></param>
|
||||
/// <returns></returns>
|
||||
//public int UpdateStationDetailInfo(TCavityInfo stationDetail)
|
||||
//{
|
||||
// using (var Context = new BakingEntities())
|
||||
// {
|
||||
// Context.Set<TCavityInfo>().Attach(stationDetail);//将数据附加到上下文,支持实体修改和新实体,重置为UnChanged
|
||||
// Context.Entry<TCavityInfo>(stationDetail).State = EntityState.Modified;
|
||||
// return Context.SaveChanges();
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user