예제 #1
0
        /// <summary>
        /// Activate user account
        /// </summary>
        /// <param name="dni"></param>
        /// <param name="codigoActivacion"></param>
        /// <returns>Usuario</returns>
        public Usuario ActivateAccount(int dni, int codigoActivacion)
        {
            try
            {
                SqlParameter[] parameters = new SqlParameter[]
                {
                    new SqlParameter("@DNI", dni),
                    new SqlParameter("@CodigoActivacion", codigoActivacion)
                };

                Usuario user = new Usuario();

                using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "UsuarioActivateAccount", parameters))
                {
                    while (dataReader.Read())
                    {
                        user = MapDataReader(dataReader);
                    }
                    SqlConnection.ClearAllPools();
                    return user;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if ((Request.QueryString["user"] != null) && (Request.QueryString["code"] != null))
                {
                    userActivate = new Usuario();
                    userActivate.DNI = Convert.ToInt32(Cryptography.Decrypt(Request.QueryString["user"].ToString()));
                    userActivate.CodigoActivacion = Convert.ToInt32(Cryptography.Decrypt(Request.QueryString["code"].ToString()));

                    userActivate = UsuarioDTO.ActivateAccount(userActivate);
                    if (userActivate.DNI != 0)
                    {
                        Session.Add("user", userActivate);
                        InfoText.Text = String.Format(ConfigurationManager.AppSettings["ContentActivationAccountSuccesMessage"], userActivate.ApellidoNombre);
                        divLoading.Visible = true;
                        Response.AddHeader("REFRESH", "5;URL=" + Page.ResolveUrl("~") + ConfigurationManager.AppSettings["UrlStudent"]);
                    }
                    else
                        InfoText.Text = ConfigurationManager.AppSettings["ContentActivationAccountError"];
                }
                else
                    Response.Redirect(Page.ResolveUrl("~") + ConfigurationManager.AppSettings["UrlLogin"]);
            }
            catch (ThreadAbortException)
            {

            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "Page_Load", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
예제 #3
0
        /// <summary>
        /// Method for check if the user changed the generated password
        /// </summary>
        /// <param name="loggedUser"></param>
        public static bool CheckAccountStatus(object session, int userType)
        {
            try
            {
                Usuario loggedUser = new Usuario();
                loggedUser = (Usuario)session;

                switch (userType)
                {
                    case 1:
                        if ((loggedUser.CambioPrimerLogin))
                            return true;
                        else
                            return false;
                    case 2:
                        if ((loggedUser.CambioPrimerLogin) && (loggedUser.CuentaActivada))
                            return true;
                        else
                            return false;
                    default:
                        return false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 /// <summary>
 /// Method to send again the activation email to the user
 /// </summary>
 private void ResendEmail()
 {
     try
     {
         if (Utils.ValidateDni(txtDni.Text))
         {
             resendUser = new Usuario(Convert.ToInt32(txtDni.Text));
             resendUser = UsuarioDTO.GetUsuario(resendUser);
             if (resendUser != null)
             {
                 if (resendUser.Email != null)
                 {
                     if (Utils.SendMail(resendUser, mailTypeActivation))
                         SetMessage(ConfigurationManager.AppSettings["ContentResendEmailOk"], 1);
                     else
                         SetMessage(ConfigurationManager.AppSettings["ErrorMessageResendEmailFailed"], 2);
                 }
                 else
                     SetMessage(ConfigurationManager.AppSettings["ErrorMessageUserSinMail"], 2);
             }
             else
                 SetMessage(ConfigurationManager.AppSettings["ErrorMessageDniInexistente"], 2);
         }
         else
             SetMessage(ConfigurationManager.AppSettings["ErrorMessageLoginDni"], 2);
     }
     catch (Exception ex)
     {
         LogWriter log = new LogWriter();
         log.WriteLog(ex.Message, "ResendEmail", Path.GetFileName(Request.PhysicalPath));
         throw ex;
     }
 }
예제 #5
0
 public static List<Materia> GetMateriasBySedeAndFilters(Usuario loggedUser, BusquedaFiltro filter, int rol)
 {
     try
     {
         MateriaDAO materiasDAO = new MateriaDAO(connectionString);
         return materiasDAO.SelectAllBySedeAndFilters(loggedUser.IdSede, filter.IdDepartamento, filter.IdCarrera, filter.FechaActual, rol);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #6
0
 public static List<Analitico> GetAnalitic(Usuario user)
 {
     try
     {
         AnaliticoDAO analiticoDAO = new AnaliticoDAO(connectionString);
         return analiticoDAO.SelectByDNI(user.DNI);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
 public static List<CatedraComision> GetCatedraComisionFiltered(Usuario loggedUser, BusquedaFiltro filter, int rol)
 {
     try
     {
         CatedraComisionDAO catedraComisionDAO = new CatedraComisionDAO(connectionString);
         return catedraComisionDAO.SelectAllByIdSedeAndFilters(loggedUser.IdSede, filter.IdDepartamento, filter.IdCarrera, filter.IdMateria, filter.FechaActual, rol);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #8
0
 /// <summary>
 /// Method to activate account
 /// </summary>
 public static Usuario ActivateAccount(Usuario user)
 {
     try
     {
         var usuarioDAO = new UsuarioDAO(connectionString);
         return usuarioDAO.ActivateAccount(user.DNI, user.CodigoActivacion);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #9
0
 /// <summary>
 /// Selects all Materia for user PlanCarrera.
 /// </summary>
 public List<PlanCarrera> GetPlan(Usuario user)
 {
     using (SqlDataReader dataReader = SqlClientUtility.ExecuteReader(connectionStringName, CommandType.StoredProcedure, "CarreraSelectAll"))
     {
         List<PlanCarrera> planList = new List<PlanCarrera>();
         while (dataReader.Read())
         {
             PlanCarrera materia = MapDataReaderPlan(dataReader);
             planList.Add(materia);
         }
         SqlConnection.ClearAllPools();
         return planList;
     }
 }
        /// <summary>
        /// Method to auto-generate a Password.
        /// </summary>
        private void GeneratePassword()
        {
            try
            {
                string definitions = ConfigurationManager.AppSettings["RandomDefinitions"];
                Random random = new Random();
                StringBuilder passwordReturn = new StringBuilder();

                if (Utils.ValidateDni(txtDni.Text))
                {
                    FailureText.Visible = false;

                    for (int i = 0; i < 10; i++)
                        passwordReturn.Append(definitions.Substring(random.Next(definitions.Length), 1));

                    userPasswordUpdate = new Usuario();
                    userPasswordUpdate.DNI = Convert.ToInt32(txtDni.Text);
                    userPasswordUpdate.Password = passwordReturn.ToString();
                    userPasswordUpdate = UsuarioDTO.UpdatePassword(userPasswordUpdate);

                    if (userPasswordUpdate.DNI != 0)
                    {
                        divResultados.Visible = true;
                        FailureText.Visible = false;
                        txtDniResultado.Text = userPasswordUpdate.DNI.ToString();
                        txtApellidoNombreResultado.Text = userPasswordUpdate.ApellidoNombre;
                        txtPasswordResultado.Attributes.Add("value", userPasswordUpdate.ToString());

                        PrintForm(userPasswordUpdate);
                    }
                    else
                    {
                        FailureText.Text = ConfigurationManager.AppSettings["ErrorMessageDniInexistente"];
                        FailureText.Visible = true;
                    }
                }
                else
                {
                    FailureText.Visible = true;
                    FailureText.Text = ConfigurationManager.AppSettings["ErrorMessageLoginDni"];
                }
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "GeneratePassword", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
        /// <summary>
        /// Method to update user email
        /// </summary>
        private void ChangeEmail()
        {
            try
            {
                userMailChange = new Usuario();
                userMailChange.DNI = Convert.ToInt32(txtDni.Text);
                userMailChange.Email = txtEmailChange.Text;
                UsuarioDTO.UpdateEmail(userMailChange);

                lblEstado.Text = ConfigurationManager.AppSettings["ContentCambioEmailOk"];
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "ChangeEmail", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
        /// <summary>
        /// Method to recover user info
        /// </summary>
        private void RecoverUserPasswordAndSend(string userDni)
        {
            try
            {
                if (Utils.ValidateDni(txtDni.Text))
                {
                    recoveryUser = new Usuario(Convert.ToInt32(userDni));
                    recoveryUser = UsuarioDTO.GetUsuario(recoveryUser);

                    if (recoveryUser != null)
                    {
                        if (recoveryUser.IdCargo == UserTypeStudent)
                        {
                            if (recoveryUser.Email != null && recoveryUser.CambioPrimerLogin && recoveryUser.CuentaActivada)
                            {
                                if (Utils.SendMail(recoveryUser, mailTypeActivation))
                                {
                                    SetMessage(String.Format(ConfigurationManager.AppSettings["ContentSendPasswordEmail"], recoveryUser.Email.ToLower()), 1);
                                    Response.AddHeader("REFRESH", "3;URL=" + Page.ResolveUrl("~") + ConfigurationManager.AppSettings["UrlLogin"]);
                                }
                                else
                                    SetMessage(ConfigurationManager.AppSettings["ErrorMessageSendPasswordEmailFailed"], 2);
                            }
                            else
                                SetMessage(ConfigurationManager.AppSettings["ErrorMessageSendPasswordEmailEmpty"], 2);
                        }
                        else
                            SetMessage(ConfigurationManager.AppSettings["ErrorMessageSendPasswordEmailCargo"], 2);
                    }
                    else
                        SetMessage(ConfigurationManager.AppSettings["ErrorMessageDniInexistente"], 2);
                }
                else
                    SetMessage(ConfigurationManager.AppSettings["ErrorMessageLoginDni"], 2);
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "RecoverUserPasswordAndSend", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
예제 #13
0
        /// <summary>
        /// Method to check if the user is logged in
        /// </summary>
        /// <param name="session"></param>
        /// <param name="userType"></param>
        /// <returns></returns>
        public static bool CheckLoggedUser(object session, int userType)
        {
            try
            {
                if (session != null)
                {
                    Usuario loggedUser = new Usuario();
                    loggedUser = (Usuario)session;

                    if (loggedUser.IdCargo == userType)
                        return true;
                    else
                        return false;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #14
0
 /// <summary>
 /// Method to validate login credentials.
 /// </summary>
 public static Usuario ValidateLogin(Usuario user)
 {
     try
     {
         var usuarioDAO = new UsuarioDAO(connectionString);
         return usuarioDAO.ValidateLogin(user.DNI, user.Password);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #15
0
 /// <summary>
 /// Method to update the first password generated
 /// </summary>
 public static Usuario UpdatePassword(Usuario user)
 {
     try
     {
         var usuarioDAO = new UsuarioDAO(connectionString);
         return usuarioDAO.UpdateGeneratedPassword(user.DNI, user.Password);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #16
0
 /// <summary>
 /// Method to update the user limitations
 /// </summary>
 /// <param name="user"></param>
 public static void UpdateLimitaciones(Usuario user)
 {
     try
     {
         var usuarioDAO = new UsuarioDAO(connectionString);
         usuarioDAO.UpdateLimitaciones(user);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #17
0
 /// <summary>
 /// Method to update mandatory
 /// </summary>
 public static bool UpdateMandatoryPasswordEmail(Usuario user)
 {
     try
     {
         var usuarioDAO = new UsuarioDAO(connectionString);
         return usuarioDAO.UpdateMandatoryPasswordEmail(user.DNI, user.Password, user.Email, user.CodigoActivacion);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
예제 #18
0
        /// <summary>
        /// Login Authenticate Event.
        /// </summary>
        protected void Login_Authenticate(object sender, AuthenticateEventArgs e)
        {
            try
            {
                int dni;
                bool incorrectData = false;
                Usuario user = new Usuario();
                loggedUser = new Usuario();

                if (login.UserName == string.Empty)
                {
                    login.FailureText = ConfigurationManager.AppSettings["ErrorMessageLoginDni"];
                    e.Authenticated = false;
                    incorrectData = true;
                }
                else
                {
                    if (!int.TryParse(login.UserName, out dni))
                    {
                        login.FailureText = ConfigurationManager.AppSettings["ErrorMessageLoginDni"];
                        e.Authenticated = false;
                        incorrectData = true;
                    }
                    #region Old Validate DNI Min Length
                    //else
                    //{
                    //    if (login.UserName.Length < 8)
                    //    {
                    //        login.FailureText = ConfigurationManager.AppSettings["ErrorMessageLoginDni"];
                    //        e.Authenticated = false;
                    //        incorrectData = true;
                    //    }
                    //}
                    #endregion
                }

                if (login.Password == string.Empty)
                {
                    login.FailureText = login.FailureText + "<br>" + ConfigurationManager.AppSettings["ErrorMessageLoginPassword"];
                    e.Authenticated = false;
                    incorrectData = true;
                }
                else
                {
                    if (login.Password.Length < 6)
                    {
                        login.FailureText = login.FailureText + "<br>" + ConfigurationManager.AppSettings["ErrorMessageLoginPassword"];
                        e.Authenticated = false;
                        incorrectData = true;
                    }
                }

                if (!incorrectData)
                {
                    user.DNI = Convert.ToInt32(login.UserName);
                    user.Password = login.Password;

                    loggedUser = UsuarioDTO.ValidateLogin(user);

                    if (loggedUser.DNI != 0)
                    {
                        if (loggedUser.IdCargo == 2)
                            Session.Add("user", loggedUser);
                        else
                            Session.Add("userEmployee", loggedUser);
                        e.Authenticated = true;
                    }
                    else
                    {
                        login.FailureText = ConfigurationManager.AppSettings["ErrorMessageLoginCredentials"];
                        e.Authenticated = false;
                    }
                }
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "Login_Authenticate", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
예제 #19
0
        /// <summary>
        /// Method to send activation email
        /// </summary>
        /// <returns></returns>
        public static bool SendMail(Usuario user, int mailType)
        {
            try
            {
                Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
                MailSettingsSectionGroup settingsMail = (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");
                MailMessage message = new MailMessage();
                NetworkCredential credentials = new NetworkCredential(settingsMail.Smtp.From, settingsMail.Smtp.Network.Password);

                message.To.Add(user.Email);
                message.From = new MailAddress(settingsMail.Smtp.From);
                switch (mailType)
                {
                    case mailTypeActivation:
                        message.Subject = ConfigurationManager.AppSettings["MailActivationSubject"];
                        message.Body = GenerateActivationMailBody(user);
                        break;
                    case mailTypePasswordRecovery:
                        message.Subject = ConfigurationManager.AppSettings["MailPasswordRecoverSubject"];
                        message.Body = GenerateRecoverMailBody(user);
                        break;
                }

                message.IsBodyHtml = true;

                SmtpClient smtp = new SmtpClient(settingsMail.Smtp.Network.Host, settingsMail.Smtp.Network.Port);
                smtp.UseDefaultCredentials = settingsMail.Smtp.Network.DefaultCredentials;
                smtp.Credentials = credentials;
                smtp.EnableSsl = settingsMail.Smtp.Network.EnableSsl;
                smtp.Send(message);

                return true;
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "SendMail", "Utils.cs");
                return false;
            }
        }
        /// <summary>
        /// Method to fill user data
        /// </summary>
        private void FillUserData()
        {
            try
            {
                loggedUser = new Usuario();
                loggedUser = (Usuario)Session["userEmployee"];

                txtDni.Text = loggedUser.DNI.ToString();
                txtApellidoNombre.Text = loggedUser.ApellidoNombre;
                //txtNombre.Text = loggedUser.Nombre;
                //txtApellido.Text = loggedUser.Apellido;
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "FillUserData", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
예제 #21
0
 /// <summary>
 /// Method to get user data
 /// </summary>
 /// <param name="user"></param>
 /// <returns></returns>
 public static Usuario GetUsuario(Usuario user)
 {
     try
     {
         var usuarioDAO = new UsuarioDAO(connectionString);
         return usuarioDAO.Select(user.DNI);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// Method to print a form transaction.
        /// </summary>
        private void PrintForm(Usuario user)
        {
            try
            {
                string enter = "<br />";
                StringBuilder scriptingBuilder = new StringBuilder();
                StringBuilder dataPrint = new StringBuilder();
                dataPrint.Append("<img src=\"" + Page.ResolveUrl("~") + "img/header_impresion.gif\" alt=\"UNLZ\" />");
                dataPrint.Append("<div><div style=\"display:inline\">Fecha Tramite: " + DateTime.Now.ToShortDateString() + "</div>");
                dataPrint.Append("<div style=\"display:inline; float:right;\">Hora: " + DateTime.Now.ToShortTimeString() + "</div></div><br />");
                dataPrint.Append("<div>DNI: " + user.DNI.ToString() + "</div><div>" + "Apellido y Nombre: " + user.ApellidoNombre + "</div><br /><div style=\"display:inline;\">" + "Contraseña: <div style=\"color:#FFFFFF; font-weight: bold; display:inline;\"/>" + user.Password + "</div><div><br />");
                dataPrint.Append(String.Format(ConfigurationManager.AppSettings["ContentPrintForm"], enter, enter, enter));

                scriptingBuilder.Append("<script type='text/javascript'>");
                scriptingBuilder.Append("var win=null;");
                scriptingBuilder.Append("win = window.open();");
                scriptingBuilder.Append("self.focus();");
                scriptingBuilder.Append("win.document.open();");
                scriptingBuilder.Append("win.document.write('<'+'html'+'><'+'head'+'><'+'style'+'>');");
                scriptingBuilder.Append("win.document.write('body, td { font-family: Verdana; font-size: 10pt;}');");
                scriptingBuilder.Append("win.document.write('<'+'/'+'style'+'><'+'/'+'head'+'><'+'body'+'>');");
                scriptingBuilder.Append("win.document.write('" + HttpUtility.JavaScriptStringEncode(dataPrint.ToString()) + "');");
                scriptingBuilder.Append("win.document.write('<'+'/'+'body'+'><'+'/'+'html'+'>');");
                scriptingBuilder.Append("win.document.close();");
                scriptingBuilder.Append("win.print();");
                scriptingBuilder.Append("win.close();");
                scriptingBuilder.Append("</script>");

                ClientScriptManager script = Page.ClientScript;
                script.RegisterStartupScript(this.GetType(), "jsPrint", scriptingBuilder.ToString());
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "PrintForm", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
        /// <summary>
        /// Fill Combo Materia
        /// </summary>
        private void FillComboMateria()
        {
            try
            {
                loggedUser = new Usuario();
                loggedUser = (Usuario)Session["user"];
                rol = Session["userEmployee"] != null ? 1 : 2;
                filtro = new BusquedaFiltro(Convert.ToInt32(comboDepartamento.SelectedValue), Convert.ToInt32(comboCarrera.SelectedValue), DateTime.Now);

                comboMateria.DataTextField = COMBOTEXTFIELDMATERIA;
                comboMateria.DataValueField = COMBOVALUEFIELDMATERIA;
                comboMateria.DataSource = MateriaDTO.GetMateriasBySedeAndFilters(loggedUser, filtro, rol).Select(p => new { IdMateria = p.IdMateria, Descripcion = p.IdMateria.ToString() + "- " + p.Descripcion, IdDepartamento = p.IdDepartamento });
                comboMateria.DataBind();
                comboMateria.Items.Insert(0, new ListItem(ConfigurationManager.AppSettings["ContentComboMateriaDefault"], "0"));
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "FillComboMateria", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
        /// <summary>
        /// Method to search the user filtered data
        /// </summary>
        private void SearchComboSelection()
        {
            try
            {
                if (comboMateria.SelectedIndex != 0)
                {
                    Session.Remove("catedras");
                    loggedUser = new Usuario();
                    loggedUser = (Usuario)Session["user"];
                    SetEstado(false);

                    rol = Session["userEmployee"] != null ? 1 : 2;

                    filtro = new BusquedaFiltro(Convert.ToInt32(comboDepartamento.SelectedValue), Convert.ToInt32(comboCarrera.SelectedValue), Convert.ToInt32(comboMateria.SelectedValue), DateTime.Now);
                    catedras = new List<CatedraComision>(CatedraComisionDTO.GetCatedraComisionFiltered(loggedUser, filtro, rol));

                    Session.Add("catedras", catedras);
                    GridResultados.DataSource = catedras;

                    if (GridResultados.DataSource != null)
                    {
                        setGridCatedrasHeaders();
                        divResultados.Visible = true;
                        GridResultados.DataBind();
                    }
                }
                else
                    SetEstado(false);
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "SearchComboSelection", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
        protected void btnRequest_Click(object sender, EventArgs e)
        {
            try
            {
                ddInscripciones.RefreshControl();

                RemoveSessionVars();
                user = ValidateStudent(Convert.ToInt32(txtDni.Text));

                if (user != null && user.DNI != 0)
                {
                    SetStudentData();
                    Session.Remove("user");
                    Session.Add("user", user);
                    listInscripcionesActivas = new List<InscripcionActiva>();
                    listInscripcionesActivas = InscripcionActivaDTO.ValidateInscipcionesActivas(DateTime.Now, 1);
                    Session.Add("inscripcionesActivas", listInscripcionesActivas);

                    if (listInscripcionesActivas.Count != 0)
                    {
                        inscripcion = new Inscripcion();
                        inscripcion.IdTipoInscripcion = listInscripcionesActivas[0].IdTipoInscripcion;
                        inscripcion.TurnoInscripcion = listInscripcionesActivas[0].TurnoInscripcion;
                        inscripcion.IdVuelta = listInscripcionesActivas[0].IdVuelta;
                        inscripcion.DNI = ((Usuario)Session["user"]).DNI;
                        Session.Add("idVuelta", inscripcion.IdVuelta);

                        //Seteamos el estado en A, para que traiga las inscripciones en alta
                        inscripcion.IdEstadoInscripcion = IdEstadoAltaInscripcion;

                        listCarroAlta = new List<Carro>();
                        listCarroBaja = new List<Carro>();
                        listCarroAlta = InscripcionDTO.GetInscriptionsInTurn(inscripcion);

                        SetCartLimit();
                        ddInscripciones.Visible = true;

                        if (listCarroAlta.Count > 0)
                        {
                            //Seteamos el estado en M, para que traiga las inscripciones en baja
                            inscripcion.IdEstadoInscripcion = IdEstadoBajaModificacion;
                            listCarroBaja = InscripcionDTO.GetInscriptionsInTurn(inscripcion);

                            Session.Add("carro", RemoveDuplicateItemsDifRounds(listCarroAlta, listCarroBaja));
                            Session.Add("preCarro", listCarroBaja);

                            if ((listCarroAlta != null) && (listCarroAlta.Count != 0))
                            {
                                ((GridView)ddInscripciones.FindControl("wucCarro").FindControl("GridCarro")).DataSource = listCarroAlta;
                                setGridCartHeaders();
                                ((GridView)ddInscripciones.FindControl("wucCarro").FindControl("GridCarro")).DataBind();
                                ShowEmptyCartHeader(false);
                            }
                        }
                        else
                        {
                            ((GridView)ddInscripciones.FindControl("wucCarro").FindControl("GridCarro")).DataSource = null;
                            ((GridView)ddInscripciones.FindControl("wucCarro").FindControl("GridCarro")).DataBind();
                            ShowEmptyCartHeader(true);
                        }
                    }
                    else
                        SetMessage(ConfigurationManager.AppSettings["ContentInscripcionActivaNoDisponible"], 2);
                }
                else
                    SetMessage(ConfigurationManager.AppSettings["ErrorMessageDniInexistente"], 1);

            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "btnRequest_Click", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
        /// <summary>
        /// Method to fill user data
        /// </summary>
        private void FillUserData()
        {
            try
            {
                loggedUser = new Usuario();
                loggedUser = (Usuario)Session["user"];

                txtDni.Text = loggedUser.DNI.ToString();
                txtApellidoNombre.Text = loggedUser.ApellidoNombre;
                txtEmail.Text = loggedUser.Email;
                txtCarrera.Text = loggedUser.Carrera;

                ucRelevamientoMod.ShowEnviarButton(false);
                ucRelevamientoMod.ShowControlTitle(false);
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "FillUserData", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
예제 #27
0
        private void SetUp()
        {
            try
            {
                if (Session["user"] != null && Session["userEmployee"] == null)
                    loggedUser = (Usuario)Session["user"];
                else
                    loggedUser = (Usuario)Session["userEmployee"];

                if (loggedUser != null)
                {
                    if (loggedUser.IdCargo == UserTypeEmployee)
                    {
                        lblUser.Text = String.Format(ConfigurationManager.AppSettings["ContentLoginControl"], Utils.TruncateAtWord(loggedUser.ApellidoNombre, 12));
                        btnManagement.Text = ConfigurationManager.AppSettings["BotonGestionCuentas"];
                        btnTools.Text = ConfigurationManager.AppSettings["BotonTools"];
                        btnPassword.Text = ConfigurationManager.AppSettings["BotonGenerarClave"];
                        btnInscription.Text = ConfigurationManager.AppSettings["BotonInscribirAlumno"];
                        btnLogout.Text = ConfigurationManager.AppSettings["BotonLogout"];
                        btnResend.Text = ConfigurationManager.AppSettings["BotonResend"];
                        btnEmailChange.Text = ConfigurationManager.AppSettings["BotonEmailChange"];
                        btnProcess.Text = ConfigurationManager.AppSettings["BotonProceso"];
                        btnQueries.Text = ConfigurationManager.AppSettings["BotonConsultas"];
                        btnTextsChange.Text = ConfigurationManager.AppSettings["BotonCambioTextos"];
                        btnInterface.Text = ConfigurationManager.AppSettings["BotonInterfazAlumnos"];
                        liPassword.Visible = liInscription.Visible  = true;

                        if (coleccionDniResend.IndexOf(loggedUser.DNI.ToString()) != -1)
                            liTools.Visible = liResend.Visible = liEmailChange.Visible = liProcess.Visible = true;

                        if (coleccionDniStatistics.IndexOf(loggedUser.DNI.ToString()) != -1)
                            liTools.Visible = liQueries.Visible = liTextsChange.Visible = liInterface.Visible = true;

                        if (Session["user"] != null && Session["userEmployee"] != null)
                            menuSimulador.Visible = true;
                        divLoginTools.Visible = true;
                    }
                    else
                    {
                        menuAlumnos.Visible = true;
                        //divContent.Attributes.Add("class", "contenidoCentral");

                        if (!loggedUser.LimitacionRelevada)
                            EnableButtons(false);
                    }
                }
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "SetUp", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
예제 #28
0
 /// <summary>
 /// Method to import users
 /// </summary>
 public static void ImportPadron(Usuario user)
 {
     try
     {
         var usuarioDAO = new UsuarioDAO(connectionString);
         usuarioDAO.ImportPadron(user);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// Method to search the input email
        /// </summary>
        /// <param name="dni"></param>
        private void SearchEmail(int dni)
        {
            try
            {
                if (Utils.ValidateDni(dni.ToString()))
                {
                    FailureText.Visible = false;
                    ClearFields();
                    userMailChange = new Usuario();
                    userMailChange.DNI = dni;
                    userMailChange = UsuarioDTO.GetUsuario(userMailChange);

                    if (userMailChange != null)
                    {
                        txtEmail.Text = userMailChange.Email;
                        txtApellidoNombre.Text = userMailChange.ApellidoNombre;
                        ShowResults(true);
                    }
                    else
                    {
                        FailureText.Visible = true;
                        FailureText.Text = ConfigurationManager.AppSettings["ErrorMessageDniInexistente"];
                        ShowResults(false);
                    }
                }
                else
                {
                    FailureText.Visible = true;
                    FailureText.Text = ConfigurationManager.AppSettings["ErrorMessageLoginDni"];
                }
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "SearchEmail", Path.GetFileName(Request.PhysicalPath));
                throw ex;
            }
        }
예제 #30
0
        /// <summary>
        /// Method to send activation email
        /// </summary>
        /// <returns></returns>
        public static bool SendMail(Usuario user, string subject, string body)
        {
            try
            {
                Configuration config = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath);
                MailSettingsSectionGroup settingsMail = (MailSettingsSectionGroup)config.GetSectionGroup("system.net/mailSettings");
                MailMessage message = new MailMessage();
                NetworkCredential credentials = new NetworkCredential(settingsMail.Smtp.From, settingsMail.Smtp.Network.Password);

                message.To.Add(user.Email);
                message.From = new MailAddress(settingsMail.Smtp.From);
                message.Subject = subject;
                message.Body = body;
                message.IsBodyHtml = true;

                SmtpClient smtp = new SmtpClient(settingsMail.Smtp.Network.Host, settingsMail.Smtp.Network.Port);
                smtp.UseDefaultCredentials = settingsMail.Smtp.Network.DefaultCredentials;
                smtp.Credentials = credentials;
                smtp.EnableSsl = settingsMail.Smtp.Network.EnableSsl;
                smtp.Send(message);

                return true;
            }
            catch (Exception ex)
            {
                LogWriter log = new LogWriter();
                log.WriteLog(ex.Message, "SendMail_Overload", "Utils.cs");
                return false;
            }
        }