コード例 #1
0
        protected override SubscribeResults InternalPerformSubscribe(MailboxSession mailboxSession, SharingContext context)
        {
            ADRecipient      mailboxOwner             = DirectoryHelper.ReadADRecipient(mailboxSession.MailboxOwner.MailboxInfo.MailboxGuid, mailboxSession.MailboxOwner.MailboxInfo.IsArchive, mailboxSession.GetADRecipientSession(true, ConsistencyMode.IgnoreInvalid));
            SharedFolderData matchingSharedFolderData = this.GetMatchingSharedFolderData(context, mailboxOwner);

            if (context.InitiatorSmtpAddress == null)
            {
                throw new InvalidSharingDataException("InitiatorSmtpAddress", string.Empty);
            }
            IdAndName     idAndName     = null;
            StoreObjectId storeObjectId = null;

            using (SharingSubscriptionManager sharingSubscriptionManager = new SharingSubscriptionManager(mailboxSession))
            {
                SharingSubscriptionData sharingSubscriptionData = this.CreateSubscriptionData(mailboxOwner, context, matchingSharedFolderData);
                SharingFolderManager    sharingFolderManager    = new SharingFolderManager(mailboxSession);
                SharingSubscriptionData existing = sharingSubscriptionManager.GetExisting(sharingSubscriptionData.Key);
                if (existing != null)
                {
                    existing.CopyFrom(sharingSubscriptionData);
                }
                SharingSubscriptionData sharingSubscriptionData2 = existing ?? sharingSubscriptionData;
                idAndName = sharingFolderManager.EnsureFolder(sharingSubscriptionData2);
                if (sharingSubscriptionData2.LocalFolderId == null || !sharingSubscriptionData2.LocalFolderId.Equals(idAndName.Id))
                {
                    storeObjectId = (sharingSubscriptionData2.LocalFolderId = idAndName.Id);
                }
                SharingSubscriptionData sharingSubscriptionData3 = sharingSubscriptionManager.CreateOrUpdate(sharingSubscriptionData2, false);
                if (!sharingSubscriptionData2.LocalFolderId.Equals(sharingSubscriptionData3.LocalFolderId))
                {
                    idAndName = sharingFolderManager.GetFolder(sharingSubscriptionData3);
                }
            }
            return(new SubscribeResultsExternal(context.DataType, context.InitiatorSmtpAddress, context.InitiatorName, context.FolderName, matchingSharedFolderData.FolderId, idAndName.Id, storeObjectId != null, idAndName.Name));
        }
コード例 #2
0
 internal void CopyFrom(SharingSubscriptionData other)
 {
     if (this.Id == null || other.Id != null || !this.Key.Equals(other.Key))
     {
         throw new InvalidOperationException();
     }
     this.DataType                    = other.DataType;
     this.SharerName                  = other.SharerName;
     this.RemoteFolderName            = other.RemoteFolderName;
     this.IsPrimary                   = other.IsPrimary;
     this.SharerIdentityFederationUri = other.SharerIdentityFederationUri;
     this.SharingUrl                  = other.SharingUrl;
     this.SharingKey                  = other.SharingKey;
     this.SubscriberIdentity          = other.SubscriberIdentity;
 }