public static Boolean SetAppConfigDBAndCache(int storeId, String paramName, String value, List <string> dontDupValues) { AppConfigs configs = EnsureStoreConfigsExists(storeId); try { if (configs[paramName] != null) { configs[paramName].ConfigValue = value; } else { if (dontDupValues.Contains(value)) { return(false); } AppConfig newConfig = DuplicateAppConfigForStore(storeId, paramName, value); if (newConfig == null) { return(false); } configs.Add(newConfig); } return(true); } catch (Exception) { return(false); } }
public static void LoadAllConfigs() { lock (syncLock) { // make a temporary copy during loading, this way we don't touch the main config files // for other threads trying to access it during loading/reloading time var loadConfigs = new Dictionary <int, AppConfigs>(); Action <IDataReader> readAction = (rs) => { while (rs.Read()) { AppConfig config = new AppConfig(rs.FieldInt("AppConfigID"), rs.FieldGuid("AppConfigGUID"), rs.Field("Name"), rs.Field("Description"), rs.Field("ConfigValue"), rs.Field("GroupName"), rs.FieldBool("SuperOnly"), rs.FieldDateTime("CreatedOn"), rs.Field("ValueType")); // these 2 fields are guaranteed to not automatically update the database upon setting property values config.StoreId = rs.FieldInt("StoreId"); config.AllowableValues.AddCommaDelimited(rs.Field("AllowableValues")); AppConfigs configs = EnsureStoreConfigsExists(loadConfigs, config.StoreId); configs.Add(config); } }; DB.UseDataReader("dbo.aspdnsf_getAppconfig", readAction); // clear the master data repository storeConfigs.Clear(); // push the config data to the main repository foreach (int storeId in loadConfigs.Keys) { AppConfigs configs = loadConfigs[storeId]; storeConfigs.Add(storeId, configs); } } }
public static AppConfigs GetAppConfigCollection(int storeId, Boolean IncludeSuperConfigs) { if (storeConfigs.ContainsKey(storeId)) { if (IncludeSuperConfigs) { return(storeConfigs[storeId]); } else { AppConfigs nonSuperAppConfigs = new AppConfigs(storeConfigs[storeId].Where(c => c.SuperOnly == false).ToDictionary(item => item.Name, item => item)); return(nonSuperAppConfigs); } } var empty = new AppConfigs(); return(empty); }
internal static IEnumerable <AppConfig> SearchAppConfigs(string SearchTerm, int StoreId) { AppConfigs data = EnsureStoreConfigsExists(StoreId); return(data.Where(d => d.Name.ContainsIgnoreCase(SearchTerm))); }