/// <summary> /// Queries database status. /// </summary> /// <param name="database">.</param> /// <remarks>Asim Naeem, 7/20/2017.</remarks> internal void QueryDatabaseStatus(int database) { try { string commandText = "SELECT TX1_FLAG, TX2_FLAG, BR1_FLAG, BR2_FLAG, BR1_DBType,BR2_DBType,TX1_DBType,TX2_DBType, TX1_SERVER, TX1_DBNAME, TX2_SERVER, TX2_DBNAME, BR1_SERVER, BR1_DBNAME, BR2_SERVER, BR2_DBNAME FROM LU_DATABASE_STATUS"; DataTable dataTable = this.ICommands.ExecuteDataTable(commandText); if (dataTable.Rows.Count > 0) { DataRow dataRow = dataTable.Rows[0]; if (this.BXConfig.Count > 0) { bool bx = (( this.BXConfig[0].ServerName.ToLower().Equals(dataRow["BR1_SERVER"].ToString().ToLower()) && this.BXConfig[0].DatabaseName.ToLower().Equals(dataRow["BR1_DBNAME"].ToString().ToLower()) && this.BXConfig[0].ActiveFlag.Equals(dataRow["BR1_FLAG"]) ) || ( this.BXConfig[1].ServerName.ToLower().Equals(dataRow["BR2_SERVER"].ToString().ToLower()) && this.BXConfig[1].DatabaseName.ToLower().Equals(dataRow["BR2_DBNAME"].ToString().ToLower()) && this.BXConfig[1].ActiveFlag.Equals(dataRow["BR2_FLAG"]) ) ) ? true : false; if (!bx) { this.BXConfig.Clear(); this.BXConfig = new List <WDDBConfig>(); this.BXConfig.Add(new WDDBConfig(1, HelperUtility.ConvertTo <string>(dataRow["BR1_SERVER"], string.Empty), HelperUtility.ConvertTo <string>(dataRow["BR1_DBNAME"], string.Empty), (dataRow["BR1_FLAG"].ToString() == "1" ? true : false), Helpers.HelperUtility.GetDbProvider(dataRow["BR1_DBType"].ToString()))); this.BXConfig.Add(new WDDBConfig(2, HelperUtility.ConvertTo <string>(dataRow["BR2_SERVER"], string.Empty), HelperUtility.ConvertTo <string>(dataRow["BR2_DBNAME"], string.Empty), ( dataRow["BR2_FLAG"].ToString() == "1" ? true : false), Helpers.HelperUtility.GetDbProvider(dataRow["BR2_DBType"].ToString()))); this.isChanged = true; this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "br1").Server = dataRow["BR1_SERVER"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "br1").DBName = dataRow["BR1_DBNAME"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "br1").DBType = dataRow["BR1_DBType"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "br1").ConnectType = dataRow["BR1_FLAG"].ToString() == "1" ? "ONLINE" : "NOTUSED"; this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "br2").Server = dataRow["BR2_SERVER"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "br2").DBName = dataRow["BR2_DBNAME"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "br2").DBType = dataRow["BR2_DBType"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "br2").ConnectType = dataRow["BR2_FLAG"].ToString() == "1" ? "ONLINE" : "NOTUSED"; } } if (this.TXConfig.Count > 0) { bool tx = (( this.TXConfig[0].ServerName.ToLower().Equals(dataRow["TX1_SERVER"].ToString().ToLower()) && this.TXConfig[0].DatabaseName.ToLower().Equals(dataRow["TX1_DBNAME"].ToString().ToLower()) && this.TXConfig[0].ActiveFlag.Equals(dataRow["TX1_FLAG"]) ) || ( this.TXConfig[1].ServerName.ToLower().Equals(dataRow["TX2_SERVER"].ToString().ToLower()) && this.TXConfig[1].DatabaseName.ToLower().Equals(dataRow["TX2_DBNAME"].ToString().ToLower()) && this.TXConfig[1].ActiveFlag.Equals(dataRow["TX2_FLAG"]) ) ) ? true : false; if (!tx) { this.TXConfig.Clear(); this.TXConfig = new List <WDDBConfig>(); this.TXConfig.Add(new WDDBConfig(1, HelperUtility.ConvertTo <string>(dataRow["TX1_SERVER"], string.Empty), HelperUtility.ConvertTo <string>(dataRow["TX1_DBNAME"], string.Empty), (dataRow["TX1_FLAG"].ToString() == "1" ? true : false), Helpers.HelperUtility.GetDbProvider(dataRow["TX1_DBType"].ToString()))); this.TXConfig.Add(new WDDBConfig(2, HelperUtility.ConvertTo <string>(dataRow["TX2_SERVER"], string.Empty), HelperUtility.ConvertTo <string>(dataRow["TX2_DBNAME"], string.Empty), ( dataRow["TX2_FLAG"].ToString() == "1" ? true : false), Helpers.HelperUtility.GetDbProvider(dataRow["TX2_DBType"].ToString()))); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "tx1").Server = dataRow["TX1_SERVER"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "tx1").DBName = dataRow["TX1_DBNAME"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "tx1").DBType = dataRow["TX1_DBType"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "tx1").ConnectType = dataRow["TX1_FLAG"].ToString() == "1" ? "ONLINE" : "NOTUSED"; this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "tx2").Server = dataRow["TX2_SERVER"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "tx2").DBName = dataRow["TX2_DBNAME"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "tx2").DBType = dataRow["TX2_DBType"].ToString(); this.xmlInstance.Dbs.Find(x => x.ID.ToLower() == "tx2").ConnectType = dataRow["TX2_FLAG"].ToString() == "1" ? "ONLINE" : "NOTUSED"; this.isChanged = true; } } } } catch (Exception exc) { ILogger.Fatal(exc); throw; } }