コード例 #1
0
        private static MetricViewModel FillObject(DbDataReader reader, DbDataReader readerTest, DbDataReader readerService)
        {
            MetricViewModel Servicemetrics = new MetricViewModel();

            Servicemetrics.ServiceProfile        = reader.GetString(2);
            Servicemetrics.NumberBugs            = reader.GetInt32(3);
            Servicemetrics.NumberVulnerabilities = reader.GetInt32(4);
            Servicemetrics.NumberCodeSmells      = reader.GetInt32(5);
            Servicemetrics.Coverage      = reader.GetDecimal(6);
            Servicemetrics.Duplication   = reader.GetDecimal(7);
            Servicemetrics.Size          = reader.GetInt32(8);
            Servicemetrics.Complexity    = reader.GetInt32(9);
            Servicemetrics.Documentation = reader.GetDecimal(10);
            Servicemetrics.ServiceName   = readerService.GetString(1);
            Servicemetrics.DirectionName = readerService.GetString(2);
            Servicemetrics.TeamName      = readerService.GetString(3);

            if (readerTest.Read())
            {
                if (!readerTest.IsDBNull(8))
                {
                    Servicemetrics.PassedTests = readerTest.GetInt32(8);
                }

                if (!readerTest.IsDBNull(6))
                {
                    Servicemetrics.TotalTests = readerTest.GetInt32(6);
                }
            }


            return(Servicemetrics);
        }
コード例 #2
0
        public static List <MetricViewModel> GetLastestMetrics(IConfigurationRoot configuration)
        {
            DbDataReader           reader  = null;
            List <MetricViewModel> Metrics = new List <MetricViewModel>();

            MySqlConnection myConnectionServices = new MySqlConnection(configuration["connectionString"]);
            MySqlConnection myConnectionMetrics  = new MySqlConnection(configuration["connectionString"]);
            MySqlConnection myConnectionTests    = new MySqlConnection(configuration["connectionString"]);

            myConnectionServices.Open();
            myConnectionMetrics.Open();
            myConnectionTests.Open();

            //string queryServices = "select ServiceID, serviceName from serviceinformation";
            string       queryServices   = "SELECT ServiceID, ServiceName, DirectionName, DirectionteamName FROM serviceinformation se, teamdirection te, direction di where se.DirectionTeamID = te.DirectionTeamID and te.DirectionID = di.DirectionID";
            MySqlCommand commandServices = new MySqlCommand(queryServices, myConnectionServices);

            reader = commandServices.ExecuteReader();

            while (reader.Read())
            {
                string       queryMetrics   = "select * from servicemetrics where ServiceID = @ServiceID order by InterrogationDate DESC";
                MySqlCommand commandMetrics = new MySqlCommand(queryMetrics, myConnectionMetrics);
                commandMetrics.Parameters.AddWithValue("@ServiceID", reader.GetInt32(0));

                DbDataReader readerMetrics = commandMetrics.ExecuteReader();
                readerMetrics.Read();

                string       queryTests   = "SELECT * FROM servicebuild where ServiceID=@ServiceID and (result = 'succeeded' or result = 'partiallySucceeded') and BuildName LIKE 'Sonar_%' order by FinishTime DESC";
                MySqlCommand commandTests = new MySqlCommand(queryTests, myConnectionTests);
                commandTests.Parameters.AddWithValue("@ServiceID", reader.GetInt32(0));


                DbDataReader readerTests = commandTests.ExecuteReader();


                MetricViewModel Servicemetrics = new MetricViewModel();
                Servicemetrics.ServiceProfile        = readerMetrics.GetString(2);
                Servicemetrics.NumberBugs            = readerMetrics.GetInt32(3);
                Servicemetrics.NumberVulnerabilities = readerMetrics.GetInt32(4);
                Servicemetrics.NumberCodeSmells      = readerMetrics.GetInt32(5);
                Servicemetrics.Coverage      = readerMetrics.GetDecimal(6);
                Servicemetrics.Duplication   = readerMetrics.GetDecimal(7);
                Servicemetrics.Size          = readerMetrics.GetInt32(8);
                Servicemetrics.Complexity    = readerMetrics.GetInt32(9);
                Servicemetrics.Documentation = readerMetrics.GetDecimal(10);
                Servicemetrics.ServiceName   = reader.GetString(1);
                Servicemetrics.DirectionName = reader.GetString(2);
                Servicemetrics.TeamName      = reader.GetString(3);

                if (readerTests.Read())
                {
                    //Servicemetrics.PassedTests = readerTests.GetInt32(8);
                    //Servicemetrics.TotalTests = readerTests.GetInt32(6);
                    if (!readerTests.IsDBNull(8))
                    {
                        Servicemetrics.PassedTests = readerTests.GetInt32(8);
                    }

                    if (!readerTests.IsDBNull(6))
                    {
                        Servicemetrics.TotalTests = readerTests.GetInt32(6);
                    }
                }


                readerMetrics.Dispose();
                readerTests.Dispose();

                Metrics.Add(Servicemetrics);
            }

            return(Metrics);
        }