1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 |
- 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<QueueAlarmConfig> Get(int start, int length, string order, string sort, string filter, ref string errorinfo, out int total)
- {
- var pros = CurrDb.FindListForCondition<QueueAlarmConfig>($" {filter} order by {sort} {order} limit {start - 1},{length}", ref errorinfo);
- total = CurrDb.FindListForCondition<QueueAlarmConfig>(filter, ref errorinfo)
- .Count();
- return pros;
- }
- public QueueAlarmConfig Get(int id)
- {
- var pro = CurrDb.FindEntityFor<QueueAlarmConfig>(id);
- return pro;
- }
- public int Add(QueueAlarmConfig pro, string userCode, ref string errorinfo)
- {
- var entities = CurrDb.FindListForCondition<QueueAlarmConfig>($" 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<string>(sql).FirstOrDefault() ?? "-1");
- return id;
- }
- public int Update(QueueAlarmConfig role, string userCode, ref string errorinfo)
- {
- var entities = CurrDb.FindListForCondition<QueueAlarmConfig>($" 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<QueueAlarmConfig>(id) < 0)
- {
- msg = "删除失败";
- return -1;
- }
- msg = string.Empty;
- return 1;
- }
- }
- }
|