Esempio n. 1
0
        internal override IEnumerable <T> FindPaged <T>(QueryFilter filter, MapiObjectId root, QueryScope scope, SortBy sort, int pageSize, int maximumResultsSize)
        {
            MailboxResourceMonitorEntry.< > c__DisplayClass1 <T> CS$ < > 8__locals1 = new MailboxResourceMonitorEntry.< > c__DisplayClass1 <T>();
            CS$ < > 8__locals1.< > 4__this = this;
            if (!base.GetType().IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException("T");
            }
            CS$ < > 8__locals1.databaseId = (root as DatabaseId);
            if (null == CS$ < > 8__locals1.databaseId)
            {
                throw new NotSupportedException(Strings.ExceptionIdentityTypeInvalid);
            }
            if (QueryScope.SubTree != scope)
            {
                throw new ArgumentException("scope");
            }
            if (sort != null)
            {
                throw new ArgumentException("sort");
            }
            if (0 > maximumResultsSize)
            {
                throw new ArgumentException("maximumResultsSize");
            }
            if (base.MapiSession == null)
            {
                throw new MapiInvalidOperationException(Strings.ExceptionSessionNull);
            }
            base.EnableDisposeTracking();
            PropTag[] tagsToRead;
            using (MailboxResourceMonitorEntry mailboxResourceMonitorEntry2 = (MailboxResourceMonitorEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))))
            {
                tagsToRead = mailboxResourceMonitorEntry2.GetPropertyTagsToRead();
            }
            if (tagsToRead == null || tagsToRead.Length == 0)
            {
                tagsToRead = new PropTag[]
                {
                    PropTag.UserGuid,
                    PropTag.EmailAddress
                };
            }
            PropValue[][] entries = null;
            base.MapiSession.InvokeWithWrappedException(delegate()
            {
                entries = CS$ < > 8__locals1.< > 4__this.MapiSession.Administration.GetResourceMonitorDigest(CS$ < > 8__locals1.databaseId.Guid, tagsToRead);
            }, Strings.ExceptionFindObject(typeof(T).Name, (null == root) ? Strings.ConstantNull : root.ToString()), CS$ < > 8__locals1.databaseId);
            int resultSize = entries.Length;

            if (0 < maximumResultsSize && maximumResultsSize < resultSize)
            {
                resultSize = maximumResultsSize;
            }
            foreach (PropValue[] entry in entries)
            {
                MailboxResourceMonitorEntry mailboxResourceMonitorEntry = (MailboxResourceMonitorEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T)));
                try
                {
                    mailboxResourceMonitorEntry.Instantiate(entry);
                    mailboxResourceMonitorEntry.MapiSession = base.MapiSession;
                    if (mailboxResourceMonitorEntry[MapiPropertyDefinitions.MailboxGuid] != null)
                    {
                        mailboxResourceMonitorEntry.Identity = new MailboxId(CS$ < > 8__locals1.databaseId, (Guid)mailboxResourceMonitorEntry[MapiPropertyDefinitions.MailboxGuid]);
                    }
                    mailboxResourceMonitorEntry.UpdateIdentity(mailboxResourceMonitorEntry.UpdateIdentityFlagsForFinding);
                    mailboxResourceMonitorEntry.OriginatingServer = Fqdn.Parse(mailboxResourceMonitorEntry.MapiSession.ServerName);
                    mailboxResourceMonitorEntry.ResetChangeTracking(true);
                }
                finally
                {
                    mailboxResourceMonitorEntry.Dispose();
                }
                yield return((T)((object)mailboxResourceMonitorEntry));
            }
            yield break;
            yield break;
        }
Esempio n. 2
0
        internal override IEnumerable <T> FindPaged <T>(QueryFilter filter, MapiObjectId root, QueryScope scope, SortBy sort, int pageSize, int maximumResultsSize)
        {
            if (!base.GetType().IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException("T");
            }
            DatabaseId databaseId = root as DatabaseId;

            if (!(null != databaseId))
            {
                throw new NotSupportedException(Strings.ExceptionIdentityTypeInvalid);
            }
            if (MapiObject.RetrievePropertiesScope.Database != this.RetrievePropertiesScopeForFinding && this.RetrievePropertiesScopeForFinding != MapiObject.RetrievePropertiesScope.Instance)
            {
                yield break;
            }
            if (QueryScope.SubTree != scope)
            {
                throw new ArgumentException("scope");
            }
            if (sort != null)
            {
                throw new ArgumentException("sort");
            }
            if (0 > maximumResultsSize)
            {
                throw new ArgumentException("maximumResultsSize");
            }
            if (base.MapiSession == null)
            {
                throw new MapiInvalidOperationException(Strings.ExceptionSessionNull);
            }
            base.EnableDisposeTracking();
            PropTag[] tagsToRead;
            using (LogonStatisticsEntry logonStatisticsEntry = (LogonStatisticsEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T))))
            {
                tagsToRead = logonStatisticsEntry.GetPropertyTagsToRead();
            }
            if (tagsToRead == null || tagsToRead.Length == 0)
            {
                tagsToRead = new PropTag[]
                {
                    PropTag.MailboxDN
                };
            }
            MdbFlags[] flagsSetToBeTried = new MdbFlags[]
            {
                MdbFlags.Private | MdbFlags.System | MdbFlags.User,
                MdbFlags.Public | MdbFlags.System | MdbFlags.User
            };
            int count = 0;

            MdbFlags[] array = flagsSetToBeTried;
            for (int i = 0; i < array.Length; i++)
            {
                LogonStatisticsEntry.< > c__DisplayClass5 <T> CS$ < > 8__locals3 = new LogonStatisticsEntry.< > c__DisplayClass5 <T>();
                CS$ < > 8__locals3.flags = array[i];
                PropValue[][] entries = null;
                base.MapiSession.InvokeWithWrappedException(delegate()
                {
                    ExTraceGlobals.LogonStatisticsTracer.TraceDebug <DatabaseId, string, MdbFlags>((long)this.GetHashCode(), "To Find LogonStatistics from in the database '{0}' on server '{1}' with flag '{2}'.", databaseId, this.MapiSession.ServerName, CS$ < > 8__locals3.flags);
                    entries = this.MapiSession.Administration.GetLogonTable(CS$ < > 8__locals3.flags, databaseId.Guid, tagsToRead);
                }, Strings.ExceptionFindObject(typeof(T).Name, (null == root) ? Strings.ConstantNull : root.ToString()), databaseId);
                foreach (PropValue[] entry in entries)
                {
                    LogonStatisticsEntry logonStatisitcs = (LogonStatisticsEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T)));
                    try
                    {
                        logonStatisitcs.Instantiate(entry);
                        logonStatisitcs.MapiSession = base.MapiSession;
                        logonStatisitcs.UpdateIdentity(logonStatisitcs.UpdateIdentityFlagsForFinding);
                        logonStatisitcs.OriginatingServer = Fqdn.Parse(logonStatisitcs.MapiSession.ServerName);
                        logonStatisitcs.ResetChangeTrackingAndObjectState();
                    }
                    finally
                    {
                        logonStatisitcs.Dispose();
                    }
                    yield return((T)((object)logonStatisitcs));

                    count++;
                    if (0 < maximumResultsSize && count == maximumResultsSize)
                    {
                        yield break;
                    }
                }
                if (0 < count)
                {
                    break;
                }
            }
            yield break;
        }
Esempio n. 3
0
        internal override IEnumerable <T> FindPaged <T>(QueryFilter filter, MapiObjectId root, QueryScope scope, SortBy sort, int pageSize, int maximumResultsSize)
        {
            MailboxEntry.< > c__DisplayClass1 <T> CS$ < > 8__locals1 = new MailboxEntry.< > c__DisplayClass1 <T>();
            CS$ < > 8__locals1.< > 4__this       = this;
            CS$ < > 8__locals1.mailboxGuid       = Guid.Empty;
            CS$ < > 8__locals1.mailboxTableFlags = MailboxTableFlags.MailboxTableFlagsNone;
            if (!base.GetType().IsAssignableFrom(typeof(T)))
            {
                throw new ArgumentException("T");
            }
            CS$ < > 8__locals1.databaseId = (root as DatabaseId);
            if (null == CS$ < > 8__locals1.databaseId)
            {
                throw new NotSupportedException(Strings.ExceptionIdentityTypeInvalid);
            }
            if (filter != null)
            {
                MailboxContextFilter mailboxContextFilter = filter as MailboxContextFilter;
                if (mailboxContextFilter == null)
                {
                    throw new NotSupportedException(Strings.ExceptionIdentityTypeInvalid);
                }
                CS$ < > 8__locals1.mailboxGuid        = mailboxContextFilter.MailboxGuid;
                CS$ < > 8__locals1.mailboxTableFlags |= (MailboxTableFlags)mailboxContextFilter.MailboxFlags;
                this.noADLookup = mailboxContextFilter.NoADLookup;
            }
            else
            {
                this.noADLookup = false;
            }
            if (MapiObject.RetrievePropertiesScope.Database != this.RetrievePropertiesScopeForFinding)
            {
                yield break;
            }
            if (QueryScope.SubTree != scope)
            {
                throw new ArgumentException("scope");
            }
            if (sort != null)
            {
                throw new ArgumentException("sort");
            }
            if (0 > maximumResultsSize)
            {
                throw new ArgumentException("maximumResultsSize");
            }
            if (base.MapiSession == null)
            {
                throw new MapiOperationException(Strings.ExceptionSessionNull);
            }
            base.EnableDisposeTracking();
            PropTag[] tagsToRead = base.GetPropertyTagsToRead();
            if (tagsToRead == null || tagsToRead.Length == 0)
            {
                tagsToRead = new PropTag[]
                {
                    PropTag.UserGuid,
                    PropTag.EmailAddress
                };
            }
            PropValue[][] entries = null;
            base.MapiSession.InvokeWithWrappedException(delegate()
            {
                entries = CS$ < > 8__locals1.< > 4__this.MapiSession.Administration.GetMailboxTableInfo(CS$ < > 8__locals1.databaseId.Guid, CS$ < > 8__locals1.mailboxGuid, CS$ < > 8__locals1.mailboxTableFlags, tagsToRead);
            }, Strings.ExceptionFindObject(typeof(T).Name, (null == root) ? Strings.ConstantNull : root.ToString()), CS$ < > 8__locals1.databaseId);
            int resultSize = entries.Length;

            if (0 < maximumResultsSize && maximumResultsSize < resultSize)
            {
                resultSize = maximumResultsSize;
            }
            int entryIndex = 0;

            while (resultSize > entryIndex)
            {
                MailboxEntry mailbox = (MailboxEntry)((object)((default(T) == null) ? Activator.CreateInstance <T>() : default(T)));
                try
                {
                    mailbox.Instantiate(entries[entryIndex]);
                    mailbox.MapiSession = base.MapiSession;
                    if (mailbox[MapiPropertyDefinitions.MailboxGuid] != null)
                    {
                        mailbox.Identity = new MailboxId(CS$ < > 8__locals1.databaseId, (Guid)mailbox[MapiPropertyDefinitions.MailboxGuid]);
                    }
                    mailbox.UpdateIdentity(mailbox.UpdateIdentityFlagsForFinding);
                    mailbox.OriginatingServer = Fqdn.Parse(mailbox.MapiSession.ServerName);
                    mailbox.ResetChangeTrackingAndObjectState();
                }
                finally
                {
                    mailbox.Dispose();
                }
                yield return((T)((object)mailbox));

                entryIndex++;
            }
            yield break;
        }
Esempio n. 4
0
 internal static void ThrowWrappedException(LocalizedException exception, LocalizedString message, MapiObjectId source, MapiSession mapiSession)
 {
     if (exception is MapiExceptionNotFound)
     {
         if (source is PublicFolderId)
         {
             throw new PublicFolderNotFoundException(source.ToString(), exception);
         }
         if (source is MailboxId)
         {
             mapiSession.AnalyzeMailboxNotFoundAndThrow((MailboxId)source, exception);
         }
         throw new MapiObjectNotFoundException(message, exception);
     }
     else if (exception is MapiExceptionLogonFailed)
     {
         if (source is PublicFolderId)
         {
             throw new PublicStoreLogonFailedException(mapiSession.ServerName, exception);
         }
         if (source is MailboxId)
         {
             mapiSession.AnalyzeMailboxLogonFailedAndThrow((MailboxId)source, exception);
         }
         throw new MapiLogonFailedException(Strings.LogonFailedExceptionError(message, mapiSession.ServerName), exception);
     }
     else
     {
         if (exception is MapiExceptionSessionLimit)
         {
             throw new MapiLogonFailedException(Strings.SessionLimitExceptionError, exception);
         }
         if (exception is MapiExceptionUnknownMailbox)
         {
             if (source is MailboxId)
             {
                 mapiSession.AnalyzeMailboxNotFoundAndThrow((MailboxId)source, exception);
             }
             throw new MapiObjectNotFoundException(message, exception);
         }
         if (exception is MapiExceptionMdbOffline)
         {
             if (mapiSession == null)
             {
                 throw new DatabaseUnavailableException(Strings.DatabaseUnavailableExceptionErrorSimple, exception);
             }
             DatabaseId databaseId = null;
             if (source is MailboxId && null != ((MailboxId)source).MailboxDatabaseId)
             {
                 databaseId = ((MailboxId)source).MailboxDatabaseId;
             }
             else if (source is DatabaseId)
             {
                 databaseId = (DatabaseId)source;
             }
             if (null == databaseId)
             {
                 throw new DatabaseUnavailableException(Strings.DatabaseUnavailableExceptionError(mapiSession.ServerName), exception);
             }
             throw new DatabaseUnavailableException(Strings.DatabaseUnavailableByIdentityExceptionError(mapiSession.GetDatabaseIdentityString(databaseId), mapiSession.ServerName), exception);
         }
         else
         {
             if (exception is MapiExceptionPartialCompletion)
             {
                 throw new MapiPartialCompletionException(message, exception);
             }
             if (exception is MapiExceptionNetworkError)
             {
                 if (mapiSession != null)
                 {
                     throw new MapiNetworkErrorException(Strings.MapiNetworkErrorExceptionError(mapiSession.ServerName), exception);
                 }
                 throw new MapiNetworkErrorException(Strings.MapiNetworkErrorExceptionErrorSimple, exception);
             }
             else if (exception is MapiExceptionNoAccess)
             {
                 if (null != source)
                 {
                     throw new MapiAccessDeniedException(Strings.MapiAccessDeniedExceptionError(source.ToString()), exception);
                 }
                 throw new MapiAccessDeniedException(Strings.MapiAccessDeniedExceptionErrorSimple, exception);
             }
             else
             {
                 if (exception is MapiRetryableException)
                 {
                     throw new MapiTransientException(message, exception);
                 }
                 if (exception is MapiPermanentException)
                 {
                     throw new MapiOperationException(message, exception);
                 }
                 if (exception is MapiInvalidOperationException)
                 {
                     throw new MapiOperationException(message, exception);
                 }
                 return;
             }
         }
     }
 }