将S7后台服务移植到DMS.Infrastructure项目中

This commit is contained in:
2025-07-24 22:03:26 +08:00
parent 35e5033094
commit 58cb05645e
9 changed files with 597 additions and 3 deletions

View File

@@ -0,0 +1,34 @@
using DMS.Application.Interfaces;
using DMS.Core.Interfaces;
using DMS.Core.Models;
using Microsoft.Extensions.Logging;
using System.Threading.Tasks;
namespace DMS.Infrastructure.Services;
public class DataProcessingService : IDataProcessingService
{
private readonly ILogger<DataProcessingService> _logger;
private readonly IRepositoryManager _repositoryManager;
public DataProcessingService(ILogger<DataProcessingService> logger, IRepositoryManager repositoryManager)
{
_logger = logger;
_repositoryManager = repositoryManager;
}
public async Task EnqueueAsync(Variable variable)
{
_logger.LogInformation($"Processing variable: {variable.Name}, Value: {variable.DataValue}");
// 这里可以添加将变量数据保存到数据库的逻辑
// 例如:保存到 VariableHistory 表
var history = new VariableHistory
{
VariableId = variable.Id,
Value = variable.DataValue.ToString(),
Timestamp = System.DateTime.Now
};
await _repositoryManager.VariableHistories.AddAsync(history);
}
}