Пример #1
0
        protected void btnRestoreBD_Click(object sender, EventArgs e)
        {
            try
            {
                sinBackup.Visible = false;
                if (dpBackUps.Items == null || dpBackUps.Items.Count <= 0)
                {
                    sinBackup.Visible = true;
                    return;
                }

                var seguridad = new SeguridadBLL();
                var bk        = new BackUp()
                {
                    BackUpPath = Server.MapPath("~/BackUps/"),
                    NombreBD   = dpBackUps.SelectedItem.Text
                };


                bool res = seguridad.RestoreBD(bk);
                divError.Visible = !res;
                divExito.Visible = res;
            }
            catch (Exception)
            {
                sinBackup.Visible = true;
            }
        }
Пример #2
0
        private List <BackUp> CargarBackUps()
        {
            var seguridad = new SeguridadBLL();
            var path      = Server.MapPath("~/BackUps");

            return(seguridad.ObtenerBackUps(path));
        }
Пример #3
0
        private void ObtenerSucursales()
        {
            var seguridad = new SeguridadBLL();
            var result    = seguridad.ObtenerSucursales();

            dpSucursales.DataSource = null;
            dpSucursales.Items.Clear();
            dpSucursalUpdate.DataSource = null;
            dpSucursalUpdate.Items.Clear();


            dpSucursales.Items.Add(new ListItem()
            {
                Text = "Selecciona una Sucursal", Value = "NoSucursal"
            });
            dpSucursalUpdate.Items.Add(new ListItem()
            {
                Text = "Selecciona una Sucursal", Value = ""
            });

            result.ForEach(suc =>
            {
                var listItem = new ListItem()
                {
                    Text  = suc.Descripcion,
                    Value = suc.Id.ToString()
                };
                dpSucursales.Items.Add(listItem);
                dpSucursalUpdate.Items.Add(listItem);
            });

            dpSucursalUpdate.DataBind();
            dpSucursales.DataBind();
        }
Пример #4
0
        protected void btnIngresar_Click(object sender, EventArgs e)
        {
            var logIn     = new LogInBLL();
            var seguridad = new SeguridadBLL();

            var usuario = new UsuarioBE()
            {
                Password        = seguridad.EncriptarClaveDeUsuario(txtPassword.Text),
                NombreDeUsuario = txtUsuario.Text
            };

            UsuarioBE usuarioActual = logIn.ObtenerLoginIn(usuario);



            if (usuarioActual != null)
            {
                seguridad.CrearBitacora(usuarioActual, "Ingresó");
                Session["UsuarioLogueado"] = usuarioActual;

                FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, txtUsuario.Text, DateTime.Now, DateTime.Now.AddMinutes(2880), false, usuarioActual.PerfilDeUsuario.Descripcion, FormsAuthentication.FormsCookiePath);
                string     hash   = FormsAuthentication.Encrypt(ticket);
                HttpCookie cookie = new HttpCookie(FormsAuthentication.FormsCookieName, hash);
                //cookie.Expires = DateTime.Now.AddDays(-1);

                Response.Cookies.Add(cookie);
                Response.Redirect("~/Default.aspx");
            }
            else
            {
                lblErrorLogin.Visible = true;
                lblErrorLogin.Text    = "El usuario y/o contraseña ingresado es incorrecto";
            }
        }
Пример #5
0
        private void ObtenerProductos()
        {
            var seguridad = new SeguridadBLL();
            var result    = seguridad.ObtenerProductos();

            dpProducto.DataSource = null;
            dpProducto.Items.Clear();

            dpProducto.Items.Add(new ListItem()
            {
                Text = "Selecciona un Producto", Value = ""
            });

            result.ForEach(prod =>
            {
                var listItem = new ListItem()
                {
                    Text  = prod.Descripcion,
                    Value = prod.Id.ToString()
                };

                dpProducto.Items.Add(listItem);
            });

            dpProducto.DataBind();
        }
Пример #6
0
        private bool ValidarIntegridadDeBaseDeDatos()
        {
            var seguridad         = new SeguridadBLL();
            var erroresIntegridad = new List <GrillaIntegridadBE>();
            var resultado         = seguridad.ValidarIntegridadDeAplicacion();

            if (resultado.Bebidas.Count > 0 || resultado.Usuarios.Count > 0)
            {
                erroresIntegridad.AddRange(resultado.Bebidas.Select(x => new GrillaIntegridadBE()
                {
                    Tabla           = "Bebidas",
                    IdRegistro      = x.Id,
                    ValoresActuales = string.Format("Descripcion: {0}; Precio: ${1}, SKU: {2}", x.Descripcion, x.Precio, x.SKU)
                }).ToList());

                erroresIntegridad.AddRange(resultado.Usuarios.Select(x => new GrillaIntegridadBE()
                {
                    Tabla           = "Usuarios",
                    IdRegistro      = x.Id,
                    ValoresActuales = string.Format("Usuario: {0}; Perfil: {1}", x.NombreDeUsuario, x.PerfilDeUsuario.Descripcion)
                }));


                gvErroresIntegridad.DataSource = erroresIntegridad;
                gvErroresIntegridad.DataBind();

                divIntegridad.Visible = true;
                var usuarioActual = Session["UsuarioLogueado"] as UsuarioBE;

                if (string.Compare(usuarioActual.PerfilDeUsuario.Descripcion, "webmaster", true) == 0)
                {
                    Master.EnableMenu();
                }
                else
                {
                    Master.DisableMenu();


                    seguridad.CrearBitacora(usuarioActual, "Cerró sesión");

                    FormsAuthentication.SignOut();

                    Session.Clear();
                    Session.Abandon();
                }
                return(true);
            }
            else
            {
                divIntegridad.Visible = false;
                Master.EnableMenu();
                return(false);
            }
        }
Пример #7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var permisos = new SeguridadBLL();
            var usuario  = Session["UsuarioLogueado"] as UsuarioBE;

            var resultado = permisos.ObtenerBitacoraCompleta();

            gvBitacora.DataSource = resultado;

            gvBitacora.AutoGenerateColumns = true;
            gvBitacora.DataBind();
        }
Пример #8
0
        protected void aCerrarSesion_Click(Object sender, EventArgs e)
        {
            var       seguridad = new SeguridadBLL();
            UsuarioBE usuario   = Session["UsuarioLogueado"] as UsuarioBE;

            seguridad.CrearBitacora(usuario, "Cerró sesión");

            FormsAuthentication.SignOut();
            FormsAuthentication.RedirectToLoginPage();
            Session.Clear();
            Session.Abandon();
        }
Пример #9
0
        void OnButtonClick(object sender, EventArgs e)
        {
            string nombreOpcion = ((Button)sender).Text;

            if (nombreOpcion == "Salir")
            {
                SeguridadBLL seguridadBLL = new SeguridadBLL();
                seguridadBLL.EliminarCredencialesUsuario();
                Navigation.PushAsync(new LoginView());
            }

            if (nombreOpcion == "Turnos")
            {
                Navigation.PushAsync(new Turnos.TurnosView());
            }
            if (nombreOpcion == "Logística")
            {
                Navigation.PushAsync(new Logistica.MenuEventosView());
            }
            if (nombreOpcion == "Notificaciones")
            {
                Navigation.PushAsync(new Notificaciones.HistorialNotificacionesView());
            }
            if (nombreOpcion == "Sincronización")
            {
                Navigation.PushAsync(new Sincronizacion.PendientesSincronizarView());
            }
            if (nombreOpcion == "Historial Manifiestos")
            {
                Navigation.PushAsync(new Logistica.HistorialCalifiacionViajesView());
            }
            if (nombreOpcion == "Almacenamiento")
            {
                Navigation.PushAsync(new Almacenamiento.CrearInventarioContenedores());
            }

            if (nombreOpcion == "Extractos")
            {
                Navigation.PushAsync(new ExtractoCondductores.ExtractoConductoresView());
            }

            if (nombreOpcion == "Bodega")
            {
                Navigation.PushAsync(new Bodega.BodegaView());
            }


            ((ListView)lvMenu).SelectedItem = null; //uncomment line if you want to disable the visual selection state.
        }
        protected void btnDigHorizontal_Click(object sender, EventArgs e)
        {
            try
            {
                var seguridadBLL = new SeguridadBLL();
                seguridadBLL.RecalcularDigitoVerificadorHorizontalTodos();

                divExito.Visible = true;
                divError.Visible = false;
            }
            catch (Exception)
            {
                divExito.Visible = false;
                divError.Visible = true;
            }
        }
Пример #11
0
 protected void btnExecBackup_Click(object sender, EventArgs e)
 {
     if (Session["CheckRefresh"].ToString() == ViewState["CheckRefresh"].ToString())
     {
         var  seguridad = new SeguridadBLL();
         var  path      = Server.MapPath("~/BackUps/");
         bool res       = seguridad.CrearBackUpBD(dpDB.SelectedValue, path);
         divBackupError.Visible  = !res;
         divBackupExito.Visible  = res;
         Session["CheckRefresh"] =
             Server.UrlDecode(System.DateTime.Now.ToString());
     }
     else
     {
         //Label1.Text = "Page Refreshed";
     }
 }
Пример #12
0
        void OnSelection(object sender, SelectedItemChangedEventArgs e)
        {
            if (e.SelectedItem == null)
            {
                return; //ItemSelected is called on deselection, which results in SelectedItem being set to null
            }
            //DisplayAlert("Item Selected", e.SelectedItem.ToString(), "Ok");
            var opcion = (OpcionMenu)e.SelectedItem;

            if (opcion != null && opcion.NombreOpcion == "Salir")
            {
                SeguridadBLL seguridadBLL = new SeguridadBLL();
                seguridadBLL.EliminarCredencialesUsuario();
            }

            Navigation.PushAsync(opcion.PageFn());


            ((ListView)sender).SelectedItem = null; //uncomment line if you want to disable the visual selection state.
        }
Пример #13
0
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            var persona = new PersonaBE()
            {
                Apellido        = txtApellido.Text,
                Direccion       = txtDireccion.Text,
                DNI             = uint.Parse(txtDNI.Text),
                Nombre          = txtNombre.Text,
                ProvinciaEstado = txtCiudad.Text,
                PaisID          = int.Parse(dpPais.SelectedValue)
            };

            var seguridad = new SeguridadBLL();

            var usuario = new UsuarioBE()
            {
                NombreDeUsuario = txtEmail.Text,
                Password        = seguridad.EncriptarClaveDeUsuario(txtPassword.Text),
                PerfilDeUsuario = new PerfilBE()
                {
                    Descripcion = "Usuario", Id = 5
                }
            };

            usuario.DigVerificador = seguridad.GenerarDigitoVerificadorDeUsuario(usuario);

            var       registrarBll = new LogInBLL();
            UsuarioBE newUser      = registrarBll.RegistrarUsuario(usuario, persona);

            if (newUser.Id != 0)
            {
                FormsAuthentication.RedirectToLoginPage();
            }
            else
            {
                lblError.Visible = true;
            }
        }
Пример #14
0
        public async void btnRecuperarClaveClicked(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtUsuario.Text))
            {
                await DisplayAlert("Error", "Debe ingresar su nombre de usuario para poder recuperar la contraseña.", "Aceptar");
            }
            else
            {
                SeguridadBLL seguridadBLL = new SeguridadBLL();
                try
                {
                    if (await seguridadBLL.RecuperarClave(txtUsuario.Text))
                    {
                        await DisplayAlert("Atención", "Se le ha enviado un correo con los datos de recuperación de contraseña.", "Aceptar");
                    }
                }
                catch (Exception ex)
                {
                    await DisplayAlert("Error", ex.Message, "Aceptar");

                    throw;
                }
            }
        }
        public async void btnRegistrarClicked(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(txtCelular.Text) || String.IsNullOrEmpty(txtNombre.Text) || String.IsNullOrEmpty(txtNumeroIdentificacion.Text) ||
                String.IsNullOrEmpty(txtPassword.Text) || pickerGenero.SelectedIndex < 0)
            {
                await DisplayAlert("Error", "Debe ingresar los campos obligatorios", "Aceptar");
            }
            else if (txtPassword.Text != txtPassword2.Text)
            {
                await DisplayAlert("Error", "Las contraseñas no coinciden.", "Aceptar");
            }
            else if (txtPassword.Text.Length < 6)
            {
                await DisplayAlert("Error", "La contraseña debe ser de mínimo 6 caracteres de longitud.", "Aceptar");
            }
            else
            {
                Usuario usuario = new Usuario();
                usuario.CodigoUsuario        = txtNumeroIdentificacion.Text;
                usuario.ContraseñaUsuario    = txtPassword.Text;
                usuario.CorreoUsuario        = txtCorreoElectronico.Text;
                usuario.NombreUsuario        = txtNombre.Text;
                usuario.NumeroIdentificacion = Convert.ToInt32(txtNumeroIdentificacion.Text);
                usuario.TipoIdentificacion   = "CC";
                usuario.Sexo            = pickerGenero.Items[pickerGenero.SelectedIndex] == "Masculino" ? "M" : "F";
                usuario.TelefonoCelular = txtCelular.Text;
                usuario.UsuarioCreacion = "tdmapp";
                SeguridadBLL seguridadBLL = new SeguridadBLL();
                string       respuesta    = await seguridadBLL.Registrar(usuario);

                if (await DisplayAlert("Información", respuesta, "Volver a inicio", "Cerrar"))
                {
                    await Navigation.PopAsync();
                }
            }
        }
Пример #16
0
        public async void btnIngresarClicked(object sender, EventArgs e)
        {
            btnLogin.IsEnabled = false;
            IsBusy             = true;

            SeguridadBLL bll = new SeguridadBLL();

            //Se borran las credeciales almacenadas
            bll.EliminarCredencialesUsuario();

            if (await ParametrosSistema.isOnline)
            {
                TokenSeguridad token = null;

                try
                {
                    lblEstado.Text = "Autenticando usuario.";
                    token          = await bll.Autenticar(txtUsuario.Text, txtPassword.Text);

                    if (token != null)
                    {
                        lblEstado.Text = "Autenticación correcta.";
                        Com.OneSignal.OneSignal.IdsAvailable idsPrinterDelegate = async delegate(string playerID, string pushToken)
                        {
                            try
                            {
                                NotificacionBLL notificacionBLL       = new NotificacionBLL();
                                CodigoNotificacionAplicacionMovil not = new CodigoNotificacionAplicacionMovil();
                                not.OneSignalId = playerID;
                                not.PushToken   = string.Empty;
                                not.Plataforma  = "android";
                                not.Usuario     = Common.ParametrosSistema.UsuarioActual;
                                await notificacionBLL.RegistrarDispositivo(not);

                                lblEstado.Text = "Dispositivo registrado correctamente.";
                            }
                            catch (Exception ex)
                            {
                                lblEstado.Text = "Error registrando dispositivo para notificaciones.";
                            }
                        };
                        lblEstado.Text = "Registrando dispositivo para notificaciones.";
                        Com.OneSignal.OneSignal.GetIdsAvailable(idsPrinterDelegate);


                        //Se crea la base de datos local
                        lblEstado.Text = "Creando base de datos local.";
                        DatabaseBLL      dbBLL     = new DatabaseBLL();
                        RespuestaProceso respuesta = await dbBLL.CrearBaseDeDatos();

                        lblEstado.Text = "Base de datos creada correctamente.";
                        if (respuesta.ProcesadoCorrectamente == true)
                        {
                            btnLogin.IsEnabled = true;
                            IsBusy             = false;
                            await Navigation.PopAsync();

                            await Navigation.PushAsync(new HomeView());
                        }
                        else
                        {
                            btnLogin.IsEnabled = true;
                            IsBusy             = false;
                            await Navigation.PushAsync(new ErrorView(respuesta.Respuesta));
                        }
                    }
                    else
                    {
                        btnLogin.IsEnabled = true;
                        IsBusy             = false;
                        DisplayAlert("Error al Ingresar", "Ocurrió un error inesperado en la autenticación.", "Aceptar");
                    }
                }
                catch (Exception ex)
                {
                    btnLogin.IsEnabled = true;
                    IsBusy             = false;
                    if (ex.Message.Contains("Bad Request"))
                    {
                        DisplayAlert("Error al Ingresar", "Nombre de usuario y/o contraseña no válidos.", "Aceptar");
                    }
                    else
                    {
                        DisplayAlert("Error al Ingresar", "Ocurrió un error inesperado en la autenticación.", "Aceptar");
                    }
                }
            }
            else
            {
                DisplayAlert("ERROR", "No tiene conexión a Internet", "Aceptar");
                IsBusy             = false;
                btnLogin.IsEnabled = true;
            }
        }