private void LoadDataForListCHKMailFile() { try { var listMailFile = BLLMailFile.GetAll();// mailFileDAO.GetListSelectItem(); if (listMailFile != null && listMailFile.Count > 0) { foreach (var item in listMailFile) { this.listchkFileAttack.Items.Add(new DevExpress.XtraEditors.Controls.CheckedListBoxItem(item.Id, item.Name)); } } } catch (Exception ex) { throw ex; } }
private void SendMails(int mailTemplateId) { try { // GhiFileLog(DateTime.Now + "SendMails "); error = string.Empty; var mailTemplateInfo = BLLMailTemplate.GetById(mailTemplateId); //mailTemplateFileDAO.GetIrnfoById(mailTemplateId); if (mailTemplateInfo != null) { var mSend = BLLMailSend.GetById(mailTemplateInfo.MailSendId); if (mSend != null) { strType = mSend.MailTypeName; strHost = mSend.Host.Trim(); intPort = int.Parse(mSend.Port); strFrom = mSend.Address; strDisplayName = mSend.Note; strPassword = mSend.PassWord; strSubject = mailTemplateInfo.Subject; strBody = mailTemplateInfo.Content; strTo = string.Empty; if (!string.IsNullOrEmpty(mailTemplateInfo.MailReceiveIds)) { var mRecives = BLLMailReceive.GetAll(mailTemplateInfo.MailReceiveIds.Split('|').Select(x => Convert.ToInt32(x)).ToList()); if (mRecives != null && mRecives.Count > 0) { foreach (var email in mRecives) { strTo += (strTo.Length == 0 ? email.Address : ", " + email.Address); } } if (!string.IsNullOrEmpty(mailTemplateInfo.MailFileIds)) { var mFiles = BLLMailFile.GetAll(mailTemplateInfo.MailFileIds.Split('|').Select(x => Convert.ToInt32(x)).ToList()); if (mFiles != null && mFiles.Count > 0) { if (listFileAttactment == null) { listFileAttactment = new List <string>(); } DateTime dtTo = DateTime.Now; foreach (var file in mFiles) { string path = Application.StartupPath + @file.Path; string tieuDe = file.Name; string fileName = file.Code.Trim() + dtTo.ToString("dd_MM_yyyy_hh_mm") + ".xlsx"; List <string> files; switch (file.SystemName.Trim().ToUpper()) { case eFile.NSCHUYEN: listFileAttactment.AddRange(LoadDataNSChuyenExportToExcel(tieuDe, path, fileName)); break; case eFile.NSCCUM: listFileAttactment.AddRange(LoadDataNSCum(tieuDe, path, fileName)); break; case eFile.NS_CHUYEN_THEO_GIO_MrTri: listFileAttactment.AddRange(LoadNS_Chuyen_Theo_Gio(tieuDe, path, fileName, (int)eReportType.MrTri)); break; case eFile.NS_CHUYEN_THEO_GIO_MDG: listFileAttactment.AddRange(LoadNS_Chuyen_Theo_Gio(tieuDe, path, fileName, (int)eReportType.MDG)); break; case eFile.NS_CHUYEN_THEO_GIO_THIENSON: files = LoadNS_Chuyen_Theo_Gio(tieuDe, path, fileName, (int)eReportType.ThienSon); listFileAttactment.AddRange(files); break; case eFile.NS_CHUYEN_THEO_GIO_SONHA: files = LoadNS_Chuyen_Theo_Gio(tieuDe, path, fileName, (int)eReportType.SonHa); listFileAttactment.AddRange(files); break; case eFile.NSCHUYEN_HOANGGIA: // MessageBox.Show("eFile.NSCHUYEN_HOANGGIA"); files = LoadNS_Chuyen_Theo_Gio(tieuDe, path, fileName, (int)eReportType.HoangGia); listFileAttactment.AddRange(files); break; case eFile.Chart_KCSInHour: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, false, true, true, (int)eGetType.KCS)); break; case eFile.Chart_TCInHour: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, false, false, true, (int)eGetType.TC)); break; case eFile.Chart_ERRORInHour: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, true, false, true, (int)eGetType.Error)); break; case eFile.Chart_KCSInDay: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, false, true, false, (int)eGetType.KCS)); break; case eFile.Chart_TCInDay: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, false, false, false, (int)eGetType.TC)); break; case eFile.Chart_ERRORInDay: listFileAttactment.AddRange(GetChart(tieuDe, path, fileName, true, true, false, (int)eGetType.Error)); break; } } } } isSendMail = true; } else { error = "Lỗi: Không có địa chỉ nhận mail."; } } else { error = "Lỗi: Không tìm thấy thông tin mail gửi."; } } else { error = "Lỗi: Không tìm thấy cấu hình mail."; } if (!string.IsNullOrEmpty(error)) { MessageBox.Show(error); } } catch (Exception ex) { } }