Files
6098/Cowain.Bake.BLL/StationService.cs

104 lines
3.4 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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();
// }
//}
}
}