private async void Timer1_Tick(object sender, EventArgs e) { FirebaseResponse response = await client.GetAsync("/Respostas"); RespostaClass resposta = response.ResultAs <RespostaClass>(); FirebaseResponse responseI = await client.GetAsync("/Indexes/"); IndexesClass indexes = responseI.ResultAs <IndexesClass>(); if (resposta.Pot) { string index = (indexes.Pot).ToString(); FirebaseResponse responseP = await client.GetAsync("/Sensores/Pot/" + index); DataClass data = responseP.ResultAs <DataClass>(); lbDataPot.Text = data.Data; lbHoraPot.Text = data.Hora; lbValorPot.Text = data.Valor; resposta.LDR = false; resposta.Pot = false; FirebaseResponse resposeRR = await client.SetAsync("/Respostas", resposta); } if (resposta.LDR) { string index = (indexes.LDR).ToString(); FirebaseResponse responseD = await client.GetAsync("/Sensores/LDR/" + index); DataClass data = responseD.ResultAs <DataClass>(); lbDataLdr.Text = data.Data; lbHoraLdr.Text = data.Hora; lbValorLdr.Text = data.Valor; resposta.LDR = false; resposta.Pot = false; FirebaseResponse resposeRR = await client.SetAsync("/Respostas", resposta); } }
private async void MainForm_Load(object sender, EventArgs e) { client = new FireSharp.FirebaseClient(config); if (client != null) { MessageBox.Show("Conectado ao Servidor Firebase", "Sucesso", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("Erro ao conectar-se ao servidor,\n tente novamente mais tarde!", "Erro", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Application.Exit(); } var resposta = new RespostaClass { LDR = false, Pot = false }; FirebaseResponse response = await client.SetAsync("/Respostas/", resposta); timer1.Enabled = true; }