/// <summary> /// Inintialize new instance of <see cref="EmailMiner"/> /// </summary> /// <param name="userConnection">User connection for data operations (search contacts, accounts).</param> public EmailMiner(UserConnection userConnection) { _userConnection = userConnection; var userConnectionConstructorArgument = new ConstructorArgument("userConnection", userConnection); _emailMinerService = ClassFactory.Get <IEmailMiningServiceProxy>(userConnectionConstructorArgument); _contactSearcher = ClassFactory.Get <IContactSearcher>(userConnectionConstructorArgument); _deduplicator = ClassFactory.Get <IDeduplicator>(userConnectionConstructorArgument); int actualDaysPeriod = Core.Configuration.SysSettings.GetValue(userConnection, IdentificationActualPeriodSysSettingsName, 1); _actualMinDate = _userConnection.CurrentUser.GetCurrentDateTime().AddDays(-actualDaysPeriod); _enrchTextEntitySchema = _userConnection.EntitySchemaManager.GetInstanceByName("EnrchTextEntity"); _enrichEntitySearchHelper = new EnrichEntitySearchHelper(_userConnection); }
private ContactIdentificationType IdentifyContact(ContactEntity contactEntity, TextEntities textEntities, string senderEmail, out IEnumerable <Guid> contactIds) { if (contactEntity.IsFoundInLastEmail) { contactIds = _contactSearcher.SearchByEmails(new List <string> { senderEmail }); if (!contactIds.IsNullOrEmpty()) { return(ContactIdentificationType.SenderEmail); } } List <string> emails = EnrichEntitySearchHelper.GetEmails(textEntities, contactEntity.Id); contactIds = _contactSearcher.SearchByEmails(emails); if (!contactIds.IsNullOrEmpty()) { return(ContactIdentificationType.Email); } contactIds = _contactSearcher.SearchByName(contactEntity.Value); if (!contactIds.IsNullOrEmpty()) { return(ContactIdentificationType.Name); } contactIds = _contactSearcher.SearchByFirstAndLastName(contactEntity.GivenName, contactEntity.Surname); if (!contactIds.IsNullOrEmpty()) { return(ContactIdentificationType.FirstLastName); } List <string> phones = EnrichEntitySearchHelper.GetPhones(textEntities, contactEntity.Id); contactIds = _contactSearcher.SearchByPhones(phones); if (!contactIds.IsNullOrEmpty()) { return(ContactIdentificationType.Phone); } return(null); }