2 3 - 迁移 IMqttServiceManager 接口到 DMS.Core 4 - 在 DataCenterService 中添加 MQTT 服务器和变量别名的加载逻辑 5 - 实现 MqttPublishProcessor 的核心处理逻辑 6 - 为 DTO 和 ViewModel 的 MqttAliases 属性提供默认空列表初始化 7 - 更新 AutoMapper 映射配置以支持 VariableMqttAliasDto
3.3 KiB
Project Overview: 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.
A significant feature described in the README is an OPC UA service implementation, suggesting the system is designed for industrial device communication and management.
Project Structure
The solution (DMS.sln) is organized into several key projects:
DMS.Core: Contains fundamental, reusable components and shared models. Likely includes utilities, common data transfer objects (DTOs), and core business logic abstractions. It referencesMicrosoft.Extensions.Logging.Abstractions,Newtonsoft.Json, andNLog.DMS.Application: Implements application-specific business logic. It depends onDMS.Coreand uses libraries likeAutoMapperfor object mapping andMicrosoft.Extensionsfor hosting and logging abstractions.DMS.Infrastructure: Handles data access, external integrations, and technical implementations. It referencesDMS.CoreandDMS.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 targetsnet8.0-windowsand uses WPF-specific libraries likeCommunityToolkit.Mvvm,HandyControl(UI toolkit),Hardcodet.NotifyIcon.Wpf(system tray icon), andiNKORE.UI.WPF.Modern(modern UI styling). It depends onDMS.ApplicationandDMS.Infrastructure.DMS.Infrastructure.UnitTests: Unit tests for theDMS.Infrastructureproject. Usesxunit,Moq,Bogus(for fake data), andMicrosoft.NET.Test.Sdk.DMS.WPF.UnitTests: Unit tests for theDMS.WPFproject. Also usesxunit,Moq, andBogus.
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.
To Build:
Use the standard .NET CLI command within the solution directory:
dotnet build
To Run:
The main executable is the WPF application (DMS.WPF). You can run it using:
dotnet run --project DMS.WPF
To Test:
Unit tests are included in DMS.Infrastructure.UnitTests and DMS.WPF.UnitTests.
Run all tests using:
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.WPFproject. - Logging: NLog is used for logging, configured via
DMS.WPF\Configurations\nlog.config. - Mapping: AutoMapper is used for object-to-object mapping.