首次提交:添加src文件夹代码
This commit is contained in:
70
Cowain.Bake.BLL/RgvActionService.cs
Normal file
70
Cowain.Bake.BLL/RgvActionService.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
using Cowain.Bake.Common.Enums;
|
||||
using Cowain.Bake.Model;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using Unity;
|
||||
|
||||
namespace Cowain.Bake.BLL
|
||||
{
|
||||
public class RgvActionService : ServiceBase
|
||||
{
|
||||
private readonly List<TRgvAction> _actions;
|
||||
public RgvActionService(IUnityContainer unityContainer) : base(unityContainer)
|
||||
{
|
||||
using (var Context = new BakingEntities())
|
||||
{
|
||||
_actions = Context.Set<TRgvAction>().ToList();
|
||||
}
|
||||
}
|
||||
public List<TRgvAction> GetAll()
|
||||
{
|
||||
return _actions;
|
||||
}
|
||||
|
||||
public int GetNext(int cmd)
|
||||
{
|
||||
var action = _actions.Find(x => x.StepId == cmd);
|
||||
var next = _actions.Find(x => x.Id == action.Id + 1);
|
||||
if (null == next)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return next.StepId;
|
||||
}
|
||||
|
||||
public int GetPrevious(int cmd)
|
||||
{
|
||||
var action = _actions.Find(x => x.StepId == cmd);
|
||||
var next = _actions.Find(x => x.Id == action.Id - 1);
|
||||
if (null == next)
|
||||
{
|
||||
return (int)ETaskStep.MoveFrom;
|
||||
}
|
||||
return next.StepId;
|
||||
}
|
||||
|
||||
public TRgvAction GetAction(int cmd)
|
||||
{
|
||||
var action = _actions.Find(x => x.StepId == cmd);
|
||||
if (null == action)
|
||||
{
|
||||
return _actions.Find(x => x.Id == 1);
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
public List<TRgvAction> GetPreviousActions(int cmd)
|
||||
{
|
||||
var firstAction = _actions.Find(x => x.StepId == (int)ETaskStep.Unexecuted);
|
||||
var cmdAction = _actions.Find(x => x.StepId == cmd);
|
||||
return _actions.Where(x => x.Id <= cmdAction.Id && x.Id >= firstAction.Id).OrderBy(x => x.Id).ToList(); //= cmdAction.Id
|
||||
}
|
||||
|
||||
|
||||
public List<TRgvAction> GetNextActions(int cmd)
|
||||
{
|
||||
return _actions.Where(x => x.StepId >= cmd).OrderBy(x=>x.Id).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user