示例#1
0
        /// <summary>
        /// Envia correo a usuario de password nuevo
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <param name="USR_PASSWORD"></param>
        /// <param name="Configuracion"></param>
        public static void EnviarCorreoUsuarioPasswordNuevo(string USR_USERNAME, string USR_PASSWORD, XmlDocument Configuracion)
        {
            try
            {
                UsuarioLogic usuariologica = new UsuarioLogic();
                usuario user = usuariologica.GetUsuario(USR_USERNAME);

                string mailto = user.USR_CORREO;
                string nombre = user.USR_NOMBRE + " " + user.USR_APELLIDO;

                string subject = "";
                string message = "";

                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.plantillas_notificaciones", "PLANTILLAS_LLAVE", "PASSWORDNUEVO");
                    var pl = db.GetObjectByKey(k);
                    plantilla_notificacion plantilla = (plantilla_notificacion)pl;

                    subject = plantilla.PLANTILLAS_ASUNTO;
                    message = plantilla.PLANTILLAS_MENSAJE;
                }

                message = message.Replace("{NOMBRE}", nombre);
                message = message.Replace("{USUARIO}", USR_USERNAME);
                message = message.Replace("{CONTRASEÑA}", USR_PASSWORD);

                EnviarCorreo(mailto, subject, message, Configuracion);
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al enviar correo de password nuevo.", ex);
                throw;
            }
        }
示例#2
0
        public void Button1_Click()
        {
            try
            {
                UsuarioLogic usuarioLogic = new UsuarioLogic();
                if (usuarioLogic.Autenticar(this.txtUsername.Text, this.txtPassword.Text) == true)
                {
                    Session["username"] = this.txtUsername.Text;

                    Window1.Close();
                    Response.Redirect("~/Source/Desktop.aspx");
                }
                else
                {
                    log.WarnFormat("Error al intentar autenticar usuario. Username: {0} - Password (Encriptada): {1} .", this.txtUsername.Text, this.txtPassword.Text);

                    this.txtUsername.Clear();
                    this.txtPassword.Clear();
                    X.Msg.Alert("Inicio de Sesión", "El nombre de usuario o contraseña son incorrectos.", "#{txtUsername}.focus();").Show();
                }
            }
            catch (System.Threading.ThreadAbortException tex)
            {
                log.Warn("Error de terminacion de hilo al intentar autenticar usuario. Nota: Este error pudo ser causado por Response.Redirect.", tex);
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al intentar autenticar usuario.", ex);
            }
        }
示例#3
0
        public void CargarClave()
        {
            try
            {
                string loggedUsr = Session["username"] as string;

                if (string.IsNullOrEmpty(loggedUsr))
                    return;

                if (loggedUsr.CompareTo("DEVELOPER") != 0)
                {
                    UsuarioLogic usuariologic = new UsuarioLogic();

                    COCASJOL.DATAACCESS.usuario user = usuariologic.GetUsuario(loggedUsr);

                    this.CambiarClaveUsernameTxt.Text = loggedUsr;
                    this.CambiarClaveActualTxt.Text = user.USR_PASSWORD;
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al cargar control de cambiar clave.", ex);
                throw;
            }
        }
示例#4
0
        public void CambiarClaveGuardarBtn_Click()
        {
            try
            {
                string loggedUsr = Session["username"] as string;

                UsuarioLogic usuariologic = new UsuarioLogic();
                usuariologic.ActualizarClave(this.CambiarClaveUsernameTxt.Text, this.CambiarClaveNuevaConfirmarTxt.Text, loggedUsr);
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al actualizar clave.", ex);
                throw;
            }
        }
示例#5
0
        public void CambiarClaveGuardarBtn_Click()
        {
            try
            {
                string user = this.CambiarClaveUsernameTxt.Text;

                UsuarioLogic usuariologic = new UsuarioLogic();

                usuariologic.ActualizarClave(user, this.CambiarClaveConfirmarTxt.Text, this.LoggedUserHdn.Text);
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al cambiar clave de usuario.", ex);
                throw;
            }
        }
 protected void AddFecha_Change(object sender, RemoteValidationEventArgs e)
 {
     try
     {
         DateTime Fecha = DateTime.Parse(this.AddPlazoTxt.Text);
         DateTime Ahora = DateTime.Now;
         UsuarioLogic usuarioLogic = new UsuarioLogic();
         if (Ahora.CompareTo(Fecha)<1)
         {
             e.Success = false;
             e.ErrorMessage = "La Fecha debe ser posterior a la actual.";
         }
         else
             e.Success = true;
     }
     catch (Exception ex)
     {
         log.Fatal("Error fatal al validar la fecha de plazo para la solicitud de prestamo.", ex);
         throw;
     }
 }
示例#7
0
        /// <summary>
        /// Envia correo de rol nuevo
        /// </summary>
        /// <param name="USR_USERNAME"></param>
        /// <param name="ROL_ID"></param>
        /// <param name="Configuracion"></param>
        public static void EnviarCorreoRolNuevo(string USR_USERNAME, int ROL_ID, XmlDocument Configuracion)
        {
            try
            {
                UsuarioLogic usuariologica = new UsuarioLogic();
                usuario user = usuariologica.GetUsuario(USR_USERNAME);

                string mailto = user.USR_CORREO;
                string nombre = user.USR_NOMBRE + " " + user.USR_APELLIDO;

                string rol = "";
                string privs = "";

                string subject = "";
                string message = ""; 

                using (var db = new colinasEntities())
                {
                    EntityKey k = new EntityKey("colinasEntities.roles", "ROL_ID", ROL_ID);
                    var r = db.GetObjectByKey(k);
                    rol role = (rol)r;

                    rol = role.ROL_NOMBRE + " - " + role.ROL_DESCRIPCION;

                    foreach (privilegio p in role.privilegios)
                        privs += p.PRIV_NOMBRE + ", ";

                    if (privs.Length > 2)
                        privs.Remove(privs.Length - 2);


                    EntityKey k2 = new EntityKey("colinasEntities.plantillas_notificaciones", "PLANTILLAS_LLAVE", "ROLNUEVO");
                    var pl = db.GetObjectByKey(k2);
                    plantilla_notificacion plantilla = (plantilla_notificacion)pl;

                    subject = plantilla.PLANTILLAS_ASUNTO;
                    message = plantilla.PLANTILLAS_MENSAJE;
                }

                message = message.Replace("{NOMBRE}", nombre);
                message = message.Replace("{USUARIO}", USR_USERNAME);
                message = message.Replace("{ROL}", rol);
                message = message.Replace("{PRIVILEGIOS}", privs);

                EnviarCorreo(mailto, subject, message, Configuracion);
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al enviar correo de rol nuevo.", ex);
                throw;
            }
        }
示例#8
0
        private void RemoveObjects()
        {
            try
            {                
                string loggedUser = Session["username"] as string;
#if DEBUG
                if (loggedUser == "DEVELOPER")
                    return;
#endif

                UsuarioLogic usuariologic = new UsuarioLogic();

                List<COCASJOL.DATAACCESS.privilegio> privs = usuariologic.GetPrivilegiosDeUsuario(loggedUser);

                XmlDocument doc = new XmlDocument();
                doc.Load(Server.MapPath(System.Configuration.ConfigurationManager.AppSettings.Get("privilegesXML")));

                XmlNodeList nodes = doc.SelectNodes("privilegios/privilege");

                DesktopShortcuts listDS = this.MyDesktop.Shortcuts;
                DesktopModulesCollection listDM = this.MyDesktop.Modules;
                ItemsCollection<Component> listIC = this.MyDesktop.StartMenu.Items;

                if (privs.Count == 0)
                {
                    listDS.Clear();
                    listDM.Clear();
                    listIC.Clear();
                }
                else
                {

                    foreach (XmlNode node in nodes)
                    {
                        XmlNode keyNode = node.SelectSingleNode("key");
                        XmlNode moduleNode = node.SelectSingleNode("module");
                        XmlNode shortcutNode = node.SelectSingleNode("shortcut");
                        XmlNode menuitemNode = node.SelectSingleNode("menuitem");

                        string key = keyNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();
                        string module = moduleNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();
                        string shortcut = shortcutNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();
                        string menuitem = menuitemNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();

                        var query = from p in privs.AsParallel()
                                    where p.PRIV_LLAVE == key
                                    select p;

                        if (query.Count() == 0)
                        {
                            for (int x = 0; x < listDS.Count; x++)
                            {
                                DesktopShortcut ds = listDS.ElementAt(x);

                                if (ds.ShortcutID == shortcut)
                                    listDS.Remove(ds);
                            }

                            for (int x = 0; x < listDM.Count; x++)
                            {
                                DesktopModule dm = listDM.ElementAt(x);

                                if (dm.ModuleID == module)
                                    listDM.Remove(dm);
                            }

                            for (int x = 0; x < listIC.Count; x++)
                            {
                                Component item = listIC.ElementAt(x);

                                if (item is Ext.Net.MenuItem)
                                {
                                    Ext.Net.MenuItem menuItem = (Ext.Net.MenuItem)item;

                                    if (menuItem.Menu.Count > 0)
                                    {
                                        MenuCollection menu = menuItem.Menu;

                                        for (int y = 0; y < menu.Primary.Items.Count; y++)
                                        {
                                            Component itm = menu.Primary.Items.ElementAt(y);
                                            if (itm.ID == menuitem)
                                                menu.Primary.Items.Remove(itm);
                                        }
                                    }

                                    if (menuItem.Menu.Primary.Items.Count == 0)
                                        listIC.Remove(menuItem);
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al remover objetos sin acceso.", ex);
                throw;
            }
        }
示例#9
0
        /// <summary>
        /// Valida las credenciales del usuario actual.
        /// </summary>
        protected void ValidarCredenciales()
        {
            try
            {
                string loggedUser = Session["username"] as string;
#if DEBUG
                if (loggedUser == "DEVELOPER")
                    return;
#endif
                if (pagename == "Desktop")
                    return;

                XmlNode node = docPrivilegios.SelectSingleNode("privilegios/privilege[page[contains(text(), '" + pagename + "')]]");

                if (node == null)
                {
                    Response.Redirect("~/NoAccess.aspx");
                }

                XmlNode keyNode = node.SelectSingleNode("key");

                string key = keyNode.InnerText.Replace("\t", "").Replace("\r\n", "").Replace("\n", "").Trim();

                UsuarioLogic usuariologic = new UsuarioLogic();
                List<privilegio> privs = usuariologic.GetPrivilegiosDeUsuario(loggedUser);

                foreach (privilegio p in privs)
                {
                    if (p.PRIV_LLAVE == key)
                        return;
                }

                base.Response.Redirect("~/NoAccess.aspx");
            }
            catch (System.Threading.ThreadAbortException tex)
            {
                log.Warn("Error de terminacion de hilo al intentar validar credeciales (Accesos) de usuario. Nota: Este error pudo ser causado por Response.Redirect.", tex);
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al validar credenciales.", ex);
                throw;
            }
        }
示例#10
0
        protected void AddUsernameTxt_Change(object sender, RemoteValidationEventArgs e)
        {
            try
            {
                string username = this.AddUsernameTxt.Text;

                UsuarioLogic usuariologic = new UsuarioLogic();
                if (usuariologic.UsuarioExiste(username))
                {
                    e.Success = false;
                    e.ErrorMessage = "El nombre de usuario ingresado ya existe.";
                }
                else
                    e.Success = true;
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al validar existencia de nombre de usuario.", ex);
                throw;
            }
        }
示例#11
0
        public void AddRolesAddRolBtn_Click()
        {
            try
            {
                string loggeduser = this.LoggedUserHdn.Text;
                string user = this.EditUsernameTxt.Text;

                List<int> roles = new List<int>();

                foreach (SelectedRow row in this.RolesNoDeUsuarioSelectionM.SelectedRows)
                {
                    roles.Add(Convert.ToInt32(row.RecordID));
                }

                UsuarioLogic usuariologica = new UsuarioLogic();
                usuariologica.InsertarRoles(user, roles, loggeduser);
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al agregar roles.", ex);
                throw;
            }
        }
示例#12
0
        protected void RolesNoDeUsuarioSt_Refresh(object sender, StoreRefreshDataEventArgs e)
        {
            try
            {
                string user = this.EditUsernameTxt.Text;

                UsuarioLogic usuariologica = new UsuarioLogic();
                int rol_id = string.IsNullOrEmpty(this.f2_ROL_ID.Text) ? 0 : Convert.ToInt32(this.f2_ROL_ID.Text);
                this.RolesNoDeUsuarioSt.DataSource = usuariologica.GetRolesNoDeUsuario(user, rol_id, this.f2_ROL_NOMBRE.Text);
                this.RolesNoDeUsuarioSt.DataBind();
            }
            catch (Exception ex)
            {
                log.Fatal("Error fatal al cargar roles no de usuario.", ex);
                throw;
            }
        }
示例#13
0
 protected void EditCedulaTxt_Change(object sender, RemoteValidationEventArgs e)
 {
     try
     {
         string cedula = this.EditCedulaTxt.Text;
         string username = this.EditUsernameTxt.Text;
         UsuarioLogic usuarioLogic = new UsuarioLogic();
         if (usuarioLogic.CedulaExiste(cedula, username))
         {
             e.Success = false;
             e.ErrorMessage = "La cedula ingresada ya existe.";
         }
         else
             e.Success = true;
     }
     catch (Exception ex)
     {
         log.Fatal("Error fatal al validar existencia de cedula para usuario existente.", ex);
         throw;
     }
 }