Exemplo n.º 1
0
        public static async System.Threading.Tasks.Task SaveUserAsync(UserModel model)
        {
            model.Id = Guid.NewGuid().ToString();
            string clearPasswd = GeneralHelper.CreateRandomPassword(5);

            model.Password       = HashHelper.GenerateSaltedHash(new SecureData(clearPasswd), new SecureData(model.UserName.ToLower())).ToString();;
            model.RemainingCount = 5;

            var client = new FireSharp.FirebaseClient(firebase.config);
            var get    = client.Get(@"User/");

            var rawdata           = JsonConvert.DeserializeObject <Dictionary <string, UserModel> >(get.Body);
            List <UserModel> list = new List <UserModel>();

            if (rawdata != null)
            {
                foreach (var item in rawdata)
                {
                    list.Add(item.Value);
                }

                if (list.Where(q => q.UserName.Equals(model.UserName) || q.Email.Equals(model.Email)).ToList().Count != 0)
                {
                    throw new Exception("hata");
                }
            }
            await client.PushAsync(@"User/", model);

            await MailHelper.SendMail(model.Email, "Sayın " + model.UserName + " uygulamaya giriş için şifreniz : " + clearPasswd + "\n Kullanım hakkınız 5 dir.");
        }
Exemplo n.º 2
0
        public async Task <int> IniciarCarga()
        {
            int             TotalInseridos;
            IFirebaseClient client  = new FireSharp.FirebaseClient(config);
            IFirebaseClient clientX = new FireSharp.FirebaseClient(configX);

            GravaLog("Iniciando", "Carga Iniciada!");

            ApagaTabelaTemporaria();

            Apagarconstraint();


            CriarTabelaTemporaria();

            GravaLog("Executando", "Tabela Temp Recriada!");

            //Obtendo Base AppInventor
            FirebaseResponse res2    = client.Get("/Appv09Bucket/");
            string           myJson2 = res2.Body;
            var jsonObj2             = JsonConvert.DeserializeObject <JObject>(myJson2).First.First;

            //Obtendo Base App Xamarin
            FirebaseResponse res1    = clientX.Get("/Appv09Bucket/");
            string           myJson1 = res1.Body;
            var jsonObj1             = JsonConvert.DeserializeObject <JObject>(myJson1).First.First;

            GravaLog("Executando", "Json Lido!");

            //DataTable App Inventor
            var DTFireBaseImportado = ImportarFireBaseNovaEstrutura(jsonObj2);

            //DataTable App Xamarin
            var DTFireBaseImportado1 = ImportarFireBaseNovaEstrutura(jsonObj1);

            GravaLog("Executando", "Json Convertido! Total de Registros base AppInventor: " + DTFireBaseImportado.Rows.Count.ToString() + ". Total base Xamarin: " + DTFireBaseImportado1.Rows.Count.ToString());

            TotalInseridos = ExportarLeituraSQL(DTFireBaseImportado) + ExportarLeituraSQL(DTFireBaseImportado1);

            GravaLog("Executando", "Json Inserido! Total de Registros: " + TotalInseridos.ToString());

            GravaLog("Fim", "Carga Finalizada!");

            //DadosSilimed();
            //Processar proc = new Processar();
            //proc.RetiraAmostaMedidorMedgel();
            //proc.ExcluirNaoNumerico(); //Ao invés de exlcuir, preciso gerar relatório para tratamento
            //proc.ExcluirMenorQueSete(); //Ao invés de exlcuir, preciso gerar relatório para tratamento

            //Ajustes();
            //ApagarDuplicados();
            return(1);
        }
Exemplo n.º 3
0
        public static UserModel GetUser(string userName)
        {
            var client = new FireSharp.FirebaseClient(firebase.config);
            var get    = client.Get(@"User/");

            var deser             = JsonConvert.DeserializeObject <Dictionary <string, UserModel> >(get.Body);
            List <UserModel> list = new List <UserModel>();

            foreach (var item in deser)
            {
                list.Add(item.Value);
            }

            return(list.Where(q => q.UserName.Equals(userName)).FirstOrDefault());
        }
Exemplo n.º 4
0
        private void btnEntrar_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(tbLogin.Text) &&
                string.IsNullOrWhiteSpace(tbSenha.Text))
            {
                MessageBox.Show("Por favor preencha todos os campos!");
                return;
            }

            User currentUser = new User()
            {
                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);
                FirebaseResponse response     = client.Get(@"Users/" + tbLogin.Text);
                User             Responseuser = response.ResultAs <User>();
                if (User.IsEqual(Responseuser, currentUser))
                {
                    MessageBox.Show("Usuario logado com sucesso!");
                }
                else
                {
                    MessageBox.Show(User.printError());
                }
            }
            catch (Exception m)
            {
                MessageBox.Show(m.Message);
            }
        }
Exemplo n.º 5
0
        public List <Bitacora> Read()
        {
            IFirebaseClient BitacoraI;

            IFirebaseConfig config = new FirebaseConfig
            {
                BasePath = "https://saptecnologiauai.firebaseio.com/"
            };

            BitacoraI = new FireSharp.FirebaseClient(config);
            FirebaseResponse response  = BitacoraI.Get("Bitacora");
            dynamic          data      = JsonConvert.DeserializeObject <dynamic>((response.Body));
            List <Bitacora>  Bitacoras = new List <Bitacora>();

            foreach (var item in data)
            {
                Bitacoras.Add(JsonConvert.DeserializeObject <Bitacora>(((JProperty)item).Value.ToString()));
            }
            return(Bitacoras);
        }
Exemplo n.º 6
0
        public static async System.Threading.Tasks.Task UpdateUser(string username)
        {
            var client = new FireSharp.FirebaseClient(firebase.config);
            var get    = client.Get(@"User/");

            var rawdata           = JsonConvert.DeserializeObject <Dictionary <string, UserModel> >(get.Body);
            List <UserModel> list = new List <UserModel>();

            if (rawdata != null)
            {
                foreach (var item in rawdata)
                {
                    if (item.Value.UserName == username)
                    {
                        UserModel user = item.Value;
                        user.RemainingCount -= 1;
                        await client.UpdateAsync(@"User/" + item.Key, user);
                    }
                }
            }
        }
Exemplo n.º 7
0
        // Method to configure the camera resolution so that the camera can read the barcode
        CameraResolution HandleCameraResolutionSelectorDelegate(List <CameraResolution> availableResolutions)
        {
            // Sets camera to the highest resolution avilable in order to read PDF417 barcode
            if (availableResolutions == null || availableResolutions.Count < 1)
            {
                return new CameraResolution()
                       {
                           Width = 800, Height = 600
                       }
            }
            ;

            return(availableResolutions[availableResolutions.Count - 1]);
        }

        // Configures the app with our database
        IFirebaseConfig ifc = new FirebaseConfig()
        {
            AuthSecret = "wpKeQkSg3RSCmvasQtXLCQohsyYDl1wdU7nYsNjg",
            BasePath   = "https://sd-barcode-security.firebaseio.com/"
        };

        // Instantiates our Firebase
        IFirebaseClient client;

        // Method that scans the bar code in the camera
        async void Scan_Barcode(object sender, System.EventArgs e)
        {
            var options = new MobileBarcodeScanningOptions
            {
                // Sets scanner to read PDF417 format
                TryHarder = true,
                CameraResolutionSelector = HandleCameraResolutionSelectorDelegate,
                PossibleFormats          = new List <BarcodeFormat> {
                    BarcodeFormat.PDF_417
                }
            };

            // Makes sure camera reconfigures focus if unable to read barcode at first
            options.TryHarder = true;

            // Creates the camera screen that the user places their barcode within
            var scanPage = new ZXingScannerPage(options);

            // Instantiates our Firebase object
            client = new FireSharp.FirebaseClient(ifc);

            // Waits on our scan page to be created
            await Navigation.PushModalAsync(scanPage);

            // Once scan page has read the barcode it stores the text in the variable result
            scanPage.OnScanResult += (result) =>
            {
                scanPage.IsScanning = false;

                Device.BeginInvokeOnMainThread(async() =>
                {
                    await Navigation.PopModalAsync();

                    // Accesses our datbase in order to recieve the key to decrypt the data
                    var info      = client.Get(@"flightKeys/DL263");
                    Flightkey get = info.ResultAs <Flightkey>();

                    // Once the data has been stored in the result variable and the app has accessed the firebase, the app automatically redirects to the results page where the data is presented
                    await Navigation.PushAsync(new ResultsPage(result.Text, get.key));
                });
            };
        }
    }
Exemplo n.º 8
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //client = new FireSharp.FirebaseClient(ifs);

            System.Net.NetworkInformation.NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
            String sMacAddress = string.Empty;

            foreach (NetworkInterface adapter in nics)
            {
                if (sMacAddress == String.Empty)// only return MAC Address from first card
                {
                    IPInterfaceProperties properties = adapter.GetIPProperties();
                    sMacAddress = adapter.GetPhysicalAddress().ToString();
                }
                //  Me
            }
            macaddress = sMacAddress;


            SqlConnection   con = new SqlConnection(Properties.Settings.Default.InventoryMgntConnectionString);
            IFirebaseConfig ifs = new FirebaseConfig()
            {
                AuthSecret = "BNccxyAb8l3p4CJZcrCwwB3N6KYw3o5N3fjkG8w8",
                BasePath   = "https://inventory-application-76653-default-rtdb.firebaseio.com/"
            };
            IFirebaseClient client;

            try
            {
                client = new FireSharp.FirebaseClient(ifs);



                var             seeter = client.Get("clientData/" + macaddress);
                autontification fdd    = seeter.ResultAs <autontification>();
                macaddrss = fdd.MacAddress;
                joingdate = fdd.joingDate;
                expdate   = fdd.trialend;
                //  startDate = DateTime.Parse(joingdate);
                // expdate = startDate.AddDays(30);
//MessageBox.Show("data " + expiryDate);
            }
            catch (Exception ew)
            {
                // MessageBox.Show("internet Connection not open"+ew);
            }

            if (macaddress == macaddrss)
            {
                con.Open();
                SqlCommand cmd      = new SqlCommand("Select count(*)  from PasswordCheek ", con);
                int        password = Convert.ToInt32(cmd.ExecuteScalar());
                con.Close();
                if (password == 0)
                {
                    Application.Run(new Dashboard());
                }
                else
                {
                    Application.Run(new LoginForm());
                }
            }
            else
            {
                Application.Run(new FirstLogin());
            }
        }
Exemplo n.º 9
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.º 10
0
        public static List <MyDiagnosis> GenerateDiagnoseList(string FromDate, string ToDate)
        {
            IFirebaseConfig config = new FirebaseConfig
            {
                AuthSecret = "C8u58eR9CaCRk8zC0a11EYHCC94eI0DkVQbPmbdb",
                BasePath   = "https://theusers-b5706.firebaseio.com/"
            };

            IFirebaseClient client;

            client = new FireSharp.FirebaseClient(config);

            var         res1          = client.Get(@"Diagnose/");
            MyDiagnosis ResDiagnosis1 = res1.ResultAs <MyDiagnosis>();
            var         i             = ResDiagnosis1.Counter.ToString();
            int         c             = Convert.ToInt32(i);

            List <MyDiagnosis> dia2 = new List <MyDiagnosis>();

            //for (int a = 0; a < b; b--) //keep looping until condition is false
            for (int d = 1; d <= c; d++)
            {
                //var res = client.Get(@"Diagnose/" + b);
                var         res          = client.Get(@"Diagnose/" + d);
                MyDiagnosis ResDiagnosis = res.ResultAs <MyDiagnosis>();

                DateTime Date  = Convert.ToDateTime(ResDiagnosis.Date); //database daytime
                DateTime Date1 = Convert.ToDateTime(FromDate);          //user given date
                DateTime Date2 = Convert.ToDateTime(ToDate);            //user give date

                if (FromDate == null && ToDate == null)
                {
                    dia2.Add(new MyDiagnosis
                    {
                        Angina              = ResDiagnosis.Angina,
                        Bruise              = ResDiagnosis.Bruise,
                        CoughingUpBlood     = ResDiagnosis.CoughingUpBlood,
                        Coughing            = ResDiagnosis.Coughing,
                        Coma                = ResDiagnosis.Coma,
                        Dizzy               = ResDiagnosis.Dizzy,
                        Diarrhea            = ResDiagnosis.Diarrhea,
                        DifficultyBreathing = ResDiagnosis.DifficultyBreathing,
                        Flu                = ResDiagnosis.Flu,
                        FootPain           = ResDiagnosis.FootPain,
                        GenitalPain        = ResDiagnosis.GenitalPain,
                        HandPain           = ResDiagnosis.HandPain,
                        Headache           = ResDiagnosis.Headache,
                        Itch               = ResDiagnosis.Itch,
                        Incontinence       = ResDiagnosis.Incontinence,
                        IrregularHeartRate = ResDiagnosis.IrregularHeartRate,
                        MusclePain         = ResDiagnosis.MusclePain,
                        MouthUlcer         = ResDiagnosis.MouthUlcer,
                        Rash               = ResDiagnosis.Rash,
                        RigidMuscles       = ResDiagnosis.RigidMuscles,
                        RunnyNose          = ResDiagnosis.RunnyNose,
                        ShoulderPain       = ResDiagnosis.ShoulderPain,
                        Stomachache        = ResDiagnosis.Stomachache,
                        SoreThroat         = ResDiagnosis.SoreThroat,
                        Sputum             = ResDiagnosis.Sputum,
                        Sneezing           = ResDiagnosis.Sneezing,
                        Toothache          = ResDiagnosis.Toothache,
                        Tinnitus           = ResDiagnosis.Tinnitus,
                        UrethralPain       = ResDiagnosis.UrethralPain,
                        VomitingBlood      = ResDiagnosis.VomitingBlood,
                        Class              = ResDiagnosis.Class,
                        Reasonings         = ResDiagnosis.Reasonings
                    });
                }
                else if (Date1.Year <= Date.Year && Date.Year <= Date2.Year && Date1.Month <= Date.Month && Date.Month <= Date2.Month && Date1.Day <= Date.Day && Date.Day <= Date2.Day)
                {
                    dia2.Add(new MyDiagnosis
                    {
                        Angina              = ResDiagnosis.Angina,
                        Bruise              = ResDiagnosis.Bruise,
                        CoughingUpBlood     = ResDiagnosis.CoughingUpBlood,
                        Coughing            = ResDiagnosis.Coughing,
                        Coma                = ResDiagnosis.Coma,
                        Dizzy               = ResDiagnosis.Dizzy,
                        Diarrhea            = ResDiagnosis.Diarrhea,
                        DifficultyBreathing = ResDiagnosis.DifficultyBreathing,
                        Flu                = ResDiagnosis.Flu,
                        FootPain           = ResDiagnosis.FootPain,
                        GenitalPain        = ResDiagnosis.GenitalPain,
                        HandPain           = ResDiagnosis.HandPain,
                        Headache           = ResDiagnosis.Headache,
                        Itch               = ResDiagnosis.Itch,
                        Incontinence       = ResDiagnosis.Incontinence,
                        IrregularHeartRate = ResDiagnosis.IrregularHeartRate,
                        MusclePain         = ResDiagnosis.MusclePain,
                        MouthUlcer         = ResDiagnosis.MouthUlcer,
                        Rash               = ResDiagnosis.Rash,
                        RigidMuscles       = ResDiagnosis.RigidMuscles,
                        RunnyNose          = ResDiagnosis.RunnyNose,
                        ShoulderPain       = ResDiagnosis.ShoulderPain,
                        Stomachache        = ResDiagnosis.Stomachache,
                        SoreThroat         = ResDiagnosis.SoreThroat,
                        Sputum             = ResDiagnosis.Sputum,
                        Sneezing           = ResDiagnosis.Sneezing,
                        Toothache          = ResDiagnosis.Toothache,
                        Tinnitus           = ResDiagnosis.Tinnitus,
                        UrethralPain       = ResDiagnosis.UrethralPain,
                        VomitingBlood      = ResDiagnosis.VomitingBlood,
                        Class              = ResDiagnosis.Class,
                        Reasonings         = ResDiagnosis.Reasonings
                    });
                }
            }
            return(dia2);
        }
Exemplo n.º 11
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();
            }
        }
Exemplo n.º 12
0
        public void listBox1_DoubleClick(object sender, EventArgs e)
        {
            deviceInfo = devices.ElementAt(listBox1.SelectedIndex);
            updateUI(deviceInfo.DeviceName + "  was selected.");

            data[0] = deviceInfo.DeviceAddress.ToString();
            // data[1] = zipFolderPath;
            // data[2] = password_result;
            //  data[3] = deviceInfo.DeviceName;
            client = new FireSharp.FirebaseClient(ifc);
            if (client == null)
            {
                MessageBox.Show("there was some internet error");
            }

            var res = client.Get(@"fileData/" + data[0]);
            // var set = client.Set(@"fileData/" + data[key, 0], fd);

            fileData fd = res.ResultAs<fileData>();

            if(fd == null)
            {
                MessageBox.Show("Selected Device is not registered!");
            }
            else
            {
                data[1] = fd.FolderPath;
                data[2] = fd.Password;
                data[3] = fd.DeviceName;
               // button1.Enabled = true;
                using (Form_password f_password = new Form_password())
                {
                    f_password.ShowDialog();

                    password_result = f_password.returnValue();
                    if (password_result.Trim() == string.Empty)
                    {
                        MessageBox.Show("This Field cannot left empty!");
                        return; // return because we don't want to run normal code of buton click
                    }
                    // MessageBox.Show(password_result);

                }

                if(password_result == data[2])
                {
                    updateUI2("Device Address : "+data[0]);
                    updateUI2("Encrypted Folder : " + data[1].Remove(data[1].Length - 4, 4));
                    updateUI2("Password : "******"Device Name : "+ data[3]);
                    button1.Enabled = true;
                    updateUI("Press OK to decrypt folder.");
                }
                else
                {
                    MessageBox.Show("Please Enter Correct password!");
                    return;
                }

            }   

        }