示例#1
0
        public override object GetContent(object model)
        {
            if (Fields.Count > 0)
            {
                //For testing -- go to the page that use this region and add ?entity=[entityId]
                HttpContext context = HttpContext.Current;
                SolrService solrSrv = new SolrService();


                //grab the columnHeaders
                foreach (var field in Fields)
                {
                    // field = CheckDisplayOption(field);
                    CFEntityTypeAttributeMapping map = entityTypeService.GetEntityTypeAttributeMappingById(field.Id);

                    if (!typeof(Catfish.Core.Models.Forms.OptionsField).IsAssignableFrom(field.GetType()))
                    {
                        if (field.SelectedDisplayOption.Equals(eDisplayOption.DropDownList))//(field.IsDropdown)
                        {
                            string fId = "value_" + map.MetadataSet.Guid.Replace('-', '_') + "_" + map.Field.Guid.Replace('-', '_') + "_en_ss";


                            string result   = SolrService.GetPartialMatichingText(fId, "", 100);
                            var    response = Newtonsoft.Json.JsonConvert.DeserializeObject <SolrResponse>(result);

                            if (response.facet_counts.facet_fields.Count > 0)
                            {
                                foreach (var f in response.facet_counts.GetFacetsForField(fId))
                                {
                                    field.ListFields.Add(new SelectListItem {
                                        Text = f.Item1, Value = f.Item1
                                    });
                                }
                            }
                        }
                        else if (field.SelectedDisplayOption.Equals(eDisplayOption.Slider))
                        {
                            string fId = "value_" + map.MetadataSet.Guid.Replace('-', '_') + "_" + map.Field.Guid.Replace('-', '_') + "_is";

                            IDictionary <string, SolrNet.StatsResult> statsResult = solrSrv.GetStats(fId, "*:*");

                            field.Min = statsResult[fId].Min;
                            field.Max = statsResult[fId].Max;
                        }
                    }

                    Mappings.Add(map);
                }
            }

            return(base.GetContent(model));
        }
示例#2
0
        public ActionResult AutoCompleteField(string fieldId, string partialText, int rows = 10)
        {
            string jsonResult = SolrService.GetPartialMatichingText(fieldId, partialText, rows);

            return(this.Content(jsonResult, "application/json"));
        }