测试线程静态前提交
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using log4net;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Web.UI.WebControls;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable IdentifierTypo
|
||||
@@ -11,8 +13,22 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
|
||||
{
|
||||
public class BEHelper
|
||||
{
|
||||
protected readonly ILog logInfo = LogManager.GetLogger("logInfo");
|
||||
|
||||
private readonly dynamic _be;
|
||||
private readonly PropertyInfo[] _props;
|
||||
private string _invCode;
|
||||
private string _free1;
|
||||
private string _free2;
|
||||
private string _free3;
|
||||
private string _free4;
|
||||
private string _free5;
|
||||
private string _free6;
|
||||
private string _free7;
|
||||
private string _free8;
|
||||
private string _free9;
|
||||
private string _free10;
|
||||
private int _bomVersion;
|
||||
|
||||
public BEHelper(dynamic be)
|
||||
{
|
||||
@@ -25,7 +41,10 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
|
||||
{
|
||||
foreach (var key in dictionary.Keys)
|
||||
{
|
||||
if (key.Contains("define") && !key.Contains("chdefine"))
|
||||
if(key != "body")
|
||||
logInfo.Debug($"正在设置字段:{key}--{dictionary[key]}");
|
||||
|
||||
if (key.Contains("define") && !key.Contains("chdefine") && !key.Contains("cbdefine"))
|
||||
{
|
||||
var defineCode = int.Parse(key.Replace("define", ""));
|
||||
if (dictionary.TryGetValue(key, out var bValue) && !string.IsNullOrWhiteSpace($"{bValue}"))
|
||||
@@ -41,46 +60,86 @@ namespace UFIDA.U8.Framework.Api.ControlObject.Common
|
||||
{
|
||||
_be.ExtendUserDefineItem[defineCode] = dictionary[key];
|
||||
}
|
||||
} else if (key.Contains("cbdefine"))
|
||||
{
|
||||
var defineCode = int.Parse(key.Replace("cbdefine", ""));
|
||||
|
||||
if (dictionary.TryGetValue(key, out var bValue) && !string.IsNullOrWhiteSpace($"{bValue}"))
|
||||
{
|
||||
_be.ExtendUserDefineItem[defineCode] = dictionary[key];
|
||||
}
|
||||
}else if (key.Contains("free"))
|
||||
{
|
||||
var freeCode = int.Parse(key.Replace("free", ""));
|
||||
|
||||
SetFreeItem(freeCode, dictionary[key]);
|
||||
|
||||
}
|
||||
else if (key != "body")
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace($"{dictionary[key]}") && _props.Any(a => string.Equals(a.Name, key, StringComparison.OrdinalIgnoreCase)))
|
||||
if (string.Equals(key, "invCode", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_invCode = $"{dictionary[key]}";
|
||||
}else if (string.Equals(key, "bomversion", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
_bomVersion = int.Parse($"{dictionary[key]}");
|
||||
}
|
||||
else 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));
|
||||
|
||||
if (prop.PropertyType == typeof(string))
|
||||
{
|
||||
prop.SetValue(_be, dictionary[key]);
|
||||
}
|
||||
|
||||
if (prop.PropertyType == typeof(DateTime))
|
||||
{
|
||||
prop.SetValue(_be, DateTime.Parse($"{dictionary[key]}"));
|
||||
}
|
||||
|
||||
if (prop.PropertyType == typeof(byte))
|
||||
{
|
||||
prop.SetValue(_be, byte.Parse($"{dictionary[key]}"));
|
||||
}
|
||||
|
||||
if (prop.PropertyType == typeof(int))
|
||||
{
|
||||
prop.SetValue(_be, int.Parse($"{dictionary[key]}"));
|
||||
}
|
||||
|
||||
if (prop.PropertyType == typeof(long))
|
||||
{
|
||||
prop.SetValue(_be, long.Parse($"{dictionary[key]}"));
|
||||
}
|
||||
|
||||
if (prop.PropertyType == typeof(decimal))
|
||||
{
|
||||
prop.SetValue(_be, decimal.Parse($"{dictionary[key]}"));
|
||||
}
|
||||
|
||||
CommonHelper.SetPropValue(prop, _be, dictionary[key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetFreeItem(int i, object value)
|
||||
{
|
||||
switch (i)
|
||||
{
|
||||
case 1:
|
||||
_free1 = $"{value}";
|
||||
break;
|
||||
case 2:
|
||||
_free2 = $"{value}";
|
||||
break;
|
||||
case 3:
|
||||
_free3 = $"{value}";
|
||||
break;
|
||||
case 4:
|
||||
_free4 = $"{value}";
|
||||
break;
|
||||
case 5:
|
||||
_free5 = $"{value}";
|
||||
break;
|
||||
case 6:
|
||||
_free6 = $"{value}";
|
||||
break;
|
||||
case 7:
|
||||
_free7 = $"{value}";
|
||||
break;
|
||||
case 8:
|
||||
_free8 = $"{value}";
|
||||
break;
|
||||
case 9:
|
||||
_free9 = $"{value}";
|
||||
break;
|
||||
case 10:
|
||||
_free10 = $"{value}";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void SetPartId()
|
||||
{
|
||||
_be.SetPartId(_invCode, new[] { _free1, _free2, _free3, _free4, _free5, _free6, _free7, _free8, _free9, _free10 });
|
||||
}
|
||||
|
||||
public void SetBomId()
|
||||
{
|
||||
_be.SetBomId(_be.PartId, _bomVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user