Esempio n. 1
0
        private async void button5_Click(object sender, EventArgs e)
        {
            FirebaseResponse response = await client.DeleteTaskAsync("SensorA/");

            response = await client.DeleteTaskAsync("SensorB/");

            response = await client.DeleteTaskAsync("SensorC/");

            response = await client.DeleteTaskAsync("SensorD/");

            var obj = new Counter_class
            {
                cnt = "0"
            };

            SetResponse response1 = await client.SetTaskAsync("Counter/node", obj);

            response1 = await client.SetTaskAsync("CounterB/node", obj);

            response1 = await client.SetTaskAsync("CounterC/node", obj);

            response1 = await client.SetTaskAsync("CounterD/node", obj);

            MessageBox.Show("La base de datos ha regresado a sus valores por defecto");
        }
Esempio n. 2
0
        private async void Export()
        {
            Random r    = new Random();
            int    rInt = r.Next(1, 101);
            string info = "OK";

            if (rInt <= 10)
            {
                info = "Error en producción";
            }
            DateTime aDate = DateTime.Now;

            FirebaseResponse resp = await client.GetTaskAsync("CounterB/node");

            Counter_class get = resp.ResultAs <Counter_class>();

            var data = new Data
            {
                Id        = (Convert.ToInt32(get.cnt) + 1).ToString(),
                Time      = aDate.ToString("HH:mm:ss"),
                Condition = info
            };

            SetResponse response = await client.SetTaskAsync("SensorB/" + data.Id, data);

            Data result = response.ResultAs <Data>();

            var obj = new Counter_class
            {
                cnt = data.Id
            };

            SetResponse response1 = await client.SetTaskAsync("CounterB/node", obj);
        }
Esempio n. 3
0
        private async void import()
        {
            dt.Rows.Clear();
            int i = 0;
            FirebaseResponse resp1 = await client.GetTaskAsync("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.GetTaskAsync("SensorA/" + i);

                    Data obj2 = resp2.ResultAs <Data>();

                    DataRow row = dt.NewRow();
                    row["ID"]        = obj2.Id;
                    row["Tiempo"]    = obj2.Time;
                    row["Condición"] = obj2.Condition;

                    dt.Rows.Add(row);
                }
                catch
                {
                    MessageBox.Show("Error al conectar a la base de datos");
                }
            }
            // MessageBox.Show("Actualizado");
        }