Example #1
0
        public void updateStatus(AutomaticMessageModel automaticMessage, ref string resultado)
        {
            string consultaSQL =
                "update tweets set status = @status where id = @idTweet";

            try
            {
                SQLiteParameter parametroidTweet = new SQLiteParameter();
                parametroidTweet.ParameterName = "@idTweet";
                parametroidTweet.DbType        = DbType.Int32;
                parametroidTweet.Value         = Convert.ToInt32(automaticMessage.Id);

                SQLiteParameter parametroTweet = new SQLiteParameter();
                parametroTweet.ParameterName = "@status";
                parametroTweet.DbType        = DbType.Int32;
                parametroTweet.Value         = Convert.ToInt32(automaticMessage.Status);

                SQLiteCommand comandoSQL =
                    new SQLiteCommand(consultaSQL, conexionSQLite);
                comandoSQL.CommandType = CommandType.Text;
                comandoSQL.Parameters.Add(parametroidTweet);
                comandoSQL.Parameters.Add(parametroTweet);
                comandoSQL.ExecuteNonQuery();
                resultado = System.DateTime.Now + " " +
                            "Actualizado tweet automatico en BD SQLite [" +
                            Convert.ToString(automaticMessage.Id) + "]";
            }
            catch (Exception error)
            {
                resultado = System.DateTime.Now + " " +
                            "Error SQLite eliminar tweet automatico: " +
                            error.Message;
            }
        }
Example #2
0
        //insertar nuevo seguidor en BD SQLite
        public void obtenerTweetsAutomatizados(ref string resultado, ref List <AutomaticMessageModel> list, string idCuenta)
        {
            List <AutomaticMessageModel> messages = new List <AutomaticMessageModel>();
            string consultaSQL =
                "select * from tweets where state = 1 and idCuenta = @idCuenta";

            try
            {
                SQLiteParameter parametroidCuenta = new SQLiteParameter();
                parametroidCuenta.ParameterName = "@idCuenta";
                parametroidCuenta.DbType        = DbType.String;
                parametroidCuenta.Value         = Convert.ToString(idCuenta);

                SQLiteCommand comandoSQL =
                    new SQLiteCommand(consultaSQL, conexionSQLite);
                comandoSQL.CommandType = CommandType.Text;
                comandoSQL.Parameters.Add(parametroidCuenta);
                SQLiteDataReader reader = comandoSQL.ExecuteReader();
                while (reader.Read())
                {
                    AutomaticMessageModel message = new AutomaticMessageModel();
                    message.Id     = Convert.ToInt32(reader["id"]);
                    message.Tweet  = Convert.ToString(reader["tweet"]);
                    message.Status = Convert.ToInt32(reader["status"]);
                    message.Fecha  = Convert.ToDateTime(reader["fecha"]);
                    message.State  = Convert.ToInt32(reader["state"]);
                    messages.Add(message);
                }
                resultado = System.DateTime.Now + " " +
                            "Mensajes automatizados extraidos exitosamente";
                list = messages;
            }
            catch (Exception error)
            {
                resultado = System.DateTime.Now + " " +
                            "Error SQLite extraer mensajes automatizados: " +
                            error.Message;
            }
        }