Exemplo n.º 1
0
        private List <Book> GetAll()
        {
            FirebaseResponse          response  = client.Get("books");
            Dictionary <String, Book> dictBooks = response.ResultAs <Dictionary <String, Book> >();

            return(dictBooks.Values.ToList());
        }
Exemplo n.º 2
0
        private String GetToken()
        {
            FirebaseResponse response = client.Get("user/" + DataStatic.user);
            String           token    = response.ResultAs <String>();

            return(token);
        }
Exemplo n.º 3
0
        private void Button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "")
            {
                string[]         valuesfromform = { textBox1.Text.Replace('.', ','), textBox2.Text.Replace('.', ','), textBox3.Text.Replace('.', ',') };
                string           path           = @"C:\Users\viazn\RiderProjects\WebApp\FormForCreatingValues\Values from the lab\";
                string           subpath        = $@"{DateTime.Now.Year}\{DateTime.Now.Month}\";
                FirebaseValue[]  firebaseValues = new FirebaseValue[3]; // Массив объектов для записи в БДРВ
                Value[]          valuestotext   = new Value[3];         // Объекты для записи в файл
                FirebaseResponse response;                              // Переменная для получения ответов из БДРВ

                DirectoryInfo dirInfo = new DirectoryInfo(path);
                if (!dirInfo.Exists)
                {
                    dirInfo.Create();
                }
                dirInfo.CreateSubdirectory(subpath);

                IFirebaseConfig config = new FirebaseConfig
                {
                    AuthSecret = "r0Dx9Gi0gj7g3kZ4EJQodtFgOIq80IuBfBuko8HS",
                    BasePath   = "https://fir-2d407.firebaseio.com/"
                };
                IFirebaseClient client = new FirebaseClient(config);


                response = client.Get("Last/Laboratory values/Id");
                int displacement = Convert.ToInt16(response.Body); // Смещение Id значений из БДРВ

                int i;
                for (i = 1 + displacement; i <= 3 + displacement; i++)
                {
                    FirebaseValue labvaluetofirebase = new FirebaseValue(i, Convert.ToDouble(valuesfromform[i - displacement - 1]), DateTime.Now);

                    client.Set("Laboratory values/" + labvaluetofirebase.Id, labvaluetofirebase);
                    Thread.Sleep(100);

                    response = client.Get("Last/Sensor values/Value");
                    valuestotext[i - displacement - 1] = new Value(i, labvaluetofirebase.Value, Convert.ToDouble(response.Body.Replace('.', ',')), labvaluetofirebase.Time);

                    if (i == 3 + displacement)
                    {
                        client.Set("Last/Laboratory values", labvaluetofirebase);
                    }
                }

                using (FileStream fstream = new FileStream(path + subpath + $@"{DateTime.Now.Day}.txt", FileMode.OpenOrCreate))
                {
                    for (i = 0; i < 3; i++)
                    {
                        // преобразуем строку в байты
                        byte[] array = Encoding.Default.GetBytes
                                           ($@"L_{valuestotext[i].LabVal} S_{valuestotext[i].SensVal} T_{valuestotext[i].Time}.{valuestotext[i].Time.Millisecond} L-S:{valuestotext[i].LabVal-valuestotext[i].SensVal}" + "\n");
                        // запись массива байтов в файл
                        fstream.Write(array, 0, array.Length);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public bool CheckToken(String user, String token)
        {
            FirebaseResponse response = client.Get("user/" + user);
            String           animal   = response.ResultAs <String>();

            if (animal == token)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        public ActionResult Login(Staff staff)
        {
            if (staff.email == "*****@*****.**" && staff.password_staff == "123456")
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                string           staff_id = "-" + staff.staff_id;
                IFirebaseClient  client   = new FirebaseClient(config);
                FirebaseResponse response = client.Get("Staffs/" + staff_id);
                Staff            data     = JsonConvert.DeserializeObject <Staff>(response.Body.ToString());

                if (data != null)
                {
                    if (data.password_staff == staff.password_staff)
                    {
                        return(View("/user/index"));
                    }

                    else
                    {
                        return(RedirectToAction("Login"));
                    }
                }
                else
                {
                    return(RedirectToAction("Login"));
                }
            }
        }
Exemplo n.º 6
0
        public ActionResult Test()
        {
            FirebaseResponse response = FirebaseClient.Get("users");
            var users = response.ResultAs <IDictionary <string, User> >();

            return(Content(JsonConvert.SerializeObject(users), "application/json"));
        }
Exemplo n.º 7
0
        public static void execute()
        {
            try
            {
                IFirebaseConfig config = new FirebaseConfig
                {
                    AuthSecret = "tqbbj0jnqp04G3LfRzptLBL82pSvBDW374GeXJEl",
                    BasePath   = "https://linzgeoquiz.firebaseio.com"
                };

                IFirebaseClient client = new FirebaseClient(config);


                //var getResponse = client.Get("streets");
                FirebaseResponse          response = client.Get("streets");
                IDictionary <int, Street> streets  = response.ResultAs <IDictionary <int, Street> >();

                Console.WriteLine("Nr. of streets: " + streets.Count);

                foreach (int i in streets.Keys)
                {
                    if (streets[i] == null || string.IsNullOrEmpty(streets[i].is_in) || string.IsNullOrEmpty(streets[i].name) || !streets[i].is_in.ToLower().Contains("linz") || streets[i].is_in.ToLower().Contains("linz-land"))
                    {
                        var deleteResponse = client.Delete("streets/" + i);
                    }
                }
            }
            catch (FirebaseException ex)
            {
                Console.WriteLine(ex.ToString());
                ContentFilter.execute();
            }
        }
        public IActionResult GetStudentById()
        {
            IFirebaseClient client = new FirebaseClient(objFireConfig);
            var             result = client.Get("StudentList/" + "2");
            Student         obj    = result.ResultAs <Student>();

            return(Content(obj.StudentId + "-" + obj.StudentName + "-" + obj.StudentDivision));
        }
Exemplo n.º 9
0
 public T GetSettings <T>(string fieldName)
 {
     if (client == null)
     {
         return(default(T));
     }
     return(client.Get($"camsnet/settings/{fieldName}").ResultAs <T>());
 }
Exemplo n.º 10
0
        //Metodo para retornar todos os usuários cadastrados no banco de dados
        public List <Usuario> GetUsuarios()
        {
            //Conectando no banco e solicitando todos objetos da 'tabela' Usuarios
            FirebaseResponse response = _client.Get("Usuarios");

            //Convertendo a resposta do banco para uma lista de objetos do tipo Usuario
            return(response.ResultAs <List <Usuario> >());
        }
Exemplo n.º 11
0
        public ActionResult Edit(string id)
        {
            IFirebaseClient  client   = new FirebaseClient(config);
            FirebaseResponse response = client.Get("Students/" + id);
            Student          data     = JsonConvert.DeserializeObject <Student>(response.Body.ToString());

            return(View(data));
        }
Exemplo n.º 12
0
        public void GetFailure()
        {
            ReturnsExtensions.ReturnsAsync(_firebaseRequestManagerMock.Setup(
                                               firebaseRequestManager => firebaseRequestManager.RequestAsync(HttpMethod.Get, "todos", (object)null)),
                                           _failureResponse);

            Assert.Throws <FirebaseException>(() => _firebaseClient.Get("todos"));
        }
Exemplo n.º 13
0
 // GET: Sermon
 public ActionResult Sermon(string id)
 {
     FirebaseClient client = new FirebaseClient(config);
     var response = client.Get("/sermons");
     var json = JsonConvert.DeserializeObject(response.Body);
     var sermon = new Sermon();
     JToken selectedSermon = null;
     foreach (JToken item in ((JToken)(json)).Children())
     {
         var prop = ((JToken)(JsonConvert.DeserializeObject(((JProperty)(item)).Value.ToString()))).Children();
         foreach (var obj in prop)
         {
             var ser = (JProperty)(obj);
             if (ser.Name == "ID" && ser.Value.ToString() == id)
             {
                 selectedSermon = item;
             }
         }
     }
     var property = ((JToken)(JsonConvert.DeserializeObject(((JProperty)(selectedSermon)).Value.ToString()))).Children();
     foreach (var obj in property)
     {
         var ser = (JProperty)(obj);
         if (ser.Name == "Name")
         {
             sermon.Name = ser.Value.ToString();
         }
         else if (ser.Name == "About")
         {
             var tag = HTMLTagStripper.StripTagsCharArray(ser.Value.ToString());
             sermon.About = tag;
         }
         else if (ser.Name == "ID")
         {
             sermon.ID = ser.Value.ToString();
         }
         else if (ser.Name == "Art")
         {
             sermon.Art = ser.Value.ToString();
         }
         else if (ser.Name == "SmallArt")
         {
             sermon.SmallArt = ser.Value.ToString();
         }
         else if (ser.Name == "Audio")
         {
             sermon.Audio = ser.Value.ToString();
         }
     }
     this.ViewData.Add("ID", sermon.ID);
     this.ViewData.Add("name", sermon.Name);
     this.ViewData.Add("content", sermon.About);
     this.ViewData.Add("art", sermon.Art);
     this.ViewData.Add("smallArt", sermon.SmallArt);
     this.ViewData.Add("audio", sermon.Audio);
     return View();
 }
Exemplo n.º 14
0
        public ActionResult Edit(string project_id, string nameproject, string type, string goal, string detail, string image, string image2, string image3)
        {
            IFirebaseClient  client   = new FirebaseClient(config);
            FirebaseResponse response = client.Get("Projects/" + project_id);
            Project          data     = JsonConvert.DeserializeObject <Project>(response.Body.ToString());


            ViewData["data"] = data;
            return(View());
        }
Exemplo n.º 15
0
 public static FireBaseRetorno GetFireBaseData(FireBaseEntrada Entrada)
 {
     IFirebaseConfig config = new FirebaseConfig{ AuthSecret = Entrada.AuthSecret, BasePath = Entrada.BasePath};
     IFirebaseClient client = new FirebaseClient(config);
     FirebaseResponse response = client.Get(Entrada.item.ToString());
      FireBaseRetorno retorno = new FireBaseRetorno {StatusCode = response.StatusCode.ToString(), Body = response.Body};
     retorno.StatusCode = response.StatusCode.ToString();
     retorno.Body = response.Body;
     return retorno;
 }
Exemplo n.º 16
0
        public static PlacedBet GetPlacedBet(Pending pending)
        {
            var client = new FirebaseClient(_config);

            FirebaseResponse response = client.Get(Helper.GetPlacedBetUrl(pending.DatePlaced, pending.CustomId, pending.Sport));

            var placedBet = response.ResultAs <PlacedBet>();

            return(placedBet ?? new PlacedBet());
        }
Exemplo n.º 17
0
        public ActionResult Edit(string staff_id, string password_staff, string name, string phone, string email)
        {
            IFirebaseClient  client   = new FirebaseClient(config);
            FirebaseResponse response = client.Get("Staffs/" + staff_id);
            Staff            data     = JsonConvert.DeserializeObject <Staff>(response.Body.ToString());


            ViewData["data"] = data;
            return(View());
        }
        public IActionResult GetAllStudents()
        {
            IFirebaseClient client = new FirebaseClient(objFireConfig);

            client = new FirebaseClient(objFireConfig);

            var result = client.Get("StudentList/");

            return(Content(result.Body));
        }
Exemplo n.º 19
0
 //Downloads all Data from FireBase and saves it to List<Face>
 public Dictionary <Guid, string> GetData()
 {
     try
     {
         FirebaseResponse response = Client.Get("Faces");
         var Data = response.ResultAs <Dictionary <Guid, string> >();
         return(Data ?? new Dictionary <Guid, string>());
     }
     catch
     {
         return(new Dictionary <Guid, string>());
     }
 }
        private void Acquire(string resource, TimeSpan timeout)
        {
            System.Diagnostics.Stopwatch acquireStart = new System.Diagnostics.Stopwatch();
            acquireStart.Start();

            while (true)
            {
                FirebaseResponse response = client.Get("locks");
                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    Dictionary <string, Lock> locks = response.ResultAs <Dictionary <string, Lock> >();
                    string reference = locks?.Where(l => l.Value.Resource == resource).Select(l => l.Key).FirstOrDefault();
                    if (string.IsNullOrEmpty(reference))
                    {
                        response = client.Push("locks", new Lock {
                            Resource = resource, ExpireOn = DateTime.UtcNow.Add(timeout)
                        });
                        if (response.StatusCode == System.Net.HttpStatusCode.OK)
                        {
                            reference = ((PushResponse)response).Result.name;
                            if (!string.IsNullOrEmpty(reference))
                            {
                                lockReference = reference;
                                break;
                            }
                        }
                    }
                }

                // check the timeout
                if (acquireStart.ElapsedMilliseconds > timeout.TotalMilliseconds)
                {
                    throw new FirebaseDistributedLockException($"Could not place a lock on the resource '{resource}': Lock timeout.");
                }

                // sleep for 500 millisecond
                System.Threading.Thread.Sleep(500);
            }
        }
Exemplo n.º 21
0
        // IFirebaseClient client;
        public IActionResult Index()
        {
            IFirebaseClient  client   = new FirebaseClient(config);
            FirebaseResponse response = client.Get("Projects/");
            dynamic          data     = JsonConvert.DeserializeObject <dynamic>(response.Body.ToString());
            var list = new List <Project>();

            foreach (var item in data)
            {
                list.Add(JsonConvert.DeserializeObject <Project>(((JProperty)item).Value.ToString()));
            }

            return(View(list));
        }
Exemplo n.º 22
0
 public JObject getTransactions()
 {
     try
     {
         IFirebaseClient  client       = new FirebaseClient(config);
         FirebaseResponse response     = client.Get("transactions");
         JObject          transactions = JsonConvert.DeserializeObject <JObject>(response.Body);
         return(transactions);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 23
0
 public Account getAccountById(string id)
 {
     try
     {
         IFirebaseClient  client          = new FirebaseClient(config);
         FirebaseResponse accountResponse = client.Get("accounts/" + id);
         Account          accountResult   = accountResponse.ResultAs <Account>();
         return(accountResult);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 24
0
 public JObject getAccounts()
 {
     try
     {
         IFirebaseClient  client   = new FirebaseClient(config);
         FirebaseResponse response = client.Get("accounts");
         JObject          accounts = JsonConvert.DeserializeObject <JObject>(response.Body);
         return(accounts);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Exemplo n.º 25
0
        private void buttonGirisYap_Click(object sender, EventArgs e)
        {
            Data.CurrentUser = kAdi.Text;


            if (kAdi.Text == "" || Sifre.Text == "" || kAdi.Text == "Kullanıcı Adınızı Giriniz..." || Sifre.Text == "Şifrenizi Giriniz...")
            {
                MessageBox.Show("Hatalı İşlem! Kullanıcı Adınızı veya Şifrenizi Boş Bırakamazsınız!", "HATA", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                IFirebaseConfig config = new FirebaseConfig()
                {
                    AuthSecret = "Um2q5EJk0TzKlL8BJIEI8XfHrylv0Nx5JpewBOiN",
                    BasePath   = "https://ogrenci-topluluklari.firebaseio.com/"
                };
                IFirebaseClient client = new FirebaseClient(config);


                FirebaseResponse res   = client.Get(@"USERS/" + kAdi.Text + "/KullanıcıAdı");
                string           data  = res.ResultAs <string>();
                FirebaseResponse res2  = client.Get(@"USERS/" + kAdi.Text + "/Şifre");
                string           data2 = res.ResultAs <string>();

                if (data == kAdi.Text && data2 == Sifre.Text)
                {
                    MessageBox.Show("Giriş Başarılı", "BİLGİLENDİRME", MessageBoxButtons.OK, MessageBoxIcon.Information);


                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Giriş Başarız! Kullanıcı Adınızı veya Şifrenizi Yanlış Girdiniz!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Exemplo n.º 26
0
        public ActionResult Add(OrderViewModel model)
        {
            if (ModelState.IsValid)
            {
                Order order = new Order();
                order.Time              = TimeUtils.ConvertToTimestamp(DateTime.Now);
                order.Sender.FullName   = model.SenderFullName;
                order.Sender.Address    = model.SenderAddress;
                order.Sender.Phone      = model.SenderPhone;
                order.Sender.Lat        = model.SenderLatLng.Lat;
                order.Sender.Lng        = model.SenderLatLng.Lng;
                order.Receiver.FullName = model.ReceiveFullName;
                order.Receiver.Address  = model.ReceiveAddress;
                order.Receiver.Phone    = model.ReceivePhone;
                order.Receiver.Lat      = model.ReceiveLatLng.Lat;
                order.Receiver.Lng      = model.ReceiveLatLng.Lng;
                order.TotalPrice        = model.TotalPrice;
                if (model.UserID == "")
                {
                    ViewBag("Vui long chon nhan vien can giao");
                }
                else
                {
                    order.UserID = model.UserID;
                }
                order.Status = false;
                FirebaseClient.PushTaskAsync("orders", order);

                //Push notification to user
                FMessage FMessage = new FMessage(order.UserID);
                FMessage.Title   = "Nhận được hàng mới";
                FMessage.Message = "Bạn vừa được tiếp nhận một đơn hàng mới";
                FirebaseClient.PushNotification("global", FMessage);

                return(RedirectToAction("Index", "Order"));
            }
            var resUser   = FirebaseClient.Get("users");
            var users     = resUser.ResultAs <Dictionary <String, User> >();
            var modelUser = users.Select(u => new User
            {
                UserID = u.Key,
                Name   = u.Value.Name,
                Phone  = u.Value.Phone,
                Url    = u.Value.Url,
            }).ToList();

            ViewBag.Users = modelUser;
            return(View(model));
        }
Exemplo n.º 27
0
        public ActionResult Add()
        {
            var resUser   = FirebaseClient.Get("users");
            var users     = resUser.ResultAs <Dictionary <String, User> >();
            var modelUser = users.Select(u => new User
            {
                UserID = u.Key,
                Name   = u.Value.Name,
                Phone  = u.Value.Phone,
                Url    = u.Value.Url,
            }).ToList();

            ViewBag.Users = modelUser;
            return(View(new OrderViewModel()));
        }
Exemplo n.º 28
0
        public ActionResult Edit(String id)
        {
            if (id == null)
            {
                return(new HttpNotFoundResult());
            }
            var userChild = FirebaseClient.Get("users/" + id);
            var model     = userChild.ResultAs <User>();

            if (model == null)
            {
                return(new HttpNotFoundResult());
            }
            model.UserID = id;
            return(View(model));
        }
Exemplo n.º 29
0
        public ActionResult Contact(StaffContactViewModel model)
        {
            if (ModelState.IsValid)
            {
                FMessage message = new FMessage(model.UserId);
                message.Title   = model.Title;
                message.Message = model.Message;
                var content = FirebaseClient.PushNotification("global", message);
                return(RedirectToAction("Index", "Staff"));
            }
            var userChild = FirebaseClient.Get("users/" + model.UserId);
            var user      = userChild.ResultAs <User>();

            ViewBag.User = user;
            return(View(model));
        }
        public string GetFireBaseData(string AuthSecret, string BasePath, string item)
        {
            IFirebaseConfig config = new FirebaseConfig
            {
                AuthSecret = AuthSecret,
                BasePath = BasePath
            };

            IFirebaseClient client = new FirebaseClient(config);

            FirebaseResponse response = client.Get(item.ToString());

            //string retorno = JsonConvert.SerializeObject(response).ToString();
            string retorno = response.Body.ToString();

            return retorno;
        }
Exemplo n.º 31
0
        public void ClearLeaderboard()
        {
            var config = new FirebaseConfig
            {
                BasePath = "https://testing-challenge.firebaseio.com/word-statistics/"
            };

            using (var client = new FirebaseClient(config))
            {
                var response = client.Get("");
                var jObject  = JsonConvert.DeserializeObject(response.Body) as JObject;
                foreach (var pair in jObject)
                {
                    client.Delete(pair.Key);
                }
            }
        }
Exemplo n.º 32
0
            private async void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
            {
                IFirebaseConfig config = new FirebaseConfig()
                {
                    AuthSecret = "swZHTKc94vPvU61ENUWwthu1Bx1iRqqXiUzh3J7U",
                    BasePath = "https://ogrenci-topluluklari.firebaseio.com/"
                };
                IFirebaseClient client = new FirebaseClient(config);


                yetk = dataGridView1.Columns[dataGridView1.CurrentCell.ColumnIndex].HeaderText.ToString();
                kadi1 = userDataGridView.CurrentRow.Cells[0].Value.ToString();

                FirebaseResponse res = client.Get(@"USERS/" + userListkadi1 + "/" + UserListyetk);
                string data = res.ResultAs<string>();


                if (data == "true")
                {
                    st2 = "false";
                }
                else
                {
                    st2 = "true";
                }

                DialogResult dialog = new DialogResult();
                dialog = MessageBox.Show("Kişinin Yetkisini Değiştirmek İstiyor Musunuz?", "YETKİ", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (dialog == DialogResult.Yes)
                {
                    var set2 = await client.SetAsync(@"USERS/" + userListkadi1 + "/" + UserListyetk, userListst2);

                    userDataGridView.Rows.Clear();
                    UserList_Load(sender, e);

                    MessageBox.Show("Yetki Değiştirildi!!!", "BİLGİLENDİRME", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
                else
                {
                    MessageBox.Show("Yetki Değiştirilmedi!!!", "UYARI", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
Exemplo n.º 33
0
        public ActionResult Contact(String id)
        {
            if (id == null)
            {
                return(new HttpNotFoundResult());
            }
            var userChild = FirebaseClient.Get("users/" + id);
            var user      = userChild.ResultAs <User>();

            if (user == null)
            {
                return(new HttpNotFoundResult());
            }
            user.UserID  = id;
            ViewBag.User = user;
            var model = new StaffContactViewModel();

            model.UserId = user.UserID;
            return(View(model));
        }
        public HttpResponseMessage Get(string AuthSecret, string BasePath, string command)
        {
            try
            {
                IFirebaseConfig config = new FirebaseConfig
                {
                    AuthSecret = AuthSecret,
                    BasePath = BasePath
                };

                IFirebaseClient client = new FirebaseClient(config);

                FirebaseResponse response;

                if (String.IsNullOrWhiteSpace(command))
                    response = client.Get("/");
                else
                    response = client.Get("/"+command.ToString());

                return Request.CreateResponse(HttpStatusCode.OK, response); ;
            }
            catch (KeyNotFoundException)
            {
                string mensagem = string.Format("Não foi possível criptografar a entrada: ", command);
                HttpError error = new HttpError(mensagem);
                return Request.CreateResponse(HttpStatusCode.NotFound, error);
            }
        }