1
pulg
2025-06-17 03f92b99d7f00b728dccd409863c38d1191a4c60
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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 static string GetValueTwo(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();
                        return value.Replace("\r\n", "");
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.DanInfo("获取json文件", "值timeSpan失败!原因:" + ex.Message);
                return "";
            }
 
        }
 
    }
 
    public class TableName
    {
        public string tableName { get; set; }
 
        public string value { get; set; }
    }
}