private static bool UpdateSipConfigFiles() { ConfigParams cfgs = new ConfigParams(); cfgs.LoadFromTableByComponent(ConfigParams.e_Components.SIP.ToString()); if (0 == cfgs.Count) { Console.Error.WriteLine("ERROR: Unable to generate SIP configuration files - couldn't load SIP settings from database."); return(false); } ConfigParams cfgs2 = new ConfigParams(); cfgs2.LoadFromTableByComponent(ConfigParams.e_Components.SIP2.ToString()); if (0 == cfgs2.Count) { Console.Error.WriteLine("ERROR: Unable to generate SIP configuration files - couldn't load SIP2 settings from database."); return(false); } else { cfgs.Add(GetPbxValue(cfgs2)); } ConfigParams cfgs3 = new ConfigParams(); cfgs3.LoadFromTableByComponent(ConfigParams.e_Components.SIP3.ToString()); if (0 == cfgs3.Count) { Console.Error.WriteLine("ERROR: Unable to generate SIP configuration files - couldn't load SIP3 settings from database."); return(false); } else { foreach (ConfigParams.ConfigParam cfg in cfgs3) { cfgs.Add(cfg); } } SIP sip = new SIP(); return(sip.Persist(cfgs, g_sConfigPath)); } // UpdateSipConfigFiles
public MainViewModel(EntityFramework.Models.Users currentuser) : this() { // TODO: Complete member initialization this.currentuser = currentuser; ConfigParams.Add(new ConfigParamModel { Changer = "user", Description = currentuser.Name, Name = "Потребител", Value = currentuser.Username + " " + currentuser.Rights }); }
public MainViewModel(User currentuser) : this() { // TODO: Complete member initialization this.currentuser = currentuser; ConfigParams.Add(new ConfigParamModel { Changer = "user", Description = currentuser.Name, Name = "Потребител", Value = currentuser.UserName }); }
public LimitsFilePersistenceTest() { Persistence = new LimitsFilePersistence(); var config = new ConfigParams(); config.Add("path", "./Data/beacons.test.json"); Persistence.Configure(config); Fixture = new LimitsPersistenceFixture(Persistence); }
} // StartWorkerThread protected static bool CheckIPAutoSave(ILegacyLogger i_Logger) { // FIX - As with the constants in GetPbxValue(), these constants should be pulled out. const string csProxyServer = "SpeechBridge SIP Proxy"; const string csAudiomgrAddr = "AudioMgr IP address"; bool bRet = true, bRes = true; string sCheck = "", sPath = "", sCurrAddr = ""; System.Net.IPHostEntry tmpIpHost = null; System.Net.IPAddress[] tmpIpAddrs = null; string[] asAddrs = null; int ii = 0, iNumAddrs = 0; ConfigParams cfgs = null; SBConfigStor.SIP sipTmp = null; int iNumElems = 0; string sProxyAddr = "", sAMAddr = ""; try { sCheck = ConfigurationManager.AppSettings["CheckIpOnStartup"]; if ((sCheck == null) || (sCheck.Length == 0) || (sCheck.ToLower() == false.ToString().ToLower())) { // Default or 'false' is to do nothing. i_Logger.Log(Level.Info, "CheckIPAutoSave - Not checking/saving IP address."); } else { // Get current IP address and compare it against what is stored in the DB. tmpIpHost = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()); tmpIpAddrs = tmpIpHost.AddressList; iNumAddrs = tmpIpAddrs.Length; asAddrs = new string[iNumAddrs]; for (ii = 0; ii < iNumAddrs; ii++) { asAddrs[ii] = tmpIpAddrs[ii].ToString(); } sCurrAddr = asAddrs[0]; // FIX - Assumes active NIC is 1'st one cfgs = new ConfigParams(); cfgs.LoadFromTableByComponent(ConfigParams.e_Components.SIP.ToString()); iNumElems = cfgs.Count; if (iNumElems <= 0) { i_Logger.Log(Level.Exception, "SBLocalRM.CheckIPAutoSave Couldn't load settings from DB."); } else { sProxyAddr = cfgs[csProxyServer].Value; sAMAddr = cfgs[csAudiomgrAddr].Value; // If address is different, save it to SIP Proxy and AudioMgr values, and save config files. if ((sCurrAddr != sProxyAddr) || (sCurrAddr != sAMAddr)) { sPath = ConfigurationManager.AppSettings["DefaultConfigPath"]; cfgs[csProxyServer].Value = sCurrAddr; cfgs[csAudiomgrAddr].Value = sCurrAddr; bRes = cfgs.SaveToTableByComponent(ConfigParams.e_Components.SIP.ToString()); if (!bRes) { i_Logger.Log(Level.Exception, "SBLocalRM.CheckIPAutoSave Error saving settings to DB."); } else { i_Logger.Log(Level.Info, "CheckIPAutoSave Saved settings to DB."); } // Get the PBX Type information and append it to the other configuration data before // regenerating the configuration files for the Proxy Server and the Audio Routers. // // NOTE: This code is very similar to what exists in ServerSettings.aspx.cs (m_buttonUpdate_Click()) // so it should be refactored to a common location. // Also, as per the comment in ServerSettings.aspx.cs, if more elements are added to SIP2 then // those will also have to be added to the configuration data passed to SIP.Persist(). ConfigParams cfgs2 = new ConfigParams(); cfgs2.LoadFromTableByComponent(ConfigParams.e_Components.SIP2.ToString()); cfgs.Add(GetPbxValue(cfgs2)); // Get the load-balancing/failover information and append it to the other configuration data before // regenerating the configuration files for the Proxy Server and the Audio Routers. ConfigParams cfgs3 = new ConfigParams(); cfgs3.LoadFromTableByComponent(ConfigParams.e_Components.SIP3.ToString()); foreach (ConfigParams.ConfigParam cfg in cfgs3) { cfgs.Add(cfg); } sipTmp = new SIP(); bRes = sipTmp.Persist(cfgs, sPath); if (!bRes) { i_Logger.Log(Level.Exception, "SBLocalRM.CheckIPAutoSave Error saving settings to config files."); } else { i_Logger.Log(Level.Info, "CheckIPAutoSave Saved settings to config files."); } // Write addr to /etc/hosts, hostname to /etc/sysconfig/network } else { i_Logger.Log(Level.Info, "CheckIPAutoSave - IP addresses matched."); } } } } catch (Exception exc) { i_Logger.Log(Level.Exception, "SBLocalRM.CheckIPAutoSave caught exception: " + exc.ToString()); bRet = false; } return(bRet); } // CheckIPAutoSave