/// <summary> /// To fetch details from database /// </summary> /// <param name="EMAILTEMPLATECODE"></param> /// <returns></returns> public EmailTemplateBO GetEmailDetailsForOverDue(string EMAILTEMPLATECODE) { OracleConnection cnn = new OracleConnection(AppConfiguration.ConnectionString); OracleCommand cmd; string proc = "USP_GET_EMAILDETAILSFORDUE"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("EMAILTEMPLATECODE_", EMAILTEMPLATECODE); cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output; cmd.Connection.Open(); OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); EmailTemplateBO EmailTemplateBOobj = null; while (dr.Read()) { EmailTemplateBOobj = new EmailTemplateBO(); if (!dr.IsDBNull(dr.GetOrdinal("EMAILSUBJECT"))) { EmailTemplateBOobj.EmailSubject = (dr.GetString(dr.GetOrdinal("EMAILSUBJECT"))); } if (!dr.IsDBNull(dr.GetOrdinal("EMAILBODY"))) { EmailTemplateBOobj.EmailBody = (dr.GetString(dr.GetOrdinal("EMAILBODY"))); } } dr.Close(); return(EmailTemplateBOobj); }
public static ObservableCollection <EmailTemplateBO> GetAllEmailTemplates() { ObservableCollection <EmailTemplateBO> ets = new ObservableCollection <EmailTemplateBO>(); var emailTemplates = new List <EmailTemplate>(); using (ElibriumEntities db = new ElibriumEntities()) { if (db.Client.Count() > 0) { emailTemplates = db.EmailTemplate.ToList(); foreach (var et in emailTemplates) { EmailTemplateBO clt = new EmailTemplateBO(et); ets.Add(clt); } } } return(ets); }
/// <summary> /// To fetch details from database /// </summary> /// <returns></returns> public EmailTemplateList GetAllOverdueApprovals() { OracleConnection cnn = new OracleConnection(AppConfiguration.ConnectionString); OracleCommand cmd; string proc = "USP_NOTIF_OVERDUE_APPROVAL"; cmd = new OracleCommand(proc, cnn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("Sp_recordset", OracleDbType.RefCursor).Direction = ParameterDirection.Output; cmd.Connection.Open(); OracleDataReader dr = cmd.ExecuteReader(CommandBehavior.CloseConnection); EmailTemplateBO EmailTemplateBOobj = null; EmailTemplateList EmailTemplateListobj = new EmailTemplateList(); while (dr.Read()) { EmailTemplateBOobj = new EmailTemplateBO(); if (!dr.IsDBNull(dr.GetOrdinal("DESCRIPTION"))) { EmailTemplateBOobj.Description = (dr.GetString(dr.GetOrdinal("DESCRIPTION"))); } if (!dr.IsDBNull(dr.GetOrdinal("WORKFLOWCODE"))) { EmailTemplateBOobj.Workflowcode = (dr.GetString(dr.GetOrdinal("WORKFLOWCODE"))); } if (!dr.IsDBNull(dr.GetOrdinal("EMAILID"))) { EmailTemplateBOobj.EmailID = (dr.GetString(dr.GetOrdinal("EMAILID"))); } if (!dr.IsDBNull(dr.GetOrdinal("cellnumber"))) { EmailTemplateBOobj.Cellnumber = (dr.GetString(dr.GetOrdinal("cellnumber"))); } if (!dr.IsDBNull(dr.GetOrdinal("triggertype"))) { EmailTemplateBOobj.Triggertype = (dr.GetString(dr.GetOrdinal("triggertype"))); } if (!dr.IsDBNull(dr.GetOrdinal("DISPLAYNAME"))) { EmailTemplateBOobj.ApproverUserName = (dr.GetString(dr.GetOrdinal("DISPLAYNAME"))); } if (!dr.IsDBNull(dr.GetOrdinal("PROJECTCODE"))) { EmailTemplateBOobj.ProjectCode = (dr.GetString(dr.GetOrdinal("PROJECTCODE"))); } if (!dr.IsDBNull(dr.GetOrdinal("PROJECTNAME"))) { EmailTemplateBOobj.ProjectName = (dr.GetString(dr.GetOrdinal("PROJECTNAME"))); } if (!dr.IsDBNull(dr.GetOrdinal("REQUESTDATE"))) { EmailTemplateBOobj.Requestdate = Convert.ToString(dr.GetValue(dr.GetOrdinal("REQUESTDATE"))); } if (!dr.IsDBNull(dr.GetOrdinal("DUEDATE"))) { EmailTemplateBOobj.Duedate = Convert.ToString(dr.GetValue(dr.GetOrdinal("DUEDATE"))); } EmailTemplateListobj.Add(EmailTemplateBOobj); } dr.Close(); return(EmailTemplateListobj); }
static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); //Application.Run(new Form1()); EmailTemplateBLL EmailTemplateBLLobj = new EmailTemplateBLL(); EmailTemplateList EmailTemplateListObj = EmailTemplateBLLobj.GetAllOverdueApprovals(); int a = 0; if (EmailTemplateBLLobj != null) { for (int i = 0; i < EmailTemplateListObj.Count; i++) { try { string fileLoc = ConfigurationManager.AppSettings["ERROS_PATH"].ToString(); FileStream fs = null; if (!File.Exists(fileLoc)) { using (fs = File.Create(fileLoc)) { } } MailMessage mailMessage = new MailMessage(); SmtpClient smtp = new SmtpClient(); if (EmailTemplateListObj[i].Triggertype.ToUpper() == "SMS" || EmailTemplateListObj[i].Triggertype.ToUpper() == "BOTH") { EmailTemplateBO EmailTemplateBOobj = EmailTemplateBLLobj.GetSMSDetailsForOverDue(EmailTemplateListObj[i].Workflowcode); if (EmailTemplateBOobj != null) { WIS_ConfigBO WIS_ConfigBO = EmailTemplateBLLobj.GetSMSSenderDataForOverDue(); ReddyInfoSoft ris = new ReddyInfoSoft(); ris.sendSMS(WIS_ConfigBO.MobileNumber, WIS_ConfigBO.MobilePassword, EmailTemplateBOobj.Smstext, EmailTemplateListObj[i].Cellnumber, WIS_ConfigBO.SiteUrl, "1"); } else { // for get errors using (StreamWriter sw = new StreamWriter(fileLoc, true)) { if (a == 0) { sw.WriteLine("[" + DateTime.Now.ToString() + "]" + Environment.NewLine); a++; } sw.WriteLine(i + 1 + ") " + EmailTemplateListObj[i].Workflowcode.ToString() + " Does not contain SMS Text." + Environment.NewLine); //sw.WriteLine(Environment.NewLine + "-------------------------------------------------------" + Environment.NewLine); } //end } } if (EmailTemplateListObj[i].Triggertype.ToUpper() != "SMS") { string mailBody = ""; mailMessage.To.Add(EmailTemplateListObj[i].EmailID); mailMessage.From = new MailAddress(ConfigurationManager.AppSettings["MAIL_FROM"].ToString()); EmailTemplateBO EmailTemplateBOobj = EmailTemplateBLLobj.GetEmailDetailsForOverDue(EmailTemplateListObj[i].Workflowcode); if (EmailTemplateBOobj != null) { mailMessage.Subject = EmailTemplateBOobj.EmailSubject; mailMessage.Body = "Dear Sir, <br/><br/> " + EmailTemplateBOobj.EmailBody + " <br/><br/> ProjectCode : " + EmailTemplateListObj[i].ProjectCode + "<br/> ProjectName : " + EmailTemplateListObj[i].ProjectName + "<br/>" + "<br/> Requested Date : " + EmailTemplateListObj[i].Requestdate + "<br/>" + "<br/> Due Date : " + EmailTemplateListObj[i].Duedate + "<br/><br/>" + "Thanks and Regards, <br/> WIS - UETCL Team"; mailMessage.IsBodyHtml = true; smtp.Send(mailMessage); } else { // for get errors using (StreamWriter sw = new StreamWriter(fileLoc, true)) { if (a == 0) { sw.WriteLine("[" + DateTime.Now.ToString() + "]" + Environment.NewLine); a++; } sw.WriteLine(i + 1 + ") " + EmailTemplateListObj[i].Workflowcode.ToString() + " Does not contain Subject and Body." + Environment.NewLine); //sw.WriteLine(Environment.NewLine + "-------------------------------------------------------" + Environment.NewLine); } //end } } } catch (Exception ex) { // for get errors string fileLoc = ConfigurationManager.AppSettings["ERROS_PATH"].ToString(); FileStream fs = null; if (!File.Exists(fileLoc)) { using (fs = File.Create(fileLoc)) { } } using (StreamWriter sw = new StreamWriter(fileLoc, true)) { if (a == 0) { sw.WriteLine("[" + DateTime.Now.ToString() + "]" + Environment.NewLine); a++; } sw.WriteLine(i + 1 + ") " + EmailTemplateListObj[i].Workflowcode.ToString() + "-" + ex.ToString()); //sw.WriteLine(Environment.NewLine + "-------------------------------------------------------" + Environment.NewLine); } //end } } } }