public EmailSend() { srdBUS = new SendRegisterDetailBUS(); scBUS = new SendContentBUS(); mcBUS = new MailConfigBUS(); ctBUS = new CustomerBUS(); dtGroupBUS = new DetailGroupBUS(); countBUS = new CountBuyBUS(); }
protected void btnDelete_Click(object sender, ImageClickEventArgs e) { try { UserLoginDTO userLogin = getUserLogin(); ConnectionData.OpenMyConnection(); int Id = int.Parse(((ImageButton)sender).CommandArgument.ToString()); mcBUS = new MailConfigBUS(); SendRegisterBUS srBUS = new SendRegisterBUS(); if (srBUS.GetByMailConfigID(Id) > 0) { visibleMessage(false); pnError.Visible = true; lblError.Text = "Bạn vừa không thể xóa cấu hình này được. Cấu hình này đang có mail chờ gửi !"; } else { int IDCurrent = userLogin.UserId; if (Id != IDCurrent) { mcBUS.tblMailConfig_Delete(Id); //Response.Redirect(Request.RawUrl); dlMailConfig.DataSource = mcBUS.GetAll(); dlMailConfig.DataBind(); visibleMessage(false); pnSuccess.Visible = true; lblSuccess.Text = "Bạn vừa xóa thành một cấu hình !"; } else { visibleMessage(false); pnError.Visible = true; lblError.Text = "Bạn vừa không thể xóa cấu hình này được. Cấu hình này đang là cấu hình bạn đang đăng nhập!"; } } ConnectionData.CloseMyConnection(); } catch (Exception ex) { //pnError.Visible = true; //lblError.Text = ex.Message; } }
public EmailSend() { srdBUS = new SendRegisterDetailBUS(); scBUS = new SendContentBUS(); mcBUS= new MailConfigBUS(); }
protected void btnSave_Click(object sender, EventArgs e) { ci = new CultureInfo("vi-VN"); try { if (CheckValidate() == "") { mcBUS = new MailConfigBUS(); ConnectionData.OpenMyConnection(); if (getUserLogin().DepartmentId == 1) { mcBUS.tblMailConfig_insert(GetMailConfigDTO()); ConnectionData.CloseMyConnection(); pnSuccess.Visible = true; //lblSuccess.Text = this.GetGlobalResourceObject("Resource", "InsertSucces").ToString(); Resources.Resource.Culture = ci; lblSuccess.Text = Resources.Resource.InsertSucces; dlMailConfig.DataSource = mcBUS.GetAll(); dlMailConfig.DataBind(); pnError.Visible = false; } else { this.btnSave.Enabled = false; pnError.Visible = true; lblError.Text = Resources.Resource.InsertFail; Resources.Resource.Culture=ci; } } else { pnError.Visible = true; lblError.Text = CheckValidate(); pnSuccess.Visible = false; } } catch (Exception ex) { pnError.Visible = true; lblError.Text = "Vui lòng kiểm tra lại cấu hình mail.<br/>" + ex.Message; } }
private void InitBUS() { mcBUS = new MailConfigBUS(); dpBUS = new DepartmentBUS(); if (getUserLogin().DepartmentId == 1) { drlDepartmen.Items.Clear(); drlDepartmen.DataSource = dpBUS.GetAll(); drlDepartmen.DataTextField = "Name"; drlDepartmen.DataValueField = "ID"; drlDepartmen.DataBind(); dlMailConfig.DataSource = mcBUS.GetAll(); dlMailConfig.DataBind(); } else { this.btnSave.Enabled = false; } }
protected void getRegisterSendList() { try { cateBUs = new CategoryBUS(); srBUS = new SendRegisterBUS(); srdBus = new SendRegisterDetailBUS(); mailConfigBus = new MailConfigBUS(); mailGroupBus = new MailGroupBUS(); sendContentBus = new SendContentBUS(); dsgBus = new DetailGroupBUS(); UserLoginDTO userLogin = getUserLogin(); DataTable tblSendRegister = new DataTable(); if (userLogin.DepartmentId == 1) { tblSendRegister = srBUS.GetAll(); } else { tblSendRegister = srBUS.GetAll(userLogin.UserId); } if (tblSendRegister.Rows.Count > 0) { dlWaitSend.DataSource = tblSendRegister; dlWaitSend.DataBind(); for (int i = 0; i < tblSendRegister.Rows.Count; i++) { try { DataRow row = tblSendRegister.Rows[i]; int Sendtype = int.Parse(row["Sendtype"].ToString()); HiddenField hdfId = (HiddenField)dlWaitSend.Items[i].FindControl("hdfId"); hdfId.Value = row["Id"].ToString(); int contentId = int.Parse(row["SendContentId"].ToString()); //DataTable tblContent = sendContentBus.GetByID(contentId); Label lblSubject = (Label)dlWaitSend.Items[i].FindControl("lblSubject"); //if (tblContent.Rows.Count > 0) //{ // lblSubject.Text = tblContent.Rows[0]["Subject"].ToString(); //} //else lblSubject.Text = row["Subject"] + ""; int mailConfig = int.Parse(row["MailConfigID"].ToString()); DataTable tblMailConfig = mailConfigBus.GetByID(mailConfig); if (tblMailConfig.Rows.Count > 0) { Label lblMailConfig = (Label)dlWaitSend.Items[i].FindControl("lblMailConfig"); lblMailConfig.Text = tblMailConfig.Rows[0]["Email"].ToString(); } int groupTo = int.Parse(row["GroupTo"].ToString()); if (groupTo == -3) { Label lblGroupTo = (Label)dlWaitSend.Items[i].FindControl("lblGroupTo"); lblGroupTo.Text = "Tất cả khách hàng"; } else if (groupTo == -2) { Label lblGroupTo = (Label)dlWaitSend.Items[i].FindControl("lblGroupTo"); lblGroupTo.Text = "Nhóm mua nhiều lần"; } else if (groupTo == -1) { Label lblGroupTo = (Label)dlWaitSend.Items[i].FindControl("lblGroupTo"); lblGroupTo.Text = "Nhóm mua lần đầu"; } else { DataTable tblGroupTo = new DataTable(); if (Sendtype == 1) { tblGroupTo = mailGroupBus.GetByID(groupTo); if (tblGroupTo.Rows.Count > 0) { Label lblGroupTo = (Label)dlWaitSend.Items[i].FindControl("lblGroupTo"); lblGroupTo.Text = tblGroupTo.Rows[0]["Name"].ToString(); } } else { tblGroupTo = cateBUs.GetByID(groupTo); if (tblGroupTo.Rows.Count > 0) { Label lblGroupTo = (Label)dlWaitSend.Items[i].FindControl("lblGroupTo"); lblGroupTo.Text = tblGroupTo.Rows[0]["Title"].ToString(); } } } Label lblStartDate = (Label)dlWaitSend.Items[i].FindControl("lblStartDate"); lblStartDate.Text = row["StartDate"].ToString(); Label lblEndDate = (Label)dlWaitSend.Items[i].FindControl("lblEndDate"); int status = int.Parse(row["Status"].ToString()); Panel panel = (Panel)dlWaitSend.Items[i].FindControl("Panel1"); TextBox progressbar = (TextBox)dlWaitSend.Items[i].FindControl("progressbar"); LinkButton lbtDetail = (LinkButton)dlWaitSend.Items[i].FindControl("lbtDetail"); //get list detail DataTable listDetail = srdBus.GetByID(int.Parse(row["Id"].ToString())); int hasSend = 0, sumSend = dsgBus.GetByID(groupTo).Rows.Count; for (int k = 0; k < listDetail.Rows.Count; k++) { hasSend++; } //calc percent has send int percent = 0; if (sumSend != 0) { percent = (hasSend * 100) / sumSend; } if (status == 0) { //display process bar panel.Visible = true; progressbar.BackColor = System.Drawing.Color.Cornsilk; progressbar.Width = percent + 20; progressbar.Text = percent + "%"; lbtDetail.Visible = false; lbtDetail.Text = ""; lblEndDate.Text = "Chưa xác định "; } else { //hidden process bar panel.Visible = false; lbtDetail.Text = "Xem chi tiết"; lbtDetail.PostBackUrl = "reportSend.aspx?campaign-id=" + row["Id"].ToString(); lblEndDate.Text = row["EndDate"].ToString(); } LinkButton lbtDelete = (LinkButton)dlWaitSend.Items[i].FindControl("lbtDelete"); lbtDelete.CommandArgument = row["Id"].ToString(); } catch (Exception) { continue; } } } } catch (Exception) { } }
private void LoadMailConfigLists() { mailConfigBus = new MailConfigBUS(); DataTable dtMailConfig = new DataTable(); UserLoginDTO userLogin = getUserLogin(); if (userLogin != null) { if (userLogin.DepartmentId == 1) { dtMailConfig = mailConfigBus.GetAll(); } else { dtMailConfig = mailConfigBus.GetByUserId(userLogin.UserId); } } else { Response.Redirect("login.aspx", false); } drlMailConfig.Items.Clear(); drlMailConfig.DataSource = dtMailConfig.DefaultView; drlMailConfig.DataTextField = "Email"; drlMailConfig.DataValueField = "Id"; drlMailConfig.DataBind(); }
private void InitialBUS() { scBUS = new SendContentBUS(); mailConfigBus = new MailConfigBUS(); mailGroupBus = new MailGroupBUS(); customerBus = new CustomerBUS(); srBUS = new SendRegisterBUS(); common = new Common(); dsgBUS = new DetailGroupBUS(); }
private void LoadVerifyList() { try { int stt = 0; DataTable List = this.CreateListEmail(); VerifyBUS vBus = new VerifyBUS(); DataTable dtVerifyList = vBus.GetByUserId(getUserLogin().UserId); MailConfigBUS mcBUS = new MailConfigBUS(); // Load accessKey & secretKey & Password. getConfigAmazone(); veriryEmail = new VerifyEmail(accessKey, secretKey); List<string> listEmail = new List<string>(); try { listEmail = veriryEmail.ListVerifiedEmailAddresses(); } catch (Exception ex) { logs.Error(userLogin.Username + "-Verify", ex); } foreach (DataRow EmailItem in dtVerifyList.Rows) { stt++; DataRow row = List.NewRow(); row["No"] = stt; row["Email"] = EmailItem["EmailVerify"].ToString(); if (listEmail.Contains(EmailItem["EmailVerify"].ToString())) { row["Status"] = "Đã xác thực"; } else { row["Status"] = "Chờ xác thực.."; } string email = EmailItem["EmailVerify"].ToString(); DataTable mailConfig = mcBUS.GetByEmailAndPass(email, password, userLogin.UserId); if (mailConfig.Rows.Count > 0) { row["Name"] = mailConfig.Rows[0]["Name"].ToString(); } else { row["Name"] = "Chưa cấu hình"; } List.Rows.Add(row); } this.dtlEmail.DataSource = List; this.dtlEmail.DataBind(); } catch (Exception ex) { logs.Error(userLogin.Username + "-Verify", ex); } }
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) //{ //} }
protected void Page_Load(object sender, EventArgs e) { try { string eventId, name, email, company, phone, secondPhone, address1, address2, city, province, country, zipcode, fax, groupId, visibleField, gender, requireTime, UserID, Job; eventId = Request.Params["eventId"]; name = Request.Params["Name"]; if (name == null || name == "") { name = ""; } email = Request.Params["Email"]; if (email == null || email == "") { Session["Error"] = "Vui lòng kiểm tra lại thông tin đăng ký !"; Response.Redirect("event-register-error.aspx", false); return; } gender = Request.Params["Gender"]; if (gender == null || gender == "") { gender = "Nam"; } Job = Request.Params["Job"]; if (Job == null || Job == "") { Job = ""; } company = Request.Params["Company"]; if (company == null || company == "") { company = ""; } phone = Request.Params["Phone"]; if (phone == null || phone == "") { phone = ""; } secondPhone = Request.Params["SecondPhone"]; if (secondPhone == null || secondPhone == "") { secondPhone = ""; } address1 = Request.Params["Address1"]; if (address1 == null || address1 == "") { address1 = ""; } address2 = Request.Params["Address2"]; if (address2 == null || address2 == "") { address2 = ""; } city = Request.Params["City"]; if (city == null || city == "") { city = ""; } province = Request.Params["Province"]; if (province == null || province == "") { province = ""; } country = Request.Params["Country"]; if (country == null || country == "") { country = ""; } zipcode = Request.Params["ZipCode"]; if (zipcode == null || zipcode == "") { zipcode = ""; } fax = Request.Params["Fax"]; if (fax == null || fax == "") { fax = ""; } requireTime = Request.Params["requireTime"]; groupId = Request.Params["groupId"]; UserID = Request.Params["UserID"]; //startDate = Request.Params["startDate"]; //endDate = Request.Params["endDate"]; visibleField = Request.Params["visibleField"]; string[] arrVisible = visibleField.Trim().Split(' '); eventDetailBus = new EventDetailBUS(); eventBus = new EventBUS(); EventDetailDTO eventDetailDto = new EventDetailDTO(); eventDetailDto.EventId = int.Parse(eventId); eventDetailDto.FullName = name; eventDetailDto.EmailID = email; eventDetailDto.Job = Job; eventDetailDto.Company = company; eventDetailDto.Phone = phone; eventDetailDto.SecondPhone = secondPhone; eventDetailDto.Address = address1; eventDetailDto.Address2 = address2; eventDetailDto.City = city; eventDetailDto.Province = province; eventDetailDto.Country = country; eventDetailDto.ZipCode = zipcode; eventDetailDto.Fax = fax; eventDetailDto.CreateDate = DateTime.Now; eventDetailDto.GroupId = int.Parse(groupId); eventDetailDto.CountReceivedMail = 0; eventDetailDto.LastReceivedMail = DateTime.Now; // Kiem tra dieu kien // Check thời gian của sự kiện DataTable tblEvent = eventBus.GetByID(int.Parse(eventId)); if (tblEvent.Rows.Count > 0) { if (requireTime.Equals("true")) { if (DateTime.Parse(tblEvent.Rows[0]["StartDate"].ToString()) <= DateTime.Now && DateTime.Now <= DateTime.Parse(tblEvent.Rows[0]["EndDate"].ToString())) { } else { Session["Error"] = "Thời hạn đăng ký đã hết, vui lòng chờ sự kiện kế tiếp. Cảm ơn !"; Response.Redirect("event-register-error.aspx", false); return; } } } // Mot email chi dang ky duoc mot event DataTable checkEmail = eventDetailBus.GetByIdAndEmail(int.Parse(eventId), email); if (checkEmail.Rows.Count > 0) { Session["Error"] = "Email đã được sử dụng. Vui lòng chọn email khác !"; Response.Redirect("event-register-error.aspx", false); return; } // Gui mail // Lay thong tin event eventBus = new EventBUS(); DataTable tbEvent = eventBus.GetByID(int.Parse(eventId)); //get mail config if (tbEvent.Rows.Count > 0) { DataRow rEvent = tbEvent.Rows[0]; mailConfigBus = new MailConfigBUS(); DataTable tbMailConfig = mailConfigBus.GetByID(int.Parse(tbEvent.Rows[0]["ConfigId"].ToString())); // Them khach hang vao bang event detail eventDetailBus.tblEventDetail_insert(eventDetailDto); try { // Them khach hang vao danh sach khach hang customerBus = new CustomerBUS(); DataTable tblCustomer = customerBus.GetByEmail(email, int.Parse(UserID)); int customerId = 0; if (tblCustomer.Rows.Count == 0) { CustomerDTO customerDto = new CustomerDTO(); customerDto.Name = name; customerDto.Gender = gender; customerDto.BirthDay = DateTime.Now; customerDto.Email = email; customerDto.Phone = phone; customerDto.SecondPhone = secondPhone; customerDto.Address = address1; customerDto.Fax = fax; customerDto.Company = company; customerDto.Job = Job; customerDto.City = city; customerDto.Province = province; customerDto.Country = country; customerDto.Type = "0"; customerDto.UserID = int.Parse(UserID); customerDto.createBy = int.Parse(UserID); customerDto.AssignTo = int.Parse(UserID); customerId = customerBus.tblCustomer_insert(customerDto); this.SendMail(customerDto); logs_info.Info("Email Register: " + email); } else { customerId = int.Parse(tblCustomer.Rows[0]["Id"].ToString()); } // Them khach hang vao detail group. dgBus = new DetailGroupBUS(); DataTable tblDetailGroup = dgBus.GetByID(int.Parse(groupId), customerId); if (tblDetailGroup.Rows.Count <= 0) { DetailGroupDTO dgDto = new DetailGroupDTO(); dgDto.GroupID = int.Parse(groupId); dgDto.CustomerID = customerId; dgDto.CountReceivedMail = 0; dgDto.LastReceivedMail = DateTime.Now; dgBus.tblDetailGroup_insert(dgDto); } eventBus.tblEventCustomer_Insert(customerId, eventId); } catch (Exception) { } if (tbMailConfig.Rows.Count > 0) { DataRow rConfig = tbMailConfig.Rows[0]; ProcessSendEmail process = new ProcessSendEmail(); // Xu ly them loi chao trong noi dung mail string body = rEvent["Body"].ToString(); string welcome = (name == "" || name == null) ? email : name; // Replace with [khachhang] or [email] body = body.Replace("[khachhang]", welcome); body = body.Replace("[email]", email); bool rsSend = true; //rsSend = process.SendMail(rEvent["Subject"].ToString(), // body, rConfig["Server"].ToString(), int.Parse(rConfig["Port"].ToString()), // rConfig["Email"].ToString(), rConfig["Password"].ToString(), rConfig["Name"].ToString(), // email, rConfig["username"].ToString(),bool.Parse(rConfig["isSSL"].ToString())); if (rsSend) { // chuyen den trang success string url = rEvent["ResponeUrl"].ToString(); if (url.Equals("Default")) { Response.Redirect("event-register-success.aspx", false); } else { Response.Redirect(url, false); } } else { Session["Error"] = "Bạn đã đăng ký không thành công."; Response.Redirect("event-register-error.aspx", false); } } else { Session["Error"] = "Bạn đã đăng ký không thành công."; Response.Redirect("event-register-error.aspx", false); } } } catch (Exception ex) { Session["Error"] = "Một số lỗi hệ thống đã xảy ra. Vui lòng kiểm tra lại thông tin !\n" + ex.Message; Response.Redirect("event-register-error.aspx"); } }
private void InitialBUS() { mailConfigBus = new MailConfigBUS(); mailGroupBus = new MailGroupBUS(); eventBus = new EventBUS(); }
private void InitBUS() { dpBUS = new DepartmentBUS(); mcBUS = new MailConfigBUS(); }