using System.Windows.Forms; using System.Xml; namespace SSWMS.Common { public static class AppSettings { public static string ServiceUrl { get; set; } public static string ERPServiceUrl { get; set; } public static string WebAPIUrl { get; set; } public static string WebAPIUrl_Android { get; set; } public static bool IsOracleDatabase = false; public static bool IsStockSingleGoods = false; public static bool IsStockUniqueGoods = false; public static bool IsNetworkDeployed = false; public static void Init(bool isNetworkDeployed) { IsNetworkDeployed = isNetworkDeployed; if (isNetworkDeployed) { ServiceUrl = "http://10.241.121.10:8001/Service/"; ERPServiceUrl = "http://10.241.121.10:8001/Service/"; WebAPIUrl = "http://10.70.3.4:8087"; WebAPIUrl_Android = "http://10.241.121.10:8087"; } else { ServiceUrl = "http://localhost:8001/Service/"; ERPServiceUrl = "http://localhost:8001/Service/"; WebAPIUrl = "http://localhost:8087"; WebAPIUrl_Android = "http://localhost:8087"; } } public static string GetValue(string sKey) { try { string sConfigPath = Application.ExecutablePath + ".config"; XmlDocument xDoc = new XmlDocument(); xDoc.Load(sConfigPath); XmlElement xElem = (XmlElement)xDoc.SelectSingleNode( string.Format("//appSettings//add[@key='{0}']", sKey)); if (xElem != null) { return xElem.GetAttribute("value"); } } catch { } return string.Empty; } public static void SetValue(string sKey, string sValue) { try { string sConfigPath = Application.ExecutablePath + ".config"; XmlDocument xDoc = new XmlDocument(); xDoc.Load(sConfigPath); XmlElement xElem1 = (XmlElement)xDoc.SelectSingleNode( string.Format("//appSettings//add[@key='{0}']", sKey)); if (xElem1 != null) { xElem1.SetAttribute("value", sValue); xDoc.Save(sConfigPath); } } catch { } } } }