/// <summary> /// Retrieves Get Total Rows of EmailHistory /// </summary> /// <returns>Int32 type object</returns> public Int32 GetRowCount() { using (EmailHistoryDataAccess data = new EmailHistoryDataAccess(ClientContext)) { return(data.GetRowCount()); } }
/// <summary> /// Retrieve list of EmailHistory by query String. /// <param name="query"></param> /// </summary> /// <returns>List of EmailHistory</returns> public EmailHistoryList GetByQuery(String query) { using (EmailHistoryDataAccess data = new EmailHistoryDataAccess(ClientContext)) { return(data.GetByQuery(query)); } }
/// <summary> /// Retrieve list of EmailHistory by PageRequest. /// <param name="request"></param> /// </summary> /// <returns>List of EmailHistory</returns> public EmailHistoryList GetPaged(PagedRequest request) { using (EmailHistoryDataAccess data = new EmailHistoryDataAccess(ClientContext)) { return(data.GetPaged(request)); } }
/// <summary> /// Retrieve list of EmailHistory. /// no parameters required to be passed in. /// </summary> /// <returns>List of EmailHistory</returns> public EmailHistoryList GetAll() { using (EmailHistoryDataAccess data = new EmailHistoryDataAccess(ClientContext)) { return(data.GetAll()); } }
/// <summary> /// Retrieve EmailHistory data using unique ID /// </summary> /// <param name="_Id"></param> /// <returns>EmailHistory Object</returns> public EmailHistory Get(Int32 _Id) { using (EmailHistoryDataAccess data = new EmailHistoryDataAccess(ClientContext)) { return(data.Get(_Id)); } }
/// <summary> /// Delete operation for EmailHistory /// <param name="_Id"></param> /// <returns></returns> private bool Delete(Int32 _Id) { using (EmailHistoryDataAccess data = new EmailHistoryDataAccess(ClientContext)) { // return if code > 0 return(data.Delete(_Id) > 0); } }
public MailFacade(ClientContext clientContext) : base(clientContext) { if (_EmailTemplateDataAccess == null) { _EmailTemplateDataAccess = (EmailTemplateDataAccess)_ClientContext[typeof(EmailTemplateDataAccess)]; } if (_EmailHistoryDataAccess == null) { _EmailHistoryDataAccess = (EmailHistoryDataAccess)_ClientContext[typeof(EmailHistoryDataAccess)]; } }
/// <summary> /// Retrieve list of EmailHistory. /// </summary> /// <param name="fillChild"></param> /// <returns>List of EmailHistory</returns> public EmailHistoryList GetAll(bool fillChild) { EmailHistoryList emailHistoryList = new EmailHistoryList(); using (EmailHistoryDataAccess data = new EmailHistoryDataAccess(ClientContext)) { emailHistoryList = data.GetAll(); } if (fillChild) { foreach (EmailHistory emailHistoryObject in emailHistoryList) { FillEmailHistoryWithChilds(emailHistoryObject, fillChild); } } return(emailHistoryList); }
/// <summary> /// Update base of EmailHistory Object. /// Data manipulation processing for: new, deleted, updated EmailHistory /// </summary> /// <param name="emailHistoryObject"></param> /// <returns></returns> public bool UpdateBase(EmailHistory emailHistoryObject) { // use of switch for different types of DML switch (emailHistoryObject.RowState) { // insert new rows case BaseBusinessEntity.RowStateEnum.NewRow: return(Insert(emailHistoryObject)); // delete rows case BaseBusinessEntity.RowStateEnum.DeletedRow: return(Delete(emailHistoryObject.Id)); } // update rows using (EmailHistoryDataAccess data = new EmailHistoryDataAccess(ClientContext)) { return(data.Update(emailHistoryObject) > 0); } }
/// <summary> /// Insert new emailHistory. /// data manipulation for insertion of EmailHistory /// </summary> /// <param name="emailHistoryObject"></param> /// <returns></returns> private bool Insert(EmailHistory emailHistoryObject) { // new emailHistory using (EmailHistoryDataAccess data = new EmailHistoryDataAccess(ClientContext)) { // insert to emailHistoryObject Int32 _Id = data.Insert(emailHistoryObject); // if successful, process if (_Id > 0) { emailHistoryObject.Id = _Id; return(true); } else { return(false); } } }
private bool SentEmailRemainder(Hashtable TemplateValue, string TemplateKey, List <Attachment> Attachments) { EmailTemplateDataAccess maildata = new EmailTemplateDataAccess(); EmailHistoryDataAccess mailhistory = new EmailHistoryDataAccess(); EmailTemplate emailTemplate = maildata.GetByQuery("TemplateKey='" + TemplateKey + "'").FirstOrDefault(); EmailParser parser = null; string toEmailAddress = ""; if (emailTemplate == null || emailTemplate.Id == 0) { //Elmah.ErrorSignal.FromCurrentContext().Raise(new Exception("Template not found for key :" + TemplateKey)); return(false); } if (!string.IsNullOrWhiteSpace(emailTemplate.BodyFile)) { string FilePath = emailTemplate.BodyFile; FilePath = System.Web.Hosting.HostingEnvironment.MapPath(FilePath); parser = new EmailParser(FilePath, TemplateValue, true); //parser = new EmailParser(HttpContext.Current.Server.MapPath(emailTemplate.BodyFile), TemplateValue, true); } else if (!string.IsNullOrWhiteSpace(emailTemplate.BodyContent)) { parser = new EmailParser(emailTemplate.BodyContent, TemplateValue, false); } MailMessage message = new MailMessage(); message.Body = parser.Parse(); if (emailTemplate.ToEmail.IndexOf("##") > -1) { EmailParser ToEmailParser = new EmailParser(emailTemplate.ToEmail, TemplateValue, false); message.To.Add(new MailAddress(ToEmailParser.Parse())); toEmailAddress = message.To[0].ToString(); } else { message.To.Add(emailTemplate.ToEmail); toEmailAddress = message.To[0].ToString(); } if (emailTemplate.ReplyEmail.IndexOf("##") > -1) { EmailParser ToEmailParser = new EmailParser(emailTemplate.ReplyEmail, TemplateValue, false); message.ReplyTo = new MailAddress(ToEmailParser.Parse()); toEmailAddress = message.To[0].ToString(); } else { message.ReplyTo = new MailAddress(emailTemplate.ReplyEmail); } if (emailTemplate.FromEmail.IndexOf("##") > -1) { EmailParser ToEmailParser = new EmailParser(emailTemplate.FromEmail, TemplateValue, false); message.From = new MailAddress(ToEmailParser.Parse()); } else { message.From = new MailAddress(emailTemplate.FromEmail); } if (!string.IsNullOrWhiteSpace(emailTemplate.BccEmail)) { message.Bcc.Add(emailTemplate.BccEmail); } if (!string.IsNullOrWhiteSpace(emailTemplate.CcEmail)) { message.CC.Add(emailTemplate.CcEmail); } if (emailTemplate.Subject.IndexOf("##") > -1) { EmailParser SubjectParser = new EmailParser(emailTemplate.Subject, TemplateValue, false); message.Subject = SubjectParser.Parse(); } else { message.Subject = emailTemplate.Subject; } if (Attachments != null) { if (Attachments.Count > 0) { foreach (var attachment in Attachments) { message.Attachments.Add(attachment); } } } message.IsBodyHtml = true; message.BodyEncoding = System.Text.Encoding.UTF8; try { //if (HttpContext.Current!=null && HttpContext.Current.Request.IsLocal) //{ //SmtpClient client = new SmtpClient(); //client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "piiscenter.com"); //client.EnableSsl = false; //client.Send(message); //} SmtpClient smtp = new SmtpClient { Host = "smtp.gmail.com", //change the port to prt 587. This seems to be the standard for Google smtp transmissions. Port = 587, //enable SSL to be true, otherwise it will get kicked back by the Google server. EnableSsl = true, //The following properties need set as well DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, Credentials = new NetworkCredential("*****@*****.**", "Inf0rmrcl@ud") }; smtp.Send(message); EmailHistory emailHistory = new EmailHistory(); emailHistory.TemplateKey = TemplateKey; emailHistory.ToEmail = toEmailAddress; emailHistory.CcEmail = message.CC.ToString(); emailHistory.BccEmail = message.Bcc.ToString(); emailHistory.FromEmail = message.From.ToString(); emailHistory.EmailBodyContent = message.Body; emailHistory.EmailSubject = message.Subject; emailHistory.EmailSentDate = DateTime.Now; emailHistory.LastUpdatedDate = DateTime.Now; mailhistory.Insert(emailHistory); return(true); } catch (Exception ex) { EmailHistory emailHistory = new EmailHistory(); emailHistory.TemplateKey = TemplateKey; emailHistory.ToEmail = toEmailAddress; emailHistory.CcEmail = message.CC.ToString(); emailHistory.BccEmail = message.Bcc.ToString(); emailHistory.FromEmail = message.From.ToString(); emailHistory.EmailBodyContent = message.Body; emailHistory.EmailSubject = message.Subject; emailHistory.LastUpdatedDate = DateTime.Now; mailhistory.Insert(emailHistory); //Logger.AddElmah(ex); } return(false); }