public static OwaStoreObjectId CreateFromItemId(StoreObjectId itemStoreObjectId, Folder containerFolder)
        {
            if (itemStoreObjectId == null)
            {
                throw new ArgumentNullException("itemStoreObjectId");
            }
            if (containerFolder == null)
            {
                throw new ArgumentNullException("containerFolder");
            }
            OwaStoreObjectIdType owaStoreObjectIdType = OwaStoreObjectIdType.MailBoxObject;
            string legacyDN = null;

            if (Utilities.IsPublic(containerFolder))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreItem;
            }
            else if (Utilities.IsOtherMailbox(containerFolder))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.OtherUserMailboxObject;
                legacyDN             = Utilities.GetMailboxSessionLegacyDN(containerFolder);
            }
            else if (Utilities.IsInArchiveMailbox(containerFolder))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveMailboxObject;
                legacyDN             = Utilities.GetMailboxSessionLegacyDN(containerFolder);
            }
            return(OwaStoreObjectId.CreateFromItemId(itemStoreObjectId, (containerFolder.Id == null) ? null : containerFolder.Id.ObjectId, owaStoreObjectIdType, legacyDN));
        }
        public static OwaStoreObjectId CreateFromStoreObjectId(StoreObjectId storeObjectId, OwaStoreObjectId relatedStoreObjectId)
        {
            if (storeObjectId == null)
            {
                throw new ArgumentNullException("storeObjectId");
            }
            StoreObjectId        storeObjectId2       = null;
            OwaStoreObjectIdType owaStoreObjectIdType = OwaStoreObjectIdType.MailBoxObject;

            if (IdConverter.IsFromPublicStore(storeObjectId))
            {
                if (IdConverter.IsMessageId(storeObjectId))
                {
                    owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreItem;
                    storeObjectId2       = IdConverter.GetParentIdFromMessageId(storeObjectId);
                }
                else
                {
                    owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreFolder;
                }
            }
            else if (relatedStoreObjectId != null)
            {
                if (!relatedStoreObjectId.IsConversationId)
                {
                    owaStoreObjectIdType = relatedStoreObjectId.OwaStoreObjectIdType;
                }
                else if (relatedStoreObjectId.OwaStoreObjectIdType == OwaStoreObjectIdType.ArchiveConversation)
                {
                    owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveMailboxObject;
                }
            }
            return(new OwaStoreObjectId(owaStoreObjectIdType, storeObjectId, storeObjectId2, (relatedStoreObjectId == null) ? null : relatedStoreObjectId.MailboxOwnerLegacyDN));
        }
 private OwaStoreObjectId(OwaStoreObjectIdType objectIdType, StoreObjectId storeObjectId, StoreObjectId containerFolderId, string mailboxOwnerLegacyDN)
 {
     this.objectIdType         = objectIdType;
     this.storeObjectId        = storeObjectId;
     this.containerFolderId    = containerFolderId;
     this.mailboxOwnerLegacyDN = mailboxOwnerLegacyDN;
 }
        // Token: 0x0600191B RID: 6427 RVA: 0x000921A0 File Offset: 0x000903A0
        private Folder GetFolderFromModule(string module)
        {
            StoreObjectId        storeObjectId = null;
            OwaStoreObjectIdType objectIdType  = OwaStoreObjectIdType.MailBoxObject;

            if (string.Equals(module, "inbox", StringComparison.OrdinalIgnoreCase))
            {
                storeObjectId = this.userContext.TryGetMyDefaultFolderId(DefaultFolderType.Inbox);
            }
            else if (string.Equals(module, "calendar", StringComparison.OrdinalIgnoreCase))
            {
                storeObjectId = this.userContext.TryGetMyDefaultFolderId(DefaultFolderType.Calendar);
            }
            else if (string.Equals(module, "contacts", StringComparison.OrdinalIgnoreCase))
            {
                storeObjectId = this.userContext.TryGetMyDefaultFolderId(DefaultFolderType.Contacts);
            }
            else if (string.Equals(module, "tasks", StringComparison.OrdinalIgnoreCase))
            {
                storeObjectId = this.userContext.TryGetMyDefaultFolderId(DefaultFolderType.Tasks);
            }
            else if (string.Compare(module, "publicfolders", StringComparison.OrdinalIgnoreCase) == 0)
            {
                storeObjectId = this.userContext.PublicFolderRootId;
                objectIdType  = OwaStoreObjectIdType.PublicStoreFolder;
            }
            if (storeObjectId != null)
            {
                return(this.GetFolderFromId(OwaStoreObjectId.CreateFromFolderId(storeObjectId, objectIdType)));
            }
            return(null);
        }
        // Token: 0x0600191D RID: 6429 RVA: 0x000922A4 File Offset: 0x000904A4
        private Folder GetFolderFromPath(string path, bool isPublicFolder)
        {
            string[] array = path.Split(new char[]
            {
                '/',
                '\\'
            }, StringSplitOptions.RemoveEmptyEntries);
            CultureInfo          userCulture   = Culture.GetUserCulture();
            StoreObjectId        storeObjectId = null;
            StoreSession         storeSession  = null;
            OwaStoreObjectIdType objectIdType  = OwaStoreObjectIdType.MailBoxObject;

            try
            {
                if (isPublicFolder)
                {
                    storeSession  = PublicFolderSession.OpenAsAdmin(this.userContext.ExchangePrincipal.MailboxInfo.OrganizationId, this.userContext.ExchangePrincipal, Guid.Empty, null, userCulture, "Client=OWA;Action=WebPart + Admin + GetFolderFromPath", null);
                    storeObjectId = this.userContext.PublicFolderRootId;
                    objectIdType  = OwaStoreObjectIdType.PublicStoreFolder;
                }
                else
                {
                    storeSession = MailboxSession.OpenAsAdmin(this.owaContext.ExchangePrincipal, userCulture, "Client=OWA;Action=WebPart + Admin + GetFolderFromPath");
                    GccUtils.SetStoreSessionClientIPEndpointsFromHttpRequest(storeSession, this.owaContext.HttpContext.Request);
                    storeObjectId = this.userContext.GetRootFolderId(this.userContext.MailboxSession);
                }
                for (int i = 0; i < array.Length; i++)
                {
                    object[][] folderIdByDisplayName = this.GetFolderIdByDisplayName(array[i], storeObjectId, storeSession);
                    if (folderIdByDisplayName == null || folderIdByDisplayName.Length == 0)
                    {
                        return(null);
                    }
                    storeObjectId = ((VersionedId)folderIdByDisplayName[0][0]).ObjectId;
                }
            }
            finally
            {
                if (storeSession != null)
                {
                    storeSession.Dispose();
                    storeSession = null;
                }
            }
            if (storeObjectId == null)
            {
                return(null);
            }
            return(this.GetFolderFromId(OwaStoreObjectId.CreateFromFolderId(storeObjectId, objectIdType)));
        }
        public static OwaStoreObjectId CreateFromStoreObject(StoreObject storeObject)
        {
            if (storeObject == null)
            {
                throw new ArgumentNullException("storeObject");
            }
            if (storeObject.Id == null)
            {
                throw new ArgumentException("storeObject.Id must not be null");
            }
            OwaStoreObjectIdType owaStoreObjectIdType = OwaStoreObjectIdType.MailBoxObject;
            string legacyDN = null;

            if (Utilities.IsOtherMailbox(storeObject))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.OtherUserMailboxObject;
                legacyDN             = Utilities.GetMailboxSessionLegacyDN(storeObject);
            }
            else if (Utilities.IsInArchiveMailbox(storeObject))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveMailboxObject;
                legacyDN             = Utilities.GetMailboxSessionLegacyDN(storeObject);
            }
            if (storeObject is Item)
            {
                if (Utilities.IsPublic(storeObject))
                {
                    owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreItem;
                }
                return(OwaStoreObjectId.CreateFromItemId(storeObject.Id.ObjectId, (owaStoreObjectIdType == OwaStoreObjectIdType.OtherUserMailboxObject) ? null : storeObject.ParentId, owaStoreObjectIdType, legacyDN));
            }
            if (storeObject is Folder)
            {
                if (Utilities.IsPublic(storeObject))
                {
                    owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreFolder;
                }
                return(OwaStoreObjectId.CreateFromFolderId(storeObject.Id.ObjectId, owaStoreObjectIdType, legacyDN));
            }
            string message = string.Format(CultureInfo.InvariantCulture, "OwaStoreObjectId.CreateOwaStoreObjectId(StoreObject) only support item or folder as input, but the input is an {0}", new object[]
            {
                storeObject.GetType().ToString()
            });

            throw new ArgumentOutOfRangeException("storeObject", message);
        }
Beispiel #7
0
        public static Item CreatePostReplyItem(BodyFormat bodyFormat, PostItem item, UserContext userContext, StoreObjectId parentFolderId)
        {
            PostItem postItem = null;
            bool     flag     = true;

            try
            {
                string bodyPrefix = ReplyForwardUtilities.CreateReplyForwardHeader(bodyFormat, item, userContext, parentFolderId);
                string legacyDN   = null;
                OwaStoreObjectIdType owaStoreObjectIdType = Utilities.GetOwaStoreObjectIdType(userContext, item);
                if (owaStoreObjectIdType == OwaStoreObjectIdType.OtherUserMailboxObject)
                {
                    legacyDN = Utilities.GetMailboxSessionLegacyDN(item);
                }
                OwaStoreObjectId destinationFolderId        = OwaStoreObjectId.CreateFromFolderId(parentFolderId, owaStoreObjectIdType, legacyDN);
                OwaStoreObjectId scratchPadForImplicitDraft = Utilities.GetScratchPadForImplicitDraft(StoreObjectType.Post, destinationFolderId);
                try
                {
                    ReplyForwardConfiguration replyForwardConfiguration = new ReplyForwardConfiguration(bodyFormat);
                    replyForwardConfiguration.ConversionOptionsForSmime = Utilities.CreateInboundConversionOptions(userContext);
                    replyForwardConfiguration.AddBodyPrefix(bodyPrefix);
                    postItem = item.ReplyToFolder(scratchPadForImplicitDraft.GetSession(userContext), scratchPadForImplicitDraft.StoreObjectId, replyForwardConfiguration);
                }
                catch (StoragePermanentException ex)
                {
                    if (ex.InnerException is MapiExceptionNoCreateRight)
                    {
                        throw new OwaAccessDeniedException(LocalizedStrings.GetNonEncoded(995407892), ex);
                    }
                    throw ex;
                }
                ReplyForwardUtilities.CopyMessageClassificationProperties(item, postItem, userContext);
                Utilities.SetPostSender(postItem, userContext, Utilities.IsPublic(item));
                postItem.ConversationTopic = item.ConversationTopic;
                flag = false;
            }
            finally
            {
                if (flag && postItem != null)
                {
                    postItem.Dispose();
                    postItem = null;
                }
            }
            return(postItem);
        }
        public static OwaStoreObjectId CreateFromSessionFolderId(OwaStoreObjectIdType owaStoreObjectIdType, string legacyDN, StoreObjectId folderId)
        {
            if (folderId == null)
            {
                throw new ArgumentNullException("folderId");
            }
            switch (owaStoreObjectIdType)
            {
            case OwaStoreObjectIdType.MailBoxObject:
                return(OwaStoreObjectId.CreateFromMailboxFolderId(folderId));

            case OwaStoreObjectIdType.PublicStoreFolder:
                return(OwaStoreObjectId.CreateFromPublicFolderId(folderId));

            case OwaStoreObjectIdType.OtherUserMailboxObject:
                return(OwaStoreObjectId.CreateFromOtherUserMailboxFolderId(folderId, legacyDN));

            case OwaStoreObjectIdType.ArchiveMailboxObject:
                return(OwaStoreObjectId.CreateFromArchiveMailboxFolderId(folderId, legacyDN));
            }
            throw new ArgumentException("mailbox session type is unknown");
        }
 internal static OwaStoreObjectId CreateFromFolderId(StoreObjectId folderStoreObjectId, OwaStoreObjectIdType objectIdType)
 {
     if (folderStoreObjectId == null)
     {
         throw new ArgumentNullException("folderStoreObjectId");
     }
     if (objectIdType == OwaStoreObjectIdType.OtherUserMailboxObject)
     {
         throw new OwaInvalidOperationException("Mailbox legacy DN is required for other user mailbox");
     }
     return(new OwaStoreObjectId(objectIdType, folderStoreObjectId));
 }
 internal static OwaStoreObjectId CreateFromFolderId(StoreObjectId folderStoreObjectId, OwaStoreObjectIdType objectIdType, string legacyDN)
 {
     if (folderStoreObjectId == null)
     {
         throw new ArgumentNullException("folderStoreObjectId");
     }
     return(new OwaStoreObjectId(objectIdType, folderStoreObjectId, legacyDN));
 }
 public static OwaStoreObjectId CreateFromItemId(StoreObjectId itemStoreObjectId, StoreObjectId containerFolderId, OwaStoreObjectIdType objectIdType, string legacyDN)
 {
     if (itemStoreObjectId == null)
     {
         throw new ArgumentNullException("itemStoreObjectId");
     }
     if (objectIdType == OwaStoreObjectIdType.PublicStoreItem && containerFolderId == null)
     {
         throw new ArgumentNullException("containerFolderId");
     }
     if (objectIdType == OwaStoreObjectIdType.OtherUserMailboxObject && string.IsNullOrEmpty(legacyDN))
     {
         throw new ArgumentNullException("legacyDN");
     }
     if (objectIdType == OwaStoreObjectIdType.ArchiveMailboxObject && string.IsNullOrEmpty(legacyDN))
     {
         throw new ArgumentNullException("legacyDN");
     }
     return(new OwaStoreObjectId(objectIdType, itemStoreObjectId, containerFolderId, legacyDN));
 }
 private OwaStoreObjectId(OwaStoreObjectIdType objectIdType, StoreObjectId storeObjectId, StoreObjectId containerFolderId) : this(objectIdType, storeObjectId, containerFolderId, null)
 {
 }
 private OwaStoreObjectId(OwaStoreObjectIdType objectIdType, StoreObjectId storeObjectId, string mailboxOwnerLegacyDN) : this(objectIdType, storeObjectId, null, mailboxOwnerLegacyDN)
 {
 }
        public static OwaStoreObjectId CreateFromString(string owaStoreObjectIdString)
        {
            OwaStoreObjectIdType owaStoreObjectIdType = OwaStoreObjectIdType.MailBoxObject;

            if (owaStoreObjectIdString.StartsWith("PSF.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreFolder;
            }
            else if (owaStoreObjectIdString.StartsWith("PSI.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.PublicStoreItem;
            }
            else if (owaStoreObjectIdString.StartsWith("OUM.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.OtherUserMailboxObject;
            }
            else if (owaStoreObjectIdString.StartsWith("CID.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.Conversation;
            }
            else if (owaStoreObjectIdString.StartsWith("AMB.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveMailboxObject;
            }
            else if (owaStoreObjectIdString.StartsWith("ACI.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.ArchiveConversation;
            }
            else if (owaStoreObjectIdString.StartsWith("GS.", StringComparison.Ordinal))
            {
                owaStoreObjectIdType = OwaStoreObjectIdType.GSCalendar;
            }
            StoreObjectId folderStoreObjectId  = null;
            StoreObjectId folderStoreObjectId2 = null;
            string        text = null;

            switch (owaStoreObjectIdType)
            {
            case OwaStoreObjectIdType.PublicStoreFolder:
                folderStoreObjectId = Utilities.CreateStoreObjectId(owaStoreObjectIdString.Substring("PSF".Length + 1));
                OwaStoreObjectId.ValidateFolderId(folderStoreObjectId);
                break;

            case OwaStoreObjectIdType.PublicStoreItem:
            {
                int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal);
                if (num == "PSI".Length)
                {
                    throw new OwaInvalidIdFormatException(string.Format("There should be two separator \"{0}\" in the id of the public item. Invalid Id string: {1}", ".", owaStoreObjectIdString));
                }
                folderStoreObjectId2 = Utilities.CreateStoreObjectId(owaStoreObjectIdString.Substring("PSI".Length + 1, num - "PSI".Length - 1));
                folderStoreObjectId  = Utilities.CreateStoreObjectId(owaStoreObjectIdString.Substring(num + 1));
                OwaStoreObjectId.ValidateFolderId(folderStoreObjectId2);
                break;
            }

            case OwaStoreObjectIdType.Conversation:
            {
                string[] array = owaStoreObjectIdString.Split(new char[]
                    {
                        "."[0]
                    });
                OwaStoreObjectId owaStoreObjectId;
                if (array.Length == 4)
                {
                    owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), string.IsNullOrEmpty(array[2]) ? null : Utilities.CreateStoreObjectId(array[2]), string.IsNullOrEmpty(array[3]) ? null : Utilities.CreateInstanceKey(array[3]));
                }
                else if (array.Length == 3)
                {
                    owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), Utilities.CreateStoreObjectId(array[2]), null);
                }
                else
                {
                    if (array.Length != 2)
                    {
                        throw new OwaInvalidRequestException(string.Format("There should be one or two separator \"{0}\" in the id of the conversation item", "."));
                    }
                    owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), null, null);
                }
                owaStoreObjectId.bufferedIdString = owaStoreObjectIdString;
                return(owaStoreObjectId);
            }

            case OwaStoreObjectIdType.OtherUserMailboxObject:
            {
                int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal);
                folderStoreObjectId = OwaStoreObjectId.CreateStoreObjectIdFromString(owaStoreObjectIdString, "OUM", num);
                text = OwaStoreObjectId.ParseLegacyDnBase64String(owaStoreObjectIdString.Substring(num + 1));
                break;
            }

            case OwaStoreObjectIdType.ArchiveMailboxObject:
            {
                int num = owaStoreObjectIdString.LastIndexOf(".", StringComparison.Ordinal);
                folderStoreObjectId = OwaStoreObjectId.CreateStoreObjectIdFromString(owaStoreObjectIdString, "AMB", num);
                text = OwaStoreObjectId.ParseLegacyDnBase64String(owaStoreObjectIdString.Substring(num + 1));
                break;
            }

            case OwaStoreObjectIdType.ArchiveConversation:
            {
                string[] array = owaStoreObjectIdString.Split(new char[]
                    {
                        "."[0]
                    });
                OwaStoreObjectId owaStoreObjectId;
                if (array.Length == 5)
                {
                    text             = OwaStoreObjectId.ParseLegacyDnBase64String(array[3]);
                    owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), string.IsNullOrEmpty(array[2]) ? null : Utilities.CreateStoreObjectId(array[2]), text, string.IsNullOrEmpty(array[4]) ? null : Utilities.CreateInstanceKey(array[4]));
                }
                else if (array.Length == 4)
                {
                    text             = OwaStoreObjectId.ParseLegacyDnBase64String(array[3]);
                    owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), Utilities.CreateStoreObjectId(array[2]), text, null);
                }
                else
                {
                    if (array.Length != 3)
                    {
                        throw new OwaInvalidRequestException(string.Format("There should be two or three separator \"{0}\" in the id of the archive conversation item", "."));
                    }
                    text             = OwaStoreObjectId.ParseLegacyDnBase64String(array[2]);
                    owaStoreObjectId = new OwaStoreObjectId(ConversationId.Create(array[1]), null, text, null);
                }
                owaStoreObjectId.bufferedIdString = owaStoreObjectIdString;
                return(owaStoreObjectId);
            }

            case OwaStoreObjectIdType.GSCalendar:
            {
                string[] array = owaStoreObjectIdString.Split(new char[]
                    {
                        "."[0]
                    });
                if (array.Length != 2)
                {
                    throw new OwaInvalidRequestException(string.Format("There should be two separator \"{0}\" in the id of the GS calendar item", "."));
                }
                text = OwaStoreObjectId.ParseLegacyDnBase64String(array[1]);
                break;
            }

            default:
                return(OwaStoreObjectId.CreateFromStoreObjectId(Utilities.CreateStoreObjectId(owaStoreObjectIdString), null));
            }
            return(new OwaStoreObjectId(owaStoreObjectIdType, folderStoreObjectId, folderStoreObjectId2, text)
            {
                bufferedIdString = owaStoreObjectIdString
            });
        }
 private OwaStoreObjectId(OwaStoreObjectIdType objectIdType, StoreObjectId storeObjectId) : this(objectIdType, storeObjectId, null, null)
 {
 }