예제 #1
0
        public async Task <ActionResult <OversiteModel> > SearchResultOversitesAsync([FromBody] SearchResultRequest request)
        {
            _Logger.LogInformation(request.SearchResult);

            var osList = await _OversiteManager.GetBySearchResultAsync(request.SearchResult);

            return(Ok(osList));
        }
예제 #2
0
        private async Task <T> GetInternalAsync <T>(
            string query,
            SearchResultRequest request,
            Func <Link, IRequestParameters, Task <T> > getSearchResultsFunc)
        {
            Requires.ArgumentNotNull(query, nameof(query));
            Requires.ArgumentNotNull(request, nameof(request));
            Requires.ArgumentNotNull(getSearchResultsFunc, nameof(getSearchResultsFunc));

            var root = await _halClient.GetRootAsync().ConfigureAwait(_halClient);

            request.Parameters.Add("query", query);

            return(await getSearchResultsFunc(root.SearchLink, request).ConfigureAwait(_halClient));
        }
예제 #3
0
        public async Task <IEnumerable <Venue> > GetByName(string name)
        {
            var searchRequest = new SearchResultRequest()
            {
                Embed = new List <SearchResultEmbed>()
                {
                    SearchResultEmbed.Venue
                },
                Type = new List <SearchResultTypeFilter>()
                {
                    SearchResultTypeFilter.Venue
                }
            };
            var results = await _viagogoClient.Search.GetAsync(name, searchRequest);

            return(results.Items.Select(i => i.Venue));
        }
예제 #4
0
        public async Task <IActionResult> GetAsync(string query)
        {
            var searchRequest = new SearchResultRequest
            {
                Type = new List <SearchResultTypeFilter>
                {
                    SearchResultTypeFilter.Category
                },
                PageSize = PAGE_SIZE
            };

            var results = await ViagogoClient.Search.GetAsync(query, searchRequest);

            var items = results.Items.Select(TicketsSuggestion.FromSearchResult);

            return(Json(items.ToArray()));
        }
예제 #5
0
 public Task <IReadOnlyList <SearchResult> > GetAllAsync(string query, SearchResultRequest request)
 {
     return(GetInternalAsync(query, request, _halClient.GetAllPagesAsync <SearchResult>));
 }
예제 #6
0
 public Task <PagedResource <SearchResult> > GetAsync(string query, SearchResultRequest request)
 {
     return(GetInternalAsync(query, request, _halClient.GetAsync <PagedResource <SearchResult> >));
 }
        /// <summary>
        /// populateGrid - This method which populates the values in NameSearchResults gridview
        /// </summary>
        public void PopulateGrid()
        {
            if ((_LastName.Text != string.Empty && _MailingZip.Text != string.Empty))
            {
                try
                {
                    Results.Visible = true;
                    //// MAIG - Begin - 11122014
                    lblerrorMessage.Text      = string.Empty;
                    lblerrorMessage.Visible   = false;
                    NameSearchResults.Visible = true;
                    //// MAIG - End - 11122014
                    //Constructs request parameter for Elastic Search
                    SearchResultRequest searchRequest = new SearchResultRequest();
                    searchRequest.Parameter.RequestParam.Search    = string.Empty;
                    searchRequest.Parameter.RequestParam.DocType   = "Policy";
                    searchRequest.Parameter.RequestParam.FirstName = (!string.IsNullOrEmpty(_FirstName.Text.Trim())) ? _FirstName.Text.Trim() : default(string);
                    searchRequest.Parameter.RequestParam.LastName  = (!string.IsNullOrEmpty(_LastName.Text.Trim())) ? _LastName.Text.Trim() : default(string);

                    //CHG0115410 - BEGIN - CH1 - Modified the input request passed to the Customer Search API
                    if (Convert.ToString(_MailingZip.Text).Trim().Length > 0)
                    {
                        //Passed zipcode type as the new parameter along with the input request to the API
                        searchRequest.Parameter.RequestParam.ZipCode.Type = new string[4] {
                            "risk", "billing", "mailing", "home"
                        }
                    }
                    ;
                    //Modified the type of zipcode from string to zipcode class
                    searchRequest.Parameter.RequestParam.ZipCode.value = (!string.IsNullOrEmpty(_MailingZip.Text.Trim())) ? _MailingZip.Text.Trim() : default(string);
                    //CHG0115410 - END - CH1 - Modified the input request passed to the Customer Search API

                    searchRequest.Parameter.Header.ChannelType = "DSU";

                    //Constructs service call request
                    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(Config.Setting("jsonURL"));
                    request.Method      = "POST";
                    request.ContentType = "application/json; charset=utf-8";
                    using (MemoryStream ms = new MemoryStream())
                    {
                        DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(searchRequest.GetType());
                        jsonSerializer.WriteObject(ms, searchRequest);
                        using (StreamWriter writer = new StreamWriter(request.GetRequestStream()))
                        {
                            String json = Encoding.UTF8.GetString(ms.ToArray());
                            CSAAWeb.AppLogger.Logger.Log("Elastic Search Request Received. UserID: " + Page.User.Identity.Name);
                            if (Config.Setting("Logging.ElasticSearch").Equals("1"))
                            {
                                CSAAWeb.AppLogger.Logger.Log("Elastic Search Request Details." + json);
                            }
                            writer.Write(json);
                            writer.Close();
                            //txtRequest.Text = json; //TO DO: Remove this line, if you dont want to show raw request
                        }
                    }

                    //Invokes service call & gets response
                    var httpResponse = (HttpWebResponse)request.GetResponse();

                    //Constructs response entity and bind the datasource into grid
                    using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
                    {
                        //Gets the raw JSON response
                        string jsonResponse = streamReader.ReadToEnd();
                        //txtResponse.Text = jsonResponse.ToString(); //TO DO: Remove this line, if you dont want to show raw response

                        //TO DO: Try to use DataContractJsonSerializer instead of JavaScriptSerializer
                        //       to follow the code standard of search response (Property Name should be PASCAL CASE).
                        //       Need to follow the same coding standard which is in the SearchRequest.

                        //Converts raw JSON response to business entity
                        JavaScriptSerializer jsSerializer   = new JavaScriptSerializer();
                        SearchResultResponse searchResponse = jsSerializer.Deserialize <SearchResultResponse>(jsonResponse);
                        CSAAWeb.AppLogger.Logger.Log(String.Format("Elastic Search Response Received. Total Number of Hits: {0}  UserID: {1} ", searchResponse.responseJson.totalHits, Page.User.Identity.Name));
                        if (Config.Setting("Logging.ElasticSearch").Equals("1"))
                        {
                            CSAAWeb.AppLogger.Logger.Log("Elastic Search Response Details." + jsonResponse);
                        }
                        //Session["NameSearchResult"] = null;
                        NameSearchResults.DataSource = null;
                        NameSearchResults.DataBind();
                        NameSearchResults.PageIndex = 0;
                        int val = 0;
                        if (searchResponse.responseJson != null && searchResponse.responseJson.searchedPolicies != null && searchResponse.responseJson.searchedPolicies.Count() > 0)
                        {
                            //CHG0115410 - BEGIN - CH2 - Modified the query with respect to the new response generated from Upgraded Customer Search API.
                            //CHG0116140 - BEGIN - CH1 - Added FirstCharToUpper function to modify 1st Letter of string as Upper Case
                            SearchResult = (from result in searchResponse.responseJson.searchedPolicies
                                            from cons in result.partyList
                                            from party in cons.partyRoles
                                            where ((!string.IsNullOrEmpty(result.sourceSystem) && result.sourceSystem != "NCNU_MEM") && (!string.IsNullOrEmpty(party.roleType) && (party.roleType.ToUpper() == "NAMEDINSURED" || party.roleType.ToUpper() == "NAMED INSURED" || party.roleType.ToUpper() == "INSURED")))
                                            select(new SearchResultEntity
                            {
                                SourceSystem = (result.sourceSystem.ToUpper() == "MAIG_HOME") ? "KIC" : (result.sourceSystem.ToUpper() == "PUP") ? "PUPSYS" : (result.sourceSystem.ToUpper() == "MAIG_AUTO") ? "KIC" : result.sourceSystem,
                                policyNumber = string.IsNullOrEmpty(result.policyNumber) ? string.Empty : (result.sourceSystem.ToUpper() == "MAIG_AUTO") ? result.policyNumber.Substring(1) : (result.sourceSystem.ToUpper() == "SIS" && result.policyNumber.StartsWith(Config.Setting("SISpolicyPrefix"))) ? result.policyNumber.Substring(2) : (result.sourceSystem == "SIS") ? result.policyNumber.Substring(3) : result.policyNumber,
                                policyStatus = string.IsNullOrEmpty(result.policyStatus) ? string.Empty : result.policyStatus,
                                //Added logic for HOME : if prodTypeCode:"DP" & productCode:"DP3" & sourceSystem:"COGEN"
                                productCode = string.IsNullOrEmpty(result.prodTypeCode) ? string.Empty : ((result.prodTypeCode.ToUpper() == "HO" && (string.IsNullOrEmpty(result.productCode) || result.productCode.ToUpper() != "DP3")) || (result.prodTypeCode.ToUpper().Equals("DP") && (!string.IsNullOrEmpty(result.productCode) && result.productCode.ToUpper().Equals("DP3")) && result.sourceSystem.ToUpper().Equals("MAIG_HOME"))) ? "Home" : (result.prodTypeCode.ToUpper() == "AU" || result.prodTypeCode.ToUpper() == "PA") ? "Auto" : ((result.prodTypeCode.ToUpper() == "SPCL" && !string.IsNullOrEmpty(result.productCode) && result.productCode.ToUpper() == "MC") || result.prodTypeCode.ToUpper() == "MC") ? "Motorcycle" : ((result.prodTypeCode.ToUpper() == "SPCL" && !string.IsNullOrEmpty(result.productCode) && result.productCode.ToUpper() == "PWC") || result.prodTypeCode.ToUpper() == "WC") ? "Watercraft" : ((result.prodTypeCode.ToUpper() == "HO" && !string.IsNullOrEmpty(result.productCode) && result.productCode.ToUpper() == "DP3") || result.prodTypeCode.ToUpper() == "DF") ? "Dwelling Fire" : (result.prodTypeCode.ToUpper() == "PUP" || result.prodTypeCode.ToUpper() == "PU") ? "Personal Umbrella" : result.prodTypeCode,
                                NamedInsured = FirstCharToUpper(((string.IsNullOrEmpty(cons.firstName)) ? string.Empty : cons.firstName)) +
                                               "  " + FirstCharToUpper(((string.IsNullOrEmpty(cons.lastName)) ? string.Empty : cons.lastName)),
                                address = ((cons.partyAddress != null) ? GetAddress(cons.partyAddress) : "")
                            })).Distinct().OrderBy(SearchEntity => SearchEntity.policyNumber, new SemiNumericComparer()).ToList();
                            //CHG0116140 - END - CH1 - Added FirstCharToUpper function to modify 1st Letter of string as Upper Case
                            //CHG0115410 - END - CH2 - Modified the query with respect to the new response generated from Upgraded Customer Search API.

                            ViewState.Add("SearchResult", SearchResult);
                            NameSearchResults.DataSource = SearchResult;
                            //Keeps in Session object for maintaining pagination
                            //Session["NameSearchResult"] = SearchResult;
                        }
                        //Binds the search result in Grid
                        NameSearchResults.DataBind();
                        //if (searchResponse.responseJson.totalHits == 0)
                        //{
                        //    NameSearchResults.EmptyDataText = "There is no records for the given search criteria";
                        //}
                        lblCustomerNameSearch.Visible = true;
                    }
                }
                catch (Exception ex)
                {
                    lblerrorMessage.Visible = true;
                    lblerrorMessage.Text    = CSAAWeb.Constants.ELASTIC_SEARCH_ERROR_MESSAGE;
                    Logger.Log("There is an exception in Namesearch - PopulateGrid : " + ex.ToString());
                    //// MAIG - Begin - 11122014
                    NameSearchResults.Visible = false;
                    //// MAIG - End - 11122014
                }
            }
        }