using Furion.JsonSerialization;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace Myshipping.FlowCenter.Entity;
///
/// 表单工具
///
public class FormUtil {
///
/// 获取值
///
///
/// System.String.
public static List SetValue(string content)
{
List list = JSON.GetJsonSerializer().Deserialize>(content);
List temp = new List();
SetFormValue(list, temp);
return temp;
}
///
/// 表单赋值
///
///
///
///
private static List SetFormValue(List list, List temp)
{
foreach (var item in list)
{
if (item.tag == "grid")
{
foreach (var column in item.columns)
{
SetFormValue(column.list, temp);
}
}
else
{
temp.Add(item.id);
}
}
return temp;
}
///
/// 自定义表单设值
///
///
///
public static List SetValueByWeb(string webForm)
{
//首字母大写
webForm = webForm.Substring(0, 1).ToUpper() + webForm.Substring(1);
var path = AppDomain.CurrentDomain.RelativeSearchPath ?? AppDomain.CurrentDomain.BaseDirectory;
var referencedAssemblies = Directory.GetFiles(path, "*.dll").Select(Assembly.LoadFrom).ToArray();
var t = referencedAssemblies
.SelectMany(a => a.GetTypes().Where(t => t.FullName.Contains("Myshipping.FlowCenter"+"." + webForm))).First();
List temp = new List();
PropertyInfo[] pArray = t.GetProperties();
Array.ForEach(pArray, p =>
{
temp.Add(p.Name);
});
return temp;
}
}