コード例 #1
0
        // Token: 0x06000779 RID: 1913 RVA: 0x0001D180 File Offset: 0x0001B380
        public IAsyncResult BeginGetBackEndServerList(MiniRecipient miniRecipient, int maxServers, AsyncCallback callback, object state)
        {
            if (miniRecipient == null)
            {
                throw new ArgumentNullException("miniRecipient");
            }
            if (maxServers <= 0)
            {
                throw new ArgumentException("maxServers needs to be greater than zero");
            }
            this.database   = miniRecipient.Database;
            this.maxServers = maxServers;
            OrganizationId organizationId     = miniRecipient.OrganizationId;
            SmtpAddress    primarySmtpAddress = miniRecipient.PrimarySmtpAddress;

            if (this.database == null)
            {
                ADUser defaultOrganizationMailbox = HttpProxyBackEndHelper.GetDefaultOrganizationMailbox(organizationId, null);
                if (defaultOrganizationMailbox == null || defaultOrganizationMailbox.Database == null)
                {
                    ExTraceGlobals.CafeTracer.TraceError <OrganizationId>(0L, "[BackEndLocator.BeginGetBackEndServerList] Cannot find organization mailbox for organization {1}", organizationId);
                    throw new AdUserNotFoundException(ServerStrings.ADUserNotFound);
                }
                this.database      = defaultOrganizationMailbox.Database;
                primarySmtpAddress = defaultOrganizationMailbox.PrimarySmtpAddress;
            }
            string domainName = null;

            if (organizationId != null && !organizationId.Equals(OrganizationId.ForestWideOrgId))
            {
                domainName = primarySmtpAddress.Domain;
            }
            this.serverLocator = MailboxServerLocator.Create(this.database.ObjectGuid, domainName, this.database.PartitionFQDN);
            bool         flag = true;
            IAsyncResult result;

            try
            {
                result = this.serverLocator.BeginGetServer(callback, state);
                flag   = false;
            }
            catch (Exception ex)
            {
                ExTraceGlobals.CafeTracer.TraceError <Exception>(0L, "[AsyncBackEndLocator.BeginGetBackEndServerList] Caught exception {0}.", ex);
                if (BackEndLocator.ShouldWrapInBackendLocatorException(ex))
                {
                    throw new BackEndLocatorException(ex);
                }
                throw;
            }
            finally
            {
                if (flag)
                {
                    this.serverLocator.Dispose();
                    this.serverLocator = null;
                }
            }
            return(result);
        }
コード例 #2
0
        // Token: 0x0600077A RID: 1914 RVA: 0x0001D2EC File Offset: 0x0001B4EC
        public IList <BackEndServer> EndGetBackEndServerList(IAsyncResult asyncResult)
        {
            IList <BackEndServer> result;

            try
            {
                BackEndServer backEndServer = this.serverLocator.EndGetServer(asyncResult);
                ExTraceGlobals.CafeTracer.TraceDebug <BackEndServer, ADObjectId>(0L, "[MailboxServerLocator.EndGetServer] called inside [AsyncBackEndLocator.EndGetBackEndServerList] returned back end server {0} for database {1}", backEndServer, this.database);
                IList <BackEndServer> list = new List <BackEndServer>();
                list.Add(backEndServer);
                int    num         = 1;
                Random localRandom = new Random(AsyncBackEndLocator.GetRandomNumber(int.MaxValue));
                IEnumerable <KeyValuePair <Guid, BackEndServer> > enumerable = from x in this.serverLocator.AvailabilityGroupServers
                                                                               orderby localRandom.Next()
                                                                               select x;

                foreach (KeyValuePair <Guid, BackEndServer> keyValuePair in enumerable)
                {
                    if (num >= this.maxServers)
                    {
                        break;
                    }
                    if (!this.IsServerInBackendList(list, keyValuePair.Value))
                    {
                        list.Add(keyValuePair.Value);
                        num++;
                    }
                }
                result = list;
            }
            catch (Exception ex)
            {
                ExTraceGlobals.CafeTracer.TraceError <Exception>(0L, "[AsyncBackEndLocator.EndGetBackEndServerList] Caught exception {0}.", ex);
                if (BackEndLocator.ShouldWrapInBackendLocatorException(ex))
                {
                    throw new BackEndLocatorException(ex);
                }
                throw;
            }
            finally
            {
                this.serverLocator.Dispose();
                this.serverLocator = null;
            }
            return(result);
        }
コード例 #3
0
        private static T CallWithExceptionHandling <T>(Func <T> actualCall)
        {
            T result;

            try
            {
                result = actualCall();
            }
            catch (BackEndLocatorException)
            {
                throw;
            }
            catch (Exception ex)
            {
                ExTraceGlobals.CafeTracer.TraceError <Exception>(0L, "[BackEndLocator.CallWithExceptionHandling] Caught exception {0}.", ex);
                if (BackEndLocator.ShouldWrapInBackendLocatorException(ex))
                {
                    throw new BackEndLocatorException(ex);
                }
                throw;
            }
            return(result);
        }