Exemplo n.º 1
0
        private string ExportarLeituraFirebase(string caminho, Model_Leitura_Importada leitura)
        {
            //caminho pode ser por exemplo "/Appv99Bucket/Inventario/"


            IFirebaseClient client = new FireSharp.FirebaseClient(config);

            var response = client.Set(caminho + leitura.Data + "/" + leitura.Cliente + "/" + leitura.Barcode + "/", leitura);

            return(JsonConvert.SerializeObject(response).ToString());
        }
Exemplo n.º 2
0
        private void btnEntrar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(txtFullName.Text) &&
                string.IsNullOrWhiteSpace(tbLogin.Text) &&
                string.IsNullOrWhiteSpace(tbSenha.Text))
            {
                MessageBox.Show("Por favor preencha todos os campos!");
                return;
            }

            User user = new User()
            {
                Name     = txtFullName.Text,
                Login    = tbLogin.Text,
                Password = tbSenha.Text
            };

            IFirebaseClient client;

            IFirebaseConfig ifc = new FirebaseConfig()
            {
                AuthSecret = "iu89vBVEQLL9PvidW5ChOBeHbbKoCJCAHTqiNhRz",
                BasePath   = "https://control-plain-trade-default-rtdb.firebaseio.com/"
            };

            try
            {
                client = new FireSharp.FirebaseClient(ifc);
                SetResponse set = client.Set(@"Users/" + user.Login, user);
                MessageBox.Show("Sucesso, usuario cadastrado com sucesso!");
            }
            catch (Exception m)
            {
                MessageBox.Show(m.Message);
            }


            FormLogin lo = new FormLogin();

            this.Hide();
            lo.Show();
        }
Exemplo n.º 3
0
        public ActionResult createMessage(messageModel m)
        {
            var       context = new promoLacDbEntities();
            messages_ obj     = new messages_();

            foreach (var x in m.areaName)
            {
                obj.vendorID           = m.vendorID;
                obj.messageDescription = m.messageDescription;
                obj.messageTitle       = m.messageTitle;
                obj.areaId             = getAreaId(x);
                obj.messageStatus      = "s";

                context.messages_.Add(obj);
                context.SaveChanges();

                tempMessage objM = new tempMessage();


                objM.notificationStatus      = "s";
                objM.notificationAreaId      = obj.areaId.ToString();
                objM.notificationDescription = obj.messageDescription;
                objM.notificationTitle       = obj.messageTitle;
                objM.notificationTime        = DateTime.Now.ToString();
                objM.notificationId          = obj.messageId.ToString();
                IFirebaseConfig mes = new FirebaseConfig
                {
                    AuthSecret = "CwnE0VGXMqxNxcY5YSWVNcL7IAM3hfqRuSiNjWm5",
                    BasePath   = "https://xdadeveloperes.firebaseio.com/"
                };

                IFirebaseClient mfc;
                mfc = new FireSharp.FirebaseClient(mes);

                var set = mfc.Set(@"Messages/" + obj.messageId, objM);
            }

            return(Json(new { success = true, message = "dddd" }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 4
0
        private void ActivityTimer_Tick(object sender, EventArgs e)
        {
            activityTimer.Stop();
            try
            {
                lastCheckedTimeLabel.Text = "Last Ran Tick: " + DateTime.Now;
                if (lastChecked.Date != DateTime.Today)
                {
                    lastCheckedDatabaseLabel.Text = "Last Checked Database: " + DateTime.Now;
                    lastChecked = DateTime.Today;
                    FireSharp.Config.FirebaseConfig c = new FireSharp.Config.FirebaseConfig();
                    c.AuthSecret = "NI7XHYpZL97crh1Hfh7biXC3C4FQvJIRzi8ZetcX";
                    c.BasePath   = "https://spoileralert-394.firebaseio.com";
                    FireSharp.FirebaseClient            f = new FireSharp.FirebaseClient(c);
                    FireSharp.Response.FirebaseResponse r = f.Get("/");

                    dynamic database = JsonConvert.DeserializeObject(r.Body);

                    foreach (var user in database)
                    {
                        List <String> expiredItems      = new List <string>();
                        var           id                = user.Name;
                        var           u                 = user.First;
                        var           settings          = u["settings"];
                        int           threshold         = settings["threshold"];
                        String        emailAddress      = settings["email"];
                        bool          wantNotifications = settings["notifications"];
                        var           l                 = u["fridge"];
                        if (l == null)
                        {
                            continue;
                        }
                        foreach (var item in l)
                        {
                            var   name       = item.Name;
                            var   arr        = item.Value;
                            int   quantity   = (int)arr.First.Value;
                            int   daysTil    = (int)arr.Last.Value;
                            int   updateData = daysTil - 1;
                            int[] newVal     = new int[2] {
                                quantity, updateData
                            };

                            if (updateData <= threshold)
                            {
                                expiredItems.Add(name);
                            }

                            // ---- Update the database ----- //
                            String path = String.Format("/{0}/fridge/{1}", id, name);

                            f.Set(path, newVal);
                        }

                        // ---- Email User with any expired items
                        if (wantNotifications && (expiredItems.Count > 0))
                        {
                            String body = "Hello there!\nThe following items from your fridge expire in ";
                            body = body + threshold;
                            body = body + " days: \n";
                            foreach (var s in expiredItems)
                            {
                                body = body + s;
                                body = body + "\n";
                            }

                            body = body + "\nStay Fresh!\nSpoilerAlert";
                            String subject = "A Message From Your Fridge";

                            MailMessage mail   = new MailMessage("SpoilerAlert <*****@*****.**>", emailAddress);
                            SmtpClient  client = new SmtpClient("smtp.gmail.com");
                            client.Port                  = 587;
                            client.EnableSsl             = true;
                            client.DeliveryMethod        = SmtpDeliveryMethod.Network;
                            client.UseDefaultCredentials = false;
                            client.Credentials           = new System.Net.NetworkCredential("youremail", "yourpassword");

                            mail.Subject = subject;
                            mail.Body    = body;
                            client.Send(mail);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            finally
            {
                activityTimer.Start();
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            IFirebaseConfig ifc = new FirebaseConfig()
            {
                AuthSecret = "1HQd7t7T8G5joitCGQ1qW0Jui3piFOGlvY0aG01o",
                BasePath   = "https://adam-ddc87.firebaseio.com/"
            };

            IFirebaseClient client;

            try
            {
                client = new FireSharp.FirebaseClient(ifc);
                Console.WriteLine("Conexación se realizo de manera exitosa");

                /* CRUD */
                // Create o insertar
                Estudiante estu = new Estudiante();

                estu.RollNo       = 2;
                estu.Nombre       = "Pepito Pechugas";
                estu.Calificacion = 5.89f;

                client.Set(@"Estudiantes/" + estu.RollNo, estu);
                Console.WriteLine("Los datos se guardaron de manera correcta");

                Console.WriteLine("Continuar");
                Console.ReadKey();

                // Read, lectura o búsqueda
                Console.Write("Ingresar dato a buscar: ");
                int busca = Convert.ToInt32(Console.ReadLine());

                // La búsqueda sobre la base de datos
                var        respuesta = client.Get(@"Estudiantes/" + busca);
                Estudiante dstu      = respuesta.ResultAs <Estudiante>();

                // Verificar si el objeto es no nulo
                if (dstu != null)
                {
                    Console.WriteLine("Registro hallado:");
                    Console.WriteLine("{0} tiene {1}", dstu.Nombre, dstu.Calificacion);
                }
                else
                {
                    Console.WriteLine("No se hallo el registro");
                }

                Console.WriteLine("Continuar");
                Console.ReadKey();

                // Update, actualización
                estu.Calificacion = 8.86f;
                estu.RollNo       = 2;
                client.Update(@"Estudiantes/" + estu.RollNo, estu);

                Console.WriteLine("Continuar");
                Console.ReadKey();
                // Delete, borrar
                client.Delete(@"Estudiantes/" + "1");
            }
            catch
            {
                Console.WriteLine("Error en obtener base de datos de la web");
            }
            finally
            {
                Console.WriteLine("Presione una tecla pa' salir");
                Console.ReadKey();
            }
        }