Esempio n. 1
0
        private async void button1_Click(object sender, EventArgs e)
        {
            FirebaseResponse resp = await client.GetTaskAsync("Counter/node");

            Counter_class get = resp.ResultAs <Counter_class>();
            MemoryStream  ms  = new MemoryStream();

            imageBox.Image.Save(ms, ImageFormat.Jpeg);
            byte[] a      = ms.GetBuffer();
            string output = Convert.ToBase64String(a);
            var    data   = new Data
            {
                Id     = (Convert.ToInt32(get.cnt) + 1).ToString(),
                Name   = textBox2.Text,
                Adress = textBox3.Text,
                Age    = textBox4.Text,
                Img    = output
            };
            SetResponse response = await client.SetTaskAsync("Information/" + data.Id, data);

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

            MessageBox.Show("Data inserted" + result.Id);
            var obj = new Counter_class
            {
                cnt = data.Id
            };
            SetResponse response1 = await client.SetTaskAsync("Counter/node", obj);
        }
Esempio n. 2
0
        private async void export()
        {
            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("Information/" + i);

                    Data    obj2 = resp2.ResultAs <Data>();
                    DataRow row  = dt.NewRow();
                    row["id"]     = obj2.Id;
                    row["name"]   = obj2.Name;
                    row["adress"] = obj2.Adress;
                    row["age"]    = obj2.Age;
                    byte[]       b  = Convert.FromBase64String(obj2.Img);
                    MemoryStream ms = new MemoryStream();
                    ms.Write(b, 0, Convert.ToInt32(b.Length));
                    Bitmap bm = new Bitmap(ms, false);
                    row["Image"] = bm;
                    dt.Rows.Add(row);
                }
                catch (Exception)
                {
                }
            }
            MessageBox.Show("Done!");
        }