public List <IdpeKey> GetDataSourceKeysConnectionStrings(int dataSourceId, bool isSystem) { List <IdpeKey> keys = new List <IdpeKey>(); string commandText = "select k.[KeyId], k.[Name], k.[Value], k.[ValueBinary], k.[Type], k.[NextKeyId], k.[CreatedTS], k.[CreatedBy], k.[ModifiedTS], k.[ModifiedBy], k.[Source], kds.[IsDeployable] "; commandText += "from IdpeKey k "; commandText += "inner join IdpeKeyDataSource kds on k.KeyId = kds.KeyId "; commandText += "where kds.DataSourceId = " + dataSourceId; commandText += " and k.[Type] in (2,3,4,5)"; DataTable table = CoreDatabaseObjects.Instance.ExecuteCommand(commandText); if (table != null) { foreach (DataRow row in table.Rows) { IdpeKey key = RowToSreKey(row); if (dataSourceId == -99) { //this is added just to identify global keys IdpeKeyDataSource kds = new IdpeKeyDataSource(); kds.KeyId = key.KeyId; kds.DataSourceId = -99; key.IdpeKeyDataSources.Add(kds); } keys.Add(key); } } if ((dataSourceId != -99) && (isSystem == false)) { //adding global List <IdpeKey> gKeys = GetDataSourceKeysConnectionStrings(-99, false); foreach (IdpeKey key in gKeys) { if (keys.Where(dKey => dKey.Name == key.Name).SingleOrDefault() == null) { //this is added just to identify global keys IdpeKeyDataSource kds = new IdpeKeyDataSource(); kds.KeyId = key.KeyId; kds.DataSourceId = -99; key.IdpeKeyDataSources.Add(kds); keys.Add(key); } } } return(keys); }
private List <IdpeKeyDataSource> GetIdpeKeyDataSources() { List <IdpeKeyDataSource> idpeKeyDataSources = new List <IdpeKeyDataSource>(); string commandText = "select [KeyDataSourceId],[KeyId],[DataSourceId],[IsDeployable] from [IdpeKeyDataSource]"; DataTable table = CoreDatabaseObjects.Instance.ExecuteCommand(commandText); if (table == null) { return(idpeKeyDataSources); } foreach (DataRow row in table.Rows) { IdpeKeyDataSource idpeKeyDataSource = new IdpeKeyDataSource(); idpeKeyDataSource.KeyDataSourceId = (int)row["KeyDataSourceId"].ToString().ParseInt(); idpeKeyDataSource.KeyId = (int)row["KeyId"].ToString().ParseInt(); idpeKeyDataSource.DataSourceId = (int)row["DataSourceId"].ToString().ParseInt(); idpeKeyDataSource.IsDeployable = row["IsDeployable"].ToString().ParseBool(); idpeKeyDataSources.Add(idpeKeyDataSource); } return(idpeKeyDataSources); }