From 8c12a4017fb9ebee7e553a5588888a9a535a3310 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=AD=94=E4=BB=99?= <13068499+willowhh@user.noreply.gitee.com> Date: Thu, 15 May 2025 17:18:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=8D=E5=B0=84=E8=8E=B7=E5=8F=96=E5=AD=97?= =?UTF-8?q?=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModels/PrintControlViewModel.cs | 50 ++++++++++++------- 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/RIZO_Application/Modules/RIZO_Application.Modules.ModuleName/ViewModels/PrintControlViewModel.cs b/RIZO_Application/Modules/RIZO_Application.Modules.ModuleName/ViewModels/PrintControlViewModel.cs index 15c0be5..1218ccf 100644 --- a/RIZO_Application/Modules/RIZO_Application.Modules.ModuleName/ViewModels/PrintControlViewModel.cs +++ b/RIZO_Application/Modules/RIZO_Application.Modules.ModuleName/ViewModels/PrintControlViewModel.cs @@ -8,6 +8,8 @@ using RIZO_Application.Core.Mvvm; using RIZO_Helper.Tools; using RIZO_Application.Infrastructure.Model; using System.Linq; +using System.Reflection; +using Microsoft.Extensions.Primitives; namespace RIZO_Application.Modules.ModuleName.ViewModels { @@ -74,26 +76,38 @@ namespace RIZO_Application.Modules.ModuleName.ViewModels try { _eventAggregator.GetEvent().Publish($"收到打印请求: {printDto.Name}"); + var printParameters = new Dictionary(); + Type type = printDto.GetType(); + PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance); + + foreach (PropertyInfo property in properties) { + string value = property.GetValue(printDto)?.ToString(); + string dictionaryKey = property.Name; + printParameters[dictionaryKey] = value; + } // 1.准备全部打印参数表 - var printParameters = new Dictionary - { - { "10", printDto.PartNumber }, - { "11", "02S" }, - {"13",null }, - {"14",null }, - {"15",null }, - {"16",null }, - { "10000", printDto.WorkOrder }, - { "10002", printDto.Team }, - { "10003", printDto.Sort.ToString() }, - { "10004", printDto.BatchCode }, - { "10005", printDto.Sort.ToString() }, - { "10006", printDto.BatchCode }, - { "10007", printDto.PackageNum.ToString() }, - { "10011", printDto.LabelType.ToString() }, - {"10013",null }, - }; + //var printParameters = new Dictionary + //{ + // { "10", printDto.PartNumber }, + // { "11", "02S" }, + // {"12",printDto.Sepcification }, + // {"13",null }, + // {"14",null }, + // {"15",null }, + // {"16",null }, + // { "10000", printDto.WorkOrder }, + // { "10002", printDto.Team }, + // { "10003", printDto.Sort.ToString() }, + // { "10004", printDto.BatchCode }, + // { "10005", printDto.Sort.ToString() }, + // { "10006", printDto.BatchCode }, + // { "10007", printDto.PackageNum.ToString() }, + // { "10011", printDto.LabelType.ToString() }, + // {"10013",null }, + //}; + + var subString = _printHelper.GetNamedSubStrings(templatePath:printDto.Path).Result;