示例#1
0
        public bool Search(SearchViewModel model)
        {
            var response = new SearchResponse();
            SearchServiceClient client = new SearchServiceClient();

            response = client.Search(new SearchRequest()
            {
                Filter = new SearchFilter
                {
                    FirstName   = model.FirstName,
                    LastName    = model.LastName,
                    AgeMin      = model.AgeTo,
                    AgeMax      = model.AgeFrom,
                    Sex         = model.Sex,
                    HeightMin   = model.HeightTo,
                    HeightMax   = model.HeightFrom,
                    WeightMin   = model.WeightTo,
                    WeightMax   = model.WeightFrom,
                    Nationality = model.Nationality,
                    Email       = model.Email,
                    NoOfResults = 30
                }
            });
            return(response.Success);
        }
示例#2
0
        public IEnumerable <string> SearchKeywordLocation(string keyword, double latitude, double longitude)
        {
            var results = new List <string>();

            var searchRequest = new SearchRequest();

            // Set the credentials using a valid Bing Maps key
            searchRequest.Credentials = new SearchService.Credentials();
            searchRequest.Credentials.ApplicationId = GetBingMapsApplicationKey();

            //Create the search query
            var ssQuery = new StructuredSearchQuery();

            ssQuery.Keyword  = keyword;
            ssQuery.Location = string.Format("{0}, {1}", latitude, longitude);
            searchRequest.StructuredQuery = ssQuery;

            //Make the search request
            SearchResponse searchResponse;

            using (var searchService = new SearchServiceClient("BasicHttpBinding_ISearchService"))
            {
                searchResponse = searchService.Search(searchRequest);
            }

            foreach (var searchResult in searchResponse.ResultSets[0].Results)
            {
                results.Add(string.Format("{0} ({1})", searchResult.Name, searchResult.Distance));
            }
            return(results);
        }
        public IEnumerable<string> SearchKeywordLocation(string keyword, double latitude, double longitude)
        {
            var results = new List<string>();

            var searchRequest = new SearchRequest();

            // Set the credentials using a valid Bing Maps key
            searchRequest.Credentials = new SearchService.Credentials();
            searchRequest.Credentials.ApplicationId = GetBingMapsApplicationKey();

            //Create the search query
            var ssQuery = new StructuredSearchQuery();
            ssQuery.Keyword = keyword;
            ssQuery.Location = string.Format("{0}, {1}", latitude, longitude);
            searchRequest.StructuredQuery = ssQuery;

            //Make the search request 
            SearchResponse searchResponse;
            using (var searchService = new SearchServiceClient("BasicHttpBinding_ISearchService"))
            {
                searchResponse = searchService.Search(searchRequest);
            }

            foreach (var searchResult in searchResponse.ResultSets[0].Results)
            {
                results.Add(string.Format("{0} ({1})", searchResult.Name, searchResult.Distance));
            }
            return results;
        }
示例#4
0
 private void button2_Click(object sender, EventArgs e)
 {
     using (var serarcClient = new SearchServiceClient())
     {
         var result = serarcClient.Search(GetSearch());
         MessageBox.Show(result.Metadata.Status.ToString());
     }
 }
示例#5
0
 private void button2_Click(object sender, EventArgs e)
 {
     using (var serarcClient = new SearchServiceClient())
     {
         var result = serarcClient.Search(GetSearch());
         MessageBox.Show(result.Metadata.Status.ToString());
     }
 }
示例#6
0
        public static async void TesteChannel()
        {
            Server server = new Server();

            var serverPort = new ServerPort("127.0.0.1", P_PORTA_RPC, ServerCredentials.Insecure);

            server.Ports.Add(serverPort);

            var searchService = SearchService.BindService(new MyService());

            server.Services.Add(searchService);
            server.Start();

            Channel channel = new Channel("localhost", P_PORTA_RPC, ChannelCredentials.Insecure);

            channel.ConnectAsync(DateTime.UtcNow.AddSeconds(4)).Wait();
            var client = new SearchServiceClient(channel);

            SearchRequest req = new SearchRequest();

            req.FileMask     = "*.bat";
            req.StartDir     = @"C:\";
            req.Recursive    = true;
            req.IgnoreErrors = true;
            var result = client.Search(req);

            Debug.WriteLine("[p1]");

            var t1 = client.Delay1Async(new DelayDesc()
            {
                MilliSeconds = 2000
            });

            Debug.WriteLine("[p2]");

            Debug.WriteLine("[p3]");

            var t2 = client.Delay2Async(new DelayDesc()
            {
                MilliSeconds = 1000
            });

            Debug.WriteLine("[p4]");

            Empty v1 = await t1;

            Debug.WriteLine("[p5]");

            Empty v2 = await t2;

            Debug.WriteLine("[p6]");

            ProcessStartInfoPB psi = new ProcessStartInfoPB();

            psi.FileName = "c:/temp/teste.bat";
            var p = client.RunCmd(psi);
        }
        private void DoSearch(SearchViewModel model)
        {
            var searchService = new SearchServiceClient();
            var parameters    = CreateServiceSearchParameters(model);

            if (!searchService.Search(parameters, User.Identity.GetUserId(), model.MaxResults))
            {
                ModelState.AddModelError("", "Sorry, it wasn't possible to do your search. Please review your search parameters.");
            }
        }
示例#8
0
        //The Search Service

        private string SearchKeywordLocation(string keywordLocation)
        {
            String        results       = "";
            String        key           = "ApwndqJgdJ9M1Bpb7d_ihBwXW-J0N3HdXrZvFZqvFtmeYN5DewRoGPI7czgFo5Sh";
            SearchRequest searchRequest = new SearchRequest();

            // Set the credentials using a valid Bing Maps key
            searchRequest.Credentials = new ServiceService.Credentials();
            searchRequest.Credentials.ApplicationId = key;

            //Create the search query
            StructuredSearchQuery ssQuery = new StructuredSearchQuery();

            string[] parts = keywordLocation.Split(';');
            ssQuery.Keyword  = parts[0];
            ssQuery.Location = parts[1];
            searchRequest.StructuredQuery = ssQuery;

            //Define options on the search
            searchRequest.SearchOptions         = new SearchOptions();
            searchRequest.SearchOptions.Filters =
                new FilterExpression()
            {
                PropertyId      = 3,
                CompareOperator = CompareOperator.GreaterThanOrEquals,
                FilterValue     = 8.16
            };

            //Make the search request
            SearchServiceClient searchService  = new SearchServiceClient("BasicHttpBinding_ISearchService");
            SearchResponse      searchResponse = searchService.Search(searchRequest);

            //Parse and format results
            if (searchResponse.ResultSets[0].Results.Length > 0)
            {
                StringBuilder resultList = new StringBuilder("");
                for (int i = 0; i < searchResponse.ResultSets[0].Results.Length; i++)
                {
                    resultList.Append(String.Format("{0}. {1}\n", i + 1,
                                                    searchResponse.ResultSets[0].Results[i].Name));
                }

                results = resultList.ToString();
            }
            else
            {
                results = "No results found";
            }

            return(results);
        }
示例#9
0
        public static void TesteRpc()
        {
            Server server = new Server();

            server.AddPort(new ServerPort("localhost", 12345));
            server.Services.Add(SearchService.BindService(new SearchServiceImpl()));
            server.Start();

            Channel             channel = new Channel("localhost", 12345);
            SearchServiceClient cliente = new SearchServiceClient(channel);

            SearchRequest req = new SearchRequest();

            req.FileMask = "*.txt";

            var result = cliente.Search(req);
        }
示例#10
0
        public string SearchKeywordLocation(string keywordLocation)
        {
            String results = "";

            SearchRequest searchRequest = new SearchRequest();

            // Set the credentials using a valid Bing Maps key
            searchRequest.Credentials = new SearchService.Credentials();
            searchRequest.Credentials.ApplicationId = key;

            //Create the search query
            StructuredSearchQuery ssQuery = new StructuredSearchQuery();
            string[] parts = keywordLocation.Split(';');
            ssQuery.Keyword = parts[0];
            ssQuery.Location = parts[1];
            searchRequest.StructuredQuery = ssQuery;

            //Define options on the search
            searchRequest.SearchOptions = new SearchOptions();
            searchRequest.SearchOptions.Filters =
                new FilterExpression()
                {
                    PropertyId = 3,
                    CompareOperator = CompareOperator.GreaterThanOrEquals,
                    FilterValue = 8.16
                };

            //Make the search request
            SearchServiceClient searchService = new SearchServiceClient("BasicHttpBinding_ISearchService");
            SearchResponse searchResponse = searchService.Search(searchRequest);

            //Parse and format results
            if (searchResponse.ResultSets[0].Results.Length > 0)
            {
                StringBuilder resultList = new StringBuilder("");
                for (int i = 0; i < searchResponse.ResultSets[0].Results.Length; i++)
                {
                    resultList.Append(String.Format("{0}. {1}\n", i + 1,
                        searchResponse.ResultSets[0].Results[i].Name));
                }

                results = resultList.ToString();
            }
            else
                results = "No results found";

            return results;
        }
        /// <summary>Snippet for Search</summary>
        public void SearchRequestObject()
        {
            // Snippet: Search(SearchRequest, CallSettings)
            // Create client
            SearchServiceClient searchServiceClient = SearchServiceClient.Create();
            // Initialize request argument(s)
            SearchRequest request = new SearchRequest
            {
                Placement          = "",
                BranchAsBranchName = BranchName.FromProjectLocationCatalogBranch("[PROJECT]", "[LOCATION]", "[CATALOG]", "[BRANCH]"),
                Query      = "",
                VisitorId  = "",
                UserInfo   = new UserInfo(),
                Offset     = 0,
                Filter     = "",
                OrderBy    = "",
                FacetSpecs =
                {
                    new SearchRequest.Types.FacetSpec(),
                },
                BoostSpec          = new SearchRequest.Types.BoostSpec(),
                QueryExpansionSpec = new SearchRequest.Types.QueryExpansionSpec(),
                VariantRollupKeys  = { "", },
                DynamicFacetSpec   = new SearchRequest.Types.DynamicFacetSpec(),
                PageCategories     = { "", },
                CanonicalFilter    = "",
            };
            // Make the request
            PagedEnumerable <SearchResponse, SearchResponse.Types.SearchResult> response = searchServiceClient.Search(request);

            // Iterate over all response items, lazily performing RPCs as required
            foreach (SearchResponse.Types.SearchResult item in response)
            {
                // Do something with each item
                Console.WriteLine(item);
            }

            // Or iterate over pages (of server-defined size), performing one RPC per page
            foreach (SearchResponse page in response.AsRawResponses())
            {
                // Do something with each page of items
                Console.WriteLine("A page of results:");
                foreach (SearchResponse.Types.SearchResult item in page)
                {
                    // Do something with each item
                    Console.WriteLine(item);
                }
            }

            // Or retrieve a single page of known size (unless it's the final page), performing as many RPCs as required
            int pageSize = 10;
            Page <SearchResponse.Types.SearchResult> singlePage = response.ReadPage(pageSize);

            // Do something with the page of items
            Console.WriteLine($"A page of {pageSize} results (unless it's the final page):");
            foreach (SearchResponse.Types.SearchResult item in singlePage)
            {
                // Do something with each item
                Console.WriteLine(item);
            }
            // Store the pageToken, for when the next page is required.
            string nextPageToken = singlePage.NextPageToken;
            // End snippet
        }
示例#12
0
 private IndexProps GetDocument(string name, OperationalType type)
 {
     return(DeserializeDocument(_searchServiceClient.Search($"&$filter=sitecorename eq '{name}' and indextype eq '{type.ToString().ToUpperInvariant()}'")));
 }