You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.5 KiB
45 lines
1.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Configuration;
|
|
using System.Collections.Specialized;
|
|
using System.Reflection;
|
|
|
|
namespace connor_zwcadm.util {
|
|
public class ConfigUtil {
|
|
|
|
public const string LOG_STATUS = "log_status";
|
|
public const string TC_HOST = "tc_host";
|
|
public const string LAST_LOGIN_USER = "last_login_user";
|
|
public static string GetValue(string key) {
|
|
if (key == null||key.Length==0) {
|
|
return "";
|
|
}
|
|
Configuration appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
|
|
KeyValueConfigurationElement config = appConfig.AppSettings.Settings[key];
|
|
if (config == null) {
|
|
return "";
|
|
}
|
|
return config.Value == null ? "" : config.Value;
|
|
}
|
|
|
|
public static void SetValue(string key, string value) {
|
|
if (key == null || key.Length == 0) {
|
|
return;
|
|
}
|
|
Configuration appConfig = ConfigurationManager.OpenExeConfiguration(Assembly.GetExecutingAssembly().Location);
|
|
KeyValueConfigurationElement config = appConfig.AppSettings.Settings[key];
|
|
if (config == null) {
|
|
appConfig.AppSettings.Settings.Add(key, value);
|
|
}
|
|
else {
|
|
config.Value = value;
|
|
}
|
|
appConfig.Save(ConfigurationSaveMode.Modified);
|
|
ConfigurationManager.RefreshSection("appSettings");
|
|
}
|
|
}
|
|
}
|