SafeDispatch/AppServerMobile/Config.cs
2024-02-22 18:43:59 +02:00

86 lines
3.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Nini.Config;
using SafeMobileLib;
namespace AppServerMobile
{
public class Config
{
private IConfigSource source = null;
private string CFG_FILE = "appConfig.ini";
public string DB_IP, DB_schema, DB_user, DB_passwd, DB_port;
public int andPort;
public int andAudioPort;
public string msgBusIP;
public string msgBusPort;
public Int32 regPort;
private void LoadConfig()
{
try
{
source = new IniConfigSource(CFG_FILE);
andPort = Convert.ToInt32(source.Configs["Android"].Get("port"));
andAudioPort = Convert.ToInt32(source.Configs["Android"].Get("audioPort"));
DB_IP = source.Configs["Database"].Get("IP");
DB_schema = source.Configs["Database"].Get("Schema");
DB_user = source.Configs["Database"].Get("User");
DB_passwd = source.Configs["Database"].Get("Passwd");
DB_port = source.Configs["Database"].Get("Port");
/*
pop3Server = source.Configs["EmailService"].Get("Pop3Server");
smtpServer = source.Configs["EmailService"].Get("SmtpServer");
pop3Port = source.Configs["EmailService"].Get("Pop3Port");
smtpPort = source.Configs["EmailService"].Get("SmtpPort");
sslState = Convert.ToBoolean(source.Configs["EmailService"].Get("EnableSSL"));
*/
/*
DBemailServiceManager DB = new DBemailServiceManager(DB_IP, DB_schema, DB_user, DB_passwd, DB_port);
EmailService es = DB.GetEmailServiceSettings();
enableEmailService = es.Enable;
user = es.User;
psw = es.Pass;
SM.Debug("EmailService enable=" + enableEmailService + " user=" + user + " pass=" + psw);
RecordingsPort = Convert.ToInt32(source.Configs["RecordingsServer"].Get("port"));
RecordingsAudioPort = Convert.ToInt32(source.Configs["RecordingsServer"].Get("portAudio"));
*/
msgBusIP = source.Configs["MessageBus"].Get("ip");
msgBusPort = source.Configs["MessageBus"].Get("port");
regPort = Convert.ToInt32(source.Configs["Registration"].Get("port"));
}
catch (Exception ex)
{
SM.Debug("LoadSetup() Exception: " + ex.Message);
}
SM.Debug("LoadSetup file OK !");
}
public Config()
{
LoadConfig();
}
private void SaveCFGFile(string file)
{
source = new IniConfigSource(CFG_FILE);
//DataBase
source.Configs["Database"].Set("IP", DB_IP);
source.Configs["Database"].Set("Schema", DB_schema);
source.Configs["Database"].Set("User", DB_user);
source.Configs["Database"].Set("Passwd", DB_passwd);
source.Configs["Database"].Set("Port", DB_port);
// Save the INI file
source.Save();
//UpdateFields();
}
}
}