1.修复多账套对接时报工切换账套不生效(严重bug)
2.切换底层逻辑,增加外部增加数据源的接口 3.增加缓存,减少频繁登录导致可能存在的突发数据库连接异常
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
// ReSharper disable IdentifierTypo
|
||||
// ReSharper disable StringLiteralTypo
|
||||
|
||||
namespace UFIDA.U8.Framework.Api.ControlObject.Common
|
||||
{
|
||||
public class BEHelper
|
||||
{
|
||||
private readonly dynamic _be;
|
||||
private readonly PropertyInfo[] _props;
|
||||
|
||||
public BEHelper(dynamic be)
|
||||
{
|
||||
_be = be;
|
||||
var tp = be.GetType();
|
||||
_props = tp.GetProperties();
|
||||
}
|
||||
|
||||
public void SetValue(Dictionary<string,object> dictionary)
|
||||
{
|
||||
foreach (var key in dictionary.Keys)
|
||||
{
|
||||
if (key.Contains("define") && !key.Contains("chdefine"))
|
||||
{
|
||||
var defineCode = int.Parse(key.Replace("define", ""));
|
||||
if (dictionary.TryGetValue(key, out var bValue) && !string.IsNullOrWhiteSpace($"{bValue}"))
|
||||
{
|
||||
_be.UserDefinedItem[defineCode] = dictionary[key];
|
||||
}
|
||||
}
|
||||
else if (key.Contains("chdefine"))
|
||||
{
|
||||
var defineCode = int.Parse(key.Replace("chdefine", ""));
|
||||
|
||||
if (dictionary.TryGetValue(key, out var bValue) && !string.IsNullOrWhiteSpace($"{bValue}"))
|
||||
{
|
||||
_be.ExtendUserDefineItem[defineCode] = dictionary[key];
|
||||
}
|
||||
}
|
||||
else if (key != "body")
|
||||
{
|
||||
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]}"));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user