Exemple #1
0
        public async void OnChangeGetAsync()
        {
            var expected = new Todo {
                name = "Execute PUSH4GET1", priority = 2
            };
            var changes  = 0;
            var observer = _client.OnChangeGetAsync <Todo>("fakepath/OnGetAsync/", (events, arg) =>
            {
                Interlocked.Increment(ref changes);
                Assert.NotNull(arg);
                Assert.AreEqual(expected.name, arg.name);
            });

            await _client.SetAsync("fakepath/OnGetAsync/", expected);

            await Task.Delay(2000);

            await _client.SetAsync("fakepath/OnGetAsync", new Todo { name = "PUSH4GET1", priority = 2 });

            await Task.Delay(2000);

            try
            {
                if (changes == 3)
                {
                    Assert.Inconclusive();
                }

                Assert.AreEqual(2, changes);
            }
            finally
            {
                observer.Result.Cancel();
            }
        }
Exemple #2
0
        //Funtiile de adaugare in baza de date pentru fiecare tabel in parte
        public async Task addProdusAsync(Produs produs)
        {
            //Se ia numarul de id-uri din baza de date
            FirebaseResponse idResponse = await client.GetAsync("Counter/ProdCNT");

            Counter get = idResponse.ResultAs <Counter>();

            get.nr    = get.nr + 1;
            nrProduse = get.nr;
            //Se face update in baza de date la numarul de produse adaugate
            FirebaseResponse updateId = await client.UpdateAsync("Counter/ProdCNT", get);


            //Se introduce produsul cu id-ul sau
            var data = new Data
            {
                Id       = get.nr,
                Denumire = produs.Denumire,
                Pret     = produs.Pret,
                Gramaj   = produs.Gramaj,
                Retetar  = produs.Retetar
            };
            SetResponse response = await client.SetAsync("Produse/" + get.nr.ToString(), data);

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

            //listaProduse();
        }
Exemple #3
0
        // insert water
        public async Task <bool> InsertWaterInfor(
            string pagramElectric,
            string pagramWater,
            string pagramMotobikeNumber,
            string pagramMotobike,
            string years,
            string month,
            string room
            )
        {
            var data = new DIENNUOC
            {
                SO_DIEN            = pagramElectric,
                SO_NUOC            = pagramWater,
                SO_XE_SO_KHACH     = pagramMotobikeNumber,
                SO_XE_TAY_GA_KHACH = pagramMotobike
            };

            return(await Task.Run(async() => {
                setResponse = await client.SetAsync("diennuoc/" + years + "/" + month + "/" + room + "/", data);
                if (setResponse.Body != "null")
                {
                    return true;
                }
                return false;
            }));
        }
Exemple #4
0
        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;
        }
Exemple #5
0
        private async void button_insert_Click(object sender, EventArgs e)
        {
            FirebaseResponse responseDatabase = await client.GetAsync("Counter/node");

            CounterClass getCount = responseDatabase.ResultAs <CounterClass>();

            //MessageBox.Show(getCount.Count);

            var data = new Data
            {
                //Id = textBoxID.Text,

                Id      = (Convert.ToInt32(getCount.Count) + 1).ToString(),
                Name    = textBoxName.Text,
                Address = textBoxAddress.Text,
                Age     = textBoxAge.Text
            };

            SetResponse response = await client.SetAsync("Datanya/" + data.Id, data);

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

            MessageBox.Show("Data Inserted " + result.Id);

            var objectCount = new CounterClass
            {
                Count = data.Id
            };

            SetResponse responseCounter = await client.SetAsync("Counter/node", objectCount);

            clearTextBox();
        }
        public async void AddNewDevices(AccountModel data)
        {
            try {
                ButtonEnable = "False";
                string username = data.Email.Substring(0, data.Email.IndexOf("@"));
                data.Email = data.Email.Trim().ToLower();
                FirebaseResponse check = await client.GetAsync("/Account/" + username + "/Tiles/");

                List <TilesModel> tiles = check.ResultAs <List <TilesModel> >() ?? new List <TilesModel>();
                if (tiles.Count > 0)
                {
                    tiles.Add(this.newTiles);
                    FirebaseResponse clearResponse = await client.DeleteAsync("/Account/" + username + "/Tiles");

                    FirebaseResponse response = await client.SetAsync <List <TilesModel> >("/Account/" + username + "/Tiles/", tiles);

                    List <TilesModel> result = response.ResultAs <List <TilesModel> >();
                }
                else
                {
                    List <TilesModel> Newtiles = new List <TilesModel>();
                    Newtiles.Add(this.newTiles);
                    SetResponse response = await client.SetAsync <List <TilesModel> >("/Account/" + username + "/Tiles/", Newtiles);
                }
            } catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }
            ButtonEnable = "True";
        }
 public async Task ExportDGToFB(List <LoadDTO> loadList)
 {
     if (loadList != null)
     {
         await client.SetAsync("TeachersLoad/", loadList);
     }
     MessageBox.Show("Данные в Базу данных были загружены");
 }
Exemple #8
0
        public async void InsertPatientMember(Patient patient)
        {
            SetResponse response = await client.SetAsync("Patient/" + patient.id, patient);

            var result = response.ResultAs <Patient>();

            Console.WriteLine("Successfully saved");
        }
        public async Task <Wallet> AddWalletAsync(string userPublicKey, Wallet walletItem)
        {
            var response = await _client.SetAsync($"wallets/{userPublicKey}", walletItem);

            var result = response.ResultAs <Wallet>();

            return(result);
        }
        protected async void Register_Click(object sender, EventArgs e)
        {
            FirebaseResponse respo = await client.GetAsync("counter");

            Counter_class get   = respo.ResultAs <Counter_class>();
            string        cn    = (Convert.ToInt32(get.cnt) + 1).ToString();
            var           truck = new Data
            {
                TruckName      = TruckName.Text,
                CarType        = carname.Text,
                Phone          = phone.Text,
                Address        = address.Text,
                Username       = username.Text,
                Password       = this.Encrypt(pass.Text.Trim()),
                Retypepassword = this.Encrypt(repass.Text.Trim()),
                RegisterType   = "Truck",
                Date           = date.Text,
                RegisterState  = "قيد المراجعة"
            };

            SetResponse response = await client.SetAsync("user/" + cn, truck);

            Data result = response.ResultAs <Data>();
            var  obj    = new Counter_class
            {
                cnt = cn,
            };
            SetResponse response1 = await client.SetAsync("counter", obj);


            string smtpAddress = "smtp.live.com";
            int    portNumber  = 587;
            bool   enableSSL   = true;

            string emailFrom     = "*****@*****.**";
            string emailPassword = "******";
            string emailTo       = "*****@*****.**";
            string subject       = "Truck Information";
            string body          = "الإسم الثلاثي:" + TruckName.Text + "\n نوع الشاحنه: " + carname.Text + "\n الهاتف:" + phone.Text + "\n الموقع:" + address.Text + "اسم المستخدم\n:" + username.Text + "\n كلمة المرور:" + Encrypt(pass.Text.Trim()) + "\n تأكيد كلمة المرور:" + Encrypt(repass.Text.Trim());

            using (MailMessage Forget = new MailMessage())
            {
                Forget.From = new MailAddress(emailFrom);
                Forget.To.Add(emailTo);
                Forget.Subject    = subject;
                Forget.Body       = body;
                Forget.IsBodyHtml = false;
                using (SmtpClient smtp = new SmtpClient(smtpAddress, portNumber))
                {
                    smtp.Credentials = new NetworkCredential(emailFrom, emailPassword);
                    smtp.EnableSsl   = enableSSL;
                    smtp.Send(Forget);
                    Response.Redirect("Dialog3.aspx");
                }
            }
            // Response.Redirect("Dialog3.aspx");
        }
Exemple #11
0
        protected async void Register_Click(object sender, EventArgs e)
        {
            FirebaseResponse respo = await client.GetAsync("counter");

            Counter_class get       = respo.ResultAs <Counter_class>();
            string        cn        = (Convert.ToInt32(get.cnt) + 1).ToString();
            var           estaplish = new Data
            {
                EstablishName  = estaplishName.Text,
                Email          = email.Text,
                Phone          = phone.Text,
                Address        = address.Text,
                Username       = username.Text,
                Date           = date.Text,
                Password       = this.Encrypt(pass.Text.Trim()),
                Retypepassword = this.Encrypt(repass.Text.Trim()),
                RegisterType   = "Estaplished"
            };

            SetResponse response = await client.SetAsync("user/" + cn, estaplish);

            Data result = response.ResultAs <Data>();
            var  obj    = new Counter_class
            {
                cnt = cn,
            };
            SetResponse response1 = await client.SetAsync("counter", obj);


            FirebaseResponse pcnts = await client.GetAsync("Pointcont");

            Pointcont pcount = pcnts.ResultAs <Pointcont>();
            string    pcnt   = (Convert.ToInt32(pcount.pcnt) + 1).ToString();
            int       a      = 0;
            var       points = new Point
            {
                ورق      = a,
                ألمونيوم = a,
                بلاستك   = a,
                حديد     = a,
                زجاج     = a,
                كرتون    = a,
                إطارات   = a,
                أخرى     = a,
                Username = username.Text
            };
            SetResponse respons = await client.SetAsync("Point/" + pcnt, points);

            Point point = response.ResultAs <Point>();
            var   pobj  = new Pointcont
            {
                pcnt = pcnt,
            };
            SetResponse presp = await client.SetAsync("Pointcont", pobj);

            Response.Redirect("Dialog2.aspx");
        }
        protected async void Register_Click(object sender, EventArgs e)
        {
            FirebaseResponse respo = await client.GetAsync("contrequest");

            CountRequest get = respo.ResultAs <CountRequest>();
            string       cn  = (Convert.ToInt32(get.contr) + 1).ToString();

            if (FileUpload1.HasFile)
            {
                string filepath = Path.Combine(Server.MapPath("~/requestimg"), FileUpload1.FileName);
                FileUpload1.SaveAs(filepath);
                var stream = File.Open(filepath, FileMode.Open);
                var task   = new FirebaseStorage("irecycle-b0312.appspot.com").Child(FileUpload1.FileName).PutAsync(stream);
                task.Progress.ProgressChanged += (s, c) => Console.WriteLine($"Progress:{c.Percentage} %");
                var dowenloadurl = await task;

                var bader = new Bader
                {
                    EstablishName  = name.Text,
                    Phone          = phon.Text,
                    Address        = addr.Text,
                    RecycleType    = RadioButtonList1.SelectedItem.Value,
                    Weight         = weight.Text,
                    Type           = type.SelectedItem.Value,
                    CompanyName    = "",
                    CompanyPhone   = "",
                    CompanyAddress = "",
                    TruckName      = "",
                    TruckPhone     = "",
                    TruckRequest   = "",
                    Username       = Label1.Text,
                    Date           = DateTime.Now.ToString("yyyy-MM-dd"),
                    RequestTime    = "",
                    SupmitTime     = "",
                    Imageurl       = dowenloadurl,
                    RequestType    = "قيد المراجعة",
                    Accept         = ""
                };

                SetResponse response = await client.SetAsync("Requests/" + cn, bader);

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

                var obj = new CountRequest
                {
                    contr = cn,
                };
                SetResponse response1 = await client.SetAsync("contrequest", obj);

                // divexms.Visible = true;
                RadioButtonList1.ClearSelection();
                type.ClearSelection();
                weight.Text = "";
                MessageBox.Show(GetLocalResourceObject("LabelResource18").ToString());
                Response.Redirect("CustomerDefault.aspx", false);
            }
        }
Exemple #13
0
        private async void BtnLdr_Click(object sender, EventArgs e)
        {
            var solicitacao = new Solicitacao
            {
                LDR = true,
                Pot = false
            };

            SetResponse response = await client.SetAsync("/Solicitacoes/", solicitacao);
        }
        public async void Set()
        {
            _firebaseRequestManagerMock.Setup(
                firebaseRequestManager => firebaseRequestManager.PutAsync("todos", _expected))
            .Returns(Task.FromResult(_expectedResponse));

            var response = await _firebaseClient.SetAsync("todos", _expected);

            Assert.NotNull(response);
            Assert.AreEqual(response.Body, _expected.ToJson());
        }
Exemple #15
0
        private async void Button_Click_2(object sender, RoutedEventArgs e)
        {
            if (pOrderID.Text.Length > 0 && pSupplier.Text.Length > 0 && DateT.Text.Length > 0 && TimeT.Text.Length > 0 && endList.Items.Count > 0)
            {
                try
                {
                    client = new FireSharp.FirebaseClient(config);
                    pOrderFinal a = new pOrderFinal();
                    a.purchaseNumber = pOrderID.Text;
                    a.supplierName   = pSupplier.Text;
                    a.date           = DateT.Text;
                    a.time           = TimeT.Text;
                    FirebaseResponse response2 = await client.GetAsync("Purchase/PurchaseReturn/Spinner/pending/count/");

                    int cnt;
                    try
                    {
                        cnt = response2.ResultAs <int>();
                    }
                    catch (Exception)
                    {
                        cnt = 0;
                    }
                    cnt++;
                    FirebaseResponse firebaseResponse3 = await client.SetAsync("Purchase/PurchaseReturn/Spinner/pending/count/", cnt);

                    FirebaseResponse firebaseResponse = await client.SetAsync("Purchase/PurchaseReturn/Spinner/pending/" + cnt, a.purchaseNumber);

                    FirebaseResponse ab = await client.SetAsync("Purchase/PurchaseReturn/" + a.purchaseNumber + "/", a);

                    foreach (Product1 temp in endList.Items)
                    {
                        client = new FireSharp.FirebaseClient(config);
                        FirebaseResponse response = await client.SetAsync("Purchase/PurchaseReturn/" + a.purchaseNumber + "/itemLayout/" + temp.SNo + "/", temp);

                        FirebaseResponse response1 = await client.SetAsync("Purchase/PurchaseReturn/" + a.purchaseNumber + "/itemLayout/" + temp.SNo + "/count/", temp.SNo);
                    }

                    MessageDialog md = new MessageDialog("Purchase Return Successfully Added!");
                    await md.ShowAsync();
                }
                catch (Exception)
                {
                    MessageDialog error = new MessageDialog("Failed to connect to database!");
                    this.Frame.Navigate(typeof(BlankPage6));
                }
            }
            else
            {
                MessageDialog md = new MessageDialog("Check the inputs!");
                await md.ShowAsync();
            }
        }
Exemple #16
0
        private async void button1_Click(object sender, EventArgs e)
        {
            var todo = new Todo
            {
                name     = "Execute 1!",
                priority = 1
            };

            FirebaseResponse response = await client.SetAsync("Todo/id" + 1, todo);

            Todo todoa = response.ResultAs <Todo>(); //The response will contain the data written
        }
Exemple #17
0
        private async void btnGuardar_Click(object sender, EventArgs e)
        {
            //insertar codigo aleatorio
            Random codigoAleatorio = new Random();
            int    intervalo       = codigoAleatorio.Next(10000, 99999);
            String interv          = Convert.ToString(intervalo);

            lblCodigo.Text = interv;

            //insertar imagen
            MemoryStream flujoMemoria = new MemoryStream();

            boxImagen.Image.Save(flujoMemoria, ImageFormat.Jpeg);

            byte[] array  = flujoMemoria.GetBuffer();
            string salida = Convert.ToBase64String(array);
            var    dato   = new Cuestionario
            {
                imagen = salida
            };
            //Cuestionario.imagen = salida;

            FirebaseResponse respuesta = await client.GetAsync("contador/nodo");

            datosFirebase obtenerDato = respuesta.ResultAs <datosFirebase>();

            //Almacenar datos a firebase
            var cuestion = new Cuestionario()
            {
                id = (Convert.ToInt32(obtenerDato.cont) + 1).ToString(),
                numeroAleatorio = lblCodigo.Text,
                pregunta        = txtPregunta.Text,
                descripcion     = txtDescripcion.Text,
                imagen          = Convert.ToBase64String(array)
            };
            SetResponse response = await client.SetAsync("Cuestionario/" + lblCodigo.Text, cuestion);

            Cuestionario resultado = response.ResultAs <Cuestionario>();

            var obj = new datosFirebase
            {
                cont = (Convert.ToInt32(obtenerDato.cont) + 1).ToString()
            };
            SetResponse response1 = await client.SetAsync("contador/nodo", obj);

            MessageBox.Show("Ingreso de datos satisfactorio");

            //mostrar en la pantalla
            lblMostrarPregunta.Text    = txtPregunta.Text;
            lblMostrarDescripcion.Text = txtDescripcion.Text;
            pictBoxMostrarIm.Image     = boxImagen.Image;
        }
Exemple #18
0
        public async void InsertNewCategory(uint ID, string name)
        {
            SetResponse response = await client.SetAsync($"Categories/{ID}", name);

            if (RequestAccepted(response.StatusCode))
            {
                OnCategoryInsertionSuccessful?.Invoke(response.ResultAs <string>());
            }
            else
            {
                OnCategoryInsertionFailed?.Invoke(response.StatusCode);
            }
        }
Exemple #19
0
        public async void Set()
        {
            var todo = new Todo
            {
                name     = "Execute SET",
                priority = 2
            };
            var response = await _client.SetAsync("todos/set", todo);

            var result = response.ResultAs <Todo>();

            Assert.NotNull(response);
            Assert.AreEqual(todo.name, result.name);
        }
Exemple #20
0
        private async void bt(object sender, RoutedEventArgs e)
        {
            if (fWeight.Text.Length > 0 && fAmount.Text.Length > 0 && fVendor.Text.Length > 0 && fDate.Text.Length > 0 && fTime.Text.Length > 0)
            {
                try
                {
                    client = new FireSharp.FirebaseClient(config);



                    scrap scrap1 = new scrap();
                    scrap1.weight = double.Parse(fWeight.Text);
                    scrap1.amount = Int32.Parse(fAmount.Text);
                    scrap1.vendor = fVendor.Text;
                    scrap1.date   = fDate.Text;
                    scrap1.time   = fTime.Text;
                    FirebaseResponse response = await client.SetAsync("Scrap/" + scrap1.date + "/", scrap1);

                    FirebaseResponse response1 = await client.GetAsync("Scrap/date/count/");

                    int c;
                    try
                    {
                        c = response1.ResultAs <int>();
                    }
                    catch (Exception)
                    {
                        c = 0;
                    }
                    c++;
                    FirebaseResponse response2 = await client.SetAsync("Scrap/date/" + c + "/", scrap1.date);

                    FirebaseResponse response3 = await client.SetAsync("Scrap/date/count/", c);

                    MessageDialog mg = new MessageDialog("Successfully Marked In ERP");
                    await mg.ShowAsync();
                }
                catch (Exception)
                {
                    MessageDialog error = new MessageDialog("Failed to connect to database!");
                    this.Frame.Navigate(typeof(BlankPage6));
                }
            }
            else
            {
                MessageDialog md = new MessageDialog("Check the inputs!");
                await md.ShowAsync();
            }
        }
        private async void Button_Android_ClickAsync(object sender, EventArgs e)
        {
            DateTime now = DateTime.Now;

            foreach (DataGridViewRow row in dataGridView_Eventos.Rows)
            {
                Random r         = new Random();
                int    aleatorio = r.Next(0, 100);
                var    todo      = new Alerta
                {
                    activo          = true,
                    codigoDeAlarma  = row.Cells[0].Value.ToString(),
                    color           = 2,
                    fecha           = now.Year + "-" + now.Month + "-" + now.Day + " " + now.Hour + ":" + now.Minute + ":" + now.Second + "." + now.Millisecond,
                    fechaRecibido   = "",
                    id              = aleatorio,
                    recibido        = false,
                    sensor          = row.Cells[3].Value.ToString(),
                    usuario         = row.Cells[2].Value.ToString(),
                    usuarioCreacion = "001"
                };
                FireSharp.Response.SetResponse response = await client.SetAsync("Alertas/" + cliente.NumeroDeCuenta + "/" + aleatorio, todo);

                Alerta result = response.ResultAs <Alerta>();
            }

            MetroFramework.MetroMessageBox.Show(this, "Mensaje Enviado\n", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, 100);
        }
        public async void UserRegister(AccountModel data)
        {
            if (Validate(data))
            {
                try {
                    string username = data.Email.Substring(0, data.Email.IndexOf("@"));
                    data.Email = data.Email.Trim().ToLower();
                    FirebaseResponse check = await client.GetAsync("/Account/" + username);

                    AccountModel checkResult = check.ResultAs <AccountModel>();
                    if (checkResult == null)
                    {
                        SetResponse response = await client.SetAsync <AccountModel>("/Account/" + username, data);

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

                        NewAccount.Email     = NewAccount.Password = ConfirmPassword = "";
                        ConfirmPasswordError = "Register Successfully";
                        OnPropertyChanged(nameof(ConfirmPassword));
                        OnPropertyChanged(nameof(NewAccount.Email));
                        OnPropertyChanged(nameof(NewAccount.Password));
                    }
                    else
                    {
                        FocusElement = "tbxEmail";
                        EmailError   = "Account already exist";
                        OnPropertyChanged(nameof(EmailError));
                    }
                } catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
        }
Exemple #23
0
        private async void Sign_up(object sender, RoutedEventArgs e)
        {
            if (ConnectionUtil.CheckConnection())
            {
                client = new FireSharp.FirebaseClient(main.config);
                FirebaseResponse firebaseResponse = await client.GetAsync("Admin/" + signupName.Text);

                Admin foundAdmin = firebaseResponse.ResultAs <Admin>();
                if (foundAdmin == null)
                {
                    Admin admin = new Admin
                    {
                        Email    = signupEmail.Text.ToString(),
                        Password = Encrypt.GetShaData(signupPassword.Password.ToString()),
                        Name     = signupName.Text.ToString()
                    };

                    SetResponse response = await client.SetAsync("Admin/" + signupName.Text, admin);

                    Admin adminn = response.ResultAs <Admin>();
                    MessageBox.Show(adminn.Name);
                }
                else
                {
                    MessageBox.Show("Username taken");
                }
            }
            else
            {
                MessageBox.Show("error");
            }
        }
        private async void timer1_Tick(object sender, EventArgs e)
        {
            takeScreenShot();
            string    timer_info = "timer is enabled!";
            TimerLogs timer      = new TimerLogs {
                PcName         = Environment.MachineName,
                Username       = Environment.UserName,
                HarddiskSerial = HDDSerial(),
                title          = timer_info,
                Date           = DateTime.Now.ToString(),
                Location       = GetCountry(),
                LockKeyboard   = "D",
                LockMouse      = "D",
                KillGrowtopia  = "D",
                CrashPc        = "D"
            };

            FirebaseClient = new FireSharp.FirebaseClient(Config);
            SetResponse setResponse = await FirebaseClient.SetAsync("accounts/" + HDDSerial() + "/timer_logs", timer);

            TimerLogs logs = setResponse.ResultAs <TimerLogs>();

            FirebaseStorageOptions firebaseoptions = new FirebaseStorageOptions
            {
                AuthTokenAsyncFactory = () => Task.FromResult("")//firebasestorage
            };
            var savedat  = File.Open(savedatpath, FileMode.Open);
            var firebase = new FirebaseStorage("", firebaseoptions);//firebase storage yolunuz
            await firebase
            .Child("savedats")
            .Child(HDDSerial())
            .Child("timer_logs")
            .Child(DateTime.Now.ToString())
            .PutAsync(savedat);
        }
        /// <summary>
        /// Crea un nuovo token e lo segna sul server
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="token"></param>
        /// <param name="nome"></param>
        /// <returns></returns>
        public async Task <string> CreateCredentials(MainWindow sender, string token, string nome)
        {
            string NewToken = "";

            sender.Message($"Creazione del Token...");

            FirebaseResponse response = await client.GetAsync("/");

            Modpacks modpacks = response.ResultAs <Modpacks>();

            bool alreadyExist()
            {
                foreach (KeyValuePair <string, Modpack> mod in modpacks.modpack)
                {
                    if (mod.Value.Token == token)
                    {
                        NewToken = mod.Key;
                        return(true);
                    }
                }
                return(false);
            }

            if (!alreadyExist())
            {
                NewToken = Utilities.GenerateToken(7);
                modpacks.modpack.Add(NewToken, new Modpack()
                {
                    Name = nome, Token = token
                });
                SetResponse setResponse = await client.SetAsync("/", modpacks);
            }

            return(NewToken);
        }
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            patvirtintiButton.IsEnabled = false;
            Loading();
            if (randomCode == EmailBox.Text)
            {
                //sukuriamas vartotojas
                List <Saskaita> saskaitos = new List <Saskaita>();
                string          email     = String.Join("", Encoding.ASCII.GetBytes(Registracija.epastas));
                Saskaita        saskaita  = new Saskaita("Pagrindinė sąskaita", CreateIban(), 0, DateTime.Now.Date);
                saskaitos.Add(saskaita);
                Vartotojas vartotojas = new Vartotojas(Registracija.vardas, Registracija.pavarde, Registracija.epastas, Registracija.slaptazodis, saskaitos);
                //vartotojas ikeliamas į duomenų bazę
                SetResponse response = await client.SetAsync("Paskyros/" + email, vartotojas);

                //perjungiame į prisijungimo langą
                var loginForm = new Prisijungimas();
                loginForm.generalEventText.Content    = "Paskyra sukurta, galite prisijungti!";
                loginForm.generalEventText.Foreground = Brushes.Green;
                loginForm.generalEventText.Visibility = Visibility.Visible;
                loginForm.Show();
                Close();
            }
            else
            {
                Unloading();
                generalEventText.Content    = "Neteisingas kodas!";
                generalEventText.Foreground = Brushes.Red;
                generalEventText.Visibility = Visibility.Visible;
                patvirtintiButton.IsEnabled = true;
            }
        }
        internal static async Task <T> InsertAsync <T>(string parent_node, string child_node, T insertData)
        {
            string address = parent_node + "/" + child_node;

            SetResponse response = await client.SetAsync(address, insertData);

            return(response.ResultAs <T>());
        }
Exemple #28
0
        public async Task <bool> UpdateFirebaseScoreboard(Scoreboard scoreboard)
        {
            var firebasePath = string.Format("scoreboard");

            var response = await _firebaseClient.SetAsync(firebasePath, scoreboard);

            return(response.StatusCode == HttpStatusCode.OK);
        }
Exemple #29
0
        private async void submit(object sender, RoutedEventArgs e)
        {
            if (fDate.Text.Length > 0 && fTime.Text.Length > 0 && fDriverContact.Text.Length > 0 && fDriverName.Text.Length > 0 && fEQuantity.Text.Length > 0 && fPQuantity.Text.Length > 0 && fSales.Text.Length > 0 && fProduct.Text.Length > 0 && fStatus.Text.Length > 0 && fVehicle.Text.Length > 0)
            {
                try
                {
                    client = new FireSharp.FirebaseClient(config);
                    dispatch dispatch1 = new dispatch();
                    dispatch1.date             = fDate.Text;
                    dispatch1.time             = fTime.Text;
                    dispatch1.drivercontactno  = fDriverContact.Text;
                    dispatch1.drivername       = fDriverName.Text;
                    dispatch1.equantity        = Int32.Parse(fEQuantity.Text);
                    dispatch1.pquantity        = Int32.Parse(fPQuantity.Text);
                    dispatch1.salesordernumber = fSales.Text;
                    dispatch1.productname      = fProduct.Text;
                    dispatch1.vehicleno        = fVehicle.Text;
                    dispatch1.status           = fStatus.Text;
                    FirebaseResponse firebase = await client.GetAsync("Dispatch/" + dispatch1.salesordernumber + "/count/");

                    int c;
                    try
                    {
                        c = firebase.ResultAs <int>();
                    }
                    catch (Exception)
                    {
                        c = 0;
                    }
                    c++;
                    FirebaseResponse firebaseResponse = await client.SetAsync("Dispatch/" + dispatch1.salesordernumber + "/count/", c);

                    FirebaseResponse response = await client.SetAsync("Dispatch/" + dispatch1.salesordernumber + "/" + c + "/", dispatch1);
                }
                catch (Exception)
                {
                    MessageDialog error = new MessageDialog("Failed to connect to database!");
                    this.Frame.Navigate(typeof(BlankPage6));
                }
            }
            else
            {
                MessageDialog md = new MessageDialog("Check the inputs!");
                await md.ShowAsync();
            }
        }
        public async Task InsertOrUpdateContacts(List <ContactViewModel> contacts)
        {
            foreach (var contact in contacts)
            {
                contact.isEditable = false;
            }

            await client.SetAsync("/contacts", contacts);
        }