Esempio n. 1
0
        public static List <Modelo.Lectura> BuscarParaCompletarGrilla(string pIdVariable, DateTime pFDesde, DateTime pFHasta)
        {
            List <Modelo.Lectura> _lista = new List <Modelo.Lectura>();
            string strSQL = "";

            strSQL = strSQL + "SELECT ";
            strSQL = strSQL + "        L.fecha_lectura ";
            strSQL = strSQL + "      , L.valor_lectura ";
            strSQL = strSQL + "FROM ";
            strSQL = strSQL + "               sensor.lecturas AS L ";
            strSQL = strSQL + "WHERE ";
            strSQL = strSQL + "         L.id_variable = '" + pIdVariable + "'";
            strSQL = strSQL + "     AND DATE_FORMAT(L.fecha_lectura, '%d/%m/%Y %H:%i:%S') BETWEEN '" + pFDesde + "' AND '" + pFHasta + "'";
            MySqlConnection MyConn = new MySqlConnection();

            MyConn = DbConexion.ObtenerConexion();
            MySqlCommand _comando = new MySqlCommand(String.Format(strSQL), MyConn);

            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                Modelo.Lectura pLectura = new Modelo.Lectura();
                pLectura.Fecha_Lectura = _reader.GetDateTime(0);
                pLectura.Valor_Lectura = _reader.GetString(1);

                _lista.Add(pLectura);
            }

            MyConn.Close();

            return(_lista);
        }
Esempio n. 2
0
        private void EnvioEmailNotificacionAlerta(Modelo.Lectura oL, string pSin_Conexion_Equipo, string pTipo_Estado)
        {
            foreach (Modelo.Usuario oUsuario in Controlador.UsuariosDAL.BuscarPorConexion(oL.Id_Conexion))
            {
                oSender.mMailTo = oUsuario.Email;
                string e_mail      = "";
                string msjs_pedido = "";
                e_mail      = "<p> Estimado,     </p><p></p>";
                msjs_pedido = msjs_pedido + "<p> Informamos que el Equipo <strong>" + oL.Nombre_Equipo + "</strong> con Ubicación <strong>" + oL.Nombre_Ubicacion + "</strong> para la Conexión <strong>" + oL.Nombre_Conexion + "</strong>";
                switch (pSin_Conexion_Equipo)
                {
                case "CONECTADO":     //Este caso seria cuando hay una alerta, y el equipo esta conectado
                    switch (pTipo_Estado)
                    {
                    case "NORMAL":
                        oSender.mSubject = "Restablecida Medicion Sensor Control";
                        msjs_pedido      = msjs_pedido + " desactivo una alerta para la variable <strong>" + oL.Nombre_Variable + "</strong>.</p>";
                        msjs_pedido      = msjs_pedido + "<p> Valor según medición: <strong>" + oL.Valor_Lectura + " " + oL.Unidad_Variable + "</strong>.</p>";
                        msjs_pedido      = msjs_pedido + "<p> Valor sugerido: <strong>" + oL.Operador_Alerta_Variable + " " + oL.Alerta_Variable + oL.Unidad_Variable + "</strong>.</p>";
                        ActualizarAlertaNotificacion(oL, oUsuario, pSin_Conexion_Equipo, pTipo_Estado);
                        break;

                    case "FALLA":
                        oSender.mSubject = "Alerta Medicion Sensor Control";
                        msjs_pedido      = msjs_pedido + " presento una alerta para la variable <strong>" + oL.Nombre_Variable + "</strong> al no cumplir con lo establecido.</p>";
                        msjs_pedido      = msjs_pedido + "<p> Valor según medición: <strong>" + oL.Valor_Lectura + " " + oL.Unidad_Variable + "</strong>.</p>";
                        msjs_pedido      = msjs_pedido + "<p> Valor sugerido: <strong>" + oL.Operador_Alerta_Variable + " " + oL.Alerta_Variable + oL.Unidad_Variable + "</strong>.</p>";

                        ActualizarAlertaNotificacion(oL, oUsuario, pSin_Conexion_Equipo, pTipo_Estado);
                        break;
                    }
                    break;

                case "DESCONECTADO":     //Este caso seria cuando el equipo esta desconectado
                    oSender.mSubject = "Desconexion Sensor Control";
                    msjs_pedido      = msjs_pedido + " no esté conectado en este momento, por lo tanto no reporta eventos. Favor de corroborar que su equipo esté conectado correctamente.</p>";

                    ActualizarAlertaNotificacion(oL, oUsuario, pSin_Conexion_Equipo, pTipo_Estado);
                    break;

                case "RECONECTADO":     //Este caso seria cuando el equipo estaba desconectado y se volvio a conectar
                    oSender.mSubject = "Reconectado Sensor Control";
                    msjs_pedido      = msjs_pedido + " está nuevamente conectado.</p>";

                    ActualizarAlertaNotificacion(oL, oUsuario, pSin_Conexion_Equipo, pTipo_Estado);
                    break;
                }
                e_mail          = e_mail + "</ul>" + msjs_pedido + "</ul>";
                e_mail          = e_mail + "<p></p><p>          Muchas gracias.     </p>";
                e_mail          = e_mail + "<p></p><p> Saludos,     </p>";
                oSender.mMsg    = e_mail;
                oSender.redOSDE = redOSDE;
                oSender.Envio();
            }
        }
Esempio n. 3
0
        public static List <Modelo.Lectura> RecuperarUltimaNotificacionEnviada()
        {
            List <Modelo.Lectura> _lista = new List <Modelo.Lectura>();
            string strSQL = @"
            SELECT 
                    L.id_lectura
                  , L.fecha_lectura
                  , E.id_equipo
                  , E.id_conexion
                  , E.Sin_Conexion_Equipo
                  , subV.alerta_variable
                  , subV.operador_alerta_variable
                  , subV.id_variable
                  , E.nombre_equipo 
                  , U.nombre_ubicacion
                  , C.nombre_conexion
                  , subV.nombre_variable
            FROM         sensor.lecturas AS L 
                INNER JOIN 
                        (SELECT  MAX(L.id_lectura) AS id_lectura, V.id_equipo FROM lecturas AS L INNER JOIN sensor.variables AS V ON L.id_variable = V.id_variable GROUP BY V.id_equipo) AS subSQL ON L.id_lectura = subSQL.id_lectura
            INNER JOIN equipos AS E ON subSQL.id_equipo = E.id_equipo
            INNER JOIN ubicaciones AS U ON E.id_ubicacion = U.id_ubicacion
            INNER JOIN conexiones AS C ON E.id_conexion = C.id_conexion
            INNER JOIN (SELECT id_variable, alerta_variable, operador_alerta_variable, id_equipo, nombre_variable FROM sensor.variables AS V WHERE es_fecha = 1 AND estado_variable = 0) AS subV ON subSQL.id_equipo = subV.id_equipo
            ";

            MySqlConnection MyConn   = DbConexion.ObtenerConexion();
            MySqlCommand    _comando = new MySqlCommand(strSQL, MyConn);

            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                Modelo.Lectura pLectura = new Modelo.Lectura();
                pLectura.Id_Lectura               = _reader.GetInt32(0);
                pLectura.Fecha_Lectura            = _reader.GetDateTime(1);
                pLectura.Id_Equipo                = _reader.GetString(2);
                pLectura.Id_Conexion              = _reader.GetInt32(3);
                pLectura.Sin_Conexion_Equipo      = _reader.GetBoolean(4);
                pLectura.Alerta_Variable          = _reader.GetString(5);
                pLectura.Operador_Alerta_Variable = _reader.GetString(6);
                pLectura.Id_Variable              = _reader.GetString(7);
                pLectura.Nombre_Equipo            = _reader.GetString(8);
                pLectura.Nombre_Ubicacion         = _reader.GetString(9);
                pLectura.Nombre_Conexion          = _reader.GetString(10);
                pLectura.Nombre_Variable          = _reader.GetString(11);

                _lista.Add(pLectura);
            }

            MyConn.Close();

            return(_lista);
        }
Esempio n. 4
0
        public static int AnalizadadLecturaTrue(Modelo.Lectura pL)
        {
            int    retorno = 0;
            string strSQL  = "";

            strSQL = strSQL + " UPDATE Lecturas SET ";
            strSQL = strSQL + "                Analizada_Lectura = 1";
            strSQL = strSQL + " WHERE Id_Variable = '" + pL.Id_Variable + "' AND Id_Lectura <= " + pL.Id_Lectura;
            MySqlConnection MyConn = new MySqlConnection();

            MyConn = DbConexion.ObtenerConexion();
            MySqlCommand _comando = new MySqlCommand(String.Format(strSQL), MyConn);

            retorno = _comando.ExecuteNonQuery();

            MyConn.Close();

            return(retorno);
        }
Esempio n. 5
0
        private void ChequearDatos()
        {
            try
            {
                decimal dcmValorLectura;
                decimal dcmAlertaVariable = 0;
                foreach (Modelo.Lectura oLectura in Controlador.LecturasDAL.RecuperarUltimasLecturas())
                {
                    dcmValorLectura = Convert.ToDecimal(oLectura.Valor_Lectura.Replace(".", ","));
                    if (!System.String.IsNullOrEmpty(oLectura.Alerta_Variable))
                    {
                        dcmAlertaVariable = Convert.ToDecimal(oLectura.Alerta_Variable.Replace(".", ","));
                    }
                    if (!oLectura.Analizada_Lectura)
                    {
                        switch (oLectura.Operador_Alerta_Variable)
                        {
                        case ">":
                            if (dcmValorLectura > dcmAlertaVariable)
                            {                                    //Hay una alerta
                                if (!oLectura.Alerta_Notificada) //no esta notificada y debo hacerlo
                                {
                                    EnvioEmailNotificacionAlerta(oLectura, "CONECTADO", "FALLA");
                                }
                            }
                            else
                            {                                                                      //No hay alerta, volvio a la normalidad
                                if (oLectura.Alerta_Notificada)                                    //Si es TRUE significa que se notifico cuando ocurrio la alerta y ahora que esta normal, lo saco de alerta
                                {
                                    EnvioEmailNotificacionAlerta(oLectura, "CONECTADO", "NORMAL"); //ActualizarAlertaNotificacion(oLectura, false, "", "", "", false);
                                }
                            }
                            break;

                        case ">=":
                            if (dcmValorLectura >= dcmAlertaVariable)
                            {
                                if (!oLectura.Alerta_Notificada)
                                {
                                    EnvioEmailNotificacionAlerta(oLectura, "CONECTADO", "FALLA");
                                }
                            }
                            else
                            {
                                if (oLectura.Alerta_Notificada)
                                {
                                    EnvioEmailNotificacionAlerta(oLectura, "CONECTADO", "NORMAL");     //ActualizarAlertaNotificacion(oLectura, false, "", "", "", false);
                                }
                            }
                            break;

                        case "<":
                            if (dcmValorLectura < dcmAlertaVariable)
                            {
                                if (!oLectura.Alerta_Notificada)
                                {
                                    EnvioEmailNotificacionAlerta(oLectura, "CONECTADO", "FALLA");
                                }
                            }
                            else
                            {
                                if (oLectura.Alerta_Notificada)
                                {
                                    EnvioEmailNotificacionAlerta(oLectura, "CONECTADO", "NORMAL");     //ActualizarAlertaNotificacion(oLectura, false, "", "", "", false);
                                }
                            }
                            break;

                        case "<=":
                            if (dcmValorLectura <= dcmAlertaVariable)
                            {
                                if (!oLectura.Alerta_Notificada)
                                {
                                    EnvioEmailNotificacionAlerta(oLectura, "CONECTADO", "FALLA");
                                }
                            }
                            else
                            {
                                if (oLectura.Alerta_Notificada)
                                {
                                    EnvioEmailNotificacionAlerta(oLectura, "CONECTADO", "NORMAL");     //ActualizarAlertaNotificacion(oLectura, false, "", "", "", false);
                                }
                            }
                            break;
                            //default:
                            //    Console.WriteLine("Default case");
                            //    break;
                        }
                        int            resultado;
                        Modelo.Lectura pLectura = new Modelo.Lectura();
                        pLectura.Id_Lectura  = oLectura.Id_Lectura;
                        pLectura.Id_Variable = oLectura.Id_Variable;
                        resultado            = Controlador.LecturasDAL.AnalizadadLecturaTrue(pLectura);
                    }
                }
            }
            catch (Exception ex)
            {
                oLog.LogToFile(ex.ToString());
                //MessageBox.Show(ex.ToString());
            }
        }
Esempio n. 6
0
        private void ActualizarAlertaNotificacion(Modelo.Lectura oL, Modelo.Usuario oU, string pSin_Conexion_Equipo, string pTipo_Estado)
        {
            int resultado;

            Modelo.Notificacion pNotificacion = new Modelo.Notificacion();
            Modelo.Variable     pVariable     = new Modelo.Variable();
            Modelo.Equipo       pEquipo       = new Modelo.Equipo();
            switch (pSin_Conexion_Equipo)
            {
            case "CONECTADO":
                switch (pTipo_Estado)
                {
                case "NORMAL":         //Volvio a estar OK la variable, saco la NOTIFICACION, pongo en FALSE, de la VARIABLE
                    pVariable.Id_Variable = oL.Id_Variable;
                    resultado             = Controlador.VariablesDAL.ModificarAlertaNotificada(pVariable);

                    pVariable.Alerta_Notificada = false;
                    pVariable.Id_Variable       = oL.Id_Variable;
                    resultado = Controlador.VariablesDAL.ModificarAlertaNotificada(pVariable);

                    pNotificacion.Alerta_Notificada = false.ToString();
                    break;

                case "FALLA":         //Aca presento la falla en una variable, pongo la NOTIFICACION en TRUE de la VARIABLE
                    pVariable.Id_Variable = oL.Id_Variable;
                    resultado             = Controlador.VariablesDAL.ModificarAlertaNotificada(pVariable);

                    pVariable.Alerta_Notificada = true;
                    pVariable.Id_Variable       = oL.Id_Variable;
                    resultado = Controlador.VariablesDAL.ModificarAlertaNotificada(pVariable);

                    pNotificacion.Alerta_Notificada = true.ToString();
                    break;
                }
                pNotificacion.Valor_Leido = oL.Valor_Lectura;
                break;

            case "DESCONECTADO":     //Este caso seria cuando el equipo esta desconectado

                pVariable.Alerta_Notificada = true;
                pVariable.Id_Variable       = oL.Id_Variable;
                resultado = Controlador.VariablesDAL.ModificarAlertaNotificada(pVariable);

                pNotificacion.Valor_Leido       = dcmValorLectura.ToString();
                pNotificacion.Alerta_Notificada = true.ToString();

                pEquipo.Sin_Conexion_Equipo = true;
                pEquipo.Id_Equipo           = oL.Id_Equipo;
                resultado = Controlador.EquiposDAL.ModificarSinConexion(pEquipo);
                break;

            case "RECONECTADO":     //Este caso seria cuando el equipo estaba desconectado y se volvio a conectar

                pVariable.Alerta_Notificada = false;
                pVariable.Id_Variable       = oL.Id_Variable;
                resultado = Controlador.VariablesDAL.ModificarAlertaNotificada(pVariable);

                pNotificacion.Valor_Leido       = dcmValorLectura.ToString();
                pNotificacion.Alerta_Notificada = false.ToString();

                pEquipo.Sin_Conexion_Equipo = false;
                pEquipo.Id_Equipo           = oL.Id_Equipo;
                resultado = Controlador.EquiposDAL.ModificarSinConexion(pEquipo);
                break;
            }
            pNotificacion.Id_Variable       = oL.Id_Variable;
            pNotificacion.Nombre_Variable   = oL.Nombre_Variable;
            pNotificacion.Valor_Variable    = oL.Alerta_Variable;
            pNotificacion.Operador_Variable = oL.Operador_Alerta_Variable;

            pNotificacion.Email_Notificacion = oU.Email;
            pNotificacion.Id_Conexion        = oL.Id_Conexion.ToString();
            pNotificacion.Nombre_Conexion    = oL.Nombre_Conexion;
            pNotificacion.Id_Usuario         = oU.Login;
            pNotificacion.Nombre_Usuario     = oU.Name;
            pNotificacion.Id_Equipo          = oL.Id_Equipo;
            pNotificacion.Nombre_Equipo      = oL.Nombre_Equipo;
            resultado = Controlador.NotificacionesDAL.Agregar(pNotificacion);
        }
Esempio n. 7
0
        public static List <Modelo.Lectura> Buscar(int pIdEstado)
        {
            List <Modelo.Lectura> _lista = new List <Modelo.Lectura>();
            string strSQL = "";

            strSQL = strSQL + "SELECT ";
            strSQL = strSQL + "      L.id_lectura ";
            strSQL = strSQL + "      , L.fecha_lectura";
            strSQL = strSQL + "      , L.valor_lectura ";
            strSQL = strSQL + "      , L.id_variable ";
            strSQL = strSQL + "      , L.analizada_lectura ";
            strSQL = strSQL + "      , V.nombre_variable ";
            strSQL = strSQL + "      , V.unidad_variable ";
            strSQL = strSQL + "      , IFNULL(V.alerta_variable, '') AS alerta_variable ";
            strSQL = strSQL + "      , IFNULL((V.operador_alerta_variable, '') AS operador_alerta_variable ";
            strSQL = strSQL + "      , V.id_equipo ";
            strSQL = strSQL + "      , E.nombre_equipo ";
            strSQL = strSQL + "      , E.id_ubicacion ";
            strSQL = strSQL + "      , U.nombre_ubicacion ";
            strSQL = strSQL + "      , E.id_conexion ";
            strSQL = strSQL + "      , C.nombre_conexion ";
            strSQL = strSQL + "FROM ";
            strSQL = strSQL + "               sensor.lecturas AS L ";
            strSQL = strSQL + "    INNER JOIN sensor.variables AS V ";
            strSQL = strSQL + "                                    ON(L.id_variable = V.id_variable) ";
            strSQL = strSQL + "    INNER JOIN sensor.equipos AS E ";
            strSQL = strSQL + "                                    ON(V.id_equipo = E.id_equipo) ";
            strSQL = strSQL + "    INNER JOIN sensor.ubicaciones AS U ";
            strSQL = strSQL + "                                    ON(E.id_ubicacion = U.id_ubicacion) ";
            strSQL = strSQL + "    INNER JOIN sensor.conexiones AS C ";
            strSQL = strSQL + "                                    ON(E.id_conexion = C.id_conexion) ";
            strSQL = strSQL + "WHERE ";
            strSQL = strSQL + "     L.analizada_lectura = " + pIdEstado;
            MySqlConnection MyConn = new MySqlConnection();

            MyConn = DbConexion.ObtenerConexion();
            MySqlCommand _comando = new MySqlCommand(String.Format(strSQL), MyConn);

            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                Modelo.Lectura pLectura = new Modelo.Lectura();
                pLectura.Id_Lectura               = _reader.GetInt32(0);
                pLectura.Fecha_Lectura            = _reader.GetDateTime(1);
                pLectura.Valor_Lectura            = _reader.GetString(2);
                pLectura.Id_Variable              = _reader.GetString(3);
                pLectura.Analizada_Lectura        = _reader.GetBoolean(4);
                pLectura.Nombre_Variable          = _reader.GetString(5);
                pLectura.Unidad_Variable          = _reader.GetString(6);
                pLectura.Alerta_Variable          = _reader.GetString(7);
                pLectura.Operador_Alerta_Variable = _reader.GetString(8);
                pLectura.Id_Equipo        = _reader.GetString(9);
                pLectura.Nombre_Equipo    = _reader.GetString(10);
                pLectura.Id_Ubicacion     = _reader.GetInt32(11);
                pLectura.Nombre_Ubicacion = _reader.GetString(12);
                pLectura.Id_Conexion      = _reader.GetInt32(13);
                pLectura.Nombre_Conexion  = _reader.GetString(14);

                _lista.Add(pLectura);
            }

            MyConn.Close();

            return(_lista);
        }
Esempio n. 8
0
        public static List <Modelo.Lectura> RecuperarUltimasLecturas()
        {
            List <Modelo.Lectura> _lista = new List <Modelo.Lectura>();
            string strSQL = @"
            SELECT 
                    L.id_lectura 
                  , L.fecha_lectura
                  , L.valor_lectura 
                  , L.id_variable 
                  , L.analizada_lectura 
                  , V.nombre_variable 
                  , V.unidad_variable 
                  , IFNULL(V.alerta_variable, '') AS alerta_variable 
                  ,  IFNULL(V.operador_alerta_variable, '') AS operador_alerta_variable 
                  , V.id_equipo 
                  , E.nombre_equipo 
                  , E.id_ubicacion 
                  , U.nombre_ubicacion 
                  , E.id_conexion 
                  , C.nombre_conexion 
                  , V.Alerta_Notificada 
                  , E.Sin_Conexion_Equipo 
            FROM sensor.lecturas AS L 
            INNER JOIN sensor.variables AS V 
                ON(L.id_variable = V.id_variable) 
            INNER JOIN sensor.equipos AS E 
                ON(V.id_equipo = E.id_equipo) 
            INNER JOIN sensor.ubicaciones AS U 
                ON(E.id_ubicacion = U.id_ubicacion) 
            INNER JOIN sensor.conexiones AS C 
                ON(E.id_conexion = C.id_conexion)
            INNER JOIN (SELECT  MAX(L.id_lectura) AS id_lectura, L.id_variable FROM lecturas AS L GROUP BY L.id_variable) AS sql_ 
                ON sql_.id_lectura = L.id_lectura 
            WHERE V.estado_variable = 0
            ORDER BY V.Id_Equipo
            ";

            MySqlConnection MyConn   = DbConexion.ObtenerConexion();
            MySqlCommand    _comando = new MySqlCommand(strSQL, MyConn);

            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                Modelo.Lectura pLectura = new Modelo.Lectura();
                pLectura.Id_Lectura               = _reader.GetInt32(0);
                pLectura.Fecha_Lectura            = _reader.GetDateTime(1);
                pLectura.Valor_Lectura            = _reader.GetString(2);
                pLectura.Id_Variable              = _reader.GetString(3);
                pLectura.Analizada_Lectura        = _reader.GetBoolean(4);
                pLectura.Nombre_Variable          = _reader.GetString(5);
                pLectura.Unidad_Variable          = _reader.GetString(6);
                pLectura.Alerta_Variable          = _reader.GetString(7);
                pLectura.Operador_Alerta_Variable = _reader.GetString(8);
                pLectura.Id_Equipo           = _reader.GetString(9);
                pLectura.Nombre_Equipo       = _reader.GetString(10);
                pLectura.Id_Ubicacion        = _reader.GetInt32(11);
                pLectura.Nombre_Ubicacion    = _reader.GetString(12);
                pLectura.Id_Conexion         = _reader.GetInt32(13);
                pLectura.Nombre_Conexion     = _reader.GetString(14);
                pLectura.Alerta_Notificada   = _reader.GetBoolean(15);
                pLectura.Sin_Conexion_Equipo = _reader.GetBoolean(16);

                _lista.Add(pLectura);
            }

            MyConn.Close();

            return(_lista);
        }
Esempio n. 9
0
        public static List <Modelo.Lectura> ValoresMinimos_y_Maximos(string pIdVariable, DateTime pFDesde, DateTime pFHasta)
        {
            List <Modelo.Lectura> _lista = new List <Modelo.Lectura>();
            string          strSQL       = @"
            SELECT 
                    L.fecha_lectura
                  , MAX(L.valor_lectura) AS valor_maximo       
                  , MIN(L.valor_lectura) AS valor_minimo
                  , L.id_variable 
                  , V.nombre_variable 
                  , V.unidad_variable 
                  , V.id_equipo 
                  , E.nombre_equipo 
                  , E.id_ubicacion 
                  , U.nombre_ubicacion 
                  , E.id_conexion 
                  , C.nombre_conexion 
            FROM sensor.lecturas AS L 
            INNER JOIN sensor.variables AS V 
                ON(L.id_variable = V.id_variable) 
            INNER JOIN sensor.equipos AS E 
                ON(V.id_equipo = E.id_equipo) 
            INNER JOIN sensor.ubicaciones AS U 
                ON(E.id_ubicacion = U.id_ubicacion) 
            INNER JOIN sensor.conexiones AS C 
                ON(E.id_conexion = C.id_conexion)
            WHERE V.id_variable = @id_variable
                AND L.fecha_lectura BETWEEN @fecha_desde AND @fecha_hasta
            GROUP BY DATE_FORMAT(L.fecha_lectura, '%d/%m/%Y')
            ORDER BY L.fecha_lectura DESC
            ";
            MySqlConnection MyConn       = DbConexion.ObtenerConexion();
            MySqlCommand    _comando     = new MySqlCommand(strSQL, MyConn);

            _comando.Parameters.AddWithValue("@id_variable", pIdVariable);
            _comando.Parameters.AddWithValue("@fecha_desde", pFDesde);
            _comando.Parameters.AddWithValue("@fecha_hasta", pFHasta);

            MySqlDataReader _reader = _comando.ExecuteReader();

            while (_reader.Read())
            {
                Modelo.Lectura pLectura = new Modelo.Lectura();
                pLectura.Fecha_Lectura    = _reader.GetDateTime(0);
                pLectura.Valor_Maximo     = _reader.GetString(1);
                pLectura.Valor_Minimo     = _reader.GetString(2);
                pLectura.Id_Variable      = _reader.GetString(3);
                pLectura.Nombre_Variable  = _reader.GetString(4);
                pLectura.Unidad_Variable  = _reader.GetString(5);
                pLectura.Id_Equipo        = _reader.GetString(6);
                pLectura.Nombre_Equipo    = _reader.GetString(7);
                pLectura.Id_Ubicacion     = _reader.GetInt32(8);
                pLectura.Nombre_Ubicacion = _reader.GetString(9);
                pLectura.Id_Conexion      = _reader.GetInt32(10);
                pLectura.Nombre_Conexion  = _reader.GetString(11);

                _lista.Add(pLectura);
            }

            MyConn.Close();

            return(_lista);
        }