示例#1
0
        public static void Main(string[] args)
        {
            var node = new Uri("http://localhost:9200");

            var settings = new ConnectionSettings(node, "elastic-searcher");

            settings.SetDefaultTypeNameInferrer(t => t.Name.ToUpperInvariant());

            IElasticClient client         = new ElasticClient(settings);
            IPersonSearch  personSearcher = new PersonSearch(client);

            Utils.IndexItems(client);
            var value = Console.ReadLine();
            int id    = Convert.ToInt32(value);

            if (id != 0)
            {
                personSearcher.GetItem <Person>(id);
            }
            else
            {
                Utils.ClearItems(client);
            }

            Console.ReadKey();
        }
示例#2
0
        private async Task <IEnumerable <Models.Person> > SearchByInsz(PersonSearch model)
        {
            var response = await _client.GetAsync(CreateUrl($"members/insz/{model.Insz}"));

            return(new List <Models.Person> {
                response.ContentAsType <Models.Person>()
            });
        }
        public async Task <List <AgregatorValue> > GetTopThreeUsersSkills()
        {
            PersonSearch resultQuery = await GetUsers(0, true, 0);

            List <AgregatorValue> topSkillsUsers = resultQuery.Aggregators.Skill.Take(3).ToList();

            return(topSkillsUsers);
        }
示例#4
0
 public void Test()
 {
     PersonSearch.PersonSearchCriteria criteria = new PersonSearch.PersonSearchCriteria();
     criteria.FirstName = "George";
     criteria.LastName  = "Washington";
     List <PersonSearch.PersonSearchResults> results =
         PersonSearch.Run(criteria);
 }
        public void WhenSearchingForAPerson_AndAPageNumberIsSpecified_ItShouldReturnTheResultsForThatPage()
        {
            var query = new PersonSearch("%").AtPage(100);
            query.Find();
            var people = query.Result();

            people.Should().NotBeNull();
            people.PageNumber.Should().Be(100, "PageNumber");
        }
 public PersonController(PersonSearch personSearch,
                         PersonUpsert personUpsert,
                         UserAccountGetByEmail userAccountGetByEmail,
                         IAuthorizationService authorizationService)
 {
     _personSearch          = personSearch;
     _personUpsert          = personUpsert;
     _userAccountGetByEmail = userAccountGetByEmail;
     _authorizationService  = authorizationService;
 }
示例#7
0
        public IActionResult PersonGrid([FromForm] PersonSearchForm form)
        {
            var model = new PersonSearch(_configuration)
            {
                Search = true,
                Form   = form
            };

            return(PartialView("Partial/PersonGrid", model));
        }
        public void WhenSearchingForAPerson_WithANameThatDoesntExists_ItShouldNotBeNull()
        {
            var query = new PersonSearch(Guid.NewGuid().ToString());
            query.Find();
            var people = query.Result();

            people.Should().NotBeNull();
            people.PageNumber.Should().Be(0, "PageNumber");
            people.AdditionalPages.Should().BeGreaterOrEqualTo(0, "AdditionalPages");
            people.Count.Should().Be(0);
        }
示例#9
0
        public async Task <IActionResult> Get([FromQuery] string firstname,
                                              [FromQuery] string name,
                                              //insz
                                              [FromQuery] string insz,
                                              //member
                                              [FromQuery] int?federation,
                                              [FromQuery] string membernr,
                                              //sinumber
                                              [FromQuery] long?sinumber,
                                              //state
                                              [FromQuery] string pillar,
                                              [FromQuery] bool?StateInitiated,
                                              [FromQuery] bool?StateCompleted,
                                              [FromQuery] DateTime?StateCompletedDate,
                                              [FromQuery] bool?StateRejected,
                                              [FromQuery] DateTime?StateRejectedDate,
                                              //Output
                                              [FromQuery] bool?CSV,
                                              //general
                                              [FromQuery] int skip,
                                              [FromQuery] int limit = int.MaxValue)
        {
            PersonSearch model = new PersonSearch();

            model.Federation = federation;
            model.FirstName  = firstname;
            model.Insz       = insz;
            model.MemberNr   = membernr;
            model.Name       = name;
            model.SiNumber   = sinumber;

            model.Pillar             = pillar;
            model.StateInitiated     = StateInitiated;
            model.StateCompleted     = StateCompleted;
            model.StateCompletedDate = StateCompletedDate;
            model.StateRejected      = StateRejected;
            model.StateRejectedDate  = StateRejectedDate;

            if (!CSV.HasValue || !CSV.Value)
            {
                model.Limit = limit;
                model.Skip  = skip;
            }

            var people = await _peopleReader.SearchAsync(model);

            if (CSV.HasValue && CSV.Value)
            {
                //Output csv
                return(await this.GetPersonsCsv(people.Select(p => p.SiNumber)));
            }

            return(Ok(people.Where(p => p != null)));
        }
        public void WhenSearchingForAPerson_WithANameOfMeyer_ItShouldReturnAPeopleSearchResults()
        {
            var query = new PersonSearch("Meyer");
            query.Find();
            var people = query.Result();

            people.Should().NotBeNull();
            people.PageNumber.Should().Be(1, "PageNumber");
            people.AdditionalPages.Should().BeGreaterOrEqualTo(0, "AdditionalPages");
            people.TotalRecords.Should().BeGreaterOrEqualTo(5, "TotalRecords");
            people.Count.Should().BeGreaterOrEqualTo(5);
        }
        public List <W2uiItem> GetPersonList(PersonSearch input)
        {
            var list = new List <W2uiItem>();

            if (!string.IsNullOrEmpty(input.Search))
            {
                return(list = _context.People.Where(w => w.FullName.Contains(input.Search)).Select(s => new W2uiItem {
                    Id = s.Id.ToString(), Text = s.FullName.ToString()
                }).Take(input.Max).ToList());
            }

            return(list = _context.People.Select(s => new W2uiItem {
                Id = s.Id.ToString(), Text = s.FullName.ToString()
            }).Take(input.Max).ToList());
        }
示例#12
0
        /*Returns a person or a list ordered by firstName , for the sever side search */
        public IList <PersonDto> GetPersons(PersonSearch search)
        {
            List <PersonDto> personDtoList = new List <PersonDto>();

            var personList   = _context.Persons.ToList();
            var ageGroupList = _context.AgeGroups.ToList();

            personDtoList = CommonServices.GetPersonsDto(personList, ageGroupList);

            var personSeachList = personDtoList.Where(p => (string.IsNullOrEmpty(search.FirstName) ? true : p.FirstName.ToLower().Contains(search.FirstName.ToLower())) &&
                                                      (string.IsNullOrEmpty(search.LastName) ? true : p.LastName.ToLower().Contains(search.LastName.ToLower())))
                                  .OrderBy(p => p.FirstName).ToList();

            return(personSeachList);
        }
示例#13
0
        private async Task <IEnumerable <Models.Person> > SearchByMemberNr(PersonSearch model)
        {
            var uriBuilder = new UriBuilder(CreateUrl("members/membernr"));
            var query      = HttpUtility.ParseQueryString(uriBuilder.Query);

            query["federation"] = model.Federation.ToString();
            query["membernr"]   = model.MemberNr;
            uriBuilder.Query    = query.ToString();

            var response = await _client.GetAsync(uriBuilder.ToString());

            return(new List <Models.Person> {
                response.ContentAsType <Models.Person>()
            });
        }
示例#14
0
        private async Task <IEnumerable <Models.Person> > SearchByName(PersonSearch model)
        {
            var uriBuilder = new UriBuilder(CreateUrl("members/name"));
            var query      = HttpUtility.ParseQueryString(uriBuilder.Query);

            query["federation"] = _config.Value?.Environment.ToString();
            query["firstname"]  = model.FirstName;
            query["name"]       = model.Name;
            query["skip"]       = model.Skip.ToString();
            query["limit"]      = model.Limit.ToString();
            uriBuilder.Query    = query.ToString();

            var response = await _client.GetAsync(uriBuilder.ToString());

            return(response.ContentAsType <IEnumerable <Models.Person> >());
        }
示例#15
0
        public IActionResult Search([FromBody] PersonSearch search)
        {
            IActionResult ret            = null;
            var           personEntities = _personInfoRepository.GetPersons(search);

            if (personEntities.Count > 0)
            {
                ret = Ok(personEntities);
            }
            else
            {
                ret = NotFound();
            }

            return(ret);
        }
        private async Task <PersonSearch> GetUsers(int size, bool aggregator, int offset)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append("?size=");
            stringBuilder.Append(size.ToString());
            stringBuilder.Append("&aggregate=");
            stringBuilder.Append(aggregator.ToString().ToLower());
            stringBuilder.Append("&offset=");
            stringBuilder.Append(offset.ToString());
            var          requestUrl = _apiClient.CreateRequestUri(stringBuilder.ToString());
            PersonSearch result     = new PersonSearch();

            result = await _apiClient.PostAsync <PersonSearch>(requestUrl, result);

            return(result);
        }
示例#17
0
        public string FindFamilyMember(int idNumber)
        {
            string infoResult;

            ;           foreach (var PersonSearch in PersonList)
            {
                if (PersonSearch.Id == idNumber)
                {
                    infoResult  = PersonSearch.GetDescription();
                    infoResult += ChildSearch(idNumber);
                    return(infoResult);
                }
            }

            infoResult = "Could not find the person you are searching for, please try again...";
            return(infoResult);
        }
示例#18
0
        private async Task <IEnumerable <Models.Person> > GetSiNumbers(PersonSearch model, List <long> sinumbers)
        {
            if (model.Limit > 0)
            {
                sinumbers = sinumbers.Skip(model.Skip).Take(model.Limit).ToList();
            }

            //  !!!   Commented code is faster => but popu doesn't like it so we bulk search instead
            // List<Task<Models.Person>> tasks = new List<Task<Models.Person>>();
            // foreach (var snr in sinumbers)
            // {
            //     tasks.Add(this.SearchBySiNumber(snr));
            // }
            // return await Task.WhenAll(tasks);

            return(await this.SearchBySiNumbers(sinumbers));
        }
示例#19
0
        public ActionResult GetPerson(string name, string surname)
        {
            IEnumerable <Person> personsView = unitofwork.PersonGetRepo.GetByName(name, surname);

            if (personsView != null)
            {
                PersonSearch personsearch = new PersonSearch()
                {
                    persons = personsView
                };
                return(View(personsearch));
            }
            else
            {
                return(Content("W systemie nie ma takiego pracownika!"));
            }
        }
示例#20
0
		public PersonApiSearchModel GetList(
			[ModelBinder] string name,
			[ModelBinder] string sortExpression,
			[ModelBinder] int startRowIndex,
			[ModelBinder] int maximumRows)
		{
			var people = new PersonSearch().Search(name, sortExpression, startRowIndex, maximumRows);
			return new PersonApiSearchModel{
				People = people.Select(p => new PersonApiModel{
					Id = p.Id,
					Name = p.Name,
					DateOfBirth = p.DateOfBirth,
					DetailsLink = StateController.GetNavigationLink("Select", new NavigationData { { "id", p.Id } })
				}),
				Total = StateContext.Bag.totalRowCount,
				NextLink = StateController.GetRefreshLink(new NavigationData { { "startRowIndex", startRowIndex + maximumRows } })
			};
		}
示例#21
0
        private async Task <IEnumerable <Models.Person> > SearchTHABState(PersonSearch model)
        {
            var request = new ThabService.GetPersonsByCertificateStateRequest
            {
                Accepted = model.StateCompleted ?? false,
                Pending  = model.StateInitiated ?? false,
                Refused  = model.StateRejected ?? false,
                ReferenceDecisionMonth = GetFirstOfMonth(model.StateRejectedDate),
                ReferenceStartMonth    = GetFirstOfMonth(model.StateCompletedDate)
            };
            var certificates = await _thabService.GetPersonsByCertificateStateAsync(request);

            if (certificates.BusinessMessages.Any())
            {
                throw new Exception(certificates.BusinessMessages.FirstOrDefault().MessageString);
            }

            return(await GetSiNumbers(model, certificates?.Value?.Sinrs?.ToList()));
        }
 public ActionResult PersonSearched(int id)
 {
     try
     {
         string _connectionString = ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString as string;
         using (IDbConnection db = new SqlConnection(_connectionString))
         {
             PersonSearch pageVM = new PersonSearch();
             var          query  = "SearchPersonById";
             var          param  = new DynamicParameters();
             param.Add("Id", id);
             pageVM = db.Query <PersonSearch>(query, param, commandType: CommandType.StoredProcedure).First();
             return(View(pageVM));
         }
     }
     catch (Exception ex)
     {
         return(Content(ex.Message));
     }
 }
        public JsonResult DropdownPerson(string request)
        {
            try
            {
                dynamic response = JsonConvert.DeserializeObject(request);

                PersonSearch input = response.ToObject <PersonSearch>();

                List <W2uiItem> personList = GetPersonList(input);

                var output = new { status = "success", records = personList };

                return(Json(output));
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
 public void WhenSearchingForAPerson_WithANameOfTwoSpaces()
 {
     var query = new PersonSearch("  ").AtPage(int.MaxValue);
     query.Find();
     query.Succeeded().Should().BeFalse();
 }
示例#25
0
		public void SearchTest()
		{
			var actual = new PersonSearch().Search(null, null, 0, 10);
			Assert.AreEqual(10, actual.ToList().Count);
			Assert.AreEqual(12, StateContext.Data["totalRowCount"]);
		}
示例#26
0
 public IActionResult SearchPersonel(PersonSearch p)
 {
     PeopleRepository.SearchPeopleInfo(p);
     return(View(PeopleRepository.SearchPeopleInfo(p)));
 }
示例#27
0
        /// <summary>
        /// Processes the specified person search result.
        /// </summary>
        /// <param name="personSearch">The person search result.</param>
        /// <returns></returns>
        /// <exception cref="ArgumentNullException">personSearch</exception>
        public IEnumerable <Models.Entities.Person> Process(PersonSearch personSearch)
        {
            if (personSearch == null)
            {
                throw new ArgumentNullException(nameof(personSearch));
            }

            var log = logger.With("personSearch", personSearch);

            var stopwatch = new Stopwatch();

            stopwatch.Start();

            #region Deserialize JSON into Model

            IFindPersonResponse findPersonResponse;

            try
            {
                findPersonResponse = JsonConvert.DeserializeObject <Models.Domain.Api.Response.FindPersonResponse>(personSearch.Data, SerializerSettings);
            }
            catch (JsonException ex)
            {
                //Log and throw
                log.With("Data", personSearch.Data)
                .ErrorEvent(ex, "Run", "Json Data Deserialization failed after {ms}ms", stopwatch.ElapsedMilliseconds);
                throw;
            }

            #endregion Deserialize JSON into Model

            var people = new List <Models.Entities.Person>();

            foreach (var person in findPersonResponse.Person)
            {
                #region Map Model into Entity

                var personEntity = Mapper.Map <Models.Entities.Person>(person);
                personEntity.PersonSearchId = personSearch.Id;
                people.Add(personEntity);

                log.With("Person", personEntity);

                #endregion Map Model into Entity

                #region Save Entity to Database

                Repository.Create(personEntity);

                foreach (var addressEntity in personEntity.Addresses)
                {
                    addressEntity.PersonId = personEntity.Id;
                    Repository.Create(addressEntity);
                }

                foreach (var associateEntity in personEntity.Associates)
                {
                    associateEntity.PersonId = personEntity.Id;
                    Repository.Create(associateEntity);
                }

                foreach (var phoneEntity in personEntity.Phones)
                {
                    phoneEntity.PersonId = personEntity.Id;
                    Repository.Create(phoneEntity);
                }

                Repository.Save();

                log.With("Data", personSearch.Data)
                .InformationEvent("Run", "Created Person record after {ms}ms", stopwatch.ElapsedMilliseconds);

                #endregion Save Entity to Database
            }

            log.InformationEvent("Run", "Processing search result finished after {ms}ms", stopwatch.ElapsedMilliseconds);

            return(people);
        }
 public void WhenSearchingForAPerson_AndAPageNumberLargerThanTheTotalPagesIsSpecified_ItShouldReturnNoResultsForThatPage()
 {
     var query = new PersonSearch("%").AtPage(int.MaxValue);
     query.Find();
     query.Succeeded().Should().BeFalse();
 }
示例#29
0
        public async Task <IEnumerable <Models.Person> > SearchAsync(SearchBaseModel <Models.Person> model)
        {
            PersonSearch search = model as PersonSearch;

            if (search == null)
            {
                throw new ArgumentException($"{nameof(model)} is not a PersonSearch object");
            }

            List <Task <IEnumerable <Models.Person> > > peopleTasks = new List <Task <IEnumerable <Models.Person> > >();

            if (!string.IsNullOrEmpty(search.Insz))
            {
                peopleTasks.Add(SearchByInsz(search));
            }
            if (!string.IsNullOrEmpty(search.MemberNr))
            {
                peopleTasks.Add(SearchByMemberNr(search));
            }
            if (search.SiNumber.HasValue)
            {
                peopleTasks.Add(SearchBySiNumber(search.SiNumber.Value));
            }
            if (!string.IsNullOrEmpty(search.Name))
            {
                peopleTasks.Add(SearchByName(search));
            }
            if (search.SiNumbers?.Any() == true)
            {
                peopleTasks.Add(SearchBySiNumbers(search.SiNumbers));
            }
            switch (search.Pillar)
            {
            case "ZVZ":
                peopleTasks.Add(SearchZVZState(search));
                break;

            case "BOB":
                peopleTasks.Add(SearchBOBState(search));
                break;

            case "THAB":
                peopleTasks.Add(SearchTHABState(search));
                break;

            default:
                break;
            }

            var peopleLists = await Task.WhenAll(peopleTasks);

            var people = peopleLists.SelectMany(p => p);

            //temp fix for federation state search => should be in calls for mainframe!!!!!!
            if (search.Federation.HasValue && search.Federation.Value % 100 != 0)
            {
                people = people.Where(p => p?.FederationNumber == search.Federation.Value);
            }

            return(people);
        }
 public void WhenSearchingForAPerson_WithNoNameSpecified_ItShouldBeTheSameAsAWildcardSearch()
 {
     var query = new PersonSearch(string.Empty);
     query.Find();
     var people = query.Result();
     people.Should().NotBeEmpty();
 }
示例#31
-1
        public static void Main(string[] args)
        {
            var node = new Uri("http://localhost:9200");

            var settings = new ConnectionSettings(node, "elastic-searcher");
            settings.SetDefaultTypeNameInferrer(t => t.Name.ToUpperInvariant());

            IElasticClient client = new ElasticClient(settings);
            IPersonSearch personSearcher = new PersonSearch(client);

            Utils.IndexItems(client);
            var value = Console.ReadLine();
            int id = Convert.ToInt32(value);

            if (id != 0)
            {
                personSearcher.GetItem<Person>(id);
            }
            else
            {
                Utils.ClearItems(client);
            }

            Console.ReadKey();
        }