示例#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 IEnumerable<LookupItem> Lookup(AutoCompleteQuery query)
 {
     throw new System.NotImplementedException();
 }
示例#3
0
 public ApiResponse AutoCompletePost(AutoCompleteQuery query)
 {
     return(DoAutoComplete(query));
 }