using Cksoft.Data; using Cksoft.Unity; using DllEapEntity; using DllEapEntity.Dtos; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DllEapDal.OFILM { public class ReportlogicDal { private IDatabase CurrDb = null; public ReportlogicDal(IDatabase db) { CurrDb = db; } public IEnumerable Get(int start, int length, string order, string sort, string filter, string errorinfo) { try { var pros = CurrDb.FindListForCondition($" {filter} order by {sort} {order} limit {start - 1},{length}", ref errorinfo); return pros; } catch (Exception ex) { Console.WriteLine(ex.ToString() + ex.StackTrace); return null; } } public int GetCount(string filter) { string errorinfo = string.Empty; var entities = CurrDb.FindListForCondition(filter, ref errorinfo); if (entities != null) { return entities.Count(); } return 0; } public Reportlogic GetSingle(string pageName, string errorinfo) { string filter = $" and a.pageName='{pageName}'"; var pro = CurrDb.FindListForCondition(filter,ref errorinfo).FirstOrDefault(); return pro; } /// /// 添加WorkingProcedure并返回Id /// /// /// /// public int Add(Reportlogic pro, string userCode, ref string errorinfo) { var entities = CurrDb.FindListForCondition($" and a.pageName='{pro.pageName}' ", ref errorinfo); if (entities != null && entities.Count() > 0) { errorinfo = "已存在相同界面名称,请确认!"; return -1; } CurrDb.InsertFor(pro, userCode); var sql = "select @@identity;"; var id = Convert.ToInt32(CurrDb.FindList(sql).FirstOrDefault() ?? "-1"); return id; } /// /// /// /// /// /// /// public int Update(Reportlogic role, string userCode, ref string errorinfo) { var entities = CurrDb.FindListForCondition($" and a.pageName='{role.pageName}' and a.ID<>{role.ID}", ref errorinfo); if (entities != null && entities.Count() > 0) { errorinfo = "已存在相同界面名称,请确认"; return -1; } if (CurrDb.UpdateFor(role, userCode) < 0) { return -1; } return role.ID; } } }