using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
|
namespace IStation.Server
|
{
|
/// <summary>
|
/// 报警监测记录缓存辅助类
|
/// </summary>
|
public class MonitorRecord4AlarmCacheHelper
|
{
|
//记录列表
|
private static readonly List<Model.MonitorBasicRecord> _recordList = new List<Model.MonitorBasicRecord>();
|
//数据不变记录列表
|
private static readonly List<Model.MonitorBasicRecord> _unChangedRecordList = new List<Model.MonitorBasicRecord>();
|
|
/// <summary>
|
/// 设置
|
/// </summary>
|
public static void Set(List<Model.MonitorBasicRecord> list)
|
{
|
if (list == null || list.Count < 1)
|
return;
|
list.ForEach(x => {
|
_recordList.RemoveAll(t=>t.CorpID==x.CorpID&&t.MonitorPointID==x.MonitorPointID&&t.SignalID==x.SignalID);
|
_recordList.Add(x);
|
var lastUnChangedRecord = _unChangedRecordList.Find(t => t.CorpID == x.CorpID && t.MonitorPointID == x.MonitorPointID && t.SignalID == x.SignalID);
|
if (lastUnChangedRecord == null)
|
{
|
_unChangedRecordList.Add(x);
|
}
|
else
|
{
|
if (lastUnChangedRecord.DataValue != x.DataValue)
|
{
|
_unChangedRecordList.RemoveAll(t => t.CorpID == x.CorpID && t.MonitorPointID == x.MonitorPointID && t.SignalID == x.SignalID);
|
_unChangedRecordList.Add(x);
|
}
|
}
|
});
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取
|
/// </summary>
|
public static List<Model.MonitorBasicRecord> GetByMonitorPointID(long CorpID, long MonitorPointID)
|
{
|
return _recordList.Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID).ToList();
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取第一条
|
/// </summary>
|
public static Model.MonitorBasicRecord GetFirstByMonitorPointID(long CorpID, long MonitorPointID)
|
{
|
return _recordList.FirstOrDefault(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID);
|
}
|
|
/// <summary>
|
/// 通过 SignalID 获取
|
/// </summary>
|
public static Model.MonitorBasicRecord GetBySignalID(long CorpID, long MonitorPointID, long SignalID)
|
{
|
return _recordList.Find(x=>x.CorpID==CorpID&&x.MonitorPointID==MonitorPointID&&x.SignalID==SignalID);
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取不变的
|
/// </summary>
|
public static List<Model.MonitorBasicRecord> GetUnChangedByMonitorPointID(long CorpID, long MonitorPointID)
|
{
|
return _unChangedRecordList.Where(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID).ToList();
|
}
|
|
/// <summary>
|
/// 通过 MonitorPointID 获取不变的第一条
|
/// </summary>
|
public static Model.MonitorBasicRecord GetFirstUnChangedByMonitorPointID(long CorpID, long MonitorPointID)
|
{
|
return _unChangedRecordList.FirstOrDefault(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID);
|
}
|
|
/// <summary>
|
/// 通过 SignalID 获取不变的
|
/// </summary>
|
public static Model.MonitorBasicRecord GetUnChangedBySignalID(long CorpID, long MonitorPointID, long SignalID)
|
{
|
return _unChangedRecordList.Find(x => x.CorpID == CorpID && x.MonitorPointID == MonitorPointID && x.SignalID == SignalID);
|
}
|
|
|
|
}
|
}
|