This commit is contained in:
敏健 邱
2024-12-03 21:49:47 +08:00
parent 4e4316c6dc
commit d35c684d08
25 changed files with 1657 additions and 113 deletions
@@ -0,0 +1,41 @@
using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using NoteManageAR;
namespace UFIDA.U8.Framework.Api.ControlObject.Common
{
public class APARHelper
{
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
private readonly VoucherData _vd;
private readonly PropertyInfo[] _props;
public APARHelper(VoucherDataClass vd)
{
_vd = vd;
var tp = vd.GetType();
_props = tp.GetProperties();
}
public void SetValue(Dictionary<string, object> dictionary)
{
foreach (var key in dictionary.Keys)
{
if (key != "body")
logInfo.Debug($"正在设置字段:{key}--{dictionary[key]}");
if (!string.IsNullOrWhiteSpace($"{dictionary[key]}") && _props.Any(a => string.Equals(a.Name, key, StringComparison.OrdinalIgnoreCase)))
{
var prop = _props.First(a => string.Equals(a.Name, key, StringComparison.OrdinalIgnoreCase));
prop.SetPropValue(_vd, dictionary[key]);
}
}
}
}
}
@@ -131,7 +131,7 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
}
}
public void SetPartId()
{
_be.SetPartId(_invCode, new[] { _free1, _free2, _free3, _free4, _free5, _free6, _free7, _free8, _free9, _free10 });
@@ -3,6 +3,8 @@ using System.Collections.Generic;
using System.Reflection;
using GetComObj;
using MSXML2;
using Newtonsoft.Json.Linq;
using NoteManageAR;
using UFIDA.U8.Framework.Api.ControlObject.Json;
namespace UFIDA.U8.Framework.Api.ControlObject.Common
@@ -15,32 +17,172 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
if (prop.PropertyType == typeof(string))
{
prop.SetValue(obj, value);
return;
}
if (prop.PropertyType == typeof(DateTime))
{
prop.SetValue(obj, DateTime.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(byte))
{
prop.SetValue(obj, byte.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(int))
{
prop.SetValue(obj, int.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(long))
{
prop.SetValue(obj, long.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(decimal))
{
prop.SetValue(obj, decimal.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(double))
{
prop.SetValue(obj, double.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(float))
{
prop.SetValue(obj, float.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(short))
{
prop.SetValue(obj, short.Parse($"{value}"));
return;
}
}
public static void SetPropValue(this PropertyInfo prop, VoucherData obj, object value)
{
if (prop.PropertyType == typeof(string))
{
prop.SetValue(obj, value);
return;
}
if (prop.PropertyType == typeof(DateTime))
{
prop.SetValue(obj, DateTime.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(byte))
{
prop.SetValue(obj, byte.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(int))
{
prop.SetValue(obj, int.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(long))
{
prop.SetValue(obj, long.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(decimal))
{
prop.SetValue(obj, decimal.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(double))
{
prop.SetValue(obj, double.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(float))
{
prop.SetValue(obj, float.Parse($"{value}"));
return;
}
if (prop.PropertyType == typeof(short))
{
prop.SetValue(obj, short.Parse($"{value}"));
return;
}
//if (prop.PropertyType == typeof(object))
//{
// switch (prop.Name)
// {
// case "cDefine1":
// obj.set_cDefine1($"{value}");
// break;
// case "cDefine2":
// obj.set_cDefine2($"{value}");
// break;
// case "cDefine3":
// obj.set_cDefine3($"{value}");
// break;
// case "cDefine4":
// obj.set_cDefine4(DateTime.Parse($"{value}"));
// break;
// case "cDefine5":
// obj.set_cDefine5(int.Parse($"{value}"));
// break;
// case "cDefine6":
// obj.set_cDefine6(DateTime.Parse($"{value}"));
// break;
// case "cDefine7":
// obj.set_cDefine7(float.Parse($"{value}"));
// break;
// case "cDefine8":
// obj.set_cDefine8($"{value}");
// break;
// case "cDefine9":
// obj.set_cDefine9($"{value}");
// break;
// case "cDefine10":
// obj.set_cDefine10($"{value}");
// break;
// case "cDefine11":
// obj.set_cDefine11($"{value}");
// break;
// case "cDefine12":
// obj.set_cDefine12($"{value}");
// break;
// case "cDefine13":
// obj.set_cDefine13($"{value}");
// break;
// case "cDefine14":
// obj.set_cDefine14($"{value}");
// break;
// case "cDefine15":
// obj.set_cDefine15(int.Parse($"{value}"));
// break;
// case "cDefine16":
// obj.set_cDefine16(float.Parse($"{value}"));
// break;
// default:
// prop.SetValue(obj, $"{value}");
// break;
// }
//}
}
public static IXMLDOMDocument2 ToDocument2(this Dictionary<string,object> dictionary,IXMLDOMDocument2 domDocument2=null)