//Getting the configuration table data from master server) public static void Init() { Servers = new List <Models.Servers>(); List <byte> levels = new List <byte>(); #region Read Configuration File //Read config file //Configuration is set up on DefaultConnection string in this case BaseDataAccess DataBase = new BaseDataAccess("Data Source=localhost,8758;Initial Catalog=configuration;Integrated Security=False;User Id=tijan;Password=tijan99;MultipleActiveResultSets=True"); using (DataSet ConfigData = DataBase.ExecuteFillDataSet("select slave_id, concat(server_name, ',', db_port) as db_call, concat('Data Source=', server_name, ',8758;Initial Catalog=', database_name, ';Integrated Security=False;User Id=', username, ';Password='******';MultipleActiveResultSets=True') as database_connection_string, concat('http://', server_name, ':', api_port) as api_call, api_port, server_level, main_table, database_name, username, password FROM slaves WHERE is_using = 'true'; ", null)) { foreach (DataRow row in ConfigData.Tables[0].Rows) { Servers.Add(new Models.Servers { slave_id = Convert.ToInt16(row["slave_id"]), //smallint to int database_connection_string = row["database_connection_string"].ToString(), //string to string api_call = row["api_call"].ToString(), //string to string api_port = Convert.ToInt16(row["api_port"]), //smallint to int server_level = (byte)row["server_level"], //tinyint to int working_directory = AppDomain.CurrentDomain.BaseDirectory + "wd/", main_table = row["main_table"].ToString(), //string to string, username = row["username"].ToString(), password = row["password"].ToString(), database_name = row["database_name"].ToString(), db_call = row["db_call"].ToString() }); levels.Add((byte)row["server_level"]); } } #endregion }
public static void Init() { Servers = new List <Models.Servers>(); List <byte> levels = new List <byte>(); #region Read Configuration File //Read config file //Configuration is set up on DefaultConnection string in this case BaseDataAccess DataBase = new BaseDataAccess("Data Source=localhost,8758;Initial Catalog=configuration;Integrated Security=False;User Id=tijan;Password=tijan99;MultipleActiveResultSets=True"); using (DataSet ConfigData = DataBase.ExecuteFillDataSet("select slave_id, concat('Data Source=localhost,', db_port, ';Initial Catalog=', database_name, ';Integrated Security=False;User Id=', username, ';Password='******';MultipleActiveResultSets=True') as database_connection_string, concat('http://', server_name, ':', api_port) as api_call, api_port, server_level, main_table FROM slaves WHERE is_using = 'true';", null)) { foreach (DataRow row in ConfigData.Tables[0].Rows) { Servers.Add(new Models.Servers { slave_id = Convert.ToInt16(row["slave_id"]), //smallint to int database_connection_string = row["database_connection_string"].ToString(), //string to string api_call = row["api_call"].ToString(), //string to string api_port = Convert.ToInt16(row["api_port"]), //smallint to int server_level = (byte)row["server_level"], //tinyint to int main_table = row["main_table"].ToString() //string to string }); levels.Add((byte)row["server_level"]); } } //Initialize the values array int counter = 0; values = new List <int>(); foreach (byte level in levels) { for (byte i = 0; i < level; i++) { values.Add(counter); } counter++; } //Checkup Console.Write("Values Array: " + string.Join(",", values)); #endregion }