Exemplo n.º 1
0
        private SharingMessageItem TryGetOriginalMessage()
        {
            byte[] valueOrDefault = base.GetValueOrDefault <byte[]>(SharingMessageItemSchema.SharingOriginalMessageEntryId, null);
            if (valueOrDefault == null)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: SharingOriginalMessageEntryId was not found", this.MailboxSession.MailboxOwner);
                return(null);
            }
            StoreObjectId storeObjectId = null;

            try
            {
                storeObjectId = StoreObjectId.FromProviderSpecificId(valueOrDefault, StoreObjectType.Message);
            }
            catch (CorruptDataException)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal>((long)this.GetHashCode(), "{0}: SharingOriginalMessageEntryId is invalid", this.MailboxSession.MailboxOwner);
                return(null);
            }
            SharingMessageItem result;

            try
            {
                result = SharingMessageItem.Bind(this.MailboxSession, storeObjectId);
            }
            catch (ObjectNotFoundException)
            {
                ExTraceGlobals.SharingTracer.TraceDebug <IExchangePrincipal, StoreObjectId>((long)this.GetHashCode(), "{0}: Original sharing request message was not found {1}", this.MailboxSession.MailboxOwner, storeObjectId);
                result = null;
            }
            return(result);
        }
Exemplo n.º 2
0
        protected override void OnBeforeSend()
        {
            base.CoreItem.SaveRecipients();
            CheckRecipientsResults checkRecipientsResults = this.CheckRecipients();

            if (checkRecipientsResults.InvalidRecipients != null && checkRecipientsResults.InvalidRecipients.Length > 0)
            {
                throw new InvalidSharingRecipientsException(checkRecipientsResults.InvalidRecipients, new RecipientNotSupportedByAnyProviderException());
            }
            this.PerformInvitation();
            this.SharingContext.SerializeToMessage(this);
            this.AddBodyPrefix(this.CreateBodyPrefix());
            this.isSending = true;
            if (this.SharingMessageType.IsResponseToRequest)
            {
                SharingMessageItem sharingMessageItem = this.TryGetOriginalMessage();
                if (sharingMessageItem != null)
                {
                    try
                    {
                        SharingResponseType responseTypeFromMessageType = SharingMessageItem.GetResponseTypeFromMessageType(this.SharingMessageType);
                        sharingMessageItem.PostResponded(responseTypeFromMessageType);
                    }
                    finally
                    {
                        sharingMessageItem.Dispose();
                    }
                }
            }
            this[MessageItemSchema.RecipientReassignmentProhibited] = !this.IsPublishing;
            base.OnBeforeSend();
        }
Exemplo n.º 3
0
        public static SharingMessageItem CreateWithSpecficProvider(MailboxSession session, StoreId destFolderId, StoreId folderIdToShare, SharingProvider provider, bool force)
        {
            if (provider == null)
            {
                throw new ArgumentNullException("provider");
            }
            SharingMessageItem sharingMessageItem = SharingMessageItem.InternalCreate(session, destFolderId, folderIdToShare, provider);

            if (force)
            {
                sharingMessageItem.ForceSharingProvider = provider;
            }
            return(sharingMessageItem);
        }
Exemplo n.º 4
0
        private SharingMessageItem CreateRequestResponseMessage(SharingResponseType responseType, StoreId destFolderId)
        {
            if (base.IsDraft)
            {
                throw new InvalidOperationException("Cannot response on draft message.");
            }
            if (!this.SharingMessageType.IsRequest)
            {
                throw new InvalidOperationException("Only can response to a request message.");
            }
            StoreId            defaultFolderId    = this.MailboxSession.GetDefaultFolderId(this.SharedFolderType);
            SharingMessageItem sharingMessageItem = SharingMessageItem.InternalCreate(this.MailboxSession, destFolderId, defaultFolderId, this.GetTargetSharingProvider());

            sharingMessageItem.SharingMessageType = SharingMessageItem.GetMessageTypeFromResponseType(responseType);
            sharingMessageItem.Recipients.Add(base.From);
            sharingMessageItem[SharingMessageItemSchema.SharingOriginalMessageEntryId] = HexConverter.HexStringToByteArray(base.StoreObjectId.ToHexEntryId());
            sharingMessageItem[InternalSchema.NormalizedSubject] = this[InternalSchema.NormalizedSubject];
            sharingMessageItem[InternalSchema.SubjectPrefix]     = SharingMessageItem.GetSubjectPrefixFromResponseType(responseType).ToString(this.MailboxSession.InternalPreferedCulture);
            return(sharingMessageItem);
        }
Exemplo n.º 5
0
        private static SharingMessageItem InternalCreate(MailboxSession mailboxSession, StoreId destFolderId, StoreId folderIdToShare, SharingProvider provider)
        {
            Util.ThrowOnNullArgument(mailboxSession, "mailboxSession");
            Util.ThrowOnNullArgument(destFolderId, "destFolderId");
            Util.ThrowOnNullArgument(folderIdToShare, "folderIdToShare");
            SharingMessageItem result;

            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                SharingMessageItem sharingMessageItem = ItemBuilder.CreateNewItem <SharingMessageItem>(mailboxSession, destFolderId, ItemCreateInfo.SharingMessageItemInfo, CreateMessageType.Normal);
                disposeGuard.Add <SharingMessageItem>(sharingMessageItem);
                sharingMessageItem[InternalSchema.ItemClass] = "IPM.Sharing";
                using (Folder folder = Folder.Bind(mailboxSession, folderIdToShare))
                {
                    sharingMessageItem.SharingContext = new SharingContext(folder, provider);
                }
                disposeGuard.Success();
                result = sharingMessageItem;
            }
            return(result);
        }
Exemplo n.º 6
0
 public new static SharingMessageItem Bind(StoreSession session, StoreId messageId)
 {
     return(SharingMessageItem.Bind(session, messageId, null));
 }
Exemplo n.º 7
0
 public static SharingMessageItem CreateForPublishing(MailboxSession session, StoreId destFolderId, StoreId folderIdToShare)
 {
     return(SharingMessageItem.InternalCreate(session, destFolderId, folderIdToShare, SharingProvider.SharingProviderPublish));
 }
Exemplo n.º 8
0
 public static SharingMessageItem Create(MailboxSession session, StoreId destFolderId, StoreId folderIdToShare)
 {
     return(SharingMessageItem.InternalCreate(session, destFolderId, folderIdToShare, null));
 }