using Cksoft.Data; using DllEapEntity; using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace DllEapDal.OFILM { public class QueueAlarmConfigDal { private IDatabase CurrDb = null; public QueueAlarmConfigDal(IDatabase db) { CurrDb = db; } public IEnumerable Get(int start, int length, string order, string sort, string filter, ref string errorinfo, out int total) { var pros = CurrDb.FindListForCondition($" {filter} order by {sort} {order} limit {start - 1},{length}", ref errorinfo); total = CurrDb.FindListForCondition(filter, ref errorinfo) .Count(); return pros; } public QueueAlarmConfig Get(int id) { var pro = CurrDb.FindEntityFor(id); return pro; } public int Add(QueueAlarmConfig pro, string userCode, ref string errorinfo) { var entities = CurrDb.FindListForCondition($" and a.QueueName='{pro.QueueName}' ", 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(QueueAlarmConfig role, string userCode, ref string errorinfo) { var entities = CurrDb.FindListForCondition($" and a.QueueName='{role.QueueName}' " + $"and a.ID<>{role.Id}", ref errorinfo); if (entities != null && entities.Count() > 0) { errorinfo = "已存在该队列的报警阈值配置"; return -1; } role.ModTime = DateTime.Now; if (CurrDb.UpdateFor(role, userCode) < 0) { return -1; } return role.Id; } public int Delete(int id, ref string msg) { if (CurrDb.DeleteFor(id) < 0) { msg = "删除失败"; return -1; } msg = string.Empty; return 1; } } }