Esempio n. 1
0
        public ActionResult UpdateUserInformation()
        {
            ApplicationUser user   = context2.Users.FirstOrDefault(x => x.UserName == User.Identity.Name);
            UserInformation usInfo = context.UsersInformation.FirstOrDefault(x => x.Email == user.Email);
            UpdateModel     usUpd  = new UpdateModel
            {
                FirstName      = usInfo.FirstName,
                LastName       = usInfo.LastName,
                Email          = user.Email,
                PasswordEmail  = PasswordManager.Decrypt(usInfo.PasswordEmail),
                CorporateEmail = usInfo.CorporateEmail
            };

            return(View(usUpd));
        }
Esempio n. 2
0
        public ActionResult SendMail(Mail mail)
        {
            if (ModelState.IsValid)
            {
                UserInformation Us  = context.UsersInformation.FirstOrDefault(x => x.UserName == User.Identity.Name);
                Campaign        cam = context.Campaigns.FirstOrDefault(x => x.CampaignID == mail.IdCam);
                if (cam == null || Us == null)
                {
                    return(RedirectToAction("Default", "Users"));
                }
                int      idCam = mail.IdCam, idLoc = mail.IdLoc;
                string   to = mail.To.ToString(), from = Us.FirstName + " " + Us.LastName;
                string[] To = { };
                to = to.Trim();
                To = to.Split(' ');
                string pass = PasswordManager.Decrypt(Us.PasswordEmail), usr = Us.Email;
                try
                {
                    IAbstractFactorySmtp factory = new FactorySmtp(usr, pass);
                    var         client           = factory.CreateSmtpClient();
                    MailMessage msg = new MailMessage
                    {
                        IsBodyHtml = true,
                        From       = new MailAddress(Us.Email, from),
                        Subject    = cam.CampaignName,
                        Body       = MailContentBuilder(cam.Content, from)
                    };
                    foreach (var item in To)
                    {
                        msg.To.Add(item);
                    }

                    client.Send(msg);
                }
                catch
                {
                    ViewBag.confirmation = "No fue posible enviar los correos";
                    return(View("Confirm"));
                }
                ViewBag.confirmation = "Correos enviados";
                return(View("Confirm"));
            }
            ViewBag.confirmation = "No fue posible enviar los correos";
            return(View("Confirm"));
        }
Esempio n. 3
0
        public bool RecoveryPassword(string semail)
        {
            String password = "", name = "", email = "";
            bool   success = false;

            try
            {
                accessManager.SqlConnectionOpen(DataBase.SQQeye);
                List <SqlParameter> aParameters = new List <SqlParameter>();
                aParameters.Add(new SqlParameter("@userEmail", semail));
                SqlDataReader dr = accessManager.GetSqlDataReader("sp_ForgotPassowrd", aParameters);
                while (dr.Read())
                {
                    password = dr["UserPassword"].ToString();
                    name     = dr["UserName"].ToString();
                    email    = dr["UserEmail"].ToString();
                }
                if (name != "" && email != "")
                {
                    try
                    {
                        MailMessage message = new MailMessage();
                        SmtpClient  smtp    = new SmtpClient();
                        message.From = new MailAddress("*****@*****.**");
                        message.To.Add(new MailAddress(email));
                        message.Subject    = "Password Recovery";
                        message.IsBodyHtml = true; //to make message body as html
                        message.Body       = "Dear Mr." + name + "<br/> You requested for Recover your password <br/> Your Password for the Approval management system is : " + PasswordManager.Decrypt(password) + " <br/>" +
                                             "Thank you For Being with Us <br/>" +
                                             "<br/>Thank You<br/> <a href='http://10.12.13.163:8013/'>Data Entry Service Tracker</a><br/><br/>sqgc.com";
                        smtp.Port                  = 587;
                        smtp.Host                  = "smtp.office365.com"; //for gmail host
                        smtp.EnableSsl             = true;
                        smtp.UseDefaultCredentials = false;
                        smtp.Credentials           = new NetworkCredential("*****@*****.**", "data@235");
                        smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        smtp.Send(message);
                        success = true;
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }
                }
                return(success);
            }
            catch (Exception e)
            {
                accessManager.SqlConnectionClose(true);
                throw e;
            }
            finally
            {
                accessManager.SqlConnectionClose();
            }
        }
Esempio n. 4
0
        public bool RecoveryPassword(int userId)
        {
            String password = "", name = "", email = "";
            bool   success = false;

            try
            {
                accessManager.SqlConnectionOpen(DataBase.SQQeye);
                List <SqlParameter> aParameters = new List <SqlParameter>();
                aParameters.Add(new SqlParameter("@userId", userId));
                SqlDataReader dr = accessManager.GetSqlDataReader("sp_PasswordRecovery", aParameters);
                while (dr.Read())
                {
                    password = dr["UserPassword"].ToString();
                    name     = dr["UserName"].ToString();
                    email    = dr["UserEmail"].ToString();
                }
                if (name != "" && email != "")
                {
                    try
                    {
                        MailMessage message             = new MailMessage();
                        System.Net.Mail.SmtpClient smtp = new SmtpClient();
                        message.From = new MailAddress("*****@*****.**");
                        message.To.Add(new MailAddress(email));
                        message.Subject    = "Insentive Password Recovery";
                        message.IsBodyHtml = true; //to make message body as html
                        message.Body       = "Dear Mr." + name + "<br/> You requested for Recover your password <br/> Your Password for the Insentive Calculation system is : " + PasswordManager.Decrypt(password) + " <br/>" +
                                             "Thank you For Being with Us <br/>" +
                                             "<br/>Thank You<br/> Insentive Calculation System<br/>SQ Group<br/>sqgc.com";
                        smtp.Port                  = 587;
                        smtp.Host                  = "smtp.office365.com"; //for gmail host
                        smtp.EnableSsl             = true;
                        smtp.UseDefaultCredentials = false;
                        smtp.Credentials           = new NetworkCredential("*****@*****.**", "Sweater@123");
                        smtp.DeliveryMethod        = SmtpDeliveryMethod.Network;
                        smtp.Send(message);
                        success = true;
                    }
                    catch (Exception) { }
                }
                return(success);
            }
            catch (Exception e)
            {
                accessManager.SqlConnectionClose(true);
                throw e;
            }
            finally
            {
                accessManager.SqlConnectionClose();
            }
        }
Esempio n. 5
0
        private void dgvUserInformation_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                PasswordManager passwordManager = new PasswordManager();
                userID           = Convert.ToInt16(dgvUserInformation.CurrentRow.Cells["colID"].Value);
                txtFullName.Text = dgvUserInformation.CurrentRow.Cells["colFullName"].Value.ToString();
                txtUserName.Text = dgvUserInformation.CurrentRow.Cells["colUserName"].Value.ToString();
                txtPassword.Text = passwordManager.Decrypt(dgvUserInformation.CurrentRow.Cells["colPassword"].Value.ToString());

                if (dgvUserInformation.CurrentRow.Cells["colMobile"].Value != null)
                {
                    txtMobile.Text = dgvUserInformation.CurrentRow.Cells["colMobile"].Value.ToString();
                }
                if (dgvUserInformation.CurrentRow.Cells["colPhone"].Value != null)
                {
                    txtPhone.Text = dgvUserInformation.CurrentRow.Cells["colPhone"].Value.ToString();
                }
                if (dgvUserInformation.CurrentRow.Cells["colFax"].Value != null)
                {
                    txtFax.Text = dgvUserInformation.CurrentRow.Cells["colFax"].Value.ToString();
                }

                if (dgvUserInformation.CurrentRow.Cells["colNationalID"].Value != null)
                {
                    txtNationalID.Text = dgvUserInformation.CurrentRow.Cells["colNationalID"].Value.ToString();
                }
                if (dgvUserInformation.CurrentRow.Cells["colActive"].Value != null)
                {
                    chkActive.Checked = Convert.ToBoolean(dgvUserInformation.CurrentRow.Cells["colActive"].Value);
                }
                //if (dgvUserInformation.CurrentRow.Cells["colCountry"].Value != null)
                //{
                //    cmbCountry.SelectedItem = dgvUserInformation.CurrentRow.Cells["colCountry"].Value.ToString();
                //}
                if (dgvUserInformation.CurrentRow.Cells["colPostalCode"].Value != null)
                {
                    txtPosatalCode.Text = dgvUserInformation.CurrentRow.Cells["colPostalCode"].Value.ToString();
                }
                if (dgvUserInformation.CurrentRow.Cells["colState"].Value != null)
                {
                    txtState.Text = dgvUserInformation.CurrentRow.Cells["colState"].Value.ToString();
                }
                if (dgvUserInformation.CurrentRow.Cells["colCity"].Value != null)
                {
                    txtCity.Text = dgvUserInformation.CurrentRow.Cells["colCity"].Value.ToString();
                }
                if (dgvUserInformation.CurrentRow.Cells["colAddress2"].Value != null)
                {
                    txtAddress2.Text = dgvUserInformation.CurrentRow.Cells["colAddress2"].Value.ToString();
                }
                if (dgvUserInformation.CurrentRow.Cells["colAddress1"].Value != null)
                {
                    txtAddress1.Text = dgvUserInformation.CurrentRow.Cells["colAddress1"].Value.ToString();
                }
                if (dgvUserInformation.CurrentRow.Cells["colUserGroupID"].Value != null)
                {
                    cmbUserGroup.SelectedValue = dgvUserInformation.CurrentRow.Cells["colUserGroupID"].Value;
                }
                if (dgvUserInformation.CurrentRow.Cells["colEmail"].Value != null)
                {
                    txtEmail.Text = dgvUserInformation.CurrentRow.Cells["colEmail"].Value.ToString();
                }
            }
            catch
            {
            }
        }