using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using SqlSugar;
|
|
namespace IStation.DAL
|
{
|
/// <summary>
|
/// 监测波动记录
|
/// </summary>
|
public partial class MonitorFluctRecord : CorpDAL<Entity.MonitorFluctRecord>
|
{
|
/// <summary>
|
///
|
/// </summary>
|
public override ConnectionConfig ConnectionConfig
|
{
|
get { return ConfigHelper.MonitorRecordConnectionConfig; }
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取
|
/// </summary>
|
public List<Entity.MonitorFluctRecord> GetByMonitorPointID(long CorpID, long MonitorPointID)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.MonitorFluctRecord>()
|
.Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID).ToList();
|
}
|
}
|
|
/// <summary>
|
/// 通过 SignalID 获取
|
/// </summary>
|
public Entity.MonitorFluctRecord GetBySignalID(long CorpID, long MonitorPointID, long SignalID)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.MonitorFluctRecord>()
|
.Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID&&x.SignalID==SignalID).First();
|
}
|
}
|
|
/// <summary>
|
/// 通过 SignalID 判断是否存在
|
/// </summary>
|
public bool IsExistBySignalID(long CorpID, long MonitorPointID, long SignalID)
|
{
|
using(var db=new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.MonitorFluctRecord>()
|
.Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID && x.SignalID == SignalID)
|
.Count() > 0;
|
}
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 判断是否存在
|
/// </summary>
|
public bool IsExistByMonitorPointID(long CorpID, long MonitorPointID)
|
{
|
using (var db = new SqlSugarClient(ConnectionConfig))
|
{
|
return db.Queryable<Entity.MonitorFluctRecord>()
|
.Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID)
|
.Count() > 0;
|
}
|
}
|
|
/// <summary>
|
/// 插入或更新
|
/// </summary>
|
public bool InsertOrUpdate(Entity.MonitorFluctRecord entity)
|
{
|
if (entity == null)
|
return false;
|
var src = GetBySignalID(entity.CorpID, entity.MonitorPointID, entity.SignalID);
|
if (src == null)
|
{
|
return Insert(entity)>0;
|
}
|
entity.ID = src.ID;
|
return Update(entity);
|
}
|
|
|
}
|
}
|