internal static MailboxAssociation Convert(MailboxAssociationType associationType, IRecipientSession adSession) { ArgumentValidator.ThrowIfNull("associationType", associationType); ArgumentValidator.ThrowIfNull("adSession", adSession); return(new MailboxAssociation { Group = EwsAssociationDataConverter.Convert(associationType.Group, adSession), User = EwsAssociationDataConverter.Convert(associationType.User, adSession), IsMember = associationType.IsMember, IsPin = associationType.IsPin, JoinDate = (ExDateTime)associationType.JoinDate, JoinedBy = associationType.JoinedBy }); }
public void UpdateSlaveDataFromMailboxAssociation(MasterMailboxType masterMailboxData, MailboxAssociationType associationType) { GroupMailboxAccessLayer.Tracer.TraceDebug <MasterMailboxType, MailboxAssociationType>((long)this.GetHashCode(), "GroupMailboxAccessLayer::UpdateSlaveDataFromMailboxAssociation. Replicating data from mailbox: {0}. Association data: {1}", masterMailboxData, associationType); if (masterMailboxData.MailboxType != UserMailboxLocator.MailboxLocatorType && masterMailboxData.MailboxType != GroupMailboxLocator.MailboxLocatorType) { throw new InvalidOperationException("UpdateSlaveDataFromMailboxAssociation: Invalid MasterMailboxType"); } MailboxAssociation mailboxAssociation = EwsAssociationDataConverter.Convert(associationType, this.adSession); IMailboxLocator mailboxLocator; if (!(masterMailboxData.MailboxType == GroupMailboxLocator.MailboxLocatorType)) { IMailboxLocator group = mailboxAssociation.Group; mailboxLocator = group; } else { mailboxLocator = mailboxAssociation.User; } IMailboxLocator targetMailbox = mailboxLocator; using (IAssociationStore associationStore = this.storeProviderBuilder.Create(targetMailbox, this.PerformanceTracker)) { this.LogCommandExecution("UpdateSlaveDataFromMailboxAssociation", mailboxAssociation.Group, new UserMailboxLocator[] { mailboxAssociation.User }); BaseAssociationAdaptor baseAssociationAdaptor = (masterMailboxData.MailboxType == GroupMailboxLocator.MailboxLocatorType) ? new GroupAssociationAdaptor(associationStore, this.adSession, mailboxAssociation.User) : new UserAssociationAdaptor(associationStore, this.adSession, mailboxAssociation.Group); baseAssociationAdaptor.UseAlternateLocatorLookup = true; baseAssociationAdaptor.MasterMailboxData = masterMailboxData; baseAssociationAdaptor.ReplicateAssociation(mailboxAssociation); if (masterMailboxData.MailboxType == GroupMailboxLocator.MailboxLocatorType && mailboxAssociation.IsMember) { TimeSpan latency = ExDateTime.UtcNow - mailboxAssociation.JoinDate; this.LogPerformanceCounter(MailboxAssociationLogSchema.PerformanceCounterName.JoinGroupAssociationReplication, latency, "Group={0}, User={1}", new object[] { mailboxAssociation.Group.ExternalId, mailboxAssociation.User.ExternalId }); } } }