Esempio n. 1
0
        internal string SearchTreeTraversal(ProjectionContext pc, string val)
        {
            SearchResult result = new SearchResult();

            foreach (var top in pc.CurrentAttributeStateSet.States)
            {
                SearchStructure st = new SearchStructure();
                st = SearchStructure.BuildStructure(top, top, val, st, false, 0);
                if (st?.Result.FoundFlag == true)
                {
                    if (result.FoundFlag == false)
                    {
                        result = st.Result;
                    }
                    else if (result.FoundDepth > st?.Result.FoundDepth)
                    {
                        result = st.Result;
                    }
                    else if (result.FoundDepth == st?.Result.FoundDepth)
                    {
                        foreach (var newTops in st?.Result.Top)
                        {
                            result.Top.Add(newTops);
                        }
                    }
                }
            }

            return(result.FoundFlag ? GetResult(val, result) : string.Empty);
        }
Esempio n. 2
0
        public IActionResult SearchResults(SearchStructure search)
        {
            var url = $"{_apiRoot}/api/transaction/{search.Postcode}/{search.Radius}";

            Log.Information($"accessing {url}");
            try
            {
                WebRequest request = WebRequest.Create(url);
                // If required by the server, set the credentials.
                request.Credentials = CredentialCache.DefaultCredentials;
                //"STUFF".Humanize(LetterCasing.Sentence);
                // Get the response.
                HttpWebResponse response = (HttpWebResponse)request.GetResponse();
                // Display the status.
                Log.Information(response.StatusDescription);
                // Get the stream containing content returned by the server.
                Stream dataStream = response.GetResponseStream();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader(dataStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd();
                // Display the content.
                Console.WriteLine(responseFromServer);
                // Cleanup the streams and the response.
                reader.Close();
                dataStream.Close();
                response.Close();

                var stuff = Newtonsoft.Json.JsonConvert.DeserializeObject <PagedResult <Results> >(responseFromServer);
                return(View(stuff));
            }
            catch (Exception ex)
            {
                Log.Information($"Error accessing {url}:{ex.Message}");
                throw;
            }
        }