Beispiel #1
0
        private void AddPersonIdToLinkRejectHistoryOfContacts(PersonId personId, IList <ContactInfoForLinking> linkedContacts)
        {
            Util.ThrowOnNullArgument(personId, "personId");
            Util.ThrowOnNullArgument(linkedContacts, "linkedContacts");
            Util.ThrowOnArgumentOutOfRangeOnLessThan(linkedContacts.Count, 1, "linkedContacts");
            HashSet <PersonId> hashSet = new HashSet <PersonId>();

            hashSet.Add(personId);
            ManualLink.MergeLinkRejectHistory(hashSet, linkedContacts);
            foreach (ContactInfoForLinking contactInfoForLinking in linkedContacts)
            {
                if (!contactInfoForLinking.LinkRejectHistory.SetEquals(hashSet))
                {
                    contactInfoForLinking.LinkRejectHistory = hashSet;
                }
            }
        }
Beispiel #2
0
        internal void LinkContacts(IList <ContactInfoForLinking> contacts, IList <ContactInfoForLinking> otherContacts, ContactInfoForLinking galContact)
        {
            Util.ThrowOnNullArgument(contacts, "contacts");
            Util.ThrowOnArgumentOutOfRangeOnLessThan(contacts.Count, 1, "contacts");
            Util.ThrowOnNullArgument(otherContacts, "otherContacts");
            Util.ThrowOnArgumentOutOfRangeOnLessThan(otherContacts.Count, 1, "otherContacts");
            PersonId           personId = otherContacts[0].PersonId;
            HashSet <PersonId> hashSet  = new HashSet <PersonId>();

            ManualLink.MergeLinkRejectHistory(hashSet, contacts);
            ManualLink.MergeLinkRejectHistory(hashSet, otherContacts);
            hashSet.Remove(contacts[0].PersonId);
            hashSet.Remove(otherContacts[0].PersonId);
            ManualLink.UpdateLinkRejectHistory(contacts, hashSet);
            ManualLink.UpdateLinkRejectHistory(otherContacts, hashSet);
            GALLinkState galLinkState;
            Guid?        galLinkId;

            byte[]   addressBookEntryId;
            string[] smtpAddressCache;
            if (galContact != null)
            {
                galLinkState       = GALLinkState.Linked;
                galLinkId          = galContact.GALLinkID;
                addressBookEntryId = galContact.AddressBookEntryId;
                smtpAddressCache   = galContact.SmtpAddressCache;
            }
            else
            {
                if (contacts[0].GALLinkState == GALLinkState.NotAllowed || otherContacts[0].GALLinkState == GALLinkState.NotAllowed)
                {
                    galLinkState = GALLinkState.NotAllowed;
                }
                else
                {
                    galLinkState = GALLinkState.NotLinked;
                }
                galLinkId          = null;
                addressBookEntryId = null;
                smtpAddressCache   = Array <string> .Empty;
            }
            foreach (ContactInfoForLinking contactInfoForLinking in contacts)
            {
                if (!contactInfoForLinking.Linked || !contactInfoForLinking.PersonId.Equals(personId))
                {
                    contactInfoForLinking.Linked   = true;
                    contactInfoForLinking.PersonId = personId;
                }
                else
                {
                    ContactLink.Tracer.TraceDebug <VersionedId, string>((long)this.GetHashCode(), "ManualLink.Link: contact is already linked with PersonId set: {0}, {1}", contactInfoForLinking.ItemId, contactInfoForLinking.GivenName);
                }
                contactInfoForLinking.UpdateGALLink(galLinkState, galLinkId, addressBookEntryId, smtpAddressCache);
                contactInfoForLinking.UserApprovedLink = true;
            }
            foreach (ContactInfoForLinking contactInfoForLinking2 in otherContacts)
            {
                if (!contactInfoForLinking2.Linked)
                {
                    contactInfoForLinking2.Linked = true;
                }
                contactInfoForLinking2.UpdateGALLink(galLinkState, galLinkId, addressBookEntryId, smtpAddressCache);
                contactInfoForLinking2.UserApprovedLink = true;
            }
        }