protected virtual void SetCurrentSearchConfigAtWebLevel(CSOMModelHostBase modelHost, Web web, SearchSettingsConfig searchSettings) { InternalSetCurrentSearchConfig(modelHost, web, searchSettings, true); }
private void InternalSetCurrentSearchConfig( CSOMModelHostBase modelHost, Web web, SearchSettingsConfig searchSettings, bool isWebLevel) { var propertyBagName = "SRCH_SB_SET_SITE"; if (isWebLevel) propertyBagName = "SRCH_SB_SET_WEB"; var serializer = new JavaScriptSerializer(); var props = web.AllProperties; props[propertyBagName] = serializer.Serialize(searchSettings); }
protected virtual void SetCurrentSearchConfigAtSiteLevel(Web web, SearchSettingsConfig searchSettings) { InternalSetCurrentSearchConfig(web, searchSettings, false); }
private SearchSettingsConfig InternalGetCurrentSearchConfig(Web web, bool isWebLevel) { SearchSettingsConfig result = null; var serializer = new JavaScriptSerializer(); var propertyBagName = "SRCH_SB_SET_SITE"; if (isWebLevel) propertyBagName = "SRCH_SB_SET_WEB"; try { var rawSearchSettings = string.Empty; if (web.AllProperties.FieldValues.ContainsKey(propertyBagName)) rawSearchSettings = ConvertUtils.ToStringAndTrim(web.AllProperties[propertyBagName]); result = serializer.Deserialize<SearchSettingsConfig>(rawSearchSettings); // no setup -> an empty string gives NULL // create default one to push the setting if (result == null) result = new SearchSettingsConfig(); } catch (Exception) { } return result; }
protected virtual void SetCurrentSearchConfigAtWebLevel(SPWeb web, SearchSettingsConfig searchSettings) { InternalSetCurrentSearchConfig(web, searchSettings, true); }