Example #1
0
        /// <summary>
        /// Loads the properties from the connected server into a hashtable
        /// </summary>
        /// <param name="connection"></param>
        /// <returns></returns>
        private Dictionary <string, string> LoadServerProperties(MyCatConnection connection)
        {
            // load server properties
            Dictionary <string, string> hash = new Dictionary <string, string>();
            MyCatCommand cmd = new MyCatCommand("SHOW VARIABLES", connection);

            try
            {
                using (MyCatDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        string key   = reader.GetString(0);
                        string value = reader.GetString(1);
                        hash[key] = value;
                    }
                }
                // Get time zone offset as numerical value
                timeZoneOffset = TimeZoneInfo.Local.BaseUtcOffset.Hours;
                return(hash);
            }
            catch (Exception ex)
            {
                MyCatTrace.LogError(ThreadID, ex.Message);
                throw;
            }
        }
Example #2
0
        public SystemPerformanceMonitor(MyCatConnection connection) : base(connection)
        {
            string categoryName = Resources.PerfMonCategoryName;

            if (connection.Settings.UsePerformanceMonitor && procedureHardQueries == null)
            {
                try
                {
                    procedureHardQueries = new PerformanceCounter(categoryName,
                                                                  "HardProcedureQueries", false);
                    procedureSoftQueries = new PerformanceCounter(categoryName,
                                                                  "SoftProcedureQueries", false);
                }
                catch (Exception ex)
                {
                    MyCatTrace.LogError(connection.ServerThread, ex.Message);
                }
            }
        }
        private Driver TryToGetDriver()
        {
            int count = Interlocked.Decrement(ref available);

            if (count < 0)
            {
                Interlocked.Increment(ref available);
                return(null);
            }
            try
            {
                Driver driver = GetPooledConnection();
                return(driver);
            }
            catch (Exception ex)
            {
                MyCatTrace.LogError(-1, ex.Message);
                Interlocked.Increment(ref available);
                throw;
            }
        }
Example #4
0
        /// <summary>
        /// Loads all the current character set names and ids for this server
        /// into the charSets hashtable
        /// </summary>
        private void LoadCharacterSets(MyCatConnection connection)
        {
            MyCatCommand cmd = new MyCatCommand("SHOW COLLATION", connection);

            // now we load all the currently active collations
            try
            {
                using (MyCatDataReader reader = cmd.ExecuteReader())
                {
                    charSets = new Dictionary <int, string>();
                    while (reader.Read())
                    {
                        charSets[Convert.ToInt32(reader["id"], NumberFormatInfo.InvariantInfo)] =
                            reader.GetString(reader.GetOrdinal("charset"));
                    }
                }
            }
            catch (Exception ex)
            {
                MyCatTrace.LogError(ThreadID, ex.Message);
                throw;
            }
        }