From e92f5dac5da465e3786f3c2d0d8fa8685924139f Mon Sep 17 00:00:00 2001 From: "David P.G" Date: Tue, 9 Sep 2025 16:46:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=AD=89=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DMS.Application/Interfaces/IDataLoaderService.cs | 2 +- DMS.Application/Services/DataLoaderService.cs | 6 +++--- DMS.Infrastructure/Entities/DbMqttServer.cs | 4 ++++ DMS.WPF/Configurations/nlog.config | 2 +- DMS.WPF/ViewModels/SplashViewModel.cs | 2 +- 5 files changed, 10 insertions(+), 6 deletions(-) diff --git a/DMS.Application/Interfaces/IDataLoaderService.cs b/DMS.Application/Interfaces/IDataLoaderService.cs index db8b6cd..bb241bf 100644 --- a/DMS.Application/Interfaces/IDataLoaderService.cs +++ b/DMS.Application/Interfaces/IDataLoaderService.cs @@ -42,7 +42,7 @@ public interface IDataLoaderService /// /// 异步加载所有日志数据 /// - Task> LoadAllNlogsAsync(); + Task> LoadAllNlogsAsync(int count); /// /// 当数据加载完成时触发 diff --git a/DMS.Application/Services/DataLoaderService.cs b/DMS.Application/Services/DataLoaderService.cs index 1531c0e..0e829ad 100644 --- a/DMS.Application/Services/DataLoaderService.cs +++ b/DMS.Application/Services/DataLoaderService.cs @@ -81,7 +81,7 @@ public class DataLoaderService : IDataLoaderService var mqttServerDtos = await LoadAllMqttServersAsync(); // 加载所有日志 - var nlogDtos = await LoadAllNlogsAsync(); + var nlogDtos = await LoadAllNlogsAsync(100); // 获取变量MQTT别名 var variableMqttAliases = await _repositoryManager.VariableMqttAliases.GetAllAsync(); @@ -191,8 +191,8 @@ public class DataLoaderService : IDataLoaderService /// /// 异步加载所有日志数据 /// - public async Task> LoadAllNlogsAsync() + public async Task> LoadAllNlogsAsync(int count) { - return await _nlogAppService.GetAllLogsAsync(); + return await _nlogAppService.GetLatestLogsAsync(count); } } \ No newline at end of file diff --git a/DMS.Infrastructure/Entities/DbMqttServer.cs b/DMS.Infrastructure/Entities/DbMqttServer.cs index 96c6764..ec1c426 100644 --- a/DMS.Infrastructure/Entities/DbMqttServer.cs +++ b/DMS.Infrastructure/Entities/DbMqttServer.cs @@ -31,11 +31,13 @@ public class DbMqttServer /// /// 用户名 /// + [SugarColumn(IsNullable = true)] public string Username { get; set; } /// /// 密码 /// + [SugarColumn(IsNullable = true)] public string Password { get; set; } /// @@ -46,11 +48,13 @@ public class DbMqttServer /// /// 订阅的主题 /// + [SugarColumn(IsNullable = true)] public string SubscribeTopic { get; set; } /// /// 发布的主题 /// + [SugarColumn(IsNullable = true)] public string PublishTopic { get; set; } /// diff --git a/DMS.WPF/Configurations/nlog.config b/DMS.WPF/Configurations/nlog.config index fc71cfe..7f3648b 100644 --- a/DMS.WPF/Configurations/nlog.config +++ b/DMS.WPF/Configurations/nlog.config @@ -73,6 +73,6 @@ - + \ No newline at end of file diff --git a/DMS.WPF/ViewModels/SplashViewModel.cs b/DMS.WPF/ViewModels/SplashViewModel.cs index 42481d8..982b37c 100644 --- a/DMS.WPF/ViewModels/SplashViewModel.cs +++ b/DMS.WPF/ViewModels/SplashViewModel.cs @@ -5,6 +5,7 @@ using CommunityToolkit.Mvvm.Input; using DMS.Application.Interfaces; using DMS.WPF.Services; using System; +using System.Data; using System.Threading.Tasks; using DMS.Application.Services; using DMS.WPF.Helper; @@ -46,7 +47,6 @@ public partial class SplashViewModel : ObservableObject { try { - _logger.LogInformation("正在初始化数据库..."); LoadingMessage = "正在初始化数据库..."; _initializeService.InitializeTables();