Esempio n. 1
0
    protected void btnSaveAndSend_Click(object sender, EventArgs e)
    {
        try
        {
            getConfigAmazone();
            MailConfigDTO mcDTO = new MailConfigDTO();
            mcDTO.DepartmentID = getUserLogin().DepartmentId;
            mcDTO.userId = getUserLogin().UserId;
            mcDTO.Email = txtEmailVerify.Text.Trim();
            mcDTO.parentId = 1;
            mcDTO.levelId = 1;
            mcDTO.isSSL = true;
            mcDTO.Port = 25;
            mcDTO.Server = server;
            mcDTO.username = username;
            mcDTO.Password = password;
            mcDTO.Name = txtNameConfig.Text;
            new MailConfigBUS().tblMailConfig_insert(mcDTO);

            SmtpClient SmtpServer = new SmtpClient();
            SmtpServer.Credentials = new System.Net.NetworkCredential("AKIAIGXHHO72FHXGCPFQ", "Ara8HV/kcfjNU+rqrTpJBAAjs/OsD1xEykLsuguqpe1Z");
            SmtpServer.Port = 25;
            SmtpServer.Host = "email-smtp.us-east-1.amazonaws.com";
            SmtpServer.EnableSsl = true;
            MailMessage mail = new MailMessage();
            String[] addr = txtEmailVerify.Text.Split(' ');
            mail.From = new MailAddress("*****@*****.**",
            " Hệ Thống FA MAIL  ", System.Text.Encoding.UTF8);
            Byte i;
            for (i = 0; i < addr.Length; i++)
                mail.To.Add(addr[i]);
            mail.Subject = "Thư xác nhận";
            mail.IsBodyHtml = true;
            string lnk = "http://emailmarketing.1onlinebusinesssystem.com/VerifyEmail.aspx?userid=" + userLogin.UserId + "&email=" + txtEmailVerify.Text;
            mail.Body += "<html>  <body><table class='auto-style1'> <tr><td>Click vào link bên dưới để kích hoạt sử dụng </td></tr><tr><td>" + HttpUtility.HtmlEncode(lnk) + " </td></tr></table></body>  ";
            mail.Body += "</html>";
            mail.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
            mail.ReplyTo = new MailAddress(txtEmailVerify.Text);
            SmtpServer.Send(mail);
            LoadVerifyList();

            pnSuccess.Visible = true;
            pnError.Visible = pnSuccessverify.Visible = false;
            lblSuccess.Text = "Vui lòng kiểm tra mail và xác nhận!";
        }
        catch(Exception ex){
            logs.Error(userLogin.Username + "-AmazonManage-Verify", ex);
            pnError.Visible = true;
            pnSuccess.Visible = pnSuccessverify.Visible = false;
            lblError.Text = "Có lỗi trong quá trình gửi mail!";
        }
    }
 private MailConfigDTO GetMailConfigDTO()
 {
     MailConfigDTO mcDTO = new MailConfigDTO();
     string Name = null;
     string Server = null;
     string email = null;
     string password = null;
     string confilmPass = null;
     int port = int.Parse(this.txtPort.Text.Trim());
     int departmentID = int.Parse(this.drlDepartmen.SelectedValue);
     Name = this.txtName.Text;
     Server = this.txtServer.Text;
     email = this.txtEmailSend.Text;
     password = this.txtPassword.Text.Trim();
     confilmPass = this.txtConfilmPassword.Text.Trim();
     mcDTO.Email = email;
     mcDTO.Server = Server;
     mcDTO.Port = port;
     mcDTO.Name = Name;
     mcDTO.Password = password;
     mcDTO.DepartmentID = departmentID;
     mcDTO.levelId = 1;
     mcDTO.parentId = 1;
     mcDTO.username = this.txtEmailConfig.Text;
     mcDTO.userId = getUserLogin().UserId;
     if (this.chkIsSSL.Checked == true)
     {
         mcDTO.isSSL = true;
     }
     else
     {
         mcDTO.isSSL = false;
     }
     return mcDTO;
 }
Esempio n. 3
0
 public void tblMailConfig_Update(MailConfigDTO dt)
 {
     string sql = "UPDATE tblMailConfig SET "+
                 "Server = @Server, "+
                 "Port = @Port, "+
                 "Email = @Email, "+
                 "Name = @Name, " +
                 "DepartmentID = @DepartmentID, " +
                 "parentId = @parentId, " +
                 "levelId = @levelId, " +
                 "username = @username, " +
                 "isSSL = @isSSL, " +
                 "Password = @Password, "+
                 "UserId = @UserId, " +
                 " WHERE Id = @Id";
     cmd = new SqlCommand(sql, ConnectionData._MyConnection);
     cmd.CommandType = CommandType.Text;
     cmd.Parameters.Add("@Id", SqlDbType.Int).Value = dt.Id;
     cmd.Parameters.Add("@Server", SqlDbType.VarChar).Value = dt.Server;
     cmd.Parameters.Add("@Port", SqlDbType.Int).Value = dt.Port;
     cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = dt.Email;
     cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = dt.Password;
     cmd.Parameters.Add("@Name", SqlDbType.VarChar).Value = dt.Name;
     cmd.Parameters.Add("@DepartmentID", SqlDbType.Int).Value = dt.DepartmentID;
     cmd.Parameters.Add("@parentId", SqlDbType.Int).Value = dt.parentId;
     cmd.Parameters.Add("@levelId", SqlDbType.Int).Value = dt.levelId;
     cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = dt.username;
     cmd.Parameters.Add("@isSSL", SqlDbType.Bit).Value = dt.isSSL;
     cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = dt.userId;
     cmd.ExecuteNonQuery();
     cmd.Dispose();
 }
Esempio n. 4
0
 public void tblMailConfig_insert(MailConfigDTO dt)
 {
     string sql = "INSERT INTO tblMailConfig(Server, Port, Email, Password, Name, DepartmentID, parentId, levelId, username, isSSL, UserId) " +
                    "VALUES(@Server, @Port, @Email, @Password, @Name, @DepartmentID, @parentId, @levelId, @username, @isSSL, @UserId)";
     cmd = new SqlCommand(sql, ConnectionData._MyConnection);
     cmd.CommandType = CommandType.Text;
     cmd.Parameters.Add("@Server", SqlDbType.VarChar).Value = dt.Server;
     cmd.Parameters.Add("@Port", SqlDbType.Int).Value = dt.Port;
     cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value = dt.Email;
     cmd.Parameters.Add("@Password", SqlDbType.VarChar).Value = dt.Password;
     cmd.Parameters.Add("@Name", SqlDbType.NVarChar).Value = dt.Name;
     cmd.Parameters.Add("@DepartmentID", SqlDbType.Int).Value = dt.DepartmentID;
     cmd.Parameters.Add("@parentId", SqlDbType.Int).Value = dt.parentId;
     cmd.Parameters.Add("@levelId", SqlDbType.Int).Value = dt.levelId;
     cmd.Parameters.Add("@username", SqlDbType.VarChar).Value = dt.username;
     cmd.Parameters.Add("@isSSL", SqlDbType.Bit).Value = dt.isSSL;
     cmd.Parameters.Add("@UserId", SqlDbType.Int).Value = dt.userId;
     cmd.ExecuteNonQuery();
     cmd.Dispose();
 }
Esempio n. 5
0
 public void tblMailConfig_Update(MailConfigDTO dt)
 {
     mcDao.tblMailConfig_Update(dt);
 }
Esempio n. 6
0
 public void tblMailConfig_insert(MailConfigDTO dt)
 {
     mcDao.tblMailConfig_insert(dt);
 }
Esempio n. 7
0
    protected void btnVerify_Click(object sender, EventArgs e)
    {
        VerifyBUS vbs = new VerifyBUS();

        //try
        //{
        VerifyBUS vBus = new VerifyBUS();
        string err = ValidateNull();
        DataTable dt = vBus.GetByUserId(getUserLogin().UserId);
        if (dt.Rows.Count >= 3)
        {
            pnSuccess.Visible = false;
            pnError.Visible = true;
            lblError.Text = "Giới hạn tối đa cho phép xác thực là 3. Vui lòng xóa mail cũ !";
        }
        else if (err == "")
        {
            // Get amazone config.
            getConfigAmazone();
            veriryEmail = new VerifyEmail(accessKey, secretKey);
            bool status = veriryEmail.VerifyEmailAddress(txtEmailVerify.Text.Trim());
            if (status == true)
            {
                // Them vao danh sach email xac thuc thanh cong.
                MailConfigBUS mcBUS = new MailConfigBUS();
                VerifyDTO vDto = new VerifyDTO();
                vDto.EmailVerify = txtEmailVerify.Text.Trim();
                vDto.isdelete = 0;
                vDto.userId = getUserLogin().UserId;
                DataTable T = vBus.CheckByEmail(vDto.EmailVerify);
                if(T.Select("UserId="+userLogin.UserId).Length>0)
                {

                    pnSuccess.Visible = pnSuccessverify.Visible = false;
                    pnError.Visible = true;

                    lblError.Text = "Email " + txtEmailVerify.Text + " đã được đăng ký";
                    return;
                }
                if (vBus.CheckByEmail(vDto.EmailVerify).Rows.Count > 0)
                {
                    pnSuccessverify.Visible = true;
                    pnError.Visible = false;
                    lbverify.Text = "Email " + txtEmailVerify.Text + " này đã được verify trong hệ thống.Bạn vui lòng click vào để kích hoạt sử dụng ";
                    return;
                }
                else
                {
                    vBus.tblVerify_insert(vDto);
                }

                // Thêm vào cấu hình mail.
                MailConfigDTO mcDTO = new MailConfigDTO();
                mcDTO.DepartmentID = getUserLogin().DepartmentId;
                mcDTO.userId = getUserLogin().UserId;
                mcDTO.Email = txtEmailVerify.Text.Trim();
                mcDTO.parentId = 1;
                mcDTO.levelId = 1;
                mcDTO.isSSL = true;
                mcDTO.Port = 25;
                mcDTO.Server = server;
                mcDTO.username = username;
                mcDTO.Password = password;
                mcDTO.Name = txtNameConfig.Text;
                if (mcBUS.GetByEmailAndPass(mcDTO.Email, mcDTO.Password, userLogin.UserId).Rows.Count > 0)
                {
                    mcDTO.Id = int.Parse(mcBUS.GetByEmailAndPass(mcDTO.Email, mcDTO.Password, userLogin.UserId).Rows[0]["Id"].ToString());
                    mcBUS.tblMailConfig_Update(mcDTO);
                }
                else
                {
                    mcBUS.tblMailConfig_insert(mcDTO);
                }

                pnError.Visible = false;
                lblSuccess.Text = "Bạn đã xác thực thành công email: " + txtEmailVerify.Text + " Vui lòng kiểm tra email để hoàn thành việc xác thực";
                txtEmailVerify.Text = "";
                txtNameConfig.Text = "";
                pnSuccess.Visible = true;
                LoadVerifyList();

            }
            else
            {
                pnSuccessverify.Visible = true;
                pnError.Visible = false;
                lbverify.Text = "Email " + txtEmailVerify.Text + " này đã được verify trong hệ thống.Bạn vui lòng click vào để kích hoạt sử dụng ";
            }
        }
        else
        {
            pnSuccess.Visible = false;
            pnError.Visible = true;
            lblError.Text = err;
            txtEmailVerify.Focus();
        }
        //}
        //catch (Exception)
        //{
        //}
    }
Esempio n. 8
0
 public IHttpActionResult Put([FromUri] int id, [FromBody] MailConfigDTO MailConfig)
 {
     MaillConfigService.PrePutDTO(ModelState, currentClient, id, MailConfig);
     return(Ok());
 }
Esempio n. 9
0
 public MailConfigDTO Post([FromBody] MailConfigDTO MailConfig)
 {
     return(MaillConfigService.PrePostDTO(ModelState, currentClient, MailConfig));
 }