大屏优化

This commit is contained in:
2025-03-17 15:53:00 +08:00
parent 4ee7d38c78
commit 2927c2d985
10 changed files with 1020 additions and 774 deletions
+35 -11
View File
@@ -5,6 +5,8 @@
using Model;
using System;
using Newtonsoft.Json;
using Microsoft.SqlServer.Dts.Runtime;
using System.Runtime.Caching;
public static class ProjectService
{
@@ -256,22 +258,44 @@
/// <returns></returns>
public static List<Model.Base_Project> GetAllProjectDropDownList(string[] pids = null)
{
if (pids == null)
string cacheKey = "allProjects";
var memoryCache = MemoryCache.Default;
if (memoryCache.Get(cacheKey) != null)
{
var list = (from x in Funs.DB.Base_Project
orderby x.ProjectCode descending
select x).ToList();
return list;
var result = (List<Model.Base_Project>)memoryCache.Get(cacheKey);
if (pids == null)
{
return result;
}
else
{
result = result.Where(e => pids.Contains(e.ProjectId)).ToList();
return result;
}
}
else
{
var list = (from x in Funs.DB.Base_Project
where pids.Contains(x.ProjectId)
orderby x.ProjectCode descending
select x).ToList();
return list;
}
var list = (from x in Funs.DB.Base_Project
where x.ProjectState == Const.ProjectState_1 || x.ProjectState == null
orderby x.ProjectCode descending
select x).ToList();
var policy = new CacheItemPolicy
{
AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(Const.CacheMinutes),
};
memoryCache.Set(cacheKey, list, policy);
if (pids == null)
{
return list;
}
else
{
var result = list.Where(e => pids.Contains(e.ProjectId)).ToList();
return result;
}
}
}