反射获取字段
This commit is contained in:
@@ -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<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.准备全部打印参数表
|
||||
var printParameters = new Dictionary<string, string>
|
||||
{
|
||||
{ "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<string, string>
|
||||
//{
|
||||
// { "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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user