diff --git a/DMS.Application/DTOs/NlogDto.cs b/DMS.Application/DTOs/NlogDto.cs
new file mode 100644
index 0000000..8614ff2
--- /dev/null
+++ b/DMS.Application/DTOs/NlogDto.cs
@@ -0,0 +1,72 @@
+namespace DMS.Application.DTOs;
+
+///
+/// 用于在UI上显示NLog日志条目的DTO。
+///
+public class NlogDto
+{
+ ///
+ /// 日志ID。
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// 日志记录时间。
+ ///
+ public DateTime LogTime { get; set; }
+
+ ///
+ /// 日志级别 (如 INFO, ERROR 等)。
+ ///
+ public string Level { get; set; }
+
+ ///
+ /// 线程ID。
+ ///
+ public int ThreadId { get; set; }
+
+ ///
+ /// 线程名称。
+ ///
+ public string ThreadName { get; set; }
+
+ ///
+ /// 调用点(通常是记录日志的方法名)。
+ ///
+ public string Callsite { get; set; }
+
+ ///
+ /// 调用点所在的行号。
+ ///
+ public int CallsiteLineNumber { get; set; }
+
+ ///
+ /// 日志消息内容。
+ ///
+ public string Message { get; set; }
+
+ ///
+ /// 记录日志的记录器名称。
+ ///
+ public string Logger { get; set; }
+
+ ///
+ /// 异常信息(如果有的话)。
+ ///
+ public string Exception { get; set; }
+
+ ///
+ /// 调用方文件路径。
+ ///
+ public string CallerFilePath { get; set; }
+
+ ///
+ /// 调用方行号。
+ ///
+ public int CallerLineNumber { get; set; }
+
+ ///
+ /// 调用方成员(方法名)。
+ ///
+ public string CallerMember { get; set; }
+}
\ No newline at end of file
diff --git a/DMS.Application/Interfaces/INlogAppService.cs b/DMS.Application/Interfaces/INlogAppService.cs
new file mode 100644
index 0000000..bad8743
--- /dev/null
+++ b/DMS.Application/Interfaces/INlogAppService.cs
@@ -0,0 +1,30 @@
+using DMS.Application.DTOs;
+
+namespace DMS.Application.Interfaces;
+
+///
+/// 定义Nlog日志管理相关的应用服务操作。
+///
+public interface INlogAppService
+{
+ ///
+ /// 异步根据ID获取Nlog日志DTO。
+ ///
+ Task GetLogByIdAsync(int id);
+
+ ///
+ /// 异步获取所有Nlog日志DTO列表。
+ ///
+ Task> GetAllLogsAsync();
+
+ ///
+ /// 异步获取指定数量的最新Nlog日志DTO列表。
+ ///
+ /// 要获取的日志条目数量。
+ Task> GetLatestLogsAsync(int count);
+
+ // 可以在这里添加更多针对日志的查询服务方法,例如:
+ // Task> GetLogsByLevelAsync(string level);
+ // Task> GetLogsByDateRangeAsync(DateTime startDate, DateTime endDate);
+ // Task> SearchLogsAsync(string searchTerm);
+}
\ No newline at end of file
diff --git a/DMS.Application/Services/NlogAppService.cs b/DMS.Application/Services/NlogAppService.cs
new file mode 100644
index 0000000..8f89696
--- /dev/null
+++ b/DMS.Application/Services/NlogAppService.cs
@@ -0,0 +1,90 @@
+using AutoMapper;
+using DMS.Application.DTOs;
+using DMS.Application.Interfaces;
+using DMS.Core.Interfaces;
+
+namespace DMS.Application.Services;
+
+///
+/// Nlog日志应用服务,负责处理Nlog日志相关的业务逻辑。
+/// 实现 接口。
+///
+public class NlogAppService : INlogAppService
+{
+ private readonly IRepositoryManager _repoManager;
+ private readonly IMapper _mapper;
+
+ ///
+ /// 构造函数,通过依赖注入获取仓储管理器和AutoMapper实例。
+ ///
+ /// 仓储管理器实例。
+ /// AutoMapper 实例。
+ public NlogAppService(IRepositoryManager repoManager, IMapper mapper)
+ {
+ _repoManager = repoManager;
+ _mapper = mapper;
+ }
+
+ ///
+ /// 异步根据ID获取Nlog日志数据传输对象。
+ ///
+ /// 日志ID。
+ /// Nlog日志数据传输对象。
+ public async Task GetLogByIdAsync(int id)
+ {
+ var log = await _repoManager.Nlogs.GetByIdAsync(id);
+ return _mapper.Map(log);
+ }
+
+ ///
+ /// 异步获取所有Nlog日志数据传输对象列表。
+ ///
+ /// Nlog日志数据传输对象列表。
+ public async Task> GetAllLogsAsync()
+ {
+ var logs = await _repoManager.Nlogs.GetAllAsync();
+ return _mapper.Map>(logs);
+ }
+
+ ///
+ /// 异步获取指定数量的最新Nlog日志数据传输对象列表。
+ ///
+ /// 要获取的日志条目数量。
+ /// 最新的Nlog日志数据传输对象列表。
+ public async Task> GetLatestLogsAsync(int count)
+ {
+ // 注意:这里的实现假设仓储层或数据库支持按时间倒序排列并取前N条。
+ // 如果 BaseRepository 没有提供这种能力,可能需要直接访问 DbNlog 实体。
+ // 例如:var dbLogs = await _repoManager.Nlogs.Db.Queryable().OrderByDescending(n => n.LogTime).Take(count).ToListAsync();
+ // var logs = _mapper.Map>(dbLogs);
+ // return _mapper.Map>(logs);
+
+ // 为简化起见,这里先调用 GetAll 然后在内存中排序和截取(仅适用于日志量不大的情况)。
+ // 生产环境中建议优化数据库查询。
+ var allLogs = await GetAllLogsAsync();
+ return allLogs.OrderByDescending(l => l.LogTime).Take(count).ToList();
+ }
+
+ // 可以在这里实现 INlogAppService 接口中定义的其他方法
+ // 例如:
+ /*
+ public async Task> GetLogsByLevelAsync(string level)
+ {
+ // 假设 INlogRepository 有 GetLogsByLevelAsync 方法
+ var logs = await _repoManager.Nlogs.GetLogsByLevelAsync(level);
+ return _mapper.Map>(logs);
+ }
+
+ public async Task> GetLogsByDateRangeAsync(DateTime startDate, DateTime endDate)
+ {
+ var logs = await _repoManager.Nlogs.GetLogsByDateRangeAsync(startDate, endDate);
+ return _mapper.Map>(logs);
+ }
+
+ public async Task> SearchLogsAsync(string searchTerm)
+ {
+ var logs = await _repoManager.Nlogs.SearchLogsAsync(searchTerm);
+ return _mapper.Map>(logs);
+ }
+ */
+}
\ No newline at end of file
diff --git a/DMS.Core/Interfaces/IRepositoryManager.cs b/DMS.Core/Interfaces/IRepositoryManager.cs
index 6398bb5..88979cd 100644
--- a/DMS.Core/Interfaces/IRepositoryManager.cs
+++ b/DMS.Core/Interfaces/IRepositoryManager.cs
@@ -49,6 +49,11 @@ public interface IRepositoryManager : IDisposable
///
IUserRepository Users { get; set; }
+ ///
+ /// 获取Nlog日志仓储的实例。
+ ///
+ INlogRepository Nlogs { get; set; }
+
///
/// 初始化数据库
///
diff --git a/DMS.Core/Interfaces/Repositories/INlogRepository.cs b/DMS.Core/Interfaces/Repositories/INlogRepository.cs
new file mode 100644
index 0000000..567f13d
--- /dev/null
+++ b/DMS.Core/Interfaces/Repositories/INlogRepository.cs
@@ -0,0 +1,15 @@
+using DMS.Core.Models;
+
+namespace DMS.Core.Interfaces.Repositories;
+
+///
+/// Nlog日志仓储接口,定义了对Nlog实体的特定数据访问方法。
+/// 继承自通用仓储接口 IBaseRepository。
+///
+public interface INlogRepository : IBaseRepository
+{
+ // 可以在此处添加 Nlog 特定的查询方法,例如:
+ // Task> GetLogsByLevelAsync(string level);
+ // Task> GetLogsByDateRangeAsync(DateTime startDate, DateTime endDate);
+ // Task> SearchLogsAsync(string searchTerm);
+}
\ No newline at end of file
diff --git a/DMS.Core/Models/Nlog.cs b/DMS.Core/Models/Nlog.cs
new file mode 100644
index 0000000..45635d3
--- /dev/null
+++ b/DMS.Core/Models/Nlog.cs
@@ -0,0 +1,74 @@
+using System;
+
+namespace DMS.Core.Models;
+
+///
+/// 代表一条NLog日志记录。
+///
+public class Nlog
+{
+ ///
+ /// 日志ID。
+ ///
+ public int Id { get; set; }
+
+ ///
+ /// 日志记录时间。
+ ///
+ public DateTime LogTime { get; set; }
+
+ ///
+ /// 日志级别 (如 INFO, ERROR 等)。
+ ///
+ public string Level { get; set; }
+
+ ///
+ /// 线程ID。
+ ///
+ public int ThreadId { get; set; }
+
+ ///
+ /// 线程名称。
+ ///
+ public string ThreadName { get; set; }
+
+ ///
+ /// 调用点(通常是记录日志的方法名)。
+ ///
+ public string Callsite { get; set; }
+
+ ///
+ /// 调用点所在的行号。
+ ///
+ public int CallsiteLineNumber { get; set; }
+
+ ///
+ /// 日志消息内容。
+ ///
+ public string Message { get; set; }
+
+ ///
+ /// 记录日志的记录器名称。
+ ///
+ public string Logger { get; set; }
+
+ ///
+ /// 异常信息(如果有的话)。
+ ///
+ public string Exception { get; set; }
+
+ ///
+ /// 调用方文件路径。
+ ///
+ public string CallerFilePath { get; set; }
+
+ ///
+ /// 调用方行号。
+ ///
+ public int CallerLineNumber { get; set; }
+
+ ///
+ /// 调用方成员(方法名)。
+ ///
+ public string CallerMember { get; set; }
+}
\ No newline at end of file
diff --git a/DMS.Infrastructure/Entities/DbNlog.cs b/DMS.Infrastructure/Entities/DbNlog.cs
new file mode 100644
index 0000000..02ba6df
--- /dev/null
+++ b/DMS.Infrastructure/Entities/DbNlog.cs
@@ -0,0 +1,88 @@
+using SqlSugar;
+
+namespace DMS.Infrastructure.Entities;
+
+///
+/// NLog日志实体类,对应数据库中的 nlog 表。
+///
+[SugarTable("nlog")]
+public class DbNlog
+{
+ ///
+ /// 日志ID,主键且自增。
+ ///
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "ID")]
+ public int Id { get; set; }
+
+ ///
+ /// 日志记录时间。
+ ///
+ [SugarColumn(ColumnName = "LogTime")]
+ public DateTime LogTime { get; set; }
+
+ ///
+ /// 日志级别 (如 INFO, ERROR 等)。
+ ///
+ [SugarColumn(ColumnName = "Level")]
+ public string Level { get; set; }
+
+ ///
+ /// 线程ID。
+ ///
+ [SugarColumn(ColumnName = "ThreadID")]
+ public int ThreadId { get; set; }
+
+ ///
+ /// 线程名称。
+ ///
+ [SugarColumn(ColumnName = "ThreadName", IsNullable = true)]
+ public string ThreadName { get; set; }
+
+ ///
+ /// 调用点(通常是记录日志的方法名)。
+ ///
+ [SugarColumn(ColumnName = "Callsite", IsNullable = true)]
+ public string Callsite { get; set; }
+
+ ///
+ /// 调用点所在的行号。
+ ///
+ [SugarColumn(ColumnName = "CallsiteLineNumber")]
+ public int CallsiteLineNumber { get; set; }
+
+ ///
+ /// 日志消息内容。
+ ///
+ [SugarColumn(ColumnName = "Message")]
+ public string Message { get; set; }
+
+ ///
+ /// 记录日志的记录器名称。
+ ///
+ [SugarColumn(ColumnName = "Logger")]
+ public string Logger { get; set; }
+
+ ///
+ /// 异常信息(如果有的话)。
+ ///
+ [SugarColumn(ColumnName = "Exception", IsNullable = true)]
+ public string Exception { get; set; }
+
+ ///
+ /// 调用方文件路径。
+ ///
+ [SugarColumn(ColumnName = "CallerFilePath", IsNullable = true)]
+ public string CallerFilePath { get; set; }
+
+ ///
+ /// 调用方行号。
+ ///
+ [SugarColumn(ColumnName = "CallerLineNumber")]
+ public int CallerLineNumber { get; set; }
+
+ ///
+ /// 调用方成员(方法名)。
+ ///
+ [SugarColumn(ColumnName = "CallerMember", IsNullable = true)]
+ public string CallerMember { get; set; }
+}
\ No newline at end of file
diff --git a/DMS.Infrastructure/Repositories/NlogRepository.cs b/DMS.Infrastructure/Repositories/NlogRepository.cs
new file mode 100644
index 0000000..e420978
--- /dev/null
+++ b/DMS.Infrastructure/Repositories/NlogRepository.cs
@@ -0,0 +1,130 @@
+using AutoMapper;
+using DMS.Core.Interfaces.Repositories;
+using DMS.Core.Models;
+using DMS.Infrastructure.Data;
+using DMS.Infrastructure.Entities;
+using Microsoft.Extensions.Logging;
+
+namespace DMS.Infrastructure.Repositories;
+
+///
+/// Nlog日志仓储实现类,负责Nlog日志数据的持久化操作。
+/// 继承自 并实现 接口。
+///
+public class NlogRepository : BaseRepository, INlogRepository
+{
+ private readonly IMapper _mapper;
+
+ ///
+ /// 构造函数,注入 AutoMapper 和 SqlSugarDbContext。
+ ///
+ /// AutoMapper 实例,用于实体模型和数据库模型之间的映射。
+ /// SqlSugar 数据库上下文,用于数据库操作。
+ /// 日志记录器实例。
+ public NlogRepository(IMapper mapper, SqlSugarDbContext dbContext, ILogger logger)
+ : base(dbContext, logger)
+ {
+ _mapper = mapper;
+ }
+
+ // Nlog 通常是只读或追加的日志,因此像 AddAsync, UpdateAsync, DeleteAsync 这样的修改方法
+ // 可能不需要在仓储接口中暴露,或者可以省略具体实现或抛出 NotSupportedException。
+ // 但为了保持与基类一致性并满足接口要求,这里显式实现它们。
+
+ ///
+ /// 异步获取所有Nlog日志条目。
+ ///
+ /// 包含所有Nlog日志实体的列表。
+ public new async Task> GetAllAsync()
+ {
+ var dbList = await base.GetAllAsync();
+ return _mapper.Map>(dbList);
+ }
+
+ ///
+ /// 异步根据ID获取单个Nlog日志条目。
+ ///
+ /// 日志条目的唯一标识符。
+ /// 对应的Nlog日志实体,如果不存在则为null。
+ public new async Task GetByIdAsync(int id)
+ {
+ var dbNlog = await base.GetByIdAsync(id);
+ return _mapper.Map(dbNlog);
+ }
+
+ ///
+ /// 异步添加一个新Nlog日志条目。
+ /// 注意:直接写入数据库日志表通常不推荐,NLog本身负责写入。
+ /// 此方法主要用于满足接口契约,实际使用应谨慎。
+ ///
+ /// 要添加的Nlog日志实体。
+ /// 添加后的Nlog日志实体(包含ID等信息)。
+ public new async Task AddAsync(Core.Models.Nlog entity)
+ {
+ var dbEntity = _mapper.Map(entity);
+ var addedDbEntity = await base.AddAsync(dbEntity);
+ return _mapper.Map(addedDbEntity, entity);
+ }
+
+ ///
+ /// 异步更新一个Nlog日志条目。
+ /// 注意:直接更新数据库日志表通常不推荐,日志应视为不可变。
+ /// 此方法主要用于满足接口契约,实际使用应谨慎。
+ ///
+ /// 要更新的Nlog日志实体。
+ /// 受影响的行数。
+ public new async Task UpdateAsync(Core.Models.Nlog entity)
+ {
+ var dbEntity = _mapper.Map(entity);
+ return await base.UpdateAsync(dbEntity);
+ }
+
+ ///
+ /// 异步删除一个Nlog日志条目。
+ /// 注意:直接删除数据库日志表记录通常不推荐,除非是清理过期日志。
+ /// 此方法主要用于满足接口契约,实际使用应谨慎。
+ ///
+ /// 要删除的Nlog日志实体。
+ /// 受影响的行数。
+ public new async Task DeleteAsync(Core.Models.Nlog entity)
+ {
+ var dbEntity = _mapper.Map(entity);
+ return await base.DeleteAsync(dbEntity);
+ }
+
+ ///
+ /// 异步根据ID删除一个Nlog日志条目。
+ /// 注意:直接删除数据库日志表记录通常不推荐,除非是清理过期日志。
+ /// 此方法主要用于满足接口契约,实际使用应谨慎。
+ ///
+ /// 要删除的Nlog日志条目的ID。
+ /// 受影响的行数。
+ public new async Task DeleteByIdAsync(int id)
+ {
+ return await base.DeleteByIdsAsync(new List(){id});
+ }
+
+ ///
+ /// 异步获取指定数量的Nlog日志条目。
+ ///
+ /// 要获取的条目数量。
+ /// 包含指定数量Nlog日志实体的列表。
+ public new async Task> TakeAsync(int number)
+ {
+ var dbList = await base.TakeAsync(number);
+ return _mapper.Map>(dbList);
+ }
+
+ ///
+ /// 异步批量添加Nlog日志条目。
+ /// 注意:直接批量写入数据库日志表通常不推荐,NLog本身负责写入。
+ /// 此方法主要用于满足接口契约,实际使用应谨慎。
+ ///
+ /// 要添加的Nlog日志实体列表。
+ /// 操作是否成功。
+ public new async Task AddBatchAsync(List entities)
+ {
+ var dbEntities = _mapper.Map>(entities);
+ return await base.AddBatchAsync(dbEntities);
+ }
+}
\ No newline at end of file
diff --git a/DMS.Infrastructure/Repositories/RepositoryManager.cs b/DMS.Infrastructure/Repositories/RepositoryManager.cs
index 0028f50..f851989 100644
--- a/DMS.Infrastructure/Repositories/RepositoryManager.cs
+++ b/DMS.Infrastructure/Repositories/RepositoryManager.cs
@@ -27,6 +27,7 @@ public class RepositoryManager : IRepositoryManager
/// 菜单仓储实例。
/// 变量历史仓储实例。
/// 用户仓储实例。
+ /// Nlog日志仓储实例。
public RepositoryManager( SqlSugarDbContext dbContext,
IInitializeRepository initializeRepository,
IDeviceRepository devices,
@@ -36,7 +37,8 @@ public class RepositoryManager : IRepositoryManager
IVariableMqttAliasRepository variableMqttAliases,
IMenuRepository menus,
IVariableHistoryRepository variableHistories,
- IUserRepository users)
+ IUserRepository users,
+ INlogRepository nlogs)
{
_dbContext = dbContext;
InitializeRepository = initializeRepository;
@@ -48,6 +50,7 @@ public class RepositoryManager : IRepositoryManager
Menus = menus;
VariableHistories = variableHistories;
Users = users;
+ Nlogs = nlogs;
_db = dbContext.GetInstance();
}
@@ -93,6 +96,10 @@ public class RepositoryManager : IRepositoryManager
///
public IUserRepository Users { get; set; }
///
+ /// 获取Nlog日志仓储实例。
+ ///
+ public INlogRepository Nlogs { get; set; }
+ ///
/// 获取初始化仓储实例。
///
public IInitializeRepository InitializeRepository { get; set; }
diff --git a/DMS.WPF/App.xaml.cs b/DMS.WPF/App.xaml.cs
index f3243ab..aaa0560 100644
--- a/DMS.WPF/App.xaml.cs
+++ b/DMS.WPF/App.xaml.cs
@@ -204,6 +204,7 @@ public partial class App : System.Windows.Application
services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
+ services.AddSingleton();
services.AddSingleton();
services.AddSingleton();
diff --git a/DMS.WPF/ViewModels/Items/NlogItemViewModel.cs b/DMS.WPF/ViewModels/Items/NlogItemViewModel.cs
new file mode 100644
index 0000000..a86574e
--- /dev/null
+++ b/DMS.WPF/ViewModels/Items/NlogItemViewModel.cs
@@ -0,0 +1,50 @@
+// 文件: DMS.WPF/ViewModels/Items/NlogItemViewModel.cs
+
+using CommunityToolkit.Mvvm.ComponentModel;
+
+namespace DMS.WPF.ViewModels.Items;
+
+///
+/// 代表日志列表中的单个日志项的ViewModel。
+/// 实现了INotifyPropertyChanged,其任何属性变化都会自动通知UI。
+///
+public partial class NlogItemViewModel : ObservableObject
+{
+ public int Id { get; set; }
+
+ [ObservableProperty]
+ private DateTime _logTime;
+
+ [ObservableProperty]
+ private string _level;
+
+ [ObservableProperty]
+ private int _threadId;
+
+ [ObservableProperty]
+ private string _threadName;
+
+ [ObservableProperty]
+ private string _callsite;
+
+ [ObservableProperty]
+ private int _callsiteLineNumber;
+
+ [ObservableProperty]
+ private string _message;
+
+ [ObservableProperty]
+ private string _logger;
+
+ [ObservableProperty]
+ private string _exception;
+
+ [ObservableProperty]
+ private string _callerFilePath;
+
+ [ObservableProperty]
+ private int _callerLineNumber;
+
+ [ObservableProperty]
+ private string _callerMember;
+}
\ No newline at end of file
diff --git a/QWEN.md b/QWEN.md
index 488fd86..3153d0e 100644
--- a/QWEN.md
+++ b/QWEN.md
@@ -1,48 +1,48 @@
-# Project Overview: DMS (Device Management System)
+# 项目概述:DMS (Device Management System - 设备管理系统)
-This directory contains the source code for the Device Management System (DMS), a C#/.NET 8 application. The system is primarily composed of a WPF desktop application for the user interface, backed by a layered architecture including Core, Application, and Infrastructure projects. It also includes dedicated unit test projects for both the infrastructure and WPF layers.
+此目录包含了设备管理系统 (DMS) 的源代码,这是一个基于 C#/.NET 8 构建的应用程序。该系统主要由一个用于用户界面的 WPF 桌面应用程序组成,后端采用分层架构,包括 Core(核心)、Application(应用)和 Infrastructure(基础设施)项目。此外,还为基础设施层和 WPF 层配备了专门的单元测试项目。
-A significant feature described in the README is an OPC UA service implementation, suggesting the system is designed for industrial device communication and management.
+项目自述文件中提到的一个重要特性是 OPC UA 服务实现,表明该系统是为工业设备通信和管理而设计的。
-## Project Structure
+## 项目结构
-The solution (`DMS.sln`) is organized into several key projects:
+解决方案 (`DMS.sln`) 由几个关键项目组成:
-* **`DMS.Core`**: Contains fundamental, reusable components and shared models. Likely includes utilities, common data transfer objects (DTOs), and core business logic abstractions. It references `Microsoft.Extensions.Logging.Abstractions`, `Newtonsoft.Json`, and `NLog`.
-* **`DMS.Application`**: Implements application-specific business logic. It depends on `DMS.Core` and uses libraries like `AutoMapper` for object mapping and `Microsoft.Extensions` for hosting and logging abstractions.
-* **`DMS.Infrastructure`**: Handles data access, external integrations, and technical implementations. It references `DMS.Core` and `DMS.Application`. Key dependencies include:
- * `SqlSugarCore`: For database interaction (MySQL).
- * `MQTTnet`: For MQTT protocol communication.
- * `OPCFoundation.NetStandard.Opc.Ua`: For OPC UA communication.
- * `S7netplus`: For Siemens S7 PLC communication.
- * `NPOI`: For reading/writing Excel files.
- * `AutoMapper.Extensions.Microsoft.DependencyInjection`: For dependency injection setup of AutoMapper.
-* **`DMS.WPF`**: The main WPF desktop application. It targets `net8.0-windows` and uses WPF-specific libraries like `CommunityToolkit.Mvvm`, `HandyControl` (UI toolkit), `Hardcodet.NotifyIcon.Wpf` (system tray icon), and `iNKORE.UI.WPF.Modern` (modern UI styling). It depends on `DMS.Application` and `DMS.Infrastructure`.
-* **`DMS.Infrastructure.UnitTests`**: Unit tests for the `DMS.Infrastructure` project. Uses `xunit`, `Moq`, `Bogus` (for fake data), and `Microsoft.NET.Test.Sdk`.
-* **`DMS.WPF.UnitTests`**: Unit tests for the `DMS.WPF` project. Also uses `xunit`, `Moq`, and `Bogus`.
+* **`DMS.Core`**: 包含基础的、可复用的组件和共享模型。可能包括实用工具、通用数据传输对象 (DTOs) 以及核心业务逻辑抽象。它引用了 `Microsoft.Extensions.Logging.Abstractions`、`Newtonsoft.Json` 和 `NLog`。
+* **`DMS.Application`**: 实现应用特定的业务逻辑。它依赖于 `DMS.Core`,并使用 `AutoMapper`(用于对象映射)和 `Microsoft.Extensions`(用于托管和日志记录抽象)等库。
+* **`DMS.Infrastructure`**: 处理数据访问、外部集成和技术实现。它引用了 `DMS.Core` 和 `DMS.Application`。关键依赖包括:
+ * `SqlSugarCore`:用于数据库交互(MySQL)。
+ * `MQTTnet`:用于 MQTT 协议通信。
+ * `OPCFoundation.NetStandard.Opc.Ua`:用于 OPC UA 通信。
+ * `S7netplus`:用于西门子 S7 PLC 通信。
+ * `NPOI`:用于读写 Excel 文件。
+ * `AutoMapper.Extensions.Microsoft.DependencyInjection`:用于 AutoMapper 的依赖注入设置。
+* **`DMS.WPF`**:主 WPF 桌面应用程序。它以 `net8.0-windows` 为目标,并使用 WPF 特定的库,如 `CommunityToolkit.Mvvm`、`HandyControl`(UI 工具包)、`Hardcodet.NotifyIcon.Wpf`(系统托盘图标)和 `iNKORE.UI.WPF.Modern`(现代 UI 样式)。它依赖于 `DMS.Application` 和 `DMS.Infrastructure`。
+* **`DMS.Infrastructure.UnitTests`**:针对 `DMS.Infrastructure` 项目的单元测试。使用 `xunit`、`Moq`、`Bogus`(用于伪造数据)和 `Microsoft.NET.Test.Sdk`。
+* **`DMS.WPF.UnitTests`**:针对 `DMS.WPF` 项目的单元测试。同样使用 `xunit`、`Moq` 和 `Bogus`。
-## Building and Running
+## 构建与运行
-This is a .NET 8 solution. You will need the .NET 8 SDK and an IDE like Visual Studio or JetBrains Rider to build and run it.
+这是一个 .NET 8 解决方案。您需要安装 .NET 8 SDK 以及 Visual Studio 或 JetBrains Rider 等 IDE 来构建和运行它。
-**To Build:**
-Use the standard .NET CLI command within the solution directory:
+**构建:**
+在解决方案目录下使用标准 .NET CLI 命令:
`dotnet build`
-**To Run:**
-The main executable is the WPF application (`DMS.WPF`). You can run it using:
+**运行:**
+主可执行文件是 WPF 应用程序 (`DMS.WPF`)。您可以使用以下命令运行它:
`dotnet run --project DMS.WPF`
-**To Test:**
-Unit tests are included in `DMS.Infrastructure.UnitTests` and `DMS.WPF.UnitTests`.
-Run all tests using:
+**测试:**
+单元测试包含在 `DMS.Infrastructure.UnitTests` 和 `DMS.WPF.UnitTests` 中。
+使用以下命令运行所有测试:
`dotnet test`
-## Development Conventions
+## 开发规范
-* **Language & Framework:** C# with .NET 8.
-* **Architecture:** Layered architecture (Core, Application, Infrastructure) with a WPF presentation layer.
-* **UI Pattern:** MVVM (Model-View-ViewModel), supported by `CommunityToolkit.Mvvm`.
-* **DI (Dependency Injection):** Microsoft.Extensions.DependencyInjection is used, configured likely in the `DMS.WPF` project.
-* **Logging:** NLog is used for logging, configured via `DMS.WPF\Configurations\nlog.config`.
-* **Mapping:** AutoMapper is used for object-to-object mapping.
\ No newline at end of file
+* **语言与框架:** C# 配合 .NET 8。
+* **架构:** 分层架构(Core, Application, Infrastructure)配合 WPF 表现层。
+* **UI 模式:** MVVM(Model-View-ViewModel),由 `CommunityToolkit.Mvvm` 支持。
+* **依赖注入 (DI):** 使用 Microsoft.Extensions.DependencyInjection,在 `DMS.WPF` 项目中进行配置。
+* **日志记录:** 使用 NLog 进行日志记录,配置文件位于 `DMS.WPF\Configurations\nlog.config`。
+* **对象映射:** 使用 AutoMapper 进行对象到对象的映射。
\ No newline at end of file