コード例 #1
0
ファイル: DatabaseSetup.cs プロジェクト: radtek/Orqa
        private static string GetFirstClientKey(WowRegistryKey key)
        {
            string homeKey = null;

            if (key != null)
            {
                string[] keys = key.GetSubKeyNames();
                int      i    = 0;

                while ((i < keys.Length) && (homeKey == null))
                {
                    if (keys[i].StartsWith("KEY_Everest") ||
                        keys[i].StartsWith("KEY_OraClient") ||
                        keys[i].StartsWith("KEY_OraOdac"))
                    {
                        homeKey = registryPrefix + @"\" + keys[i];
                    }
                    else
                    {
                        i++;
                    }
                }
            }

            return(homeKey);
        }
コード例 #2
0
ファイル: DatabaseSetup.cs プロジェクト: radtek/Orqa
        //========================================================================================
        // GetSetupInformation()
        //========================================================================================

        #region GetSetupInformation

        private static void GetSetupInformation()
        {
            var subkey = WowRegistry.LocalMachine.OpenSubKey(registryPrefix);

            if (subkey != null)
            {
                oracleHomeKey = GetHomeKey(subkey);

                if (oracleHomeKey == null)
                {
                    oracleHomeKey = GetFirstClientKey(
                        WowRegistry.LocalMachine.OpenSubKey(registryPrefix));
                }

                if (oracleHomeKey != null)
                {
                    WowRegistryKey key = WowRegistry.LocalMachine.OpenSubKey(oracleHomeKey);
                    if (key != null)
                    {
                        oracleHome     = GetKeyValue(key, "ORACLE_HOME");
                        oracleHomeName = GetKeyValue(key, "ORACLE_HOME_NAME");
                        oracleSid      = GetKeyValue(key, "ORACLE_SID");
                    }
                }
            }

            uninformed = false;
        }
コード例 #3
0
ファイル: WowRegistryTest.cs プロジェクト: stevencohn/Orqa
        public void OpenSubKeyTest()
        {
            WowRegistryKey key = WowRegistry.LocalMachine.OpenSubKey(@"SOFTWARE\Oracle");

            Assert.IsNotNull(key);

            WowRegistryKey subkey = key.OpenSubKey("KEY_OraDb11g_home1");

            Assert.IsNotNull(subkey);
        }
コード例 #4
0
ファイル: WowRegistryTest.cs プロジェクト: stevencohn/Orqa
        public void GetValueTest()
        {
            WowRegistryKey key =
                WowRegistry.LocalMachine.OpenSubKey(@"SOFTWARE\ORACLE\KEY_OraDb11g_home1");

            Assert.IsNotNull(key);

            string value = (string)key.GetValue("ORACLE_HOME");

            Console.WriteLine(String.Format("GetValueTest value=[{0}]", value));
            Assert.IsNotNull(value);
        }
コード例 #5
0
ファイル: WowRegistryTest.cs プロジェクト: stevencohn/Orqa
        public void GetSubKeyNamesTest()
        {
            WowRegistryKey key = WowRegistry.LocalMachine.OpenSubKey(@"SOFTWARE\Oracle");

            string[] names = key.GetSubKeyNames();
            Assert.IsNotNull(names);
            Assert.IsTrue(names.Length > 0);

            foreach (string name in names)
            {
                Console.WriteLine(String.Format("Subkey name=[{0}]", name));
            }
        }
コード例 #6
0
ファイル: DatabaseSetup.cs プロジェクト: radtek/Orqa
        private static string GetKeyValue(WowRegistryKey key, string name)
        {
            string value = String.Empty;

            if (key != null)
            {
                try
                {
                    if ((value = (string)key.GetValue(name)) == null)
                    {
                        value = String.Empty;
                    }
                }
                catch { }
            }

            return(value);
        }
コード例 #7
0
ファイル: DatabaseSetup.cs プロジェクト: radtek/Orqa
        // Different versions of Oracle place the ODP.NET key in different locations
        // under the HKLM\SOFTWARE\ORACLE key.  So recurse down the subtree until it
        // is found.

        private static bool HasOdpNetKey(WowRegistryKey key)
        {
            string[] keys  = key.GetSubKeyNames();
            bool     found = false;
            int      i     = 0;

            while ((i < keys.Length) && !found)
            {
                if (!(found = keys[i].Equals("ODP.NET")))
                {
                    if (!(found = HasOdpNetKey(key.OpenSubKey(keys[i]))))
                    {
                        i++;
                    }
                }
            }

            return(found);
        }
コード例 #8
0
ファイル: WowRegistryTest.cs プロジェクト: stevencohn/Orqa
        public void GetSubKeyCountTest()
        {
            WowRegistryKey key   = WowRegistry.LocalMachine.OpenSubKey(@"SOFTWARE\Oracle");
            int            count = key.GetSubKeyCount();

            Console.WriteLine(String.Format("GetSubKeyCountTest count=[{0}]", count));
            Assert.IsTrue(count > 0);

            RegistryKey nativeHKLM = Registry.LocalMachine;

            if (nativeHKLM != null)
            {
                RegistryKey nativeKey = nativeHKLM.OpenSubKey(@"SOFTWARE\Oracle");
                if (nativeKey != null)
                {
                    string[] names = nativeKey.GetSubKeyNames();
                }
            }
        }
コード例 #9
0
ファイル: DatabaseSetup.cs プロジェクト: radtek/Orqa
        private static string GetHomeKey(WowRegistryKey key)
        {
            string homeKey = (string)key.GetValue("ORACLE_HOME_KEY");

            if ((homeKey == null) && (key != null))
            {
                string[] keys = key.GetSubKeyNames();
                int      i    = 0;

                while ((i < keys.Length) && (homeKey == null))
                {
                    var subkey = key.OpenSubKey(keys[i]);
                    if ((homeKey = GetHomeKey(subkey)) == null)
                    {
                        i++;
                    }
                }
            }

            return(homeKey);
        }
コード例 #10
0
ファイル: Tns.cs プロジェクト: stevencohn/Orqa
        //========================================================================================
        // ReadTnsNames()
        //		Parse the tnsnames.ora file.  This routine essentially filters out all
        //		comments and anything between paranthesis, leaving only the TNS names.
        //========================================================================================

        private static void ReadTnsNames(SortedList list, SortedList all)
        {
            string home = String.Empty;

            WowRegistryKey key =
                WowRegistry.ClassesRoot.OpenSubKey("OracleDatabase.OracleDatabase\\CurVer");

            if (key == null)
            {
                home = DatabaseSetup.OracleHome;
            }
            else
            {
                key = WowRegistry.ClassesRoot.OpenSubKey((string)key.GetValue(null) + "\\CLSID");
                if (key != null)
                {
                    string clsid = (string)key.GetValue(null);

                    key = WowRegistry.ClassesRoot.OpenSubKey("CLSID\\" + clsid + "\\LocalServer32");
                    if (key != null)
                    {
                        string oracon = (string)key.GetValue(null);
                        if (!String.IsNullOrEmpty(oracon))
                        {
                            home = oracon.Substring(0, oracon.ToLower().IndexOf("\\oracon"));

                            if (home.StartsWith("\""))
                            {
                                home = home.Substring(1);
                            }
                        }
                    }
                }
            }

            var content = new StringBuilder();

            tnsNamesOraPath = Path.Combine(home, @"network\admin\tnsnames.ora");

            try
            {
                using (var reader = new StreamReader(
                           (Stream)File.OpenRead(tnsNamesOraPath),
                           System.Text.Encoding.ASCII))
                {
                    char ch;
                    int  depth     = 0;
                    bool inComment = false;

                    while (reader.Peek() >= 0)
                    {
                        ch = (char)reader.Read();

                        if (inComment)
                        {
                            if (ch == 10)
                            {
                                inComment = false;
                            }
                        }
                        else
                        {
                            if (ch == '#')
                            {
                                inComment = true;
                            }
                            else if (ch == '(')
                            {
                                depth++;
                            }
                            else if (ch == ')')
                            {
                                depth--;
                            }
                            else if ((depth == 0) && !Char.IsWhiteSpace(ch))
                            {
                                content.Append(ch);
                            }
                        }
                    }

                    reader.Close();
                }
            }
            catch (Exception)
            {
                return;
            }

            if (content.Length > 0)
            {
                string[] names = content.ToString().Split('=');
                string   name;
                TnsName  tname;

                for (int i = 0; i < names.Length; i++)
                {
                    name = names[i].Trim().ToLower();

                    if ((name.Length > 0) &&
                        (name.IndexOf("http") < 0) &&
                        (name.IndexOf("extproc") < 0))
                    {
                        tname = new TnsName(name, Location.TnsNames, null);

                        if (!list.Contains(name))
                        {
                            list.Add(name, tname);
                        }

                        all.Add(name + Location.TnsNames.ToString(), tname);
                    }
                }
            }
        }
コード例 #11
0
ファイル: WowRegistryTest.cs プロジェクト: stevencohn/Orqa
        public void GetUnknownValueTest()
        {
            WowRegistryKey key = WowRegistry.LocalMachine.OpenSubKey(@"Does_Not_Exist_Key");

            Assert.IsNull(key);
        }
コード例 #12
0
ファイル: WowRegistryTest.cs プロジェクト: stevencohn/Orqa
        public void OpenTest()
        {
            WowRegistryKey key = WowRegistry.LocalMachine.OpenSubKey(@"SOFTWARE\Oracle");

            Assert.IsNotNull(key);
        }