Esempio n. 1
0
        public IList <Person> MatchPerson(SearchForPersonDTO dto)
        {
            IList <Person> results = new List <Person>();

            if (dto != null)
            {
                IList <LuceneSearchResult> luceneResults = new List <LuceneSearchResult>();

                if (!string.IsNullOrEmpty(dto.MilitaryIDNumber))
                {
                    luceneResults = luceneResults.Concat(this.luceneTasks.PersonSearch("MilitaryIDNumber:" + dto.MilitaryIDNumber, 10, true))
                                    .ToList();
                }

                if (!string.IsNullOrEmpty(dto.FirstName) || !string.IsNullOrEmpty(dto.LastName))
                {
                    luceneResults = luceneResults.Concat(this.luceneTasks.PersonSearch(string.Join(" ", new string[] { dto.FirstName, dto.LastName }), 10, true))
                                    .ToList();
                }

                results = luceneResults.OrderByDescending(x => x.Score).Select(x => this.GetPerson(x.GetPersonId())).ToList();
            }

            return(results.Distinct().ToList());
        }
Esempio n. 2
0
        public ActionResult MatchPersons(HttpPostedFileBase file)
        {
            if (file != null && file.InputStream != null)
            {
                IList <SearchForPersonDTO> dtos = new List <SearchForPersonDTO>();

                try
                {
                    var reader = new CsvReader(new StreamReader(file.InputStream));

                    while (reader.Read())
                    {
                        SearchForPersonDTO dto = new SearchForPersonDTO();
                        dto.MilitaryIDNumber = reader.GetField <string>(0);
                        dto.FirstName        = reader.GetField <string>(1);
                        dto.LastName         = reader.GetField <string>(2);
                        dtos.Add(dto);
                    }
                }
                catch (Exception e)
                {
                    ModelState.AddModelError("file", e.Message);
                }

                ViewData["results"] = dtos;
                return(View());
            }

            return(View());
        }
Esempio n. 3
0
 public PersonDataTableView(SearchForPersonDTO p)
 {
     this.Id               = p.PersonID;
     this.FirstName        = p.FirstName;
     this.LastName         = p.LastName;
     this.Aliases          = p.Aliases;
     this.MilitaryIDNumber = p.MilitaryIDNumber;
 }
Esempio n. 4
0
 public JsonNetResult MatchPerson(SearchForPersonDTO vm)
 {
     if (vm != null)
     {
         return(JsonNet(this.personTasks.MatchPerson(vm).Select(x => new PersonViewModel(x))));
     }
     return(null);
 }