void LoadReport(int eventId) { cseBus = new ContentSendEventBUS(); DataTable tblContent = cseBus.GetReportByEventId(eventId); dlContentSendEvent.DataSource = tblContent; dlContentSendEvent.DataBind(); for (int i = 0; i < tblContent.Rows.Count; i++) { Label lblChart = (Label)dlContentSendEvent.Items[i].FindControl("lblChart"); int totalSend = Convert.ToInt32(tblContent.Rows[i]["TotalSend"] + ""); if (totalSend == 0) lblChart.Text = "Chưa được gửi"; else CreateChart(Convert.ToInt32(tblContent.Rows[i]["TotalSend"] + ""), Convert.ToInt32(tblContent.Rows[i]["TotalErr"] + ""), Convert.ToInt32(tblContent.Rows[i]["TotalOpen"] + ""), Convert.ToInt32(tblContent.Rows[i]["TotalNotOpen"] + ""), Convert.ToInt32(tblContent.Rows[i]["TotalNotRecieve"] + ""), tblContent.Rows[i]["Subject"] + "", lblChart); } }
protected void saveContentSendEvent(int eventId) { try { ContentSendEventBUS cseBus = new ContentSendEventBUS(); DataTable dtContent = (DataTable)Session["listContentSendEvent"]; if (dtContent.Rows.Count > 0) { for (int i = 0; i < dtContent.Rows.Count; i++) { DataRow row = dtContent.Rows[i]; ContentSendEventDTO cseDto = new ContentSendEventDTO(); cseDto.Id = int.Parse(row["Id"].ToString()); cseDto.EventId = eventId; cseDto.ContentId = int.Parse(row["ContentId"].ToString()); cseDto.HourSend = int.Parse(row["HourSend"].ToString()); cseDto.Subject = row["Subject"] + ""; cseDto.Body = row["Body"] + ""; int rsUpdate = cseBus.tblContentSendEvent_Update(cseDto); if (rsUpdate <= 0) { cseBus.tblContentSendEvent_insert(cseDto); SendContentDTO scDTO = new SendContentDTO(); scDTO = getContentDTO(); int contentID = new SendContentBUS().tblSendContent_insert(scDTO); } } } } catch (Exception ex) { logs.Error(userLogin.Username + "Create-Event - btnSaveContent_Click", ex); } }
private void LoadEventList() { try { string EventId = Request.QueryString["EventId"] + ""; this.hdfEventId.Value = EventId + ""; int ID = 0; if (EventId != "") { ID = int.Parse(EventId); DataTable dtEvent = eventBus.GetByID(ID); if (dtEvent.Rows.Count > 0) { txtAutoName.Text = dtEvent.Rows[0]["Subject"].ToString(); drlMailConfig.SelectedItem.Value = dtEvent.Rows[0]["ConfigId"].ToString(); drlMailGroup.SelectedValue = dtEvent.Rows[0]["GroupId"].ToString(); txtBody.Text = dtEvent.Rows[0]["Body"].ToString(); if (dtEvent.Rows[0]["ResponeUrl"].Equals("Default")) { chkDefaultPage.Checked = true; txtResponeUrl.Enabled = false; } else { txtResponeUrl.Text = dtEvent.Rows[0]["ResponeUrl"].ToString(); } // Hien thi ConentSendEvent list. ContentSendEventBUS cseBus = new ContentSendEventBUS(); DataTable tblContent = cseBus.GetByEventId(ID); if (tblContent.Rows.Count > 0) { Session["listContentSendEvent"] = tblContent; LoadContentSendEventList(tblContent); } } } } catch (Exception ex) { logs.Error(userLogin.Username + "-Create-Event - LoadEventList", ex); } }
protected void Page_Load(object sender, EventArgs e) { userLogin = getUserLogin(); if (!IsPostBack) { try { InitialBUS(); LoadMailGroupLists(); LoadMailConfigList(); LoadEventList(); LoadSignatureList(); // Khoi tao session for store contentSendEvent ContentSendEventBUS cseBus = new ContentSendEventBUS(); Session["listContentSendEvent"] = cseBus.GetById(0); LoadContentList(); } catch (Exception ex) { logs.Error(userLogin.Username + "-Create-Event - Page_Load", ex); pnError.Visible = true; lblError.Text = ex.Message; } } }
protected void lbtEdit_Click(object sender, EventArgs e) { try { InitialBUS(); visibleMessage(false); int eventId = int.Parse(((LinkButton)sender).CommandArgument.ToString()); DataTable dtEvent = eventBus.GetByID(eventId); if (dtEvent.Rows.Count > 0) { DataRow row = dtEvent.Rows[0]; hdfEventId.Value = row["EventId"].ToString(); txtSubject.Text = row["Subject"].ToString(); drlMailConfig.SelectedValue = row["ConfigId"].ToString(); drlMailGroup.SelectedValue = row["GroupId"].ToString(); txtBody.Text = row["Body"].ToString(); if (row["ResponeUrl"].Equals("Default")) { chkDefaultPage.Checked = true; txtResponeUrl.Enabled = false; } else { txtResponeUrl.Text = row["ResponeUrl"].ToString(); } } // Hien thi ConentSendEvent list. ContentSendEventBUS cseBus = new ContentSendEventBUS(); DataTable tblContent = cseBus.GetByEventId(eventId); if (tblContent.Rows.Count > 0) { Session["listContentSendEvent"] = tblContent; LoadContentSendEventList(tblContent); } } catch (Exception ex) { logs.Error(userLogin.Username + "Create-Event - lbtEdit_Click", ex); pnError.Visible = true; lblError.Text = ex.Message; } }
protected void lbtContentDelete_Click(object sender, EventArgs e) { try { ContentSendEventBUS cseBus = new ContentSendEventBUS(); int contentId = int.Parse(((LinkButton)sender).CommandArgument.ToString()); DataTable dtContent = (DataTable)Session["listContentSendEvent"]; if (dtContent.Rows.Count > 0) { for (int i = 0; i < dtContent.Rows.Count; i++) { DataRow row = dtContent.Rows[i]; if (row["Id"].Equals(contentId)) { dtContent.Rows.Remove(row); // Xóa trong db, nếu có tồn tại. if (hdfEventId.Value != null) { cseBus.tblContentSendEvent_Delete(contentId); } } } } LoadContentSendEventList(dtContent); } catch (Exception ex) { logs.Error(userLogin.Username + "Create-Event - btnSaveContent_Click", ex); } }
protected void btnCreateNew_Click(object sender, EventArgs e) { try { resetForm(); hdfEventId.Value = ""; Response.Redirect(Request.RawUrl); // Set null value for listContentSendEvent session. ContentSendEventBUS cseBus = new ContentSendEventBUS(); Session["listContentSendEvent"] = cseBus.GetById(0); } catch (Exception ex) { logs.Error(userLogin.Username + "Create-Event - btnCreateNew_Click", ex); pnError.Visible = true; lblError.Text = ex.Message; } }
private void event_worker_DoWork(object sender, DoWorkEventArgs e) { try { EmailSend mailSend = new EmailSend(); DetailGroupBUS dgBus = new DetailGroupBUS(); ContentSendEventBUS cseBus = new ContentSendEventBUS(); SendContentBUS scBus = new SendContentBUS(); EventBUS eventBUS = new EventBUS(); DataTable tblSendList = dgBus.getGroupListByEventList(); if (tblSendList.Rows.Count > 0) { List<SendMailDTO> sendList = mailSend.convetToSendMail(tblSendList); int totalCnt = sendList.Count; foreach (SendMailDTO sendItem in sendList) { int eventId = sendItem.eventId; DataTable dtContentSendEvent = cseBus.GetByEventId(eventId); if (dtContentSendEvent.Rows.Count > 0) { if (sendItem.countReceivedMail == 0 && sendItem.lastReceivedMail == "") // Gui lan dau { int id = int.Parse(dtContentSendEvent.Rows[0]["id"].ToString()); int contentId = int.Parse(dtContentSendEvent.Rows[0]["ContentId"].ToString()); int hourSend = int.Parse(dtContentSendEvent.Rows[0]["HourSend"].ToString()); DataTable dtSendContent = scBus.GetByID(contentId); subject = dtContentSendEvent.Rows[0]["Subject"].ToString(); body = dtContentSendEvent.Rows[0]["Body"].ToString(); bool sendRs = false; // Send normal. bool send = sendMail(sendRs, sendItem.port, sendItem.hostName, sendItem.userSmtp, sendItem.passSmtp, sendItem.mailFrom, sendItem.senderName, subject, body, sendItem.recieveName, sendItem.mailTo, 0, id); logs_info.Info("Status: " + send + ", sendRegisterId:" + sendRegisterId + ", MailTo: " + sendItem.mailTo + ", mailFrom: " + mailFrom + ", Name: " + sendItem.recieveName); // Update tblDetailGroup. DetailGroupDTO dgDto = new DetailGroupDTO(); dgDto.CustomerID = sendItem.customerId; dgDto.GroupID = sendItem.groupId; dgDto.CountReceivedMail = sendItem.countReceivedMail + 1; dgDto.LastReceivedMail = DateTime.Now; dgBus.tblDetailGroup_Update(dgDto); eventBUS.tblEventCustomer_Update(eventId, sendItem.customerId, sendItem.countReceivedMail + 1); logHistoryForSendEvent(id, sendItem.mailTo, mailFrom, sendItem.recieveName, send); } else if (sendItem.countReceivedMail < dtContentSendEvent.Rows.Count) { string strReceivedMail = sendItem.lastReceivedMail; DateTime lastReceivedMail = DateTime.Now; if (strReceivedMail != "") { lastReceivedMail = DateTime.Parse(strReceivedMail); } int hourSend = int.Parse(dtContentSendEvent.Rows[sendItem.countReceivedMail]["HourSend"].ToString()); DateTime currentTime = lastReceivedMail.AddHours(hourSend); TimeSpan time = currentTime - DateTime.Now; /*if (DateTime.Now.Year == currentTime.Year && DateTime.Now.Month == currentTime.Month && DateTime.Now.Day == currentTime.Day && DateTime.Now.Hour == currentTime.Hour && DateTime.Now.Minute == currentTime.Minute)*/ if (time.Days < 0 || time.Hours < 0 || time.Minutes < 0 || time.Seconds < 0) { int contentId = int.Parse(dtContentSendEvent.Rows[sendItem.countReceivedMail]["ContentId"].ToString()); //DataTable dtSendContent = scBus.GetByID(contentId); //if (dtSendContent.Rows.Count > 0) //{ // subject = dtSendContent.Rows[0]["Subject"].ToString(); // body = dtSendContent.Rows[0]["Body"].ToString(); //} subject = dtContentSendEvent.Select("hoursend=" + hourSend)[0]["Subject"].ToString(); body = dtContentSendEvent.Select("hoursend=" + hourSend)[0]["Body"].ToString(); int id = Convert.ToInt32(dtContentSendEvent.Select("hoursend=" + hourSend)[0]["id"] + ""); bool sendRs = false; // Send normal. bool send = sendMail(sendRs, sendItem.port, sendItem.hostName, sendItem.userSmtp, sendItem.passSmtp, sendItem.mailFrom, sendItem.senderName, subject, body, sendItem.recieveName, sendItem.mailTo, 0, id); logHistoryForSendEvent(id, sendItem.mailTo, mailFrom, sendItem.recieveName, send); logs_info.Info("Status: " + send + ", sendRegisterId:" + sendRegisterId + ", MailTo: " + sendItem.mailTo + ", mailFrom: " + mailFrom + ", Name: " + sendItem.recieveName); // Update tblDetailGroup. DetailGroupDTO dgDto = new DetailGroupDTO(); dgDto.CustomerID = sendItem.customerId; dgDto.GroupID = sendItem.groupId; dgDto.CountReceivedMail = sendItem.countReceivedMail + 1; dgDto.LastReceivedMail = DateTime.Now; dgBus.tblDetailGroup_Update(dgDto); eventBUS.tblEventCustomer_Update(eventId, sendItem.customerId, sendItem.countReceivedMail + 1); } } } }// End forEach. } } catch (Exception ex) { logs.Error("timer2_tick", ex); } }