private void btnSend_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(m_objAccountForgetModel.TenDangNhap) || string.IsNullOrEmpty(m_objAccountForgetModel.Email))
            {
                XtraMessageBox.Show("Vui lòng nhập thông tin để lấy lại mật khẩu.", "Có lỗi xảy ra", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (EmailMethod.IsValidEmail(m_objAccountForgetModel.Email) == false)
            {
                XtraMessageBox.Show("Địa chỉ email không hợp lệ.", "Có lỗi xảy ra", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (m_objAccountBLL.ForgetPassword(m_objAccountForgetModel))
            {
                XtraMessageBox.Show($"Đã gửi email cập nhật mật khẩu vào email {m_objAccountForgetModel.Email}.", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Close();
            }
            else
            {
                XtraMessageBox.Show("Vui lòng nhập thông tin để lấy lại mật khẩu.", "Có lỗi xảy ra", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
        public bool ForgetPassword(AccountForgetModel m_objAccountForgetModel)
        {
            using (var context = new QuanLyDeTaiKhoaHocContext())
            {
                var data = context.Accounts.FirstOrDefault(x => x.Deleted == false && x.Email == m_objAccountForgetModel.Email && x.TenDangNhap == m_objAccountForgetModel.TenDangNhap);
                if (data == null)
                {
                    return(false);
                }
                else
                {
                    MailInfo mailInfoFrom = new MailInfo()
                    {
                        Email = Constants.MAIL_EMAIL_DEFAULT,
                        Name  = Constants.MAIL_NAME_DEFAULT,
                        Pass  = Constants.MAIL_PASSWORD_DEFAULT
                    };

                    MailInfo mailInfoTo = new MailInfo()
                    {
                        Email = data.Email
                    };

                    string strNewPassword    = EmailMethod.RandomPassword();
                    string strMD5NewPassword = CommonLibrary.CreateMD5(strNewPassword);
                    data.MatKhau = strMD5NewPassword;
                    context.SaveChanges();

                    string content = $"Quản Lý Đề Tài Khoa Học cấp lại mật khẩu.\r\n\r\nTên đăng nhập: {data.TenDangNhap}\r\nMật khẩu: {strNewPassword}";

                    EmailMethod.SendMail("Cấp lại mật khẩu - Quản Lý Đề Tài Khoa Học", content, mailInfoFrom, mailInfoTo);
                    return(true);
                }
            }
        }
 public BookLogRepository(DevHubContext context, IMapper mapper, MethodLibrary method, GuidMethod guid, QueryMethod query, EmailMethod email)
 {
     _context = context;
     _mapper  = mapper;
     _method  = method;
     _guid    = guid;
     _query   = query;
     _email   = email;
 }
Ejemplo n.º 4
0
        public async Task <bool> SendEmail(EmailMethod method, string recipients, string subject, string body)
        {
            switch (method)
            {
            case EmailMethod.SendGrid:
                return(await SendEmail_SendGrid(recipients, subject, body));

            case EmailMethod.SMTP:
            default:
                return(await SendEmail_SMTP(recipients, subject, body));
            }
        }
Ejemplo n.º 5
0
        private void Submit_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrWhiteSpace(Comments.Text) || string.IsNullOrWhiteSpace(EmailId.Text) || EmailId.Text.Contains('@') || EmailId.Text.Contains("com") || !EmailId.Text.Contains('.'))
            {
                DisplayContentMessage("Comments and Id are mandatory." + Environment.NewLine + "Please Enter the values properly." + Environment.NewLine + "ID example : John.Black", "Error");
            }
            else
            {
                try
                {
                    SqlConnection sCon = new SqlConnection();

                    try
                    {
                        sCon = SqlServer.GetConnection();
                        sCon.Open();
                        var command = sCon.CreateCommand();
                        if (RunTestsPage.SelectedProduct == null)
                        {
                            RunTestsPage.SelectedProduct = "None";
                        }
                        command.CommandText =
                            "INSERT INTO issueList (userName, machineName, reportingTime ,operatingSystem,productName,logFilePath,comments)" +
                            "VALUES ('" +
                            Environment.UserDomainName + "\\" + Environment.UserName + "','" +
                            Environment.MachineName + "','" +
                            DateTime.Now.ToString() + "','" +
                            Environment.OSVersion + "','" +
                            RunTestsPage.SelectedProduct + "','" +
                            LoggerUtil.GetTempPath() + "TestMateLogFile.txt" + "','" +
                            Comments.Text.ToString() + "');";
                        command.ExecuteNonQuery();
                    }
                    catch (Exception ex)
                    {
                        LoggerUtil.LogMessageToFile("Exception Caught at Reporting module is : " + ex.ToString());
                    }
                    finally
                    {
                        EmailMethod.SendEmailTemplate(Comments.Text.ToString(), EmailId.Text);
                        DisplayContentMessage("Reported Succefully!", "Report");
                    }
                }
                catch (Exception exe)
                {
                    ModernDialog.ShowMessage("Please Contact Automation Team.", "Error", MessageBoxButton.OK, null);
                }
            }
        }