private string GetSearchField(LibrarySettings.Field field) { var search = GetSearchObject(field); if (search == null || !search.ContainsKey("searchFields")) { return(field.DBColumnName); } var searchFields = search["searchFields"]; if (search.ContainsKey("entityName")) { string entityName = search["entityName"].ToString(); // Figure out now if we have the situation where the search needs to be performed on a navigation property // There are two things that we allow on the entity. // 1. A navigation property of same name as entityName // 2. A search property named {EntityName}{EntityPropertyName} (e.g. PlantName) // if these situations occur then the contents of searchFields delimited by AND or OR must have the prefixes added for each of the situations var searchEntityType = this.searchEngineRegistry.GetEntityType(entityName); return(BuildNavigationParameterForField(searchFields.ToString(), searchEntityType, typeof(TDocument))); } else { return(searchFields.ToString()); } }
private static JObject GetSearchObject(LibrarySettings.Field field) { if (string.IsNullOrEmpty(field.FilterData)) { return(null); } var filterData = !string.IsNullOrEmpty(field.FilterData) ? JObject.Parse(field.FilterData) : null; if (!filterData.ContainsKey("search")) { return(null); } return(filterData["search"] as JObject); }
private object GetValue(LibrarySettings.Field field, FormCollection form) { string fieldId = field.ViewColumnID; string hiddenFormValue = form["hidden" + fieldId]; string formValue = ""; if (field.Type == FieldTypeEnum.NumberRange) {// it has two values saved in two form fields named with fieldId: f934fb3f-984c-e811-9c6f-bc305bb8042d[0] f934fb3f-984c-e811-9c6f-bc305bb8042d[1] string fromValue = form[fieldId + "[0]"]; string toValue = form[fieldId + "[1]"]; if (string.IsNullOrWhiteSpace(fromValue) && string.IsNullOrWhiteSpace(toValue)) { return(null); } decimal[] values = new decimal[2]; values[0] = string.IsNullOrWhiteSpace(fromValue) ? decimal.MinValue : Convert.ToDecimal(fromValue); values[1] = string.IsNullOrWhiteSpace(toValue) ? decimal.MaxValue : Convert.ToDecimal(toValue);; return(values); } else { formValue = form[fieldId]; } var stringValue = !string.IsNullOrEmpty(hiddenFormValue) ? hiddenFormValue : formValue; if (string.IsNullOrEmpty(stringValue)) { return(null); } var mapToSplit = field.DBColumnName.Split('.'); var property = typeof(TDocument).GetProperty(mapToSplit[0]); if (property == null) { return(null); } string searchField = GetSearchField(field); return(GetValue(stringValue, searchField, property.PropertyType, false)); }