Ejemplo n.º 1
0
Archivo: FB.cs Proyecto: EdersF/sinp
        public void AtualizaRupturaPK()
        {
            IFirebaseClient firebase = new FirebaseClient(config);
            IDataReader     retornoBD;

            SQL = "SELECT B.data2, ROUND(CAST(ifnull(a.rupt, 0) AS FLOAT) / CAST(ifnull(b.fat, 0) AS FLOAT)*100, 2) " +
                  "FROM " +
                  "(SELECT substr(data, 1, 6) data2, SUM(linhas) fat " +
                  "FROM Faturamento " +
                  "GROUP BY substr(data, 1, 6)) B " +
                  "LEFT JOIN " +
                  "(SELECT substr(data, 1, 6) data2, COUNT(data) rupt " +
                  "FROM Ruptura_PK " +
                  "WHERE tipo_ruptura = 'RUPTURA DE PICKING'" +
                  "GROUP BY substr(data, 1, 6)) A " +
                  "ON a.data2 = b.data2";
            liteBD.AbrirConexao();
            retornoBD = liteBD.ConsultaReader(SQL);
            try
            {
                while (retornoBD.Read())
                {
                    firebase.Set("ruptura/" + retornoBD[0] + "/percent", retornoBD[1]);
                    firebase.Set("ruptura/" + retornoBD[0] + "/target", 0.1);
                }
                firebase.Set("ruptura/ultima_atualizacao", DateTime.Now.ToString());
            }
            catch (Exception)
            {
                MessageBox.Show("O aplicativo não foi atualizado, verifique sua conexão com a internet!", "Falha na atualização do aplicativo", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            liteBD.FecharConexao();
        }
Ejemplo n.º 2
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);
                    }
                }
            }
        }
Ejemplo n.º 3
0
 public bool LoginToken(String newAnimal, String token)
 {
     try
     {
         client.Set("user/" + newAnimal, token); // custom key
         return(true);
     }
     catch (Exception ex) { return(false); }
 }
 private void updateFirebaseU(string mMyEpc, double[,] locationArrayU)
 {
     try
     {
         fclient.Set("TheIDs/ID0" + mMyEpc.ToUpper() + "/xlocation", locationArrayU[0, 0]);
         fclient.Set("TheIDs/ID0" + mMyEpc.ToUpper() + "/ylocation", locationArrayU[1, 0]);
     }
     catch { }
 }
Ejemplo n.º 5
0
 public bool AddNew(Book newBook)
 {
     try
     {
         //client.Push("books", newBook); // auto-generated key
         client.Set("books/B" + newBook.Code, newBook); // custom key
         return(true);
     }
     catch { return(false); }
 }
Ejemplo n.º 6
0
 public static bool Register(string username, string password)
 {
     if (!client.Get(userPath + username).Body.Equals("null"))
     {
         return(false);
     }
     else
     {
         client.Set(userPath + username, new User(username, password));
         return(true);
     }
 }
Ejemplo n.º 7
0
        public static void ReportResults()
        {
            var names          = typeof(TTestClass).GetField("Names").GetValue(null);
            var updatedResults = UpdateResults();

            Console.WriteLine(names);
            if (updatedResults.Count == 0)
            {
                return;
            }
            foreach (var tuple in updatedResults)
            {
                Console.WriteLine(tuple);
            }
            var config = new FirebaseConfig
            {
                BasePath = "https://testing-challenge.firebaseio.com/bowling/"
            };

            using (var client = new FirebaseClient(config))
            {
                client.Set(names + "/tests", updatedResults.ToDictionary(kv => kv.Key, kv => kv.Value.ToString().ToLower()));
            }
            Console.WriteLine("reported");
        }
Ejemplo n.º 8
0
        public ActionResult Edit(Student student)
        {
            IFirebaseClient client   = new FirebaseClient(config);
            SetResponse     response = client.Set("Students/" + student.student_id, student);

            return(RedirectToAction("Index"));
        }
        public IActionResult Index(Student objStudent)
        {
            IFirebaseClient client = new FirebaseClient(objFireConfig);
            var             setter = client.Set("StudentList/" + objStudent.StudentId, objStudent);

            return(Content("Hello, " + objStudent.StudentId + "-" + objStudent.StudentName + " Inserted Successfully!!"));
        }
Ejemplo n.º 10
0
 public void SetSettings <T>(string fieldName, T value)
 {
     if (client == null)
     {
         return;
     }
     client.Set <T>($"camsnet/settings/{fieldName}", value);
 }
Ejemplo n.º 11
0
        public void UpdateToFirebase(bool StatusUpdate)
        {
            IFirebaseClient client = new FirebaseClient(config);

            if (client != null)
            {
                var response = client.Set("/StatusUpdate", StatusUpdate);
            }
        }
Ejemplo n.º 12
0
        public ActionResult Create(Staff staff)
        {
            IFirebaseClient client = new FirebaseClient(config);
            var             data   = staff;

            PushResponse response = client.Push("Staffs/", data);

            data.staff_id = response.Result.name;
            SetResponse setResponse = client.Set("Staffs/" + data.staff_id, data);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 13
0
        public ActionResult Create(User user)
        {
            IFirebaseClient client = new FirebaseClient(config);
            var data = user;
            PushResponse response = client.Push("Users/", user);
            data.user_id = response.Result.name;
            SetResponse setResponse = client.Set("Users/" + data.user_id, data);


            return RedirectToAction("Index");
            
        }
Ejemplo n.º 14
0
        static void Generate()
        {
            IFirebaseConfig config = new FirebaseConfig
            {
                AuthSecret = "r0Dx9Gi0gj7g3kZ4EJQodtFgOIq80IuBfBuko8HS",
                BasePath   = "https://fir-2d407.firebaseio.com/"
            };
            IFirebaseClient client = new FirebaseClient(config);

            FirebaseResponse response = client.Get("Last/Sensor values/Id");
            int    displacement       = Convert.ToInt16(response.Body);
            int    i      = displacement;
            Random random = new Random();

            while (true)
            {
                i++;
                FirebaseValue sensval = new FirebaseValue(i, 92 + Math.Round(random.NextDouble(), 2), DateTime.Now);
                client.Set("Sensor values/" + sensval.Id, sensval);
                client.Set("Last/Sensor values", sensval);
            }
        }
Ejemplo n.º 15
0
        public ActionResult Delete(string project_id, string nameproject, string type, string goal, string detail)
        {
            IFirebaseClient client = new FirebaseClient(config);
            Project         data   = new Project();

            data.project_id  = project_id;
            data.nameproject = nameproject;
            data.type        = type;
            data.goal        = goal;
            data.detail      = detail;
            data.isdelete    = "1";
            SetResponse response = client.Set("Projects/" + data.project_id, data);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 16
0
        public static void execute()
        {
            Dictionary <string, List <Street> > content = JsonConvert.DeserializeObject <Dictionary <string, List <Street> > >(File.ReadAllText("../../Linz.json"));

            content["streets"].RemoveAll(s => string.IsNullOrEmpty(s.is_in) || string.IsNullOrEmpty(s.name) || !s.is_in.ToLower().Contains("linz") || s.is_in.ToLower().Contains("linz-land"));

            IFirebaseConfig config = new FirebaseConfig
            {
                AuthSecret = "tqbbj0jnqp04G3LfRzptLBL82pSvBDW374GeXJEl",
                BasePath   = "https://linzgeoquiz.firebaseio.com"
            };

            IFirebaseClient client = new FirebaseClient(config);

            client.Set("geoobjects", content);
        }
Ejemplo n.º 17
0
        public ActionResult Delete(string staff_id, string password_staff, string name, string phone, string email)
        {
            IFirebaseClient client = new FirebaseClient(config);
            Staff           data   = new Staff();

            data.staff_id       = staff_id;
            data.password_staff = password_staff;
            data.name           = name;
            data.phone          = phone;
            data.email          = email;
            data.isdelete       = "1";
            ViewData["data"]    = data;
            SetResponse response = client.Set("Staffs/" + data.staff_id, data);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 18
0
 private static void PostResults(IList <ImplementationStatus> statuses)
 {
     try
     {
         var config = new FirebaseConfig
         {
             BasePath = "https://testing-challenge.firebaseio.com/word-statistics/"
         };
         using (var client = new FirebaseClient(config))
         {
             client.Set(names + "/implementations", statuses.Select(s => s.FailsCount).ToArray());
         }
         Console.WriteLine("");
     }
     catch
     {
         Console.WriteLine("...");
     }
 }
Ejemplo n.º 19
0
        private void buttonKayıt_Click(object sender, EventArgs e)
        {
            User u = new User();

            u.KullanıcıAdı = kAdi.Text;
            u.Şifre        = Sifre.Text;


            IFirebaseConfig config = new FirebaseConfig()
            {
                AuthSecret = "Um2q5EJk0TzKlL8BJIEI8XfHrylv0Nx5JpewBOiN",
                BasePath   = "https://ogrenci-topluluklari.firebaseio.com/USERS"
            };
            IFirebaseClient client = new FirebaseClient(config);

            var set = client.Set(@"/" + kAdi.Text, u);

            Login lgn = new Login();

            lgn.Show();
            this.Close();
        }
Ejemplo n.º 20
0
        public IActionResult Create(Reportdonet reportdonet)
        {
            Reportdonet r     = reportdonet;
            DateTime    aDate = DateTime.Now;
            string      day   = aDate.ToString("dd");
            string      month = aDate.ToString("MM");
            string      year  = aDate.ToString("yyyy");

            r.date = day + " " + month + " " + year;
            Random rnd = new Random();
            int    no  = rnd.Next(1000, 10000);

            r.no = no.ToString();
            IFirebaseClient client = new FirebaseClient(config);
            var             data   = r;

            PushResponse response = client.Push("Reportdonets/", r);

            data.reportdonet_id = response.Result.name;
            SetResponse setResponse = client.Set("Reportdonets/" + data.reportdonet_id, data);

            return(RedirectToAction("Index"));
        }
Ejemplo n.º 21
0
        private void atualizaFirebase()
        {
            IFirebaseClient firebase = new FirebaseClient(config);
            IDataReader     retornoBD;
            AccessBD        conex = new AccessBD();

            conex.AbrirConexao();
            string  dataDe, dataAte;
            decimal rotativoPercent = 0;
            string  mes             = DateTime.Now.Month.ToString();
            string  ano             = DateTime.Now.Year.ToString();


            //:::::::::::::::::::::::::::: Setando FireBase:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            //EAN x Posicao
            dataDe  = Convert.ToString(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + "01");
            dataAte = Convert.ToString(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00"));
            SQL     = "SELECT EXPR1, EXPR2 FROM (SELECT Mid(DAT_CONT,5,2) AS Expr1, Round(Avg(ACUR)*100,2) AS Expr2 " +
                      "FROM(SELECT DAT_CONT, DOC_INV1, POS_DEP, IIf(COUNT(PRODUTO) > 2, 1, IIf(COUNT(PRODUTO) = 1, 1, 0)) AS ACUR FROM(SELECT INVENTARIO.DAT_CONT, INVENTARIO.DOC_INV1, INVENTARIO.POS_DEP, INVENTARIO.PRODUTO FROM INVENTARIO RIGHT JOIN POSICAO ON INVENTARIO.POS_DEP = POSICAO.POSICAO WHERE POSICAO.TIPO_DEP <> 1003 GROUP BY INVENTARIO.DOC_INV1, INVENTARIO.POS_DEP, INVENTARIO.PRODUTO, INVENTARIO.DAT_CONT)  AS[%$##@_Alias] GROUP BY DOC_INV1, POS_DEP, DAT_CONT) AS [%$##@_Alias] " +
                      "GROUP BY Mid(DAT_CONT, 5, 2)) WHERE EXPR1 <> 0; ";
            string ultimaAtualizacao = conex.consultaScalar("SELECT RIGHT(DAT_post, 2) &'/'& MID(DAT_post, 5, 2) &'/'& LEFT(DAT_post, 4)   & ' ÀS ' & MAX(hr_post) AS hr_post FROM INVENTARIO WHERE (((INVENTARIO.[DAT_POST])=(SELECT Max(dat_POST) FROM INVENTARIO))) group by dat_post");

            retornoBD = conex.consultaReader(SQL);
            while (retornoBD.Read())
            {
                firebase.Set("EanPosicao/" + retornoBD.GetString(0) + ano + "/Acuracidade", retornoBD.GetDouble(1));
                firebase.Set("EanPosicao/" + retornoBD.GetString(0) + ano + "/UltimaAtualizacao", ultimaAtualizacao);
            }

            // Evolução Rotativo
            switch (DateTime.Now.Month)
            {
            case 1:
            case 2:
            case 3:
                dataDe  = DateTime.Now.Year + "0101";
                dataAte = Convert.ToString(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00"));
                break;

            case 4:
            case 5:
            case 6:
                dataDe  = DateTime.Now.Year + "0401";
                dataAte = Convert.ToString(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00"));
                break;

            case 7:
            case 8:
            case 9:
                dataDe  = DateTime.Now.Year + "0701";
                dataAte = Convert.ToString(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00"));
                break;

            case 10:
            case 11:
            case 12:
                dataDe  = DateTime.Now.Year + "1001";
                dataAte = Convert.ToString(DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString("00") + DateTime.Now.Day.ToString("00"));
                break;
            }
            SQL             = "SELECT (SELECT COUNT(POS) FROM (SELECT POS_DEP AS POS FROM INVENTARIO WHERE DAT_CONT BETWEEN " + dataDe + " AND " + dataAte + " GROUP BY POS_DEP)) / COUNT(CODPOS) FROM POSICAO";
            rotativoPercent = Convert.ToDecimal(conex.consultaScalar(SQL));
            firebase.Set("Rotativo/" + mes + ano + "/Concluido", Convert.ToDouble((rotativoPercent * 100).ToString("0.00")));
            firebase.Set("Rotativo/" + mes + ano + "/ultimaAtualizacao", ultimaAtualizacao);
        }
Ejemplo n.º 22
0
        public bool PutUsers(List <User> users)
        {
            var response = _firebaseClient.Set("User", users);

            return(true);
        }
Ejemplo n.º 23
0
        public async Task <IActionResult> Create(Project project, IFormFile file, IFormFile file2, IFormFile file3)
        {
            FileStream fs          = null;
            FileStream fs2         = null;
            FileStream fs3         = null;
            var        fileupload  = file;
            var        fileupload2 = file2;
            var        fileupload3 = file3;

            if (fileupload == null)
            {
                IFirebaseClient client = new FirebaseClient(config);
                var             data   = project;

                PushResponse response = client.Push("Projects/", project);
                data.project_id = response.Result.name;
                SetResponse setResponse = client.Set("Projects/" + data.project_id, data);
            }
            else
            {
                if (fileupload.Length > 0)
                {
                    if (fileupload2 == null && fileupload3 == null)
                    {
                        try
                        {
                            if (!Directory.Exists(_environment.WebRootPath + "\\imageproject\\"))
                            {
                                Directory.CreateDirectory(_environment.WebRootPath + "\\imageproject\\");
                            }
                            //ReName Image
                            Guid guid = Guid.NewGuid();

                            string fileName  = Path.GetFileNameWithoutExtension(file.FileName);
                            string extension = Path.GetExtension(file.FileName);
                            fileName = guid + extension;


                            string img = "/imageproject/" + fileName;
                            //
                            string path2 = Path.Combine(_environment.WebRootPath, $"imageproject");
                            if (Directory.Exists(path2))
                            {
                                using (fs = new FileStream(Path.Combine(path2, fileupload.FileName), FileMode.Create))
                                {
                                    await fileupload.CopyToAsync(fs);
                                }
                                fs = new FileStream(Path.Combine(path2, fileupload.FileName), FileMode.Open);
                            }
                            else
                            {
                            }
                            //
                            //  var auth = new FirebaseAuthProvider(new FirebaseConfig(ApiKey));
                            //  var a = await auth.SignInWithEmailAndPasswordAsync(AuthEmail, AuthPassword);
                            //
                            var cancellation = new CancellationTokenSource();

                            var upload = new FirebaseStorage(
                                Bucket,
                                new FirebaseStorageOptions
                            {
                                //  AuthTokenAsyncFactory = () => Task.FromResult(a.FirebaseToken),
                                ThrowOnCancel = true
                            })
                                         .Child("imagesproject")
                                         .Child(fileName)
                                         .PutAsync(fs, cancellation.Token);
                            try
                            {
                                string link = await upload;
                                project.image = link;
                                IFirebaseClient client = new FirebaseClient(config);
                                var             data   = project;

                                PushResponse response = client.Push("Projects/", project);
                                data.project_id = response.Result.name;
                                SetResponse setResponse = client.Set("Projects/" + data.project_id, data);


                                return(RedirectToAction("Index"));
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine($"*******************{ex}************************");
                                throw;
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                    else if (fileupload2.Length > 0 && fileupload3 == null)
                    {
                        try
                        {
                            if (!Directory.Exists(_environment.WebRootPath + "\\imageproject\\") && !Directory.Exists(_environment.WebRootPath + "\\imageproject2\\"))
                            {
                                Directory.CreateDirectory(_environment.WebRootPath + "\\imageproject\\");
                                Directory.CreateDirectory(_environment.WebRootPath + "\\imageproject2\\");
                            }
                            //ReName Image
                            Guid   guid      = Guid.NewGuid();
                            Guid   guid2     = Guid.NewGuid();
                            string fileName  = Path.GetFileNameWithoutExtension(file.FileName);
                            string extension = Path.GetExtension(file.FileName);
                            fileName = guid + extension;

                            string fileName2  = Path.GetFileNameWithoutExtension(file2.FileName);
                            string extension2 = Path.GetExtension(file2.FileName);

                            fileName2 = "image2" + extension2;

                            //
                            string path2 = Path.Combine(_environment.WebRootPath, $"imageproject");
                            string path3 = Path.Combine(_environment.WebRootPath, $"imageproject2");
                            if (Directory.Exists(path2) && Directory.Exists(path3))
                            {
                                using (fs = new FileStream(Path.Combine(path2, fileupload.FileName), FileMode.Create))
                                {
                                    await fileupload.CopyToAsync(fs);
                                }
                                fs = new FileStream(Path.Combine(path2, fileupload.FileName), FileMode.Open);

                                using (fs2 = new FileStream(Path.Combine(path3, fileupload2.FileName), FileMode.Create))
                                {
                                    await fileupload2.CopyToAsync(fs2);
                                }
                                fs2 = new FileStream(Path.Combine(path3, fileupload2.FileName), FileMode.Open);
                            }

                            //
                            //  var auth = new FirebaseAuthProvider(new FirebaseConfig(ApiKey));
                            //  var a = await auth.SignInWithEmailAndPasswordAsync(AuthEmail, AuthPassword);
                            //
                            var cancellation  = new CancellationTokenSource();
                            var cancellation2 = new CancellationTokenSource();

                            var upload = new FirebaseStorage(
                                Bucket,
                                new FirebaseStorageOptions
                            {
                                //  AuthTokenAsyncFactory = () => Task.FromResult(a.FirebaseToken),
                                ThrowOnCancel = true
                            })
                                         .Child("imagesproject")
                                         .Child(fileName)
                                         .PutAsync(fs, cancellation.Token);

                            var upload2 = new FirebaseStorage(
                                Bucket,
                                new FirebaseStorageOptions
                            {
                                //  AuthTokenAsyncFactory = () => Task.FromResult(a.FirebaseToken),
                                ThrowOnCancel = true
                            })
                                          .Child("imagesproject")
                                          .Child(fileName2)
                                          .PutAsync(fs2, cancellation2.Token);
                            try
                            {
                                string link  = await upload;
                                string link2 = await upload2;
                                project.image  = link;
                                project.image2 = link2;
                                IFirebaseClient client = new FirebaseClient(config);
                                var             data   = project;

                                PushResponse response = client.Push("Projects/", project);
                                data.project_id = response.Result.name;
                                SetResponse setResponse = client.Set("Projects/" + data.project_id, data);


                                return(RedirectToAction("Index"));
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine($"*******************{ex}************************");
                                throw;
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                    else if (fileupload.Length > 0 && fileupload2.Length > 0 && fileupload3.Length > 0)
                    {
                        try
                        {
                            if (!Directory.Exists(_environment.WebRootPath + "\\imageproject\\"))
                            {
                                Directory.CreateDirectory(_environment.WebRootPath + "\\imageproject\\");
                            }
                            //ReName Image
                            Guid guid  = Guid.NewGuid();
                            Guid guid2 = Guid.NewGuid();
                            Guid guid3 = Guid.NewGuid();

                            string fileName  = Path.GetFileNameWithoutExtension(file.FileName);
                            string extension = Path.GetExtension(file.FileName);
                            fileName = guid + extension;

                            string fileName2  = Path.GetFileNameWithoutExtension(file2.FileName);
                            string extension2 = Path.GetExtension(file2.FileName);
                            fileName2 = guid2 + extension2;

                            string fileName3  = Path.GetFileNameWithoutExtension(file3.FileName);
                            string extension3 = Path.GetExtension(file3.FileName);
                            fileName3 = guid3 + extension3;


                            //
                            string path2 = Path.Combine(_environment.WebRootPath, $"imageproject");
                            if (Directory.Exists(path2))
                            {
                                using (fs = new FileStream(Path.Combine(path2, fileupload.FileName), FileMode.Create))
                                {
                                    await fileupload.CopyToAsync(fs);
                                }
                                fs = new FileStream(Path.Combine(path2, fileupload.FileName), FileMode.Open);

                                using (fs2 = new FileStream(Path.Combine(path2, fileupload2.FileName), FileMode.Create))
                                {
                                    await fileupload3.CopyToAsync(fs2);
                                }
                                fs2 = new FileStream(Path.Combine(path2, fileupload2.FileName), FileMode.Open);

                                using (fs3 = new FileStream(Path.Combine(path2, fileupload3.FileName), FileMode.Create))
                                {
                                    await fileupload3.CopyToAsync(fs3);
                                }
                                fs3 = new FileStream(Path.Combine(path2, fileupload3.FileName), FileMode.Open);
                            }
                            else
                            {
                            }
                            //
                            //  var auth = new FirebaseAuthProvider(new FirebaseConfig(ApiKey));
                            //  var a = await auth.SignInWithEmailAndPasswordAsync(AuthEmail, AuthPassword);
                            //
                            var cancellation  = new CancellationTokenSource();
                            var cancellation2 = new CancellationTokenSource();
                            var cancellation3 = new CancellationTokenSource();

                            var upload = new FirebaseStorage(
                                Bucket,
                                new FirebaseStorageOptions
                            {
                                //  AuthTokenAsyncFactory = () => Task.FromResult(a.FirebaseToken),
                                ThrowOnCancel = true
                            })
                                         .Child("imagesproject")
                                         .Child(fileName)
                                         .PutAsync(fs, cancellation.Token);

                            var upload2 = new FirebaseStorage(
                                Bucket,
                                new FirebaseStorageOptions
                            {
                                //  AuthTokenAsyncFactory = () => Task.FromResult(a.FirebaseToken),
                                ThrowOnCancel = true
                            })
                                          .Child("imagesproject")
                                          .Child(fileName2)
                                          .PutAsync(fs2, cancellation2.Token);

                            var upload3 = new FirebaseStorage(
                                Bucket,
                                new FirebaseStorageOptions
                            {
                                //  AuthTokenAsyncFactory = () => Task.FromResult(a.FirebaseToken),
                                ThrowOnCancel = true
                            })
                                          .Child("imagesproject")
                                          .Child(fileName3)
                                          .PutAsync(fs3, cancellation3.Token);
                            try
                            {
                                string link  = await upload;
                                string link2 = await upload2;
                                string link3 = await upload3;
                                project.image  = link;
                                project.image2 = link2;
                                project.image3 = link3;
                                IFirebaseClient client = new FirebaseClient(config);
                                var             data   = project;

                                PushResponse response = client.Push("Projects/", project);
                                data.project_id = response.Result.name;
                                SetResponse setResponse = client.Set("Projects/" + data.project_id, data);


                                return(RedirectToAction("Index"));
                            }
                            catch (Exception ex)
                            {
                                Debug.WriteLine($"*******************{ex}************************");
                                throw;
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                        }
                    }
                }
            }


            return(RedirectToAction("Index"));
        }
        public string SetFireBaseData(string AuthSecret, string BasePath, string item)
        {
            IFirebaseConfig config = new FirebaseConfig
            {
                AuthSecret = AuthSecret,
                BasePath = BasePath
            };

            IFirebaseClient client = new FirebaseClient(config);

            var todo = new
            {
                name = "Execute SET",
                priority = 2
            };

            SetResponse response = client.Set(item, todo);

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

            return retorno;
        }