public static ContactInfoForLinkingFromCoreObject Create(ICoreItem coreObject) { Util.ThrowOnNullArgument(coreObject, "coreObject"); coreObject.PropertyBag.Load(ContactInfoForLinking.Properties); PropertyBagAdaptor propertyBagAdaptor = PropertyBagAdaptor.Create(coreObject); return(new ContactInfoForLinkingFromCoreObject(propertyBagAdaptor, coreObject)); }
public static ContactInfoForLinkingFromPropertyBag Create(MailboxSession mailboxSession, IStorePropertyBag propertyBag) { Util.ThrowOnNullArgument(mailboxSession, "mailboxSession"); Util.ThrowOnNullArgument(propertyBag, "propertyBag"); PropertyBagAdaptor propertyBagAdaptor = PropertyBagAdaptor.Create(propertyBag); return(new ContactInfoForLinkingFromPropertyBag(propertyBagAdaptor, mailboxSession, propertyBag)); }
private static HashSet <T> GetPropertyAsHashSet <T>(PropertyBagAdaptor propertyBag, StorePropertyDefinition property, HashSet <T> defaultValue) { T[] valueOrDefault = propertyBag.GetValueOrDefault <T[]>(property, null); if (valueOrDefault == null || valueOrDefault.Length == 0) { return(defaultValue); } return(new HashSet <T>(valueOrDefault)); }
public static ContactInfoForLinkingWithPropertyBagUpdater Create(MailboxSession mailboxSession, IStorePropertyBag propertyBag, ICollection <PropertyDefinition> loadedProperties) { Util.ThrowOnNullArgument(mailboxSession, "mailboxSession"); Util.ThrowOnNullArgument(propertyBag, "propertyBag"); Util.ThrowOnNullArgument(loadedProperties, "loadedProperties"); PropertyBagAdaptor propertyBagAdaptor = PropertyBagAdaptor.Create(propertyBag); return(new ContactInfoForLinkingWithPropertyBagUpdater(propertyBagAdaptor, mailboxSession, propertyBag, loadedProperties)); }
protected ContactInfoForLinking(PropertyBagAdaptor propertyBag) : this(propertyBag.GetValueOrDefault <bool>(ContactSchema.Linked, false), propertyBag.GetValueOrDefault <PersonId>(ContactSchema.PersonId, null), ContactInfoForLinking.GetPropertyAsHashSet <PersonId>(propertyBag, ContactSchema.LinkRejectHistory, new HashSet <PersonId>()), propertyBag.GetValueOrDefault <Guid?>(ContactSchema.GALLinkID, null), propertyBag.GetValueOrDefault <byte[]>(ContactSchema.AddressBookEntryId, null), propertyBag.GetValueOrDefault <GALLinkState>(ContactSchema.GALLinkState, GALLinkState.NotLinked), propertyBag.GetValueOrDefault <string[]>(ContactSchema.SmtpAddressCache, Array <string> .Empty), propertyBag.GetValueOrDefault <bool>(ContactSchema.UserApprovedLink, false)) { this.ItemId = propertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null); this.EmailAddresses = ContactInfoForLinking.GetEmailAddresses(propertyBag); this.GivenName = propertyBag.GetValueOrDefault <string>(ContactSchema.GivenName, string.Empty); this.Surname = propertyBag.GetValueOrDefault <string>(ContactSchema.Surname, string.Empty); this.DisplayName = propertyBag.GetValueOrDefault <string>(StoreObjectSchema.DisplayName, string.Empty); this.PartnerNetworkId = propertyBag.GetValueOrDefault <string>(ContactSchema.PartnerNetworkId, string.Empty); this.PartnerNetworkUserId = propertyBag.GetValueOrDefault <string>(ContactSchema.PartnerNetworkUserId, string.Empty); this.IMAddress = ContactInfoForLinking.CanonicalizeEmailAddress(propertyBag.GetValueOrDefault <string>(ContactSchema.IMAddress, string.Empty)); this.IsDL = ObjectClass.IsOfClass(propertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, string.Empty), "IPM.DistList"); }
private static HashSet <string> GetEmailAddresses(PropertyBagAdaptor propertyBag) { HashSet <string> hashSet = new HashSet <string>(); foreach (StorePropertyDefinition propertyDefinition in ContactSchema.EmailAddressProperties) { string text = ContactInfoForLinking.CanonicalizeEmailAddress(propertyBag.GetValueOrDefault <string>(propertyDefinition, string.Empty)); if (!string.IsNullOrEmpty(text)) { hashSet.Add(text); } } return(hashSet); }
protected override void UpdateContact(IExtensibleLogger logger, IContactLinkingPerformanceTracker performanceTracker) { ContactInfoForLinking.Tracer.TraceDebug <VersionedId, string>((long)this.GetHashCode(), "ContactInfoForLinkingFromPropertyBag.UpdateContact: setting link properties AND saving contact with id = {0}; given-name: {1}", base.ItemId, base.GivenName); base.RetryOnTransientExceptionCatchObjectNotFoundException(logger, "update of contact Id=" + base.ItemId, delegate { using (Contact contact = Contact.Bind(this.mailboxSession, base.ItemId, new PropertyDefinition[] { ContactSchema.PersonId })) { base.SetLinkingProperties(PropertyBagAdaptor.Create(contact)); AutomaticLink.DisableAutomaticLinkingForItem(contact); contact.Save(SaveMode.NoConflictResolution); } }); performanceTracker.IncrementContactsUpdated(); }
protected void SetLinkingProperties(PropertyBagAdaptor propertyBag) { propertyBag.SetValue(ContactSchema.Linked, this.Linked); propertyBag.SetValue(ContactSchema.PersonId, this.PersonId); if (this.LinkRejectHistory.Count > 0) { propertyBag.SetValue(ContactSchema.LinkRejectHistory, ContactInfoForLinking.ToArray <PersonId>(this.LinkRejectHistory)); } else { propertyBag.DeleteValue(ContactSchema.LinkRejectHistory); } if (this.GALLinkID != null) { propertyBag.SetValue(ContactSchema.GALLinkID, this.GALLinkID.Value); } else { propertyBag.DeleteValue(ContactSchema.GALLinkID); } if (this.addressBookEntryId != null) { propertyBag.SetValue(ContactSchema.AddressBookEntryId, this.addressBookEntryId); } else { propertyBag.DeleteValue(ContactSchema.AddressBookEntryId); } if (this.SmtpAddressCache != null) { propertyBag.SetValue(ContactSchema.SmtpAddressCache, this.SmtpAddressCache); } else { propertyBag.DeleteValue(ContactSchema.SmtpAddressCache); } propertyBag.SetValue(ContactSchema.GALLinkState, this.GALLinkState); propertyBag.SetValue(ContactSchema.UserApprovedLink, this.UserApprovedLink); }
protected ContactInfoForLinkingFromPropertyBag(PropertyBagAdaptor propertyBagAdaptor, MailboxSession mailboxSession, IStorePropertyBag propertyBag) : base(propertyBagAdaptor) { this.mailboxSession = mailboxSession; }
private ContactInfoForLinkingWithPropertyBagUpdater(PropertyBagAdaptor propertyBagAdaptor, MailboxSession mailboxSession, IStorePropertyBag propertyBag, ICollection <PropertyDefinition> loadedProperties) : base(propertyBagAdaptor, mailboxSession, propertyBag) { this.originalPropertyBag = propertyBag; this.loadedProperties = loadedProperties; }
protected override void UpdateContact(IExtensibleLogger logger, IContactLinkingPerformanceTracker performanceTracker) { base.UpdateContact(logger, performanceTracker); base.SetLinkingProperties(PropertyBagAdaptor.Create(this.WritablePropertyBag)); }
protected override void UpdateContact(IExtensibleLogger logger, IContactLinkingPerformanceTracker performanceTracker) { base.SetLinkingProperties(PropertyBagAdaptor.Create(this.coreObject)); ContactInfoForLinking.Tracer.TraceDebug <VersionedId, string>((long)this.GetHashCode(), "ContactInfoForLinkingFromCoreObject.UpdateContact: setting link properties but not saving contact with id = {0}; given-name: {1}", base.ItemId, base.GivenName); }
private ContactInfoForLinkingFromCoreObject(PropertyBagAdaptor propertyBagAdaptor, ICoreItem coreObject) : base(propertyBagAdaptor) { this.coreObject = coreObject; }