将NlogHelper,和NotificationHelper,改为服务的方式注入使用

This commit is contained in:
2025-09-04 17:29:24 +08:00
parent c45287fae0
commit bb650e2682
35 changed files with 307 additions and 474 deletions

View File

@@ -1,16 +1,18 @@
using System.Threading.Tasks;
using DMS.Application.Interfaces;
using DMS.Application.Models;
using DMS.Core.Helper;
using DMS.Core.Models;
using Microsoft.Extensions.Logging;
namespace DMS.Application.Services.Processors;
public class UpdateDbVariableProcessor : IVariableProcessor
{
private readonly ILogger<UpdateDbVariableProcessor> _logger;
public UpdateDbVariableProcessor()
public UpdateDbVariableProcessor(ILogger<UpdateDbVariableProcessor> logger)
{
_logger = logger;
}
public async Task ProcessAsync(VariableContext context)
@@ -19,18 +21,18 @@ public class UpdateDbVariableProcessor : IVariableProcessor
{
// 假设 DataServices 有一个方法来更新 Variable
// await _dataServices.UpdateVariableAsync(context.Data);
// NlogHelper.Info($"数据库变量 {context.Data.Name} 更新成功,值为: {context.Data.DataValue}");
// _logger.LogInformation($"数据库变量 {context.Data.Name} 更新成功,值为: {context.Data.DataValue}");
// if (!_dataServices.AllVariables.TryGetValue(context.Data.Id, out Variable oldVariable))
// {
// NlogHelper.Warn($"数据库更新完成修改变量值是否改变时在_dataServices.AllVariables中找不到Id:{context.Data.Id},Name:{context.Data.Name}的变量。");
// _logger.LogWarning($"数据库更新完成修改变量值是否改变时在_dataServices.AllVariables中找不到Id:{context.Data.Id},Name:{context.Data.Name}的变量。");
// context.IsHandled = true;
// }
// oldVariable.DataValue = context.Data.DataValue;
}
catch (Exception ex)
{
NlogHelper.Error($"更新数据库变量 {context.Data.Name} 失败: {ex.Message}", ex);
_logger.LogError(ex, $"更新数据库变量 {context.Data.Name} 失败: {ex.Message}");
}
}
}