Ejemplo n.º 1
0
        internal static StoreObjectPropertyBag CreatePropertyBag(StoreSession storeSession, StoreObjectId id, ICollection <PropertyDefinition> prefetchPropertyArray)
        {
            MapiProp mapiProp = null;
            StoreObjectPropertyBag storeObjectPropertyBag = null;
            bool flag = false;
            StoreObjectPropertyBag result;

            try
            {
                mapiProp = storeSession.GetMapiProp(id);
                storeObjectPropertyBag = new StoreObjectPropertyBag(storeSession, mapiProp, prefetchPropertyArray);
                flag   = true;
                result = storeObjectPropertyBag;
            }
            finally
            {
                if (!flag)
                {
                    if (storeObjectPropertyBag != null)
                    {
                        storeObjectPropertyBag.Dispose();
                        storeObjectPropertyBag = null;
                    }
                    if (mapiProp != null)
                    {
                        mapiProp.Dispose();
                        mapiProp = null;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        private StoreObjectPropertyBag CreateStorePropertyBag(MapiAttach mapiAttach, ICollection <PropertyDefinition> prefetchPropertyArray)
        {
            StoreObjectPropertyBag storeObjectPropertyBag = null;
            bool flag = false;

            try
            {
                storeObjectPropertyBag = new StoreObjectPropertyBag(this.AttachmentCollection.ContainerItem.Session, mapiAttach, prefetchPropertyArray);
                storeObjectPropertyBag.PrefetchPropertyArray = prefetchPropertyArray;
                storeObjectPropertyBag.ExTimeZone            = this.ExTimeZone;
                flag = true;
            }
            finally
            {
                if (!flag && storeObjectPropertyBag != null)
                {
                    storeObjectPropertyBag.Dispose();
                    storeObjectPropertyBag = null;
                }
            }
            return(storeObjectPropertyBag);
        }
Ejemplo n.º 3
0
        internal static MailboxStoreObject Bind(StoreSession session, MapiStore mapiStore, ICollection <PropertyDefinition> requestedProperties, bool getMappingSignature, bool overridePropertyList)
        {
            ICollection <PropertyDefinition> collection = InternalSchema.Combine <PropertyDefinition>(overridePropertyList ? new PropertyTagPropertyDefinition[]
            {
                MailboxSchema.MailboxType,
                MailboxSchema.MailboxTypeDetail
            } : MailboxSchema.Instance.AutoloadProperties, requestedProperties);
            PersistablePropertyBag persistablePropertyBag = null;
            CoreMailboxObject      coreMailboxObject      = null;
            MailboxStoreObject     mailboxStoreObject     = null;
            bool flag = false;
            MailboxStoreObject result;

            try
            {
                byte[] array = null;
                if (getMappingSignature)
                {
                    object thisObject = null;
                    bool   flag2      = false;
                    try
                    {
                        if (session != null)
                        {
                            session.BeginMapiCall();
                            session.BeginServerHealthCall();
                            flag2 = true;
                        }
                        if (StorageGlobals.MapiTestHookBeforeCall != null)
                        {
                            StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                        }
                        using (MapiFolder rootFolder = mapiStore.GetRootFolder())
                        {
                            array = (rootFolder.GetProp(PropTag.MappingSignature).Value as byte[]);
                        }
                    }
                    catch (MapiPermanentException ex)
                    {
                        throw StorageGlobals.TranslateMapiException(ServerStrings.StoreOperationFailed, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                        {
                            string.Format("Failed to get mapping signature.", new object[0]),
                            ex
                        });
                    }
                    catch (MapiRetryableException ex2)
                    {
                        throw StorageGlobals.TranslateMapiException(ServerStrings.StoreOperationFailed, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                        {
                            string.Format("Failed to get mapping signature.", new object[0]),
                            ex2
                        });
                    }
                    finally
                    {
                        try
                        {
                            if (session != null)
                            {
                                session.EndMapiCall();
                                if (flag2)
                                {
                                    session.EndServerHealthCall();
                                }
                            }
                        }
                        finally
                        {
                            if (StorageGlobals.MapiTestHookAfterCall != null)
                            {
                                StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                            }
                        }
                    }
                }
                if (array != null)
                {
                    session.MappingSignature = Convert.ToBase64String(array);
                }
                persistablePropertyBag = new StoreObjectPropertyBag(session, mapiStore, collection);
                coreMailboxObject      = new CoreMailboxObject(session, persistablePropertyBag, null, null, collection);
                mailboxStoreObject     = new MailboxStoreObject(coreMailboxObject);
                flag   = true;
                result = mailboxStoreObject;
            }
            finally
            {
                if (!flag)
                {
                    if (mailboxStoreObject != null)
                    {
                        mailboxStoreObject.Dispose();
                        mailboxStoreObject = null;
                    }
                    if (coreMailboxObject != null)
                    {
                        coreMailboxObject.Dispose();
                        coreMailboxObject = null;
                    }
                    if (persistablePropertyBag != null)
                    {
                        persistablePropertyBag.Dispose();
                        persistablePropertyBag = null;
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 4
0
        public PersistablePropertyBag OpenAttachment(ICollection <PropertyDefinition> prefetchProperties, AttachmentPropertyBag attachmentBag)
        {
            ICollection <PropertyDefinition> attachmentLoadList = this.AttachmentCollection.GetAttachmentLoadList(prefetchProperties, attachmentBag.Schema);
            int                    attachmentNumber             = attachmentBag.AttachmentNumber;
            MapiAttach             mapiAttach             = null;
            StoreObjectPropertyBag storeObjectPropertyBag = null;
            bool                   flag = false;

            try
            {
                StoreSession session = this.AttachmentCollection.ContainerItem.Session;
                bool         flag2   = false;
                try
                {
                    if (session != null)
                    {
                        session.BeginMapiCall();
                        session.BeginServerHealthCall();
                        flag2 = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    mapiAttach = this.AttachmentCollection.ContainerItem.MapiMessage.OpenAttach(attachmentNumber);
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenAttachment, ex, session, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiAttachmentProvider::OpenMapiAttachment({0})", attachmentNumber),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenAttachment, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiAttachmentProvider::OpenMapiAttachment({0})", attachmentNumber),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (session != null)
                        {
                            session.EndMapiCall();
                            if (flag2)
                            {
                                session.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
                storeObjectPropertyBag = this.CreateStorePropertyBag(mapiAttach, attachmentLoadList);
                byte[] array = ((IDirectPropertyBag)storeObjectPropertyBag).GetValue(InternalSchema.RecordKey) as byte[];
                if (array != null)
                {
                    AttachmentId attachmentId = new AttachmentId(array);
                    if (!attachmentId.Equals(attachmentBag.AttachmentId))
                    {
                        throw new StoragePermanentException(ServerStrings.MapiCannotMatchAttachmentIds(attachmentId.ToBase64String(), attachmentBag.AttachmentId.ToBase64String()));
                    }
                }
                flag = true;
            }
            finally
            {
                if (!flag)
                {
                    if (storeObjectPropertyBag != null)
                    {
                        storeObjectPropertyBag.Dispose();
                        storeObjectPropertyBag = null;
                    }
                    if (mapiAttach != null)
                    {
                        mapiAttach.Dispose();
                        mapiAttach = null;
                    }
                }
            }
            return(storeObjectPropertyBag);
        }