You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
CaiQie/RfidWeb/Tool/PromptAlarmManager.cs

55 lines
1.5 KiB
C#

2 weeks ago
using System;
using System.Collections.Generic;
using System.Linq;
using DB.Entity;
using DB.Service;
using NewLife.Caching;
using Tool.Model;
namespace RfidWeb
{
public class PromptAlarmManager:BaseManager
{
PromptAlarm cPromptAlarm=new PromptAlarm();
public Dictionary<string, DateTime> GetList()
{
Dictionary<string, DateTime> dictionary = cache[CacheKeyManager.Prompt_alarmList] as Dictionary<string, DateTime>
?? new Dictionary<string, DateTime>();
List<AlarmData> list = alarmDataService.GetList();
var listEs = GetDic(list, "", "Prompt_alarm");
var bools = cPromptAlarm.GetDb();
cache.Set(CacheKeyManager.Prompt_alarm, bools, timeOut);
for (int i = 0; i < Max; i++)
{
var obj = bools[i];
if (!listEs.TryGetValue(i, out var value)) continue;
if (Convert.ToBoolean(obj))
{
if (!dictionary.ContainsKey(value))
{
dictionary[value] = DateTime.Now;
}
}
else
{
dictionary.Remove(value);
}
}
cache.Set(CacheKeyManager.Prompt_alarmList, dictionary, TimeSpan.FromMinutes(10));
return dictionary;
}
}
}