Exemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request["idUser"]))
            {
                LoggedUser = UserDao.getUser(int.Parse(Request["idUser"]));
            }
            if (!string.IsNullOrEmpty(Request["error"]))
            {
                hdIsNew.Value = "isnew";
                pMensaje.InnerHtml = "Congratulations! Your registration has been confirmed!. Now.  please go to the <a href='http://www.freeleticsworld.com/goliaz-faq/' >Frequently Asked Questions</a> which will tell you everything you need to know.<br /><br /> Have a great challenge!";
                LoadAvailableDaysToReport();
            }
            else if (!string.IsNullOrEmpty(Request["newUser"]) && string.IsNullOrEmpty(Request["error"]))
            {
                hdIsNew.Value = "isnew";
                pMensaje.InnerHtml = "Thank you! We're almost finished. Please check your email inbox (or spam) to confirm your registration.";
            }

            if (LoggedUser != null)
            {
                hdIdUser.Value = LoggedUser.idUser.ToString();
                LoadAvailableDaysToReport();
            }
            else if (LoggedUser == null)
            {
                Response.Redirect("login.aspx");
            }
        }
Exemplo n.º 2
0
 protected void btnRegister_Click(object sender, EventArgs e)
 {
     USERS newUser = new USERS();
     string[] formats = { "dd/MM/yyyy" };
     newUser.birthDate = DateTime.ParseExact(txtBirthDate.Text, formats, new CultureInfo("en-US"), DateTimeStyles.None);
     newUser.estado = "Not Confirmed";
     newUser.email = txtEmailReg.Text;
     newUser.gender = rdSex.SelectedValue;
     newUser.name = txtName.Text;
     newUser.nationality = Nationality.Value;
     newUser.pass = txtPasswordReg.Text;
     if (!string.IsNullOrEmpty(txtPoseidonPB.Text))
     {
         newUser.poseidon_pb = txtPoseidonPB.Text;
     }
     else
     {
         newUser.poseidon_pb = "Not performed";
     }
     if (!string.IsNullOrEmpty(txtVenusPB.Text))
     {
         newUser.venus_pb = txtVenusPB.Text;
     }
     else
     {
         newUser.venus_pb = "Not performed";
     }
     if (!string.IsNullOrEmpty(txtHadesPB.Text))
     {
         newUser.hades_pb = txtHadesPB.Text;
     }
     else
     {
         newUser.hades_pb = "Not performed";
     }
     newUser.REGISTER_DAY = DateTime.Now;
     User = UserDao.registerUser(newUser);
     if (User != null)
     {
         Goliaz.Framework.Correo sentCorreo = new Framework.Correo();
         string errorMensaje = "";
         bool respConfirmEmail = sentCorreo.SendConfirmEmailMessage(User, out errorMensaje);
         if (respConfirmEmail)
         {
             Response.Redirect("index.aspx?newUser=true");
         }
         else
         {
             if (!string.IsNullOrEmpty(errorMensaje))
             {
                 LogErrorDao.ingresarError(errorMensaje);
                 User = UserDao.validateUser(User);
                 Response.Redirect("index.aspx?newUser=true&error=envio");
             }
         }
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// Method that allow send a message to confirm email
        /// </summary>
        /// <returns>true or false if was sent</returns>
        public bool SendConfirmEmailMessage(USERS userNew, out string mensajeError)
        {
            //Mensaje de correo
            bool sentMessage = false;
            mensajeError = "";
            try
            {
                MailMessage mensaje = new MailMessage();
                mensaje.From = new MailAddress(infoEmail);
                MailAddress para = new MailAddress(userNew.email);

                mensaje.To.Add(para);
                mensaje.Subject = "Goliaz Challenge, Please Confirm your Email.";
                string codigo = GetRandomHexNumber(10);

                userNew = UserDao.updateUser(userNew, codigo);
                if (!string.IsNullOrEmpty(userNew.codeConfirm))
                {
                    mensaje.IsBodyHtml = true;

                    string urlConfirm = "http://goliaz.com/confirmEmail.aspx?code=" + HttpUtility.UrlEncode(codigo) + "&em=" + userNew.email;

                    //mensaje.Body = "<html><head><title>Please Confirm Email</title></head><body style='font-size: 15px !important;font-family: Arial,sans-serif;'>Dear " + userNew.name + ", <br/><br/> Congratulations and welcome to Goliaz Challenge. Please click <a href='http://goliaz.com/confirmEmail.aspx?code=" + codigo + "&em=" + userNew.email + "' >here</a> to confirm your email address to finish the register process.<br/><br/>Regards,<br/>Goliaz Challenge Team. <br/><br/><img alt='goliaz.com' src='http://goliaz.com/images/image.jpg' /></body></html>";
                    mensaje.Body = "<html><head><title>Please Confirm Email</title></head><body style='font-size: 15px !important;font-family: Arial,sans-serif;'>Dear " + userNew.name + ", <br/><br/> Congratulations and welcome to the Goliaz Challenge!<br/><br/>Please click <a href='" + urlConfirm + "' >here</a> to confirm your email address and to finish the registration process.<br/><br/>Regards,<br/>Goliaz Challenge Team. <br/><br/><img alt='goliaz.com' src='http://goliaz.com/images/logomask2.png'  style='width:200px;' /></body></html>";
                    //mensaje.Body = "<html><head><title>Please Confirm Email</title></head><body>Dear " + userNew.name + ", <br/> Please go to http://goliaz.com/confirmEmail.aspx?code=" + codigo + "&em=" + userNew.email + " to confirm your email.<br/><br/>Regards,<br/>Goliaz Challenge Team.</body></html>";

                    //Configuracion cliente SMTP
                    SmtpClient cliente = new SmtpClient(serverAddress, portSendmail);
                    //cliente.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
                    cliente.UseDefaultCredentials = false;
                    cliente.Credentials = new System.Net.NetworkCredential(infoEmail, passEmail);
                    //Send message
                    cliente.Send(mensaje);

                    sentMessage = true;
                }
            }
            catch (SmtpException ex)
            {
                //throw new Exception(ex.Message);

                mensajeError = ex.InnerException.Message;
            }
            return sentMessage;
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(Request["em"]) && !string.IsNullOrEmpty(Request["code"]))
            {
                try
                {
                    string mensaje = "";
                    Usuario = UserDao.getAndSetConfirmUser(Request["em"], Server.UrlDecode(Request["code"]), out mensaje);
                    if (Usuario != null)
                    {
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "showMessage", "setTimeout(showMessage, 2000);", true);
                        btnGoto.Visible = true;
                    }
                    else
                    {
                        btnGoto.Visible = false;
                        if (!string.IsNullOrEmpty(mensaje))
                        {
                            errorParrafo.InnerText = mensaje;

                        }
                        else
                        {
                            errorParrafo.InnerText = "This link is not longer available";
                        }
                        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "showError", "setTimeout(showError, 2000);", true);

                    }
                }
                catch (Exception ex)
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "showError", "setTimeout(showError, 2000);", true);
                    errorParrafo.InnerText = "Error: " + ex.Message;
                }
            }
        }
Exemplo n.º 5
0
 public static USERS validateUser(USERS user)
 {
     try
     {
         using (goliazco_FWEntities entity = new goliazco_FWEntities())
         {
             user = (from t in entity.USERS where t.idUser == user.idUser select t).FirstOrDefault();
             user.estado = "Confirmed";
             entity.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return user;
 }
Exemplo n.º 6
0
 public static USERS updateUser(USERS user, string codeNew)
 {
     goliazco_FWEntities entity = null;
     USERS updateUser = null;
     try
     {
         using (entity = new goliazco_FWEntities())
         {
             updateUser = (from t in entity.USERS where t.idUser == user.idUser select t).FirstOrDefault();
             updateUser.codeConfirm = codeNew;
             entity.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return updateUser;
 }
Exemplo n.º 7
0
 public static USERS registerUser(USERS user)
 {
     goliazco_FWEntities entity = null;
     try
     {
         using (entity = new goliazco_FWEntities())
         {
             entity.USERS.Add(user);
             entity.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         throw new Exception(ex.Message);
     }
     return user;
 }