// //==================================================================================================== // public static Dictionary <string, DataSourceModel> getNameDict(CPBaseClass cp) { Dictionary <string, DataSourceModel> result = new Dictionary <string, DataSourceModel>(); try { List <string> ignoreCacheNames = new List <string>(); using (DataTable dt = cp.Db.ExecuteQuery("select id from ccdatasources where active>0")) { foreach (DataRow row in dt.Rows) { DataSourceModel instance = create <DataSourceModel>(cp, cp.Utils.EncodeInteger(row["id"])); if (instance != null) { result.Add(instance.name.ToLowerInvariant(), instance); } } } if (!result.ContainsKey("default")) { result.Add("default", getDefaultDatasource(cp)); } } catch (Exception ex) { cp.Site.ErrorReport(ex); throw; } return(result); }
// //==================================================================================================== /// <summary> /// return the default datasource. The default datasource is defined in the application configuration and is NOT a Db record in the ccdatasources table /// </summary> /// <param name="cp"></param> public static DataSourceModel getDefaultDatasource(CPBaseClass cp) { DataSourceModel result = null; try { result = new DataSourceModel { active = true, ccguid = "", connString = "", contentControlId = 0, createdBy = 0, createKey = 0, dateAdded = DateTime.MinValue, dbTypeId = 2, endpoint = cp.ServerConfig.defaultDataSourceAddress, name = "default" }; } catch (Exception ex) { cp.Site.ErrorReport(ex); throw; } return(result); }