反射获取字段
This commit is contained in:
@@ -8,6 +8,8 @@ using RIZO_Application.Core.Mvvm;
|
|||||||
using RIZO_Helper.Tools;
|
using RIZO_Helper.Tools;
|
||||||
using RIZO_Application.Infrastructure.Model;
|
using RIZO_Application.Infrastructure.Model;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using Microsoft.Extensions.Primitives;
|
||||||
|
|
||||||
namespace RIZO_Application.Modules.ModuleName.ViewModels
|
namespace RIZO_Application.Modules.ModuleName.ViewModels
|
||||||
{
|
{
|
||||||
@@ -74,26 +76,38 @@ namespace RIZO_Application.Modules.ModuleName.ViewModels
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
_eventAggregator.GetEvent<SystemLogEvent>().Publish($"收到打印请求: {printDto.Name}");
|
_eventAggregator.GetEvent<SystemLogEvent>().Publish($"收到打印请求: {printDto.Name}");
|
||||||
|
var printParameters = new Dictionary<string, string>();
|
||||||
|
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.准备全部打印参数表
|
// 1.准备全部打印参数表
|
||||||
var printParameters = new Dictionary<string, string>
|
//var printParameters = new Dictionary<string, string>
|
||||||
{
|
//{
|
||||||
{ "10", printDto.PartNumber },
|
// { "10", printDto.PartNumber },
|
||||||
{ "11", "02S" },
|
// { "11", "02S" },
|
||||||
{"13",null },
|
// {"12",printDto.Sepcification },
|
||||||
{"14",null },
|
// {"13",null },
|
||||||
{"15",null },
|
// {"14",null },
|
||||||
{"16",null },
|
// {"15",null },
|
||||||
{ "10000", printDto.WorkOrder },
|
// {"16",null },
|
||||||
{ "10002", printDto.Team },
|
// { "10000", printDto.WorkOrder },
|
||||||
{ "10003", printDto.Sort.ToString() },
|
// { "10002", printDto.Team },
|
||||||
{ "10004", printDto.BatchCode },
|
// { "10003", printDto.Sort.ToString() },
|
||||||
{ "10005", printDto.Sort.ToString() },
|
// { "10004", printDto.BatchCode },
|
||||||
{ "10006", printDto.BatchCode },
|
// { "10005", printDto.Sort.ToString() },
|
||||||
{ "10007", printDto.PackageNum.ToString() },
|
// { "10006", printDto.BatchCode },
|
||||||
{ "10011", printDto.LabelType.ToString() },
|
// { "10007", printDto.PackageNum.ToString() },
|
||||||
{"10013",null },
|
// { "10011", printDto.LabelType.ToString() },
|
||||||
};
|
// {"10013",null },
|
||||||
|
//};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var subString = _printHelper.GetNamedSubStrings(templatePath:printDto.Path).Result;
|
var subString = _printHelper.GetNamedSubStrings(templatePath:printDto.Path).Result;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user