Exemplo n.º 1
0
        private bool GetDbLocationInfoByRegistry(Guid databaseId, out DatabaseLocationInfo databaseLocationInfo)
        {
            databaseLocationInfo = null;
            if (this.m_key == null)
            {
                this.m_key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\ExchangeServer\\v15\\ActiveManager\\TestOverride", RegistryKeyPermissionCheck.ReadSubTree);
                if (this.m_key == null)
                {
                    ExTraceGlobals.ActiveManagerClientTracer.TraceDebug((long)this.GetHashCode(), "GetServerForDatabase failed opening the registry override key!");
                    return(false);
                }
                ExTraceGlobals.ActiveManagerClientTracer.TraceDebug((long)this.GetHashCode(), "Found registry override entry");
            }
            object value = this.m_key.GetValue(databaseId.ToString());

            if (value == null)
            {
                return(false);
            }
            string text = value as string;

            if (text == null)
            {
                throw new ArgumentException("Registry override for active server should be a string-typed value", "regValue");
            }
            string[] array = text.Split(new char[]
            {
                '|'
            });
            int num = array.Length;

            if (num == 3)
            {
                databaseLocationInfo = new DatabaseLocationInfo(array[0], array[1], ActiveManagerUtil.GetServerSiteFromServer(LocalServer.GetServer()), new ServerVersion(int.Parse(array[2], CultureInfo.InvariantCulture)), false);
                return(true);
            }
            if (num != 9)
            {
                throw new ArgumentException("Registry override for active server should be in a \"<fqdn>|<legacyDN>|<version>|<lastMountedServerFqdn>|<lastMountedServerLegacyDN>|<databaseLegacyDN>|<mountedTime>|<serverVersion>|<isHA>\" format", "databaseId");
            }
            databaseLocationInfo = new DatabaseLocationInfo(array[0], array[1], array[2], array[3], array[4], array[1], string.Empty, false, false, string.IsNullOrEmpty(array[5]) ? Guid.Empty : new Guid(array[5]), DateTime.Parse(array[6]), null, ActiveManagerUtil.GetServerSiteFromServer(LocalServer.GetServer()), new ServerVersion(int.Parse(array[7], CultureInfo.InvariantCulture)), MailboxRelease.None, DatabaseLocationInfoResult.Success, bool.Parse(array[8]));
            return(true);
        }
 internal DatabaseLocationInfo(Server server, bool isDatabaseHighlyAvailable) : this(server.Fqdn, server.ExchangeLegacyDN, ActiveManagerUtil.GetServerSiteFromServer(server), server.AdminDisplayVersion, isDatabaseHighlyAvailable)
 {
     this.serverGuid = new Guid?(server.Guid);
 }