从山证v2.3.0拷贝
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using YLErp.Abstract;
|
||||
|
||||
namespace YLErp.Modules.DataCacheModule
|
||||
{
|
||||
class AppConfigUpdater : IDataUpdater, IJsonSerializable
|
||||
{
|
||||
public string TableName => nameof(AppConfig);
|
||||
|
||||
public void UpdateData(IEnumerable<string> updateKeyIds)
|
||||
{
|
||||
if (updateKeyIds is null || !updateKeyIds.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const string prefix = "ProjectConfig.";
|
||||
|
||||
updateKeyIds = updateKeyIds.Where(n => n.StartsWith(prefix)).Select(n => n.Substring(prefix.Length)).ToArray();
|
||||
|
||||
if (!updateKeyIds.Any())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
using (var db = DbContextFactory.GetYLDbContext())
|
||||
{
|
||||
var datas = db.AppConfig.Where(n => n.PGroup == "ProjectConfig" && updateKeyIds.Contains(n.PName))
|
||||
.Select(n => new { n.PName, n.PValue }).ToArray();
|
||||
|
||||
var logger = LogFactory.GetLogger(nameof(AppConfigUpdater));
|
||||
|
||||
foreach (var item in datas)
|
||||
{
|
||||
PS.SetConfig(item.PName, item.PValue);
|
||||
|
||||
logger.Info($"更新PSConfig(name:{item.PName},value:{item.PValue})");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ToJson()
|
||||
{
|
||||
return PS.Config.ToJson();
|
||||
}
|
||||
|
||||
public static readonly AppConfigUpdater Default;
|
||||
|
||||
static AppConfigUpdater()
|
||||
{
|
||||
Default = new AppConfigUpdater();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user