コード例 #1
0
        public static List <Modelo.Notificacion> ValoresMinimos_y_Maximos(string pIdVariable, DateTime pFDesde, DateTime pFHasta)
        {
            List <Modelo.Notificacion> _lista = new List <Modelo.Notificacion>();
            string strSQL = "";

            strSQL = strSQL + "SELECT ";
            strSQL = strSQL + "        DATE_FORMAT(N.fecha_notificacion, '%d/%m/%Y') AS fecha_notificacion ";
            strSQL = strSQL + "      , COUNT(CASE alerta_notificada WHEN 'True' THEN 1 END) AS count_true,  ";
            strSQL = strSQL + "      , COUNT(CASE alerta_notificada WHEN 'False' THEN 1 END) AS count_false,  ";
            strSQL = strSQL + "FROM ";
            strSQL = strSQL + "               Notificaciones AS N ";
            strSQL = strSQL + "WHERE ";
            strSQL = strSQL + "         N.id_variable = '" + pIdVariable + "'";
            strSQL = strSQL + "     AND DATE_FORMAT(N.fecha_notificacion, '%d/%m/%Y') 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.Notificacion pNotificacion = new Modelo.Notificacion();
                pNotificacion.Fecha_Notificacion = _reader.GetString(0);
                pNotificacion.Count_True         = _reader.GetInt32(1);
                pNotificacion.Count_False        = _reader.GetInt32(2);

                _lista.Add(pNotificacion);
            }

            MyConn.Close();

            return(_lista);
        }
コード例 #2
0
        public static int Agregar(Modelo.Notificacion pN)
        {
            int    retorno = 0;
            string strSQL  = "";

            strSQL = strSQL + " INSERT INTO Notificaciones ";
            strSQL = strSQL + " (Id_Variable, Nombre_Variable, Email_Notificado, Id_Conexion, Nombre_Conexion, Id_Usuario, Nombre_Usuario, Id_Equipo, Nombre_Equipo, Alerta_Notificada, Valor_Variable, Operador_Variable, Valor_Leido, version_sistema ";
            strSQL = strSQL + " ) VALUES ";
            strSQL = strSQL + "('" + pN.Id_Variable + "', '" + pN.Nombre_Variable + "', '" + pN.Email_Notificacion + "', '" + pN.Id_Conexion + "', '" + pN.Nombre_Conexion + "', '" + pN.Id_Usuario + "', '" + pN.Nombre_Usuario + "', '" + pN.Id_Equipo + "', '" + pN.Nombre_Equipo + "', '" + pN.Alerta_Notificada + "', '" + pN.Valor_Variable + "', '" + pN.Operador_Variable + "', '" + pN.Valor_Leido + "', '" + Application.ProductVersion + "' ";
            strSQL = strSQL + " )";
            MySqlConnection MyConn = new MySqlConnection();

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

            retorno = _comando.ExecuteNonQuery();

            MyConn.Close();

            return(retorno);
        }
コード例 #3
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);
        }