Пример #1
0
        /// <summary>Get default statistics</summary>
        /// <cardinality>Many</cardinality>
        public List <DefaultStatisticsTop5Data> DefaultStatisticsTop5()
        {
            var ret = new List <DefaultStatisticsTop5Data>();

            string sql = @" 
                select 'utc' as measurement, convert(nvarchar(240),				getutcdate(), 121) as value
                union all
                select 'db version', @@version
                union all
                select 'default change log', convert(nvarchar(240),				count(*)) from default_change_log					
                union all
                select 'default error', convert(nvarchar(240),					count(*)) from default_error
                union all
                select 'default issue', convert(nvarchar(240),					count(*)) from default_issue
                union all
                select 'default performance issue', convert(nvarchar(240),		count(*)) from default_performance_issue
                union all
                select 'default performance time', convert(nvarchar(240),		count(*)) from default_performance_time
                union all
                select 'default rule', convert(nvarchar(240),					count(*)) from default_rule
                union all
                select 'default system reference table', convert(nvarchar(240),	count(*)) from default_system_reference_table
                union all
                select 'default system setting', convert(nvarchar(240),			count(*)) from default_system_setting
                union all
                select 'default user', convert(nvarchar(240),					count(*)) from default_user
                union all
                select 'default user activity', convert(nvarchar(240),			count(*)) from default_user_activity
                ";

            Logging log = Logging.PerformanceTimeStart("Default", "DataAccessLayer", "DefaultSearch", "DefaultStatisticsTop5");

            try {
                using (var conn = new SqlConnection(Conn.ConnectionString)) {
                    conn.Open();
                    conn.BeginTransaction(IsolationLevel.ReadUncommitted).Commit();

                    using (var command = new SqlCommand(sql, conn)) {
                        log.PerformanceTimePrepare(command);
                        IDataReader reader = command.ExecuteReader(CommandBehavior.SingleResult);
                        log.PerformanceTimeCheck();

                        var ordinals = new DefaultStatisticsTop5DataOrdinals(reader);
                        while (reader.Read())
                        {
                            var data = new DefaultStatisticsTop5Data();
                            data.Populate(reader, ordinals);
                            ret.Add(data);
                        }

                        reader.Close();
                    }
                }
            } catch (Exception ex) {
                log.Error(ex);
            }
            return(ret);
        }
Пример #2
0
 // use ordinals to speed up access to DataReader
 // links:
 //  crud definition: https://en.wikipedia.org/wiki/Create,_read,_update_and_delete
 //  docLink: http://sql2x.org/documentationLink/327451c3-64a8-4de8-b359-76742d634497
 // parameters:
 //  reader: IDataReader from SQLClient
 public void Populate(IDataReader reader, DefaultStatisticsTop5DataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.Measurement))
     {
         Measurement = reader.GetString(ordinals.Measurement);
     }
     if (!reader.IsDBNull(ordinals.Value))
     {
         Value = reader.GetString(ordinals.Value);
     }
 }