using Newtonsoft.Json;
|
using Newtonsoft.Json.Linq;
|
using SqlSugar;
|
using System;
|
using System.Collections.Generic;
|
|
namespace HH.WCS.Hexafluo.util
|
{
|
[AttributeUsage(AttributeTargets.Class, Inherited = true)]
|
public class STAttribute : SugarTable
|
{
|
public static Dictionary<string, string> attributes = new Dictionary<string, string>();
|
public STAttribute(string tableName) : base(tableName)
|
{
|
string value = "";
|
if (attributes.TryGetValue(TableName, out value))
|
TableName = value.ToUpper();
|
}
|
|
public static void GetValue(string name)
|
{
|
try
|
{
|
var jsonFile = System.AppDomain.CurrentDomain.BaseDirectory + "Config\\Config.json";
|
using (System.IO.StreamReader file = System.IO.File.OpenText(jsonFile))
|
{
|
using (JsonTextReader reader = new JsonTextReader(file))
|
{
|
JObject o = (JObject)JToken.ReadFrom(reader);
|
var value = o[name].ToString();
|
var tk = JsonConvert.DeserializeObject<List<TableName>>(value.Replace("\r\n", ""));
|
foreach (var it in tk)
|
{
|
attributes.Add(it.tableName, it.value);
|
Console.WriteLine("获取表名:tableName=" + it.tableName + " value=" + it.value);
|
}
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
Console.WriteLine("获取表名配置报错:" + ex.Message);
|
}
|
|
}
|
|
|
}
|
|
public class TableName
|
{
|
public string tableName { get; set; }
|
|
public string value { get; set; }
|
}
|
}
|