using System; using System.Collections.Generic; using System.Text; using System.Linq; namespace RoadFlow.Platform { public class WorkFlowButtons { private RoadFlow.Data.Interface.IWorkFlowButtons dataWorkFlowButtons; public WorkFlowButtons() { this.dataWorkFlowButtons = Data.Factory.Factory.GetWorkFlowButtons(); } /// /// 新增 /// public int Add(RoadFlow.Data.Model.WorkFlowButtons model) { return dataWorkFlowButtons.Add(model); } /// /// 更新 /// public int Update(RoadFlow.Data.Model.WorkFlowButtons model) { return dataWorkFlowButtons.Update(model); } /// /// 查询所有记录 /// /// 是否从缓存获取 /// public List GetAll(bool fromCache=false) { if (fromCache) { string key = RoadFlow.Utility.Keys.CacheKeys.WorkFlowButtons.ToString(); object obj = RoadFlow.Cache.IO.Opation.Get(key); if (obj != null && obj is List) { return obj as List; } else { var list = dataWorkFlowButtons.GetAll(); RoadFlow.Cache.IO.Opation.Set(key, list); return list; } } else { return dataWorkFlowButtons.GetAll(); } } /// /// 查询单条记录 /// public RoadFlow.Data.Model.WorkFlowButtons Get(Guid id, bool fromCache=false) { if (fromCache) { var all = GetAll(true); var button = all.Find(p => p.ID == id); return button == null ? dataWorkFlowButtons.Get(id) : button; } else { return dataWorkFlowButtons.Get(id); } } /// /// 删除 /// public int Delete(Guid id) { return dataWorkFlowButtons.Delete(id); } /// /// 查询记录条数 /// public long GetCount() { return dataWorkFlowButtons.GetCount(); } /// /// 清除缓存 /// public void ClearCache() { string key = RoadFlow.Utility.Keys.CacheKeys.WorkFlowButtons.ToString(); RoadFlow.Cache.IO.Opation.Remove(key); } /// /// 查询最大排序 /// public int GetMaxSort() { return dataWorkFlowButtons.GetMaxSort(); } } }