コード例 #1
0
        public PersonMailFullViewModel Search(string query, string startDate, string endDate)
        {
            var searchResponse = elasticClient.Search <_doc>(s => s
                                                             .Query(q => q
                                                                    .Bool(b => b
                                                                          .Must(a => a
                                                                                .MultiMatch(m => m
                                                                                            .Query(query)
                                                                                            .Fields(Infer.Field <_doc>(p => p.body)
                                                                                                    .And(Infer.Field <_doc>(p => p.topic))
                                                                                                    .And(Infer.Field <_doc>(p => p.attachment)))
                                                                                            .Fuzziness(Fuzziness.EditDistance(2))))
                                                                          .Filter(f => f
                                                                                  .DateRange(ra => ra
                                                                                             .Field(p => p.date)
                                                                                             .Format("yyyy-MM-dd")
                                                                                             .GreaterThanOrEquals(startDate)
                                                                                             .LessThanOrEquals(endDate)
                                                                                             ))
                                                                          )
                                                                    )
                                                             .MinScore(0.5)
                                                             );

            var mails = new List <MailRecord>();

            foreach (_doc searchedMail in searchResponse.Documents)
            {
                var jsonResponse = restClient.GetMailByKey(searchedMail.key);
                var mailRecord   = JsonConvert.DeserializeObject <List <MailRecord> >(jsonResponse)[0];
                mails.Add(mailRecord);
            }

            return(personMailGraphVMCreator.CreateFromMailRecords(mails));
        }
コード例 #2
0
        public ActionResult AllMails(PersonMailFullViewModel personMailFullViewModelFromForm)
        {
            if (personMailFullViewModelFromForm.StartDate == null)
            {
                personMailFullViewModelFromForm.StartDate = new DateTime(2017, 12, 22).ToString("yyyy-MM-dd");
            }
            if (personMailFullViewModelFromForm.EndDate == null)
            {
                personMailFullViewModelFromForm.EndDate = new DateTime(2018, 01, 30).ToString("yyyy-MM-dd");
            }

            var jsonResponse = restfulClient.GetAllMails(personMailFullViewModelFromForm.StartDate,
                                                         personMailFullViewModelFromForm.EndDate);
            List <MailRecord> mails = JsonConvert.DeserializeObject <List <MailRecord> >(jsonResponse);

            var personMailViewModel = personMailGraphVMCreator.CreateFromMailRecords(mails);

            personMailViewModel.StartDate = personMailFullViewModelFromForm.StartDate;
            personMailViewModel.EndDate   = personMailFullViewModelFromForm.EndDate;

            return(View("CorrespondenceAnalysis", personMailViewModel));
        }