using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Runtime.InteropServices; using System.Windows.Forms; namespace KHModbus { public class U3Config { public const bool FLAG_TEST = true; public const int MAX_DI = 4; public const int MAX_DEV = 100; static public string m_SqlConnStr = ""; [DllImport("kernel32")] private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath); [DllImport("kernel32")] private static extern long WritePrivateProfileString(string section, string key, string val, string filePath); protected string GetIniFile() { string AppPath = Application.ExecutablePath.Substring(0, Application.ExecutablePath.LastIndexOf("\\")); return AppPath + "\\Config.ini"; } protected string GetIniValue(string Section, string Key, string defvalue) { StringBuilder temp = new StringBuilder(255); int i = GetPrivateProfileString(Section, Key, defvalue, temp, 255, GetIniFile()); return temp.ToString(); } protected void SetIniValue(string Section, string Key, string Value) { WritePrivateProfileString(Section, Key, Value, GetIniFile()); } //public string m_StrMqttIP = ""; public string m_StrSqlServerIP = ""; public U3Config() { Load(); // 테스트용 서버 //m_SqlConnStr = "Provider=SQLOLEDB.1;Password=tlrmsjtm~1@3;Persist Security Info=False;User ID=sa;Initial Catalog=U3SMES;Data Source=signus-sf1.koreacentral.cloudapp.azure.com,14443"; // 한국하우톤 현장 서버 m_SqlConnStr = "Provider=SQLOLEDB.1;Password=signus1!;Persist Security Info=False;User ID=sa;Initial Catalog=U3SMES;Data Source=192.168.1.17,1433"; } public void Save() { //SetIniValue("MQTT", "IPADDR", m_StrMqttIP); SetIniValue("SQLSERVER", "IPADDR", m_StrSqlServerIP); } public void Load() { m_StrSqlServerIP = GetIniValue("SQLSERVER", "IPADDR", "192.168.1.17"); //m_StrMqttIP = GetIniValue("MQTT", "IPADDR", "192.168.0.200"); //m_StrSqlServerIP = GetIniValue("SQLSERVER", "IPADDR", "192.168.0.240"); } } }