Beispiel #1
0
        private ApiResponse DoAutoComplete(AutoCompleteQuery query)
        {
            query = query ?? new AutoCompleteQuery()
            {
                SearchType = "credential"
            };

            try
            {
                //HttpContext.Current.Response.Clear();
                //HttpContext.Current.Response.BufferOutput = true;
                //HttpContext.Current.Response.AppendHeader( "Access-Control-Allow-Origin", "*" );
                //string contentType = "application/json";
                //HttpContext.Current.Response.ContentType = contentType;
                //HttpContext.Current.Response.ContentEncoding = contentType == "application/json" ? Encoding.UTF8 : HttpContext.Current.Response.ContentEncoding;

                var results = SearchServices.DoAutoComplete(query.SearchType, query.FilterURI, query.Text, query.WidgetId);
                var acr     = new AutoCompleteResponse();
                acr.Items = results.Select(m => new FilterItem()
                {
                    Label = m.ToString(), Text = m.ToString(), URI = query.FilterURI, InterfaceType = "interfaceType:Text"
                }).ToList();
                return(new ApiResponse(acr, true, null));
            }
            catch (Exception ex)
            {
                return(new ApiResponse(null, false, new List <string>()
                {
                    "Error processing autocomplete request: " + ex.Message
                }));
            }
        }
        public JsonResult DoAutoComplete(string text, string context, string searchType, int widgetId = 0)
        {
            var data = SearchServices.DoAutoComplete(text, context, searchType, widgetId);

            return(JsonHelper.GetJsonWithWrapper(data, true, "", null));
        }