|
|
|
@ -1,70 +1,70 @@
|
|
|
|
|
using DevExpress.XtraEditors;
|
|
|
|
|
|
|
|
|
|
using NewLife.Caching;
|
|
|
|
|
|
|
|
|
|
using ProductionSystem_Model.Enum;
|
|
|
|
|
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace ProductionSystem.Untils
|
|
|
|
|
{
|
|
|
|
|
public class EquipmentCacheManager
|
|
|
|
|
{
|
|
|
|
|
static ICache cache=Cache.Default;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void Init(string code)
|
|
|
|
|
{
|
|
|
|
|
cache.Remove(code);
|
|
|
|
|
cache.Set(code, new Dictionary<string, string>(), TimeSpan.FromMinutes(20));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Add(string code,EquipmentEnum equipmentEnum, string value)
|
|
|
|
|
{
|
|
|
|
|
if(!cache.ContainsKey(code))
|
|
|
|
|
{
|
|
|
|
|
Init(code);
|
|
|
|
|
}
|
|
|
|
|
var dic = cache[code] as Dictionary<string, string>;
|
|
|
|
|
dic[equipmentEnum.ToString()] = value;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string GetCode(string code, EquipmentEnum equipmentEnum)
|
|
|
|
|
{
|
|
|
|
|
var dic = cache[code] as Dictionary<string, string>;
|
|
|
|
|
if (null == dic) return "-1";
|
|
|
|
|
if (dic.TryGetValue(equipmentEnum.ToString(), out var value))
|
|
|
|
|
{
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
return "-1";
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void Remove(string code)
|
|
|
|
|
{
|
|
|
|
|
cache.Remove(code);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void CleanKey(string code)
|
|
|
|
|
{
|
|
|
|
|
var list= cache.Keys;
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
{
|
|
|
|
|
if (item != code)
|
|
|
|
|
{
|
|
|
|
|
Remove(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// using DevExpress.XtraEditors;
|
|
|
|
|
//
|
|
|
|
|
// using NewLife.Caching;
|
|
|
|
|
//
|
|
|
|
|
// using ProductionSystem_Model.Enum;
|
|
|
|
|
//
|
|
|
|
|
// using SqlSugar;
|
|
|
|
|
//
|
|
|
|
|
// using System;
|
|
|
|
|
// using System.Collections.Generic;
|
|
|
|
|
// using System.Linq;
|
|
|
|
|
// using System.Text;
|
|
|
|
|
// using System.Threading.Tasks;
|
|
|
|
|
//
|
|
|
|
|
// namespace ProductionSystem.Untils
|
|
|
|
|
// {
|
|
|
|
|
// public class EquipmentCacheManager
|
|
|
|
|
// {
|
|
|
|
|
// static ICache cache=Cache.Default;
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// public static void Init(string code)
|
|
|
|
|
// {
|
|
|
|
|
// cache.Remove(code);
|
|
|
|
|
// cache.Set(code, new Dictionary<string, string>(), TimeSpan.FromMinutes(20));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// public static void Add(string code,EquipmentEnum equipmentEnum, string value)
|
|
|
|
|
// {
|
|
|
|
|
// if(!cache.ContainsKey(code))
|
|
|
|
|
// {
|
|
|
|
|
// Init(code);
|
|
|
|
|
// }
|
|
|
|
|
// var dic = cache[code] as Dictionary<string, string>;
|
|
|
|
|
// dic[equipmentEnum.ToString()] = value;
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// public static string GetCode(string code, EquipmentEnum equipmentEnum)
|
|
|
|
|
// {
|
|
|
|
|
// var dic = cache[code] as Dictionary<string, string>;
|
|
|
|
|
// if (null == dic) return "-1";
|
|
|
|
|
// if (dic.TryGetValue(equipmentEnum.ToString(), out var value))
|
|
|
|
|
// {
|
|
|
|
|
// return value;
|
|
|
|
|
// }
|
|
|
|
|
// return "-1";
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// public static void Remove(string code)
|
|
|
|
|
// {
|
|
|
|
|
// cache.Remove(code);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// public static void CleanKey(string code)
|
|
|
|
|
// {
|
|
|
|
|
// var list= cache.Keys;
|
|
|
|
|
// foreach (var item in list)
|
|
|
|
|
// {
|
|
|
|
|
// if (item != code)
|
|
|
|
|
// {
|
|
|
|
|
// Remove(item);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|