public List <MQTipoPruebaDTO> SelectMQTipoPrueba(int tipoPruebaID)
        {
            List <MQTipoPruebaDTO> listaMQTipoPruebas = new List <MQTipoPruebaDTO>();
            StringBuilder          query = new StringBuilder().Append(@"SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
                        SELECT MQTIPOPRUEBA_ID,NOMBRE,ROUTEKEY,QUEUENAME,ES_WEB FROM MQTIPOPRUEBA");

            if (tipoPruebaID != 0)
            {
                query.Append(" WHERE MQTIPOPRUEBA_ID=@TipoPruebaID");
            }

            using (var con = ConectarDB())
            {
                con.Open();
                try
                {
                    using (SqlCommand command = new SqlCommand(query.ToString(), con))
                    {
                        if (tipoPruebaID != 0)
                        {
                            command.Parameters.Add(new SqlParameter("@TipoPruebaID", tipoPruebaID));
                        }

                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                MQTipoPruebaDTO mqTipoPrueba = new MQTipoPruebaDTO();
                                mqTipoPrueba.ID        = Convert.ToInt32(reader[0]);
                                mqTipoPrueba.Nombre    = reader[1].ToString();
                                mqTipoPrueba.RouteKey  = reader[2].ToString();
                                mqTipoPrueba.QueueName = reader[3].ToString();
                                mqTipoPrueba.Es_Web    = Convert.ToInt32(reader[4]);
                                listaMQTipoPruebas.Add(mqTipoPrueba);
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Count not insert.");
                }
                finally
                {
                    con.Close();
                }
            }
            return(listaMQTipoPruebas);
        }
        /// <summary>
        /// Consulta una estrategia
        /// </summary>
        /// <param name="estrategiaID"></param>
        /// <returns></returns>
        public List <EstrategiaDTO> SelectEstrategia(int estrategiaID)
        {
            List <EstrategiaDTO> listEstrategias = new List <EstrategiaDTO>();
            StringBuilder        query           = new StringBuilder().Append(@"SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
                            SELECT 
                            T0.ESTRATEGIA_ID,
                            T0.NOMBRE,
                            T2.ESTADO_ID,
                            T2.NOMBRE NOMBREESTADO,
                            T1.APLICACION_ID,
                            T5.NUMERO,
                            T1.DESCRIPCION,
                            T1.ES_WEB,
                            T1.NOMBRE NOMBREAPLICACION,
                            T5.RUTA_APLICACION,
							T3.TIPOPRUEBA_ID,
							T4.NOMBRE,
							T4.MQTIPOPRUEBA_ID,
							T4.CANTIDAD_EJECUCIONES,
							T4.TIEMPO_EJECUCION,
							T4.SEMILLA,
							T4.API_CONTROLLER,
							T4.API_KEY,
							T4.PARAMETROS
                            FROM ESTRATEGIA T0 
                            INNER JOIN APLICACION T1 ON T0.APLICACION_ID=T1.APLICACION_ID
                            INNER JOIN ESTADO T2 ON T0.ESTADO_ID=T2.ESTADO_ID
							INNER JOIN APPVERSION T5 ON T5.ID=T0.APPVERSION_ID
							LEFT JOIN ESTRATEGIA_TIPOPRUEBA T3 ON T0.ESTRATEGIA_ID=T3.ESTRATEGIA_ID
							LEFT JOIN TIPOPRUEBA T4 ON T3.TIPOPRUEBA_ID=T4.TIPOPRUEBA_ID"                            );

            if (estrategiaID != 0)
            {
                query.Append(" WHERE T0.ESTRATEGIA_ID=@ESTRATEGIA_ID");
            }

            using (var con = ConectarDB())
            {
                con.Open();

                try
                {
                    using (SqlCommand command = new SqlCommand(query.ToString(), con))
                    {
                        if (estrategiaID != 0)
                        {
                            command.Parameters.Add(new SqlParameter("@ESTRATEGIA_ID", estrategiaID));
                        }

                        using (var reader = command.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                if (!listEstrategias.Exists(e => e.Estrategia_ID == Convert.ToInt32(reader[0])))
                                {
                                    EstrategiaDTO estrategia = new EstrategiaDTO();

                                    estrategia.Estrategia_ID = Convert.ToInt32(reader[0]);
                                    estrategia.Nombre        = reader[1].ToString();
                                    EstadoDTO estado = new EstadoDTO();

                                    //diccionario de estado
                                    var estadoDictionary = GetEstrategiaStatus(estrategia.Estrategia_ID);
                                    //estados
                                    estado.ID     = estadoDictionary.First().Key;
                                    estado.Nombre = estadoDictionary.First().Value;
                                    //agregar el estado
                                    estrategia.Estado = estado;

                                    AplicacionDTO aplicacion = new AplicacionDTO();
                                    aplicacion.Aplicacion_ID   = Convert.ToInt32(reader[4]);
                                    aplicacion.Version         = reader[5].ToString();
                                    aplicacion.Descripcion     = reader[6].ToString();
                                    aplicacion.Es_Web          = Convert.ToInt32(reader[7]) == 1 ? true : false;
                                    aplicacion.Nombre          = reader[8].ToString();
                                    aplicacion.Ruta_Aplicacion = reader[9].ToString();
                                    estrategia.Aplicacion      = aplicacion;
                                    listEstrategias.Add(estrategia);
                                }

                                if (!string.IsNullOrEmpty(reader[10].ToString()))
                                {
                                    TipoPruebaDTO tipoPrueba = new TipoPruebaDTO();

                                    tipoPrueba.ID     = Convert.ToInt32(reader[10]);
                                    tipoPrueba.Nombre = reader[11].ToString();
                                    tipoPrueba.CantidadEjecuciones = Convert.ToInt32(reader[13]);
                                    tipoPrueba.TiempoEjecucion     = Convert.ToDouble(reader[14]);
                                    tipoPrueba.Semilla             = string.IsNullOrEmpty(reader[15].ToString()) ? string.Empty : reader[15].ToString();
                                    tipoPrueba.ApiController       = string.IsNullOrEmpty(reader[16].ToString()) ? string.Empty : reader[16].ToString();
                                    tipoPrueba.ApiKey     = string.IsNullOrEmpty(reader[17].ToString()) ? string.Empty : reader[17].ToString();
                                    tipoPrueba.Parametros = string.IsNullOrEmpty(reader[18].ToString()) ? string.Empty : reader[18].ToString();


                                    MQTipoPruebaDTO mqTipo = new MQTipoPruebaDTO();
                                    if (!string.IsNullOrEmpty(reader[12].ToString()))
                                    {
                                        mqTipo.ID = Convert.ToInt32(reader[12]);
                                        tipoPrueba.MQTipoPrueba = mqTipo;
                                    }
                                    listEstrategias.Find(e => e.Estrategia_ID == Convert.ToInt32(reader[0])).TipoPruebas.Add(tipoPrueba);
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine("Count not insert.");
                }
                finally
                {
                    con.Close();
                }
            }
            return(listEstrategias);
        }