예제 #1
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, DefaultTestOverviewDataOrdinals ordinals)
 {
     if (!reader.IsDBNull(ordinals.TestArea))
     {
         TestArea = reader.GetString(ordinals.TestArea);
     }
     if (!reader.IsDBNull(ordinals.StartDateTime))
     {
         StartDateTime = reader.GetDateTime(ordinals.StartDateTime);
     }
     if (!reader.IsDBNull(ordinals.DefaultTestRunResultRcd))
     {
         DefaultTestRunResultRcd = reader.GetString(ordinals.DefaultTestRunResultRcd);
     }
 }
예제 #2
0
        /// <summary>Get Default Performance Issue</summary>
        /// <cardinality>Many</cardinality>
        public List <DefaultTestOverviewData> DefaultTestOverview(
            System.String commandName
            )
        {
            var    ret = new List <DefaultTestOverviewData>();
            string sql = @"
                select 
	                 dt.test_area
	                ,dtr.start_date_time
	                ,dtr.default_test_run_result_rcd
                from default_test_run	as dtr
                inner join default_test as dt	on dt.default_test_id = dtr.default_test_id
                order by dtr.date_time desc
                ";

            Logging log = Logging.PerformanceTimeStart("DefaultTestOverview");

            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 DefaultTestOverviewDataOrdinals(reader);
                        while (reader.Read())
                        {
                            var data = new DefaultTestOverviewData();
                            data.Populate(reader, ordinals);
                            ret.Add(data);
                        }

                        reader.Close();
                    }
                }
            } catch (Exception ex) {
                log.Error(ex);
            }
            return(ret);
        }