private void DoSurveyReminderByStaff(int selectedID, string SelectedUsername, string surveyType) { List<AttendedEvent> unsubmittedEvents = new List<AttendedEvent>(); if (surveyType == "PTA") { unsubmittedEvents = AttendedEvent.GetUnsubmitted(surveyType, selectedID); } else { unsubmittedEvents = AttendedEvent.GetUnsubmitted(surveyType, SelectedUsername); } EventDate ed = EventDate.GetById(selectedID); TrainingEvent ev = TrainingEvent.GetById(ed.EventId); foreach (AttendedEvent ae in unsubmittedEvents) { Staff staff = new Staff(); Staff supervisor = new Staff(); if (surveyType == "PTA") { staff = Staff.GetFromUsername(ae.StaffUsername); } else { staff = Staff.GetFromUsername(SelectedUsername); } if (staff == null) continue; if (surveyType == "PTA") { supervisor = Staff.GetFromUsername(SelectedUsername); } else { supervisor = staff.GetSupervisor(); } if (supervisor == null) continue; Dictionary<string, string> replacements = new Dictionary<string, string>(); replacements["Name"] = staff.Name; replacements["SupervisorName"] = supervisor.Name; replacements["EventName"] = ev.Title; replacements["StartDate"] = ed.StartDate.ToString("dd/MM/yyyy"); replacements["EndDate"] = ed.EndDate.ToString("dd/MM/yyyy"); replacements["CurrentDate"] = DateTime.Now.ToString("dd/MM/yyyy"); replacements["EventID"] = ev.SAPId.ToString(); string emailTemplateFile = System.IO.Path.Combine(EmailTemplateFolder, "Invite" + surveyType + ".htm"); emailTemplateFile = Server.MapPath(emailTemplateFile); if (surveyType == "PTA") UtilityEmail.Send(supervisor.Email, staff.Email, "Your Post-Training Assessment is Required", emailTemplateFile, replacements); else UtilityEmail.Send(staff.Email, supervisor.Email, "Your Course Evaluation is Required", emailTemplateFile, replacements); } string sScript0 = "window.alert('Email Notification has been sent to selected staff.')"; ScriptManager.RegisterClientScriptBlock(Page, GetType(), "SaveDraft_Script_20", sScript0, true); return; }