using System; using System.Collections.Generic; using System.Text; using Nini.Config; using System.Collections; using SafeNetLib; namespace PAL_SOC { public class Config { private IConfigSource source = null; private string CFG_FILE = "config.ini"; public string gatewayID; public int locPort; public string SERVER; public string DATABASE; public string UID; public string PASSWORD; public bool db_active; public int debug_port; //email service for alerts public string alert_smtpServer = ""; public string alert_pop3Server = ""; public string alert_pop3Port = ""; public string alert_smtpPort = ""; public bool alert_sslState = false; public string alert_user, alert_psw; public ArrayList ar_radioIPs = new ArrayList(); public Config(string CFG_FILE = "config.ini") { LoadConfig(); } private void LoadConfig() { try { source = new IniConfigSource(CFG_FILE); gatewayID = source.Configs["GATEWAY"].Get("id"); locPort = Convert.ToInt32(source.Configs["GATEWAY"].Get("port")); //MySQL connection info (for SMS) SERVER = source.Configs["MySQL"].Get("SERVER"); DATABASE = source.Configs["MySQL"].Get("DATABASE"); UID = source.Configs["MySQL"].Get("UID"); PASSWORD = source.Configs["MySQL"].Get("PASSWORD"); db_active = Convert.ToBoolean(source.Configs["MySQL"].Get("active")); //debug port is GWID with the first digit replage by 3. ex: 95001 -> 35001 string str_debug_port = "3" + gatewayID.Substring(1); debug_port = Int32.Parse(str_debug_port); //for alerts alert_pop3Server = source.Configs["EmailServiceAlerts"].Get("Pop3Server"); alert_smtpServer = source.Configs["EmailServiceAlerts"].Get("SmtpServer"); alert_pop3Port = source.Configs["EmailServiceAlerts"].Get("Pop3Port"); alert_smtpPort = source.Configs["EmailServiceAlerts"].Get("SmtpPort"); alert_sslState = Convert.ToBoolean(source.Configs["EmailServiceAlerts"].Get("EnableSSL")); alert_user = source.Configs["EmailServiceAlerts"].Get("User"); alert_psw = source.Configs["EmailServiceAlerts"].Get("Pass"); } catch (Exception ex) { Utils.ConsWrite(DebugMSG_Type.always, "LoadSetup() Exception: " + ex.ToString()); } Utils.ConsWrite(DebugMSG_Type.CTRL, "LoadSetup file OK !"); } } }