internal override void ContactLinkingOperation(MailboxSession mailboxSession)
        {
            ContactsEnumerator <IStorePropertyBag> contactsEnumerator = ContactsEnumerator <IStorePropertyBag> .CreateContactsOnlyEnumerator(mailboxSession, DefaultFolderType.AllContacts, RemoveOrganizationalContacts.ContactPropertiesToEnumerate, (IStorePropertyBag propertyBag) => propertyBag, new XSOFactory());

            foreach (IStorePropertyBag storePropertyBag in contactsEnumerator)
            {
                VersionedId valueOrDefault = storePropertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null);
                base.PerformanceTracker.IncrementContactsRead();
                if (valueOrDefault != null && RemoveOrganizationalContacts.ShouldDeleteContact(storePropertyBag))
                {
                    try
                    {
                        mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                        {
                            valueOrDefault.ObjectId
                        });
                        base.PerformanceTracker.IncrementContactsUpdated();
                    }
                    catch (ObjectNotFoundException)
                    {
                        this.WriteWarning(base.GetErrorMessageObjectNotFound(valueOrDefault.ObjectId.ToBase64String(), typeof(Item).ToString(), mailboxSession.ToString()));
                    }
                }
            }
        }
        private void UpdateAllItems(MailboxSession mailboxSession, Predicate <Item> filterCriteria, Action <Item> updateAction)
        {
            ContactsEnumerator <IStorePropertyBag> contactsEnumerator = ContactsEnumerator <IStorePropertyBag> .CreateContactsOnlyEnumerator(mailboxSession, DefaultFolderType.AllContacts, ResetContactLinking.ContactPropertiesToEnumerate, (IStorePropertyBag propertyBag) => propertyBag, new XSOFactory());

            foreach (IStorePropertyBag storePropertyBag in contactsEnumerator)
            {
                VersionedId valueOrDefault = storePropertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null);
                base.PerformanceTracker.IncrementContactsRead();
                if (valueOrDefault != null)
                {
                    try
                    {
                        using (Item item = Item.Bind(mailboxSession, valueOrDefault.ObjectId, ResetContactLinking.ContactPropertiesToBind))
                        {
                            if (filterCriteria(item))
                            {
                                updateAction(item);
                                base.PerformanceTracker.IncrementContactsUpdated();
                            }
                        }
                    }
                    catch (ObjectNotFoundException)
                    {
                        this.WriteWarning(base.GetErrorMessageObjectNotFound(valueOrDefault.ObjectId.ToBase64String(), typeof(Item).ToString(), mailboxSession.ToString()));
                    }
                }
            }
        }
        private List <RelevantPerson> GetRelevantContacts(IMailboxSession mailboxSession, IXSOFactory xsoFactory)
        {
            ContactsEnumerator <IStorePropertyBag> contactsEnumerator = ContactsEnumerator <IStorePropertyBag> .CreateContactsOnlyEnumerator(mailboxSession, DefaultFolderType.RecipientCache, PeopleIKnowService.RecipientCacheSortColumns, PeopleIKnowService.RecipientCacheContactProperties, (IStorePropertyBag propertyBag) => propertyBag, xsoFactory);

            List <RelevantPerson> list = new List <RelevantPerson>(50);

            foreach (IStorePropertyBag storePropertyBag in contactsEnumerator)
            {
                string valueOrDefault = storePropertyBag.GetValueOrDefault <string>(ContactSchema.Email1EmailAddress, null);
                if (string.IsNullOrEmpty(valueOrDefault))
                {
                    this.tracer.TraceDebug((long)this.GetHashCode(), "PeopleIKnowService.GetRelevantContacts: Skipped null or empty emailAddress");
                }
                else
                {
                    int            valueOrDefault2 = storePropertyBag.GetValueOrDefault <int>(ContactSchema.RelevanceScore, int.MaxValue);
                    RelevantPerson relevantPerson  = new RelevantPerson();
                    relevantPerson.EmailAddress   = valueOrDefault;
                    relevantPerson.RelevanceScore = valueOrDefault2;
                    list.Add(relevantPerson);
                    this.tracer.TraceDebug <string, int>((long)this.GetHashCode(), "PeopleIKnowService.GetRelevantContacts: Added person whose emailAddress is {0} and relevanceScore is {1}", relevantPerson.EmailAddress, relevantPerson.RelevanceScore);
                    if (list.Count == 200)
                    {
                        this.tracer.TraceDebug((long)this.GetHashCode(), "PeopleIKnowService.GetRelevantContacts: Reached max count of people that can be added.");
                        break;
                    }
                }
            }
            return(list);
        }
        private void InitializeWorkingSet()
        {
            this.contactsByPersonId = new Dictionary <PersonId, IList <ContactInfoForLinking> >(100);
            this.workingSet         = new List <ContactInfoForLinking>(100);
            ContactsEnumerator <ContactInfoForLinking> contactsEnumerator = ContactsEnumerator <ContactInfoForLinking> .CreateContactsOnlyEnumerator(this.MailboxSession, DefaultFolderType.MyContactsExtended, ContactInfoForLinking.Properties, new Func <IStorePropertyBag, ContactInfoForLinking>(base.CreateContactInfoForLinking), new XSOFactory());

            foreach (ContactInfoForLinking contact in contactsEnumerator)
            {
                this.AddContactToWorkingSet(contact);
                if (this.workingSet.Count >= 5000)
                {
                    ContactStoreForBulkContactLinking.Tracer.TraceDebug((long)this.GetHashCode(), "ContactStoreForBulkContactLinking.InitializeWorkingSet: reached contacts cap. Skipping remaining contacts in mailbox.");
                    break;
                }
            }
            this.initializedWorkingSet = true;
        }
Exemple #5
0
 internal IEnumerable <IStorePropertyBag> GetAllContacts(SortBy[] sortColumns)
 {
     this.ValidateContactProperties();
     this.ValidateFolderInScope();
     return(ContactsEnumerator <IStorePropertyBag> .CreateContactsOnlyEnumerator(base.Session, this.FolderInScope, sortColumns, this.ContactProperties, (IStorePropertyBag propertyBag) => propertyBag, base.XsoFactory));
 }
 internal static IEnumerable <ContactInfoForSuggestion> GetContactsEnumerator(MailboxSession mailboxSession)
 {
     return(ContactsEnumerator <ContactInfoForSuggestion> .CreateContactsOnlyEnumerator(mailboxSession, DefaultFolderType.AllContacts, ContactInfoForSuggestion.Properties, new Func <IStorePropertyBag, ContactInfoForSuggestion>(ContactInfoForSuggestion.Create), new XSOFactory()));
 }
Exemple #7
0
 public override IEnumerable <ContactInfoForLinking> GetAllContacts()
 {
     return(ContactsEnumerator <ContactInfoForLinking> .CreateContactsOnlyEnumerator(this.MailboxSession, DefaultFolderType.MyContactsExtended, ContactInfoForLinking.Properties, new Func <IStorePropertyBag, ContactInfoForLinking>(base.CreateContactInfoForLinking), new XSOFactory()));
 }