Exemplo n.º 1
0
        // UpdateProfile()
        public void UpdateProfile(List <string> data, string UserName)
        {
            var db = new PocoDynamo(con.GetClient());

            try
            {
                db.RegisterTable <Users>();

                db.UpdateItem(UserName,
                              put: () => new Users
                {
                    FirstName = data[0],
                    LastName  = data[1],
                    Email     = data[2],
                    Telephone = data[3],
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> UpdateProfile(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 2
0
        // DeletePanel()
        public void DeletePanel(string IdPanel)
        {
            var db = new PocoDynamo(con.GetClient());

            db.RegisterTable <Panels>();

            try
            {
                db.DeleteItem <Panels>(IdPanel);

                db.RegisterTable <SwitchInfo>();
                for (int i = 0; i < 42; i++)
                {
                    db.DeleteItem <SwitchInfo>(IdPanel + "_S" + i);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MPanels -> DeletePanel(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 3
0
        // EditUser()
        public void EditUser(Users EditUser)
        {
            var db = new PocoDynamo(con.GetClient());

            try
            {
                db.RegisterTable <Users>();

                db.UpdateItem(EditUser.UserName,
                              put: () => new Users
                {
                    FirstName = EditUser.FirstName,
                    LastName  = EditUser.LastName,
                    Email     = EditUser.Email,
                    IdCard    = EditUser.IdCard,
                    IdRole    = EditUser.IdRole,
                    Telephone = EditUser.Telephone,
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> EditUser(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 4
0
        // GetInfo()
        public int GetData2(string IdSwitch)
        {
            Debug.WriteLine(IdSwitch);

            var db = new PocoDynamo(con.GetClient());
            var r  = 0;

            try
            {
                var q        = db.FromQuery <testData>(x => x.Id == IdSwitch);
                var dbOrders = db.Query(q).Last();

                var results = dbOrders;
                r = results.payload.Medicion;
                Debug.WriteLine(results.Id);
                Debug.WriteLine(r);
                Debug.WriteLine(results.payload.Time);

                //res = db.ScanAll<testData>().Where(x => x.Id == "thing01/data").ToArray();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MPanels -> GetInfo(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
            return(r);
        }
Exemplo n.º 5
0
        // UpdateSecretCode()
        private string _UpdateSecretCode(string UserName)
        {
            var db            = new PocoDynamo(con.GetClient());
            var NewSecretCode = _CreateRandomPassword();

            try
            {
                db.RegisterTable <Users>();

                db.UpdateItem(UserName,
                              put: () => new Users
                {
                    SecretCode = _tools.Encrypt(NewSecretCode)
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> UpdateSecretCode(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
            return(NewSecretCode);
        }
Exemplo n.º 6
0
        // UpdatePanel()
        public void UpdatePanel(Panels PanelInfo)
        {
            var db = new PocoDynamo(con.GetClient());

            db.RegisterTable <Panels>();

            try
            {
                db.UpdateItem(PanelInfo.IdPanel,
                              put: () => new Panels
                {
                    Model       = PanelInfo.Model,
                    Description = PanelInfo.Description,
                    Bus         = PanelInfo.Bus,
                    Main        = PanelInfo.Main,
                    Area        = PanelInfo.Area,
                    From        = PanelInfo.From,
                    Comments    = PanelInfo.Comments,
                    Voltage     = PanelInfo.Voltage,
                    Phases      = PanelInfo.Phases,
                    Threads     = PanelInfo.Threads,
                    Frequency   = PanelInfo.Frequency
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MPanels -> UpdatePanel(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 7
0
        // CreateTable()
        public void CreateTable()
        {
            var db = new PocoDynamo(con.GetClient());

            try
            {
                db.RegisterTable <Phrases>();
                db.InitSchema();

                List <string> phrases = new List <string>();
                phrases.Add("Para ganar en la vida, antes hay que saber perder");
                phrases.Add("Educa a los niños, y no será necesario castigar a los hombres");
                phrases.Add("Vive el presente sin olvidar el pasado, pero mirando siempre hacia el futuro");
                phrases.Add("La gente inteligente cuida lo que dice, respeta lo que escucha y medita lo que calla");
                phrases.Add("Si quieres una mano que te ayude, la encontraras al final de tu brazo");
                phrases.Add("La medida de la inteligencia es la habilidad para cambiar y adaptarse");
                phrases.Add("La mente es como un paracaídas, sólo funciona si se abre");
                phrases.Add("Eres el juez de tus propios actos y el árbitro de tu propio destino");
                phrases.Add("El dinero hace personas ricas, el conocimiento hace personas sabias, la humildad hace grandes personas");
                phrases.Add("Hace falta toda una vida para aprender a vivir");
                phrases.Add("No es sabia el que sabe sino el que no sabe y quiere aprender");
                phrases.Add("La sabiduría comienza donde termina el conocimiento");
                phrases.Add("Aprende del pasado, vive el presente y trabaja para el futuro");
                phrases.Add("En la vida algunas veces se gana, otras veces se aprende");
                phrases.Add("Un hombre inteligente jamás se irritaría, si tuviera delante siempre un espejo y se viera cuando discute");
                phrases.Add("Si quieres algo que nunca tuviste, debes hacer algo que nunca hiciste");
                phrases.Add("Lo malo de aprender con la experiencia, es que nunca nos graduamos");
                phrases.Add("El mayor defecto de los defectos es no darse cuenta de ninguno de ellos");
                phrases.Add("Experiencia es lo que conseguimos cuando no leemos las instrucciones");
                phrases.Add("Un tropezón puede prevenir una caída");

                for (int i = 1; i < 21; i++)
                {
                    var pharse = new Phrases
                    {
                        Id     = i,
                        Phrase = phrases[i - 1]
                    };

                    db.PutItem(pharse);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MPhrases -> CreateTable(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 8
0
        // DropTable()
        public void DropTable()
        {
            var db = new PocoDynamo(con.GetClient());

            try
            {
                db.DeleteTable <SwitchInfo>();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MSwitchInfo -> DropTable(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 9
0
        // GetData()
        public DATA.Switch[] GetData(string IdSwitch)
        {
            DATA.Switch[] res = { };
            var           db  = new PocoDynamo(con.GetClient());

            try
            {
                res = db.ScanAll <DATA.Switch>().Where(x => x.IdSwitch == IdSwitch).ToArray();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MSwitch -> GetData(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
            return(res);
        }
Exemplo n.º 10
0
        // DeleteUser()
        public void DeleteUser(string UserName)
        {
            var db = new PocoDynamo(con.GetClient());

            db.RegisterTable <Users>();

            try
            {
                db.DeleteItem <Users>(UserName);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> DeleteUser(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 11
0
        public int CountFiles(string IdSwitch)
        {
            var db  = new PocoDynamo(con.GetClient());
            var res = 0;

            try
            {
                res = db.ScanAll <Files>().Where(x => x.IdSwitch == IdSwitch).Count();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MPanels -> CountPanels(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
            return(res);
        }
Exemplo n.º 12
0
        // GetTotalUsers()
        public int GetTotalMembers()
        {
            int res = 0;
            var db  = new PocoDynamo(con.GetClient());

            try
            {
                res = db.ScanAll <Users>().Count();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> GetTotalMembers(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
            return(res);
        }
Exemplo n.º 13
0
        // GetPanelInfo()
        public Panels[] GetPanelInfo(string IdPanel)
        {
            var db = new PocoDynamo(con.GetClient());

            Panels[] res = { };

            try
            {
                res = db.ScanAll <Panels>().Where(x => x.IdPanel == IdPanel).ToArray();
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MPanels -> GetPanelInfo(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
            return(res);
        }
Exemplo n.º 14
0
        // IfPanelExist()
        public bool IfPanelExist(string IdPanel)
        {
            var db  = new PocoDynamo(con.GetClient());
            var res = false;

            try
            {
                if (db.ScanAll <Panels>().Where(x => x.IdPanel == IdPanel).Count() == 1)
                {
                    res = true;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MPanels -> IfPanelExist(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
            return(res);
        }
Exemplo n.º 15
0
        // UpdateComments()
        public void UpdateComments(Panels PanelInfo)
        {
            ;
            var db = new PocoDynamo(con.GetClient());

            db.RegisterTable <Panels>();

            try
            {
                db.UpdateItemNonDefaults(new Panels {
                    IdPanel = PanelInfo.IdPanel, Comments = _tools.Encrypt(PanelInfo.Comments)
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MPanels -> UpdateComments(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 16
0
        // Login02()
        public bool Login02(string UserName, string Password)
        {
            var res = false;
            var db  = new PocoDynamo(con.GetClient());

            try
            {
                if (db.ScanAll <Users>().Where(x => x.UserName == UserName && x.Password == Password).Count() == 1)
                {
                    res = true;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> Login02(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }

            return(res);
        }
Exemplo n.º 17
0
        // GetRandomPhrase()
        public string GetRandomPhrase()
        {
            var res = string.Empty;
            var db  = new PocoDynamo(con.GetClient());

            try
            {
                Random rnd = new Random();
                var    n   = rnd.Next(1, 21);

                db.RegisterTable <Phrases>();
                res = db.GetItem <Phrases>(n).Phrase;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MPharses -> GetRandomPharse(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
            return(res);
        }
Exemplo n.º 18
0
        // _UpdatePhoto()
        private void _UpdatePhoto(string UserName, string NewPhoto)
        {
            var db = new PocoDynamo(con.GetClient());

            try
            {
                db.RegisterTable <Users>();

                db.UpdateItem(UserName,
                              put: () => new Users
                {
                    Photo = NewPhoto
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> _UpdatePhoto(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 19
0
        // DeleteFailedAttempts()
        public void DeleteFailedAttempts(string UserName)
        {
            var db = new PocoDynamo(con.GetClient());

            try
            {
                db.RegisterTable <Users>();

                db.UpdateItem(UserName,
                              put: () => new Users
                {
                    FailedAttempts = 0
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> DeleteFailedAttempts(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 20
0
        // CreatePanel()
        public bool CreatePanel(Panels PanelInfo)
        {
            var db = new PocoDynamo(con.GetClient());

            db.RegisterTable <Panels>();
            var res = false;

            try
            {
                db.PutItem(PanelInfo);

                res = true;
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MPanels -> CreatePanel(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
            return(res);
        }
Exemplo n.º 21
0
        // UnlockAccount()
        public void UnlockAccount(string UserName)
        {
            var db = new PocoDynamo(con.GetClient());

            try
            {
                db.RegisterTable <Users>();

                db.UpdateItem(UserName,
                              put: () => new Users
                {
                    IdStatus = 1
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> UnlockAccount(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 22
0
        // CreateTable()
        public void CreateTable()
        {
            var db = new PocoDynamo(con.GetClient());

            try
            {
                db.RegisterTable <Users>();
                db.InitSchema();

                var NewUser = new Users
                {
                    UserName       = _tools.Encrypt("ADMIN"),
                    Password       = _tools.Encrypt("ADMIN"),
                    IdRole         = 1,
                    FirstName      = _tools.Encrypt("ADMINISTRADOR"),
                    LastName       = _tools.Encrypt("."),
                    Email          = _tools.Encrypt("*****@*****.**"),
                    IdCard         = _tools.Encrypt("1234"),
                    Telephone      = _tools.Encrypt("8888-8888"),
                    Photo          = _tools.Encrypt("https://bitrush.nl/img/avatars/malecostume-512.png"),
                    IdStatus       = 1,
                    FailedAttempts = 0,
                    SecretCode     = _tools.Encrypt("ADMIN")
                };

                db.PutItem(NewUser);
            }

            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> CreateTable(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 23
0
        // CreateNewFailedAttempt()
        public void CreateNewFailedAttempt(string UserName)
        {
            var db = new PocoDynamo(con.GetClient());

            try
            {
                var res = GetFailedAttempts(UserName);

                if (res < 3)
                {
                    res = res + 1;
                    db.RegisterTable <Users>();

                    db.UpdateItem(UserName,
                                  put: () => new Users
                    {
                        FailedAttempts = res
                    });

                    switch (res)
                    {
                    case 3:
                        _LockAccount(UserName);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> CreateNewFailedAttempt(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }
Exemplo n.º 24
0
        // SetRandomSecretCode()
        public void SetRandomSecretCode(string UserName)
        {
            var db         = new PocoDynamo(con.GetClient());
            var RandomCode = _CreateRandomPassword();

            try
            {
                db.RegisterTable <Users>();

                db.UpdateItem(UserName,
                              put: () => new Users
                {
                    SecretCode = RandomCode
                });
            }
            catch (Exception ex)
            {
                Debug.WriteLine("\nError \nUbicación: Capa DAL -> MUsers -> SetRandomSecretCode(). \nDescripción: " + ex.Message);
            }
            finally
            {
                db.Close();
            }
        }