Exemple #1
0
 private void btnEliminarNota_Click(object sender, EventArgs e)
 {
     if (ListaMensajes.SelectedIndices.Count > 0)
     {
         using (SQLiteConnection connection = new SQLiteConnection(sCnn))
         {
             SQLiteCommand cmd = new SQLiteCommand("DELETE FROM [Notas] WHERE id=@id", connection);
             cmd.CommandType = CommandType.Text;
             try
             {
                 cmd.Parameters.AddWithValue("@id", ListaMensajes.SelectedItem.ToString().Split('-')[0]);
                 connection.Open();
                 int fa = cmd.ExecuteNonQuery();
                 //MessageBox.Show(fa.ToString());
             }
             catch (SQLiteException ex)
             {
                 MessageBox.Show(ex.Message);
             }
             finally
             {
                 connection.Close();
             }
         }
         ListaMensajes.Items.Remove(ListaMensajes.SelectedItem);
         ListaMensajes.Refresh();
         ListaMensajes.SelectedItem = null;
         tbLeerNotas.Clear();
     }
 }
Exemple #2
0
    internal static IEnumerator RecibirMensajes(TextMeshProUGUI listadoChat)
    {
        Player          player     = FindObjectOfType <Player>();
        UnityWebRequest httpClient = new UnityWebRequest(player.HttpServerAddress + "api/Chat/TodosMensajes", "GET");

        httpClient.SetRequestHeader("Authorization", "bearer " + player.Token);
        httpClient.SetRequestHeader("Accept", "application/json");
        httpClient.downloadHandler = new DownloadHandlerBuffer();

        yield return(httpClient.SendWebRequest());

        if (httpClient.isNetworkError || httpClient.isHttpError)
        {
            throw new Exception("Problemas al recibir los mensajes : " + httpClient.error);
        }
        else
        {
            string        jsonResponse = httpClient.downloadHandler.text;
            string        response     = "{\"myList\":" + jsonResponse + "}";
            ListaMensajes list         = JsonUtility.FromJson <ListaMensajes>(response);

            //Obtener la grandaria de la lista de Mensajes
            int longitud = list.mylist.Count();

            foreach (MensajeJson o in list.mylist)
            {
                string identificador = o.IdPlayer;
                identificador.Substring(1, 3);

                listadoChat.text += "\n" + identificador + " > " + o.Mensaje + " .";
            }

            httpClient.Dispose();
        }
    }
Exemple #3
0
        /// <summary>
        /// Muestra mensaje
        /// </summary>
        /// <param name="nombre"></param>
        /// <param name="mensaje"></param>
        private async void OnMessage(string nombre, string mensaje)
        {
            await Windows.ApplicationModel.Core.CoreApplication.MainView.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
            {
                clsMensaje objMensaje = new clsMensaje(); //mensaje que te envían otros usuarios
                objMensaje.name       = nombre;
                objMensaje.message    = mensaje;

                //Hago el listado con el mesaje obtenido
                //listView
                ListaMensajes.Add(objMensaje);
            });
        }
        public App()
        {
            InitializeComponent();

            MainPage = new ListaMensajes();
        }