Exemplo n.º 1
0
        private byte[] GetDestinationSpecificEntryId(MapiStore hierarchyStore, StoreId folderId)
        {
            StoreSession storeSession = null;
            object       thisObject   = null;
            bool         flag         = false;

            byte[] result;
            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = hierarchyStore.CreateEntryId(hierarchyStore.GetFidFromEntryId(StoreId.GetStoreObjectId(folderId).ProviderLevelItemId));
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateEntryIdFromShortTermId, ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RPCPrimaryHierarchyProvider.GetDestinationSpecificEntryId : folderId = {0}", folderId),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateEntryIdFromShortTermId, ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RPCPrimaryHierarchyProvider.GetDestinationSpecificEntryId : folderId = {0}", folderId),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public void TransportNewMail(StoreObjectId messageId, string messageClass, int messageFlags)
        {
            Util.ThrowOnNullArgument(messageId, "messageId");
            Util.ThrowOnNullArgument(messageClass, "messageClass");
            byte[]       providerLevelItemId = messageId.ProviderLevelItemId;
            StoreSession storeSession        = this.session;
            bool         flag = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                this.session.Mailbox.MapiStore.SpoolerNotifyMessageNewMail(providerLevelItemId, messageClass, messageFlags);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotNotifyMessageNewMail, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiStore.SpoolerNotifyMessageNewMail failed.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotNotifyMessageNewMail, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiStore.SpoolerNotifyMessageNewMail failed.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
Exemplo n.º 3
0
        private MapiStore GetHierarchyStore()
        {
            StoreSession storeSession = null;
            object       thisObject   = null;
            bool         flag         = false;
            MapiStore    result;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = MapiStore.OpenPublicStore(this.getLegacyDN(this.PrimaryHierarchyMailboxPrincipal).ToString(), this.userDn, null, null, null, string.Format("{0}:{1}", this.PrimaryHierarchyMailboxPrincipal.MailboxInfo.Location.ServerFqdn, 81), ConnectFlag.UseDelegatedAuthPrivilege | ConnectFlag.UseNTLM | ConnectFlag.ConnectToExchangeRpcServerOnly, OpenStoreFlag.Public, CultureInfo.CurrentCulture, PublicFolderSession.FromClientSecurityContext(this.organizationId, this.clientSecurityContext), "Client=MSExchangeRPC");
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenMailbox(this.PrimaryHierarchyMailboxPrincipal.LegacyDn), ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PublicFolderRPCHierarchyProvider.GetHierarchyStore : ServerFullyQualifiedDomainName = {0}, UserLegacyDN = {1}.", this.PrimaryHierarchyMailboxPrincipal.MailboxInfo.Location.ServerFqdn, this.userDn),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenMailbox(this.PrimaryHierarchyMailboxPrincipal.LegacyDn), ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PublicFolderRPCHierarchyProvider.GetHierarchyStore : ServerFullyQualifiedDomainName = {0}, UserLegacyDN = {1}.", this.PrimaryHierarchyMailboxPrincipal.MailboxInfo.Location.ServerFqdn, this.userDn),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        internal MapiNotificationHandle Advise(byte[] entryId, AdviseFlags eventMask, MapiNotificationHandler handler, NotificationCallbackMode callbackMode)
        {
            StoreSession           session    = this.CoreObject.Session;
            object                 thisObject = null;
            bool                   flag       = false;
            MapiNotificationHandle result;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = this.MapiStore.Advise(entryId, eventMask, handler, callbackMode, (MapiNotificationClientFlags)0);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotAddNotification, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Mailbox::Advise.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotAddNotification, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Mailbox::Advise.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
Exemplo n.º 5
0
 internal static void SetTableFilter(StoreSession session, MapiProp propertyReference, MapiTable mapiTable, QueryFilter queryFilter)
 {
     if (queryFilter != null)
     {
         Restriction restriction = FilterRestrictionConverter.CreateRestriction(session, session.ExTimeZone, propertyReference, queryFilter);
         object      thisObject  = null;
         bool        flag        = false;
         try
         {
             if (session != null)
             {
                 session.BeginMapiCall();
                 session.BeginServerHealthCall();
                 flag = true;
             }
             if (StorageGlobals.MapiTestHookBeforeCall != null)
             {
                 StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
             }
             mapiTable.Restrict(restriction);
         }
         catch (MapiPermanentException ex)
         {
             throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateRestriction, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
             {
                 string.Format("Folder::SetTableFilter. Failed to set a restriction.", new object[0]),
                 ex
             });
         }
         catch (MapiRetryableException ex2)
         {
             throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateRestriction, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
             {
                 string.Format("Folder::SetTableFilter. Failed to set a restriction.", new object[0]),
                 ex2
             });
         }
         finally
         {
             try
             {
                 if (session != null)
                 {
                     session.EndMapiCall();
                     if (flag)
                     {
                         session.EndServerHealthCall();
                     }
                 }
             }
             finally
             {
                 if (StorageGlobals.MapiTestHookAfterCall != null)
                 {
                     StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                 }
             }
         }
     }
 }
        internal ImportResult ImportMove(byte[] sourceParentSourceKey, byte[] sourceSourceKey, byte[] sourcePredecessorChangeList, byte[] destinationSourceKey, byte[] destinationChangeKey)
        {
            this.CheckDisposed(null);
            StoreSession        session = base.Session;
            bool                flag    = false;
            MapiCollectorStatus mapiCollectorStatus;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                mapiCollectorStatus = base.MapiCollector.ImportMessageMove(new PropValue(PropTag.ParentSourceKey, sourceParentSourceKey), new PropValue(PropTag.SourceKey, sourceSourceKey), new PropValue(PropTag.PredecessorChangeList, sourcePredecessorChangeList), new PropValue(PropTag.SourceKey, destinationSourceKey), new PropValue(PropTag.ChangeKey, destinationChangeKey));
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotImportMessageMove, ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Import of the message move failed", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotImportMessageMove, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Import of the message move failed", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(ContentsSynchronizationUploadContext.ConvertToImportResult(mapiCollectorStatus));
        }
        protected SynchronizationUploadContextBase(CoreFolder folder, StorageIcsState initialState)
        {
            Util.ThrowOnNullArgument(folder, "folder");
            this.folder = folder;
            StoreSession session = this.Session;
            bool         flag    = false;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                this.mapiCollector = this.MapiCreateCollector(initialState);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotCreateCollector(base.GetType()), ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("SynchronizationUploadContext::MapiCreateCollector failed", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotCreateCollector(base.GetType()), ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("SynchronizationUploadContext::MapiCreateCollector failed", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            this.mapiCollector.AllowWarnings = true;
        }
Exemplo n.º 8
0
        public byte[] GetLongTermIdFromId(long id)
        {
            StoreSession storeSession = this.session;
            bool         flag         = false;

            byte[] result;
            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = this.session.Mailbox.MapiStore.GlobalIdFromId(id);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotGetLongTermIdFromId(id), ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("StoreSession::GetLongTermIdFromId failed.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotGetLongTermIdFromId(id), ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("StoreSession::GetLongTermIdFromId failed.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
Exemplo n.º 9
0
        public StoreObjectId CreatePublicFolderId(long folderFid)
        {
            byte[]       entryId      = null;
            StoreSession storeSession = this.session;
            bool         flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                entryId = this.session.Mailbox.MapiStore.CreatePublicEntryId(folderFid);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateEntryIdFromShortTermId, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Unable to create a public folder entry id from short term id. FolderFid = {0}.", folderFid),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotCreateEntryIdFromShortTermId, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Unable to create a public folder entry id from short term id. FolderFid = {0}.", folderFid),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(StoreObjectId.FromProviderSpecificId(entryId));
        }
Exemplo n.º 10
0
        internal override byte[] GetEntryId(DefaultFolderContext context)
        {
            StoreSession session = context.Session;
            bool         flag    = false;

            byte[] result;
            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = this.getFreeId(context.Session);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenFolder, ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("FreeEntryIdStrategy::GetEntryId. Hit exception when adding ``free'' default folders.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotOpenFolder, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("FreeEntryIdStrategy::GetEntryId. Hit exception when adding ``free'' default folders.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
Exemplo n.º 11
0
        private static PropTag[] MapiGetIdsFromNames(StoreSession session, MapiProp mapiProp, bool createNamedProperties, ICollection <NamedProp> namedProperties)
        {
            object thisObject = null;
            bool   flag       = false;

            PropTag[] idsFromNames;
            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                idsFromNames = mapiProp.GetIDsFromNames(createNamedProperties, namedProperties);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetIDFromNames, ex, session, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PropertyTagCache.MapiResolveProps failed.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetIDFromNames, ex2, session, thisObject, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PropertyTagCache.MapiResolveProps failed.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(idsFromNames);
        }
Exemplo n.º 12
0
        internal void ImportChange(ExTimeZone exTimeZone, IList <PropertyDefinition> propertyDefinitions, IList <object> propertyValues)
        {
            this.CheckDisposed(null);
            PropValue[]  propValues = base.GetPropValuesFromValues(exTimeZone, propertyDefinitions, propertyValues).ToArray();
            StoreSession session    = base.Session;
            bool         flag       = false;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                base.MapiCollector.ImportFolderChange(propValues);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotImportFolderChange, ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Import of the folder change failed", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotImportFolderChange, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Import of the folder change failed", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
Exemplo n.º 13
0
        public bool Remove(long item)
        {
            StoreSession storeSession = this.session;
            bool         flag         = false;
            bool         result;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = this.gids.Remove(this.session.Mailbox.MapiStore.GlobalIdFromId(item));
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.RuleHistoryError, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RuleHistory.Remove. item = {0}.", item),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.RuleHistoryError, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RuleHistory.Remove. item = {0}.", item),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
Exemplo n.º 14
0
        private int GetMapiTableRowCount()
        {
            StoreSession storeSession = this.storeSession;
            bool         flag         = false;
            int          rowCount;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                rowCount = this.recipientTable.GetRowCount();
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetRecipientTable, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RecipientTable::Storage.RecipientTable.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetRecipientTable, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RecipientTable::Storage.RecipientTable.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(rowCount);
        }
Exemplo n.º 15
0
        internal ICollection <PropertyDefinition> GetAllFoundProperties()
        {
            PropTag[]    propTags     = null;
            StoreSession storeSession = this.StoreSession;
            bool         flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                propTags = this.mapiProp.GetPropList();
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotGetPropertyList, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Unable to get propList from the mapiProp.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotGetPropertyList, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("Unable to get propList from the mapiProp.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(PropertyTagCache.Cache.PropertyDefinitionsFromPropTags(NativeStorePropertyDefinition.TypeCheckingFlag.DisableTypeCheck, this.storeSession.Mailbox.MapiStore, this.storeSession, propTags));
        }
Exemplo n.º 16
0
        private void SetRecipientColumnsAndSortOrderOnMapiTable(NativeStorePropertyDefinition[] recipientPropertyDefinitions)
        {
            ICollection <PropTag> columns      = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions(this.mapiMessage, this.storeSession, recipientPropertyDefinitions);
            StoreSession          storeSession = this.storeSession;
            bool flag = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                this.recipientTable.SetColumns(columns);
                this.recipientTable.SortTable(new SortOrder(PropTag.RowId, SortFlags.Ascend), SortTableFlags.None);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetRecipientTable, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RecipientTable::Storage.RecipientTable.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotGetRecipientTable, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RecipientTable::Storage.RecipientTable.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
Exemplo n.º 17
0
        private static T CallMapiWithReturnValue <T>(string methodName, object obj, StoreSession session, StorageGlobals.MapiCallWithReturnValue <T> mapiCall)
        {
            bool flag = false;
            T    result;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                result = mapiCall();
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ExWrappedStreamFailure, ex, session, obj, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format(methodName, new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ExWrappedStreamFailure, ex2, session, obj, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format(methodName, new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            return(result);
        }
            protected NamedPropertyKey(Guid propGuid, int propId)
            {
                StoreSession storeSession = null;
                object       thisObject   = null;
                bool         flag         = false;

                try
                {
                    if (storeSession != null)
                    {
                        storeSession.BeginMapiCall();
                        storeSession.BeginServerHealthCall();
                        flag = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    this.namedProp = new NamedProp(propGuid, propId);
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiInvalidParam, ex, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("Unable to create property key", new object[0]),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.MapiInvalidParam, ex2, storeSession, thisObject, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("Unable to create property key", new object[0]),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (storeSession != null)
                        {
                            storeSession.EndMapiCall();
                            if (flag)
                            {
                                storeSession.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
            }
Exemplo n.º 19
0
        private void ModifyParticipants(ModifyRecipientsFlags flags, params AdrEntry[] adrEntries)
        {
            ExTraceGlobals.StorageTracer.Information((long)this.GetHashCode(), "RecipientTable::ModifyParticipants.");
            StoreSession storeSession = this.storeSession;
            bool         flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                this.mapiMessage.ModifyRecipients(flags, adrEntries);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotModifyRecipients, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RecipientTable::ModifyParticipant. The modify flags = {0}.", flags),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotModifyRecipients, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("RecipientTable::ModifyParticipant. The modify flags = {0}.", flags),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
        public void GetCurrentState(ref StorageIcsState currentState)
        {
            this.CheckDisposed(null);
            StoreSession session = this.Session;
            bool         flag    = false;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                this.MapiGetCurrentState(ref currentState);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotObtainSynchronizationUploadState(typeof(TMapiCollector)), ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("SynchronizationUploadContext::GetCurrentState failed", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.CannotObtainSynchronizationUploadState(typeof(TMapiCollector)), ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("SynchronizationUploadContext::GetCurrentState failed", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
Exemplo n.º 21
0
        private void SetReadFlagsInternal(SetReadFlags flags)
        {
            StoreSession session = base.Session;
            bool         flag    = false;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                base.MapiMessage.SetReadFlag(flags);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PostItem::SetReadFlagsInternal.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetReadFlags, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("PostItem::SetReadFlagsInternal.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
        internal void ThrowOnImportResult(ImportResult result)
        {
            StoreSession session = base.Session;
            bool         flag    = false;

            try
            {
                if (session != null)
                {
                    session.BeginMapiCall();
                    session.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                base.MapiCollector.ThrowOnCollectorStatus(ContentsSynchronizationUploadContext.ConvertToCollectorStatus(result));
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ImportResultContainedFailure, ex, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("ImportResult contained a failure", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ImportResultContainedFailure, ex2, session, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("ImportResult contained a failure", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (session != null)
                    {
                        session.EndMapiCall();
                        if (flag)
                        {
                            session.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
        private void Save()
        {
            StoreSession storeSession = this.session;
            bool         flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                this.underlyingMessage.SaveChanges();
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSaveChanges, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("CoreCalendarItemVersion::Save. Failed to save the underlying message.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSaveChanges, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("CoreCalendarItemVersion::Save. Failed to save the underlying message.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
Exemplo n.º 24
0
        public void SetSpooler()
        {
            StoreSession storeSession = this.session;
            bool         flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                this.session.Mailbox.MapiStore.SetSpooler();
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetSpooler, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiStore.SetSpooler failed.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetSpooler, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiStore.SetSpooler failed.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
Exemplo n.º 25
0
 private static void RunMapiCode(LocalizedString context, Action action)
 {
     try
     {
         action();
     }
     catch (MapiRetryableException exception)
     {
         throw StorageGlobals.TranslateMapiException(context, exception, null, null, string.Empty, new object[0]);
     }
     catch (MapiPermanentException exception2)
     {
         throw StorageGlobals.TranslateMapiException(context, exception2, null, null, string.Empty, new object[0]);
     }
 }
Exemplo n.º 26
0
        private void RetryBigProperties(IList <NativeStorePropertyDefinition> allPropDefs, ICollection <PropTag> allPropTags, object[] allValues)
        {
            List <int> list  = null;
            int        count = allPropDefs.Count;

            for (int i = 0; i < count; i++)
            {
                if (PropertyError.IsPropertyValueTooBig(allValues[i]) && MapiPropertyBag.IsPropertyRetriable(allPropDefs[i]))
                {
                    if (list == null)
                    {
                        list = new List <int>(10);
                    }
                    list.Add(i);
                }
            }
            if (list == null)
            {
                return;
            }
            PropTag[] array = new PropTag[count];
            allPropTags.CopyTo(array, 0);
            bool flag = true;

            while (flag && list.Count > 0)
            {
                flag = false;
                PropTag[] array2 = new PropTag[list.Count];
                for (int j = 0; j < array2.Length; j++)
                {
                    array2[j] = array[list[j]];
                }
                PropValue[]  array3       = null;
                StoreSession storeSession = this.StoreSession;
                bool         flag2        = false;
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.BeginMapiCall();
                        storeSession.BeginServerHealthCall();
                        flag2 = true;
                    }
                    if (StorageGlobals.MapiTestHookBeforeCall != null)
                    {
                        StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                    }
                    array3 = this.mapiProp.GetProps(array2);
                }
                catch (MapiPermanentException ex)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ExGetPropsFailed, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiPropertyBag::RetryBigProperties. MapiProp = {0}.", this.MapiProp),
                        ex
                    });
                }
                catch (MapiRetryableException ex2)
                {
                    throw StorageGlobals.TranslateMapiException(ServerStrings.ExGetPropsFailed, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                    {
                        string.Format("MapiPropertyBag::RetryBigProperties. MapiProp = {0}.", this.MapiProp),
                        ex2
                    });
                }
                finally
                {
                    try
                    {
                        if (storeSession != null)
                        {
                            storeSession.EndMapiCall();
                            if (flag2)
                            {
                                storeSession.EndServerHealthCall();
                            }
                        }
                    }
                    finally
                    {
                        if (StorageGlobals.MapiTestHookAfterCall != null)
                        {
                            StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                        }
                    }
                }
                for (int k = array3.Length - 1; k >= 0; k--)
                {
                    int    num = list[k];
                    object valueFromPropValue = MapiPropertyBag.GetValueFromPropValue(this.storeSession, this.ExTimeZone, InternalSchema.ToStorePropertyDefinition(allPropDefs[num]), array3[k]);
                    if (!PropertyError.IsPropertyValueTooBig(valueFromPropValue))
                    {
                        allValues[num] = valueFromPropValue;
                        list.RemoveAt(k);
                        flag = true;
                    }
                }
            }
        }
Exemplo n.º 27
0
        private PropertyError[] InternalSetProperties(PropertyDefinition[] propertyDefinitions, object[] propertyValues, MapiPropertyBag.MapiSetProps mapiSetProps)
        {
            this.CheckDisposed("SetProperties");
            if (propertyDefinitions == null)
            {
                throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyDefinitions", 1));
            }
            if (propertyValues == null)
            {
                throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyValues", 2));
            }
            if (propertyDefinitions.Length == 0)
            {
                return(MapiPropertyBag.EmptyPropertyErrorArray);
            }
            ICollection <PropTag> collection = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.MapiProp, this.storeSession, (this.saveFlags & PropertyBagSaveFlags.IgnoreUnresolvedHeaders) == PropertyBagSaveFlags.IgnoreUnresolvedHeaders, true, (this.saveFlags & PropertyBagSaveFlags.DisableNewXHeaderMapping) != PropertyBagSaveFlags.DisableNewXHeaderMapping, propertyDefinitions);
            List <PropValue>      list       = new List <PropValue>(propertyDefinitions.Length);
            int num = 0;

            foreach (PropTag propTag in collection)
            {
                if (propTag != PropTag.Unresolved)
                {
                    InternalSchema.CheckPropertyValueType(propertyDefinitions[num], propertyValues[num]);
                    list.Add(MapiPropertyBag.GetPropValueFromValue(this.storeSession, this.ExTimeZone, propTag, propertyValues[num]));
                }
                num++;
            }
            PropProblem[] array        = null;
            StoreSession  storeSession = this.StoreSession;
            bool          flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                try
                {
                    array = mapiSetProps(list.ToArray());
                }
                catch (MapiExceptionNotEnoughMemory mapiExceptionNotEnoughMemory)
                {
                    ExTraceGlobals.StorageTracer.TraceError <MapiExceptionNotEnoughMemory>((long)this.GetHashCode(), "MapiPropertyBag::InternalSetProperties. Failed to SetProps due to MapiException {0}.", mapiExceptionNotEnoughMemory);
                    string errorDescription    = mapiExceptionNotEnoughMemory.ToString();
                    List <PropertyError> list2 = new List <PropertyError>();
                    foreach (PropertyDefinition propertyDefinition in propertyDefinitions)
                    {
                        list2.Add(new PropertyError(propertyDefinition, PropertyErrorCode.NotEnoughMemory, errorDescription));
                    }
                    throw PropertyError.ToException(list2.ToArray());
                }
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetProps, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::InternalSetProperties.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSetProps, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::InternalSetProperties.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            PropertyError[] array2 = MapiPropertyBag.EmptyPropertyErrorArray;
            if (array != null)
            {
                array2 = new PropertyError[array.Length];
                for (int j = 0; j < array.Length; j++)
                {
                    int scode = array[j].Scode;
                    PropertyDefinition propertyDefinition2 = null;
                    int num2 = 0;
                    foreach (PropTag propTag2 in collection)
                    {
                        if (array[j].PropTag == propTag2)
                        {
                            propertyDefinition2 = propertyDefinitions[num2];
                            break;
                        }
                        num2++;
                    }
                    string            errorDescription2;
                    PropertyErrorCode error = MapiPropertyHelper.MapiErrorToXsoError(scode, out errorDescription2);
                    array2[j] = new PropertyError(propertyDefinition2, error, errorDescription2);
                    ExTraceGlobals.StorageTracer.TraceError <string, MapiProp, PropertyError>((long)this.GetHashCode(), "MapiPropertyBag::InternalSetProperties. Failed. PropDef display name= {0}, MapiProp = {1}, Error = {2}.", propertyDefinition2.Name, this.MapiProp, array2[j]);
                }
            }
            return(array2);
        }
Exemplo n.º 28
0
        internal void SaveChanges(bool force)
        {
            this.CheckDisposed("SaveChanges");
            SaveChangesFlags saveChangesFlags = SaveChangesFlags.KeepOpenReadWrite;

            if (this.updateImapItemId)
            {
                saveChangesFlags |= SaveChangesFlags.ChangeIMAPId;
            }
            if (force)
            {
                saveChangesFlags |= SaveChangesFlags.ForceSave;
            }
            if ((this.SaveFlags & PropertyBagSaveFlags.ForceNotificationPublish) == PropertyBagSaveFlags.ForceNotificationPublish)
            {
                saveChangesFlags |= SaveChangesFlags.ForceNotificationPublish;
            }
            StoreSession storeSession = this.StoreSession;
            bool         flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                this.MapiProp.SaveChanges(saveChangesFlags);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSaveChanges, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::SaveChanges.", new object[0]),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotSaveChanges, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::SaveChanges.", new object[0]),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
        }
Exemplo n.º 29
0
        internal Stream OpenPropertyStream(NativeStorePropertyDefinition propertyDefinition, PropertyOpenMode openMode, bool bufferStream)
        {
            this.CheckDisposed("OpenPropertyStream");
            EnumValidator.AssertValid <PropertyOpenMode>(openMode);
            PropTag           propTag = PropertyTagCache.Cache.PropTagFromPropertyDefinition(this.MapiProp, this.storeSession, propertyDefinition);
            OpenPropertyFlags flags;

            switch (openMode)
            {
            case PropertyOpenMode.ReadOnly:
                flags = OpenPropertyFlags.DeferredErrors;
                break;

            case PropertyOpenMode.Modify:
                flags = OpenPropertyFlags.Modify;
                break;

            case PropertyOpenMode.Create:
                flags = (OpenPropertyFlags.Create | OpenPropertyFlags.Modify);
                break;

            default:
                throw new ArgumentException(ServerStrings.ExInvalidParameter("openMode", 2), "openMode");
            }
            Stream       stream       = null;
            StoreSession storeSession = this.StoreSession;
            bool         flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                stream = new MapiStreamWrapper(this.MapiProp.OpenStream(propTag, flags), this.StoreSession);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ExUnableToGetStreamProperty(propertyDefinition.Name), ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::OpenPropertyStream. Failed to open property stream for property {0}, openMode = {1}.", propertyDefinition, openMode),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.ExUnableToGetStreamProperty(propertyDefinition.Name), ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::OpenPropertyStream. Failed to open property stream for property {0}, openMode = {1}.", propertyDefinition, openMode),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            if (bufferStream)
            {
                stream = new PooledBufferedStream(stream, StorageLimits.Instance.PropertyStreamPageSize);
            }
            return(stream);
        }
Exemplo n.º 30
0
        internal PropertyError[] DeleteProperties(ICollection <PropertyDefinition> propertyDefinitions)
        {
            this.CheckDisposed("DeleteProperties");
            if (propertyDefinitions == null)
            {
                throw new ArgumentNullException(ServerStrings.ExNullParameter("propertyDefinitions", 1));
            }
            if (propertyDefinitions.Count == 0)
            {
                ExTraceGlobals.StorageTracer.TraceError <string>((long)this.GetHashCode(), "MapiPropertyBag::DeleteProperties. {0} contain zero elements.", "propertyDefinitions");
                throw new ArgumentException(ServerStrings.ExEmptyCollection("propertyDefinitions"), "propertyDefinitions");
            }
            IList <PropertyDefinition> list  = new List <PropertyDefinition>();
            IList <PropertyDefinition> list2 = new List <PropertyDefinition>();

            foreach (PropertyDefinition propertyDefinition in propertyDefinitions)
            {
                StorePropertyDefinition       storePropertyDefinition       = InternalSchema.ToStorePropertyDefinition(propertyDefinition);
                NativeStorePropertyDefinition nativeStorePropertyDefinition = storePropertyDefinition as NativeStorePropertyDefinition;
                if (nativeStorePropertyDefinition != null)
                {
                    list.Add(storePropertyDefinition);
                }
                else
                {
                    list2.Add(storePropertyDefinition);
                }
            }
            ICollection <PropTag> tags = PropertyTagCache.Cache.PropTagsFromPropertyDefinitions <PropertyDefinition>(this.MapiProp, this.storeSession, false, list);

            PropProblem[] array        = null;
            StoreSession  storeSession = this.StoreSession;
            bool          flag         = false;

            try
            {
                if (storeSession != null)
                {
                    storeSession.BeginMapiCall();
                    storeSession.BeginServerHealthCall();
                    flag = true;
                }
                if (StorageGlobals.MapiTestHookBeforeCall != null)
                {
                    StorageGlobals.MapiTestHookBeforeCall(MethodBase.GetCurrentMethod());
                }
                array = this.MapiProp.DeleteProps(tags, (this.SaveFlags & PropertyBagSaveFlags.NoChangeTracking) != PropertyBagSaveFlags.NoChangeTracking);
            }
            catch (MapiPermanentException ex)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotDeleteProperties, ex, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::SetProperty. MapiProp = {0}.", this.MapiProp),
                    ex
                });
            }
            catch (MapiRetryableException ex2)
            {
                throw StorageGlobals.TranslateMapiException(ServerStrings.MapiCannotDeleteProperties, ex2, storeSession, this, "{0}. MapiException = {1}.", new object[]
                {
                    string.Format("MapiPropertyBag::SetProperty. MapiProp = {0}.", this.MapiProp),
                    ex2
                });
            }
            finally
            {
                try
                {
                    if (storeSession != null)
                    {
                        storeSession.EndMapiCall();
                        if (flag)
                        {
                            storeSession.EndServerHealthCall();
                        }
                    }
                }
                finally
                {
                    if (StorageGlobals.MapiTestHookAfterCall != null)
                    {
                        StorageGlobals.MapiTestHookAfterCall(MethodBase.GetCurrentMethod());
                    }
                }
            }
            PropertyError[] array2;
            if (array != null || list2.Count > 0)
            {
                int num = list2.Count;
                if (array != null)
                {
                    num += array.Length;
                }
                array2 = new PropertyError[num];
                int num2 = 0;
                if (array != null)
                {
                    int i = 0;
                    while (i < array.Length)
                    {
                        int               scode = array[i].Scode;
                        string            errorDescription;
                        PropertyErrorCode error         = MapiPropertyHelper.MapiErrorToXsoError(scode, out errorDescription);
                        PropertyError     propertyError = new PropertyError(list[array[i].Index], error, errorDescription);
                        array2[num2] = propertyError;
                        ExTraceGlobals.StorageTracer.TraceError <string, PropertyError>((long)this.GetHashCode(), "MapiPropertyBag::DeleteProperties. Failed. DisplayName = {0}, Error = {1}.", list[array[i].Index].Name, propertyError);
                        i++;
                        num2++;
                    }
                }
                int count = list2.Count;
                int j     = 0;
                while (j < count)
                {
                    PropertyError propertyError2 = new PropertyError(list2[j], PropertyErrorCode.SetCalculatedPropertyError, ServerStrings.ExSetNotSupportedForCalculatedProperty(list2[j].Name));
                    array2[num2] = propertyError2;
                    ExTraceGlobals.StorageTracer.TraceError <string, PropertyError>((long)this.GetHashCode(), "MapiPropertyBag::DeleteProperties. Failed. DisplayName = {0}, Error = {1}.", list2[j].Name, propertyError2);
                    j++;
                    num2++;
                }
            }
            else
            {
                array2 = MapiPropertyBag.EmptyPropertyErrorArray;
            }
            return(array2);
        }