public async void Save() { FirebaseResponse resp = await client.GetAsync("Counter/node"); Counter_Class get = resp.ResultAs <Counter_Class>(); MessageBox.Show(get.Cnt); var data = new Data { Id = (Convert.ToInt32(get.Cnt) + 1).ToString(), Nome = textBox1.Text, Pontos = Convert.ToInt32(textBox2.Text) }; SetResponse response = await client.SetAsync("Information/" + data.Id, data); Data result = response.ResultAs <Data>(); MessageBox.Show($"Pontuação do jogador '{result.Nome.ToUpper()}' salva com sucesso!"); var obj = new Counter_Class { Cnt = data.Id }; SetResponse response1 = await client.SetAsync("Counter/node", obj); btn_Gravar.Enabled = false; btn_Back.Enabled = false; }
public async void Export() { Dt.Rows.Clear(); int i = 0; FirebaseResponse Resp1 = await client.GetAsync("Counter/node"); Counter_Class obj1 = Resp1.ResultAs <Counter_Class>(); int cnt = Convert.ToInt32(obj1.Cnt); while (true) { if (i == cnt) { break; } i++; try { FirebaseResponse Resp2 = await client.GetAsync("Information/" + i); Data Obj2 = Resp2.ResultAs <Data>(); DataRow row = Dt.NewRow(); row["Id"] = Obj2.Id; row["Nome"] = Obj2.Nome; row["Pontos"] = Obj2.Pontos; Dt.Rows.Add(row); } catch {} } dgv_Rank.Sort(dgv_Rank.Columns[2], ListSortDirection.Descending); btn_Back.Visible = true; }
public async void ConnectFire() { dgv_Rank.Visible = false; client = new FireSharp.FirebaseClient(config); int l = 0; FirebaseResponse Resp2 = await client.GetAsync("Counter/node"); Counter_Class obj1 = Resp2.ResultAs <Counter_Class>(); cnt = Convert.ToInt32(obj1.Cnt); while (true) { if (l == cnt) { break; } l++; try { FirebaseResponse Resp3 = await client.GetAsync("Information/" + l); Data Obj2 = Resp3.ResultAs <Data>(); ranking.Add(Obj2); } catch {} } if (client != null) { pb_Loading.Visible = false; Export(); } Dt.Columns.Add("Id"); Dt.Columns.Add("Nome"); Dt.Columns.Add("Pontos"); dgv_Rank.DataSource = Dt; }