alielie
2025-04-10 6bcafc823e836ecd5790f87178a906333699f868
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
using Microsoft.Extensions.Configuration;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
 
namespace Plugin.SNGenerateTool.Entity
{
    public class UserSettings
    {
        public string OrderId { get; set; }
 
        public string Model { get; set; }
 
        public string SNPrefix { get; set; }
 
        public string MESSstartSN { get; set; }
 
        public string MESEndSN { get; set; }
 
        public string XDSNDate { get; set; }
 
        public string XDSNDaySN { get; set; }
 
        public string XDSNSpecialSN { get; set; }
 
        public string PartNo { get; set; }
 
        public string HW { get; set; }
 
        public string SW { get; set; }
 
        public string GeelyDU { get; set; }
 
        public string GeelyHWSD { get; set; }
 
        public string SXBL { get; set; }
 
        public string SXDISXBL { get; set; }
 
        public string VolvoDU { get; set; }
 
        public string VolvoHWSD { get; set; }
 
        public string DBConn { get; set; }
 
        private string IP { get; set; }
 
        private string DataBase { get; set; }
 
        private string Uid { get; set; }
 
        private string Pwd { get; set; }
 
        public string Models { get; set; }
 
        public string Field { get; set; }
 
        [DllImport("kernel32")]
        private static extern long WritePrivateProfileString(string section, string key, string val, string filePath);
 
        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
 
        [DllImport("kernel32")]
        private static extern int GetPrivateProfileString(string section, string key, string def, byte[] retVal, int size, string filePath);
 
        public UserSettings(string file)
        {
            GetString(file);
        }
 
        public UserSettings(string section, string file)
        {
            GetString(section, file);
        }
 
        private void GetString(string fPath)
        {
            //IL_0027: Unknown result type (might be due to invalid IL or missing references)
            //IL_002d: Expected O, but got Unknown
            if (!File.Exists(fPath))
            {
                MessageBox.Show("配置文件不存在,读取失败", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }
            ConfigurationBuilder val = new ConfigurationBuilder();
            IniConfigurationExtensions.AddIniFile((IConfigurationBuilder)(object)val, fPath);
            IConfigurationRoot val2 = val.Build();
            IP = ((IConfiguration)val2)["Server:ip"];
            DataBase = ((IConfiguration)val2)["Server:database"];
            Uid = ((IConfiguration)val2)["Server:uid"];
            Pwd = ((IConfiguration)val2)["Server:pwd"];
            DBConn = "Server=" + IP + ";DataBase=" + DataBase + ";Uid=" + Uid + ";Pwd=" + Pwd;
            Models = ((IConfiguration)val2)["UserDefined:models"];
            Field = ((IConfiguration)val2)["UserDefined:field"];
        }
 
        private void GetString(string section, string fPath)
        {
            //IL_0027: Unknown result type (might be due to invalid IL or missing references)
            //IL_002d: Expected O, but got Unknown
            if (!File.Exists(fPath))
            {
                MessageBox.Show("配置文件不存在,读取失败", "错误提示", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return;
            }
            ConfigurationBuilder val = new ConfigurationBuilder();
            IniConfigurationExtensions.AddIniFile((IConfigurationBuilder)(object)val, fPath);
            IConfigurationRoot val2 = val.Build();
            OrderId = ((IConfiguration)val2)[section + ":Orderid"];
            Model = ((IConfiguration)val2)[section + ":Model"];
            SNPrefix = ((IConfiguration)val2)[section + ":SNPrefix"];
            MESSstartSN = ((IConfiguration)val2)[section + ":MESStartSN"];
            MESEndSN = ((IConfiguration)val2)[section + ":MESEndSN"];
            XDSNDate = ((IConfiguration)val2)[section + ":XDSNDate"];
            XDSNDaySN = ((IConfiguration)val2)[section + ":XDSNDaySN"];
            XDSNSpecialSN = ((IConfiguration)val2)[section + ":XDSNSpecialSN"];
            PartNo = ((IConfiguration)val2)[section + ":PartNo"];
            HW = ((IConfiguration)val2)[section + ":HW"];
            SW = ((IConfiguration)val2)[section + ":SW"];
            GeelyDU = ((IConfiguration)val2)[section + ":GeelyDU"];
            GeelyHWSD = ((IConfiguration)val2)[section + ":GeelyHWSD"];
            SXBL = ((IConfiguration)val2)[section + ":SXBL"];
            SXDISXBL = ((IConfiguration)val2)[section + ":SXDISXBL"];
            VolvoDU = ((IConfiguration)val2)[section + ":VolvoDU"];
            VolvoHWSD = ((IConfiguration)val2)[section + ":VolvoHWSD"];
        }
    }
}