private static void GetGuidsFromReport(MailTrigger Trigger) { string folder = "\\AutoMailer\\"; FileSystemEntry fileSystemEntry = new FileSystemEntry(folder, FileSystemEntry.Types.Folder, (string)null); Sessions.Session defaultInstance = Session.DefaultInstance; FSExplorer rptExplorer = new FSExplorer(defaultInstance); ReportMainControl r = new ReportMainControl(defaultInstance, false); ReportIFSExplorer ifsExplorer = new ReportIFSExplorer(r, defaultInstance); FileSystemEntry report = ifsExplorer.GetFileSystemEntries(fileSystemEntry).Where(x => x.Name.Equals(Trigger.ReportFilter)).FirstOrDefault(); ReportSettings reportSettings = Session.DefaultInstance.ReportManager.GetReportSettings(report); LoanReportParameters reportParams1 = new LoanReportParameters(); reportParams1.Fields.AddRange((IEnumerable <ColumnInfo>)reportSettings.Columns); reportParams1.FieldFilters.AddRange((IEnumerable <FieldFilter>)reportSettings.Filters); reportParams1.UseDBField = reportSettings.UseFieldInDB; reportParams1.UseDBFilter = reportSettings.UseFilterFieldInDB; reportParams1.UseExternalOrganization = reportSettings.ForTPO; reportParams1.CustomFilter = CreateLoanCustomFilter(reportSettings); ReportResults results = Session.DefaultInstance.ReportManager.QueryLoansForReport(reportParams1, null); List <string[]> reportResults = ReportResults.Download(results); List <string> guids = results.GetAllResults().Select(x => x.FirstOrDefault()).ToList(); bool fieldsAreGuids = Guid.TryParse(guids.FirstOrDefault(), out Guid _); if (fieldsAreGuids) { SendEmails(Trigger, guids); } }
private static void SendEmails(MailTrigger Trigger, List <string> guids) { foreach (string guid in guids) { MailMessage mail = new MailMessage(); mail.From = new MailAddress(EncompassApplication.CurrentUser.Email, EncompassApplication.CurrentUser.FullName); mail.IsBodyHtml = true; mail.Subject = InsertEncompassValue(Trigger.Subject, guid); mail.Body = InsertEncompassValue(Trigger.Body, guid); foreach (string email in Trigger.To.Split(',')) { mail.To.Add(new MailAddress(InsertEncompassValue(email, guid))); } EncompassHelper.SendEmail(mail); } //Email Owner of Report MailMessage mailMessage = new MailMessage(); mailMessage.From = new MailAddress(EncompassApplication.CurrentUser.Email, EncompassApplication.CurrentUser.FullName); mailMessage.Subject = $"Report for {Trigger.Name}"; mailMessage.Body = $"Loans that were included in the emailed report {string.Join(Environment.NewLine, guids)}"; mailMessage.To.Add(new MailAddress(EncompassApplication.CurrentUser.Email)); EncompassHelper.SendEmail(mailMessage); }
private void CmbTriggers_SelectedIndexChanged(object sender, EventArgs e) { MailTrigger trigger = AutoMailerCDO.CDO.Triggers.Where(x => x.Name.Equals(cmbTriggers.SelectedItem.ToString())).FirstOrDefault(); TriggerName = trigger.Name; txtName.Text = trigger.Name; cmbReports.Text = trigger.ReportFilter; cmbFrequency.Text = trigger.Frequency.ToString(); dtpTime.Value = trigger.Time; chkTriggerActive.Checked = trigger.Active; if (trigger.Date != DateTime.MinValue) { dtpDate.Value = trigger.Date; } for (int day = 0; day < 7; day++) { chkDays.SetItemChecked(day, trigger.Days.Contains(day)); } txtTo.Text = trigger.To; txtCC.Text = trigger.CC; txtBcc.Text = trigger.BCC; txtSubject.Text = trigger.Subject; txtHtml.Text = trigger.Body; lblPreviewCC.Text = trigger.CC; lblPreviewFrom.Text = "*****@*****.**"; lblPreviewFrom2.Text = "*****@*****.**"; lblPreviewSubject.Text = trigger.Subject; lblPreviewSubject2.Text = trigger.Subject; lblPreviewTo.Text = trigger.To; }
private void BtnDuplicate_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(TriggerName)) { MailTrigger trigger = CDO.Triggers.Where(x => x.Name.Equals(TriggerName)).FirstOrDefault(); MailTrigger newTrigger = trigger.Clone(trigger); CDO.Triggers.Add(newTrigger); CustomDataObject.Save <AutoMailerCDO>(AutoMailerCDO.Key, CDO); SetupControls(); } }
private void BtnDelete_Click(object sender, EventArgs e) { bool update = !string.IsNullOrEmpty(TriggerName); if (update) { MailTrigger trigger = CDO.Triggers.Where(x => x.Name.Equals(TriggerName)).FirstOrDefault(); CDO.Triggers.Remove(trigger); CustomDataObject.Save <AutoMailerCDO>(AutoMailerCDO.Key, CDO); SetupControls(); } }
private void BtnDelete_Click(object sender, EventArgs e) { bool update = !string.IsNullOrEmpty(TriggerName); if (update) { AutoMailerCDORoot cdo = AutoMailerCDO.CDO; MailTrigger trigger = cdo.Triggers.Where(x => x.Name.Equals(TriggerName)).FirstOrDefault(); cdo.Triggers.Remove(trigger); AutoMailerCDO.UpdateCDO(cdo); AutoMailerCDO.UploadCDO(); SetupControls(); } }
private void BtnDuplicate_Click(object sender, EventArgs e) { AutoMailerCDORoot cdo = AutoMailerCDO.CDO; if (!string.IsNullOrEmpty(TriggerName)) { MailTrigger trigger = cdo.Triggers.Where(x => x.Name.Equals(TriggerName)).FirstOrDefault(); MailTrigger newTrigger = trigger.Clone(trigger); cdo.Triggers.Add(newTrigger); AutoMailerCDO.UpdateCDO(cdo); AutoMailerCDO.UploadCDO(); SetupControls(); } }
public static JobRoot GetJobRootNotEmpty() { var root = JobRoot.Default; CreateJob(root, "db", DbConnectionRule.Create("db")); CreateJob(root, "http", HttpRequestRule.Create("http")); foreach (Job job in root.GetJobs()) { job .AttachTrigger(MailTrigger.Create()) .SetLogSuccess(true) .SetDebugSettings() ; } return(root); }
private void BtnSave_Click(object sender, EventArgs e) { AutoMailerCDORoot cdo = AutoMailerCDO.CDO; bool update = !string.IsNullOrEmpty(TriggerName); if (cdo.Triggers.Any(x => x.Name.Equals(txtName.Text)) && !update) { MessageBox.Show("There is already a Trigger with this name."); return; } if (string.IsNullOrEmpty(txtName.Text)) { MessageBox.Show("Name cannot be blank."); return; } MailTrigger trigger = update ? cdo.Triggers.Where(x => x.Name.Equals(TriggerName)).FirstOrDefault() : new MailTrigger(); trigger.Name = txtName.Text; trigger.ReportFilter = cmbReports.SelectedItem.ToString(); trigger.Frequency = (FrequencyType)Enum.Parse(typeof(FrequencyType), cmbFrequency.SelectedItem.ToString()); trigger.Time = dtpTime.Value; trigger.Date = dtpDate.Value; trigger.Days = chkDays.CheckedIndices.Cast <int>().ToArray(); trigger.To = txtTo.Text; trigger.CC = txtCC.Text; trigger.BCC = txtBcc.Text; trigger.Subject = txtSubject.Text; trigger.Body = txtHtml.Text; trigger.Active = chkTriggerActive.Checked; if (!update) { cdo.Triggers.Add(trigger); } AutoMailerCDO.UpdateCDO(cdo); AutoMailerCDO.UploadCDO(); SetupControls(); }
public static void Run(MailTrigger Trigger) { GetGuidsFromReport(Trigger); }