public void SendPasswordToUser() { // use Assignment Manager sysadmin email UserM amsaUser = UserM.Load(Constants.ASSIGNMENTMANAGER_SYSTEM_ADMIN_USERID); string sentByEmail = amsaUser.EmailAddress; string emailSubject = SharedSupport.GetLocalizedString("User_EmailSubject"); string[] replacements = new string[2] { this._username, this._password }; string emailBody = SharedSupport.GetLocalizedString("User_EmailBody", replacements); MessageM.SendMessage(sentByEmail, this._emailAddress, emailSubject, emailBody); }
public void SendNotifications(object sender, System.Timers.ElapsedEventArgs args) { // disable the timer timer.Enabled = false; try { // use Assignment Manager sysadmin email UserM amsaUser = UserM.Load(Constants.ASSIGNMENTMANAGER_SYSTEM_ADMIN_USERID); string sentByEmail = amsaUser.EmailAddress; System.Data.DataSet dsAssignmentList = new System.Data.DataSet(); DatabaseCall dbc = new DatabaseCall("Notifications_GetAssignmentList", DBCallType.Select); dbc.Fill(dsAssignmentList); if (dsAssignmentList.Tables[0].Rows.Count <= 0) { return; } for (int j = 0; j < dsAssignmentList.Tables[0].Rows.Count; j++) { int assignmentID = Convert.ToInt32(dsAssignmentList.Tables[0].Rows[j]["AssignmentID"]); // send the notifications try { ////////////////////////////////////////////////////////////////////// /// Past Due Notifications ////////////////////////////////////////////////////////////////////// System.Data.DataSet ds = new System.Data.DataSet(); dbc = new DatabaseCall("Notifications_BrowsePastDueNotifications", DBCallType.Select); dbc.AddParameter("AssignmentID", assignmentID); dbc.Fill(ds); if (ds.Tables[0].Rows.Count <= 0) { continue; } for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { if (ds.Tables[0].Rows[i]["AssignmentID"] != DBNull.Value) { string assignName = ds.Tables[0].Rows[i]["ShortName"].ToString(); DateTime dueDate = Convert.ToDateTime(ds.Tables[0].Rows[i]["DueDate"]); string[] AssignmentInfo = new string[] { assignName, string.Format("{0:d}", dueDate) }; string pastDueSubject = SharedSupport.GetLocalizedString("Notification_PastDueSubject", AssignmentInfo); string pastDueBody = SharedSupport.GetLocalizedString("Notification_PastDueBody", AssignmentInfo); string reminderSubject = SharedSupport.GetLocalizedString("Notification_ReminderSubject", AssignmentInfo); string reminderBody = SharedSupport.GetLocalizedString("Notification_ReminderBody", AssignmentInfo); TimeSpan difference = dueDate - DateTime.Today; if (Convert.ToBoolean(ds.Tables[0].Rows[i]["SendPastDue"]) && (difference.Days == -1 * Convert.ToInt32(ds.Tables[0].Rows[i]["PastDueWarningDays"]))) { UserM user = UserM.Load(Convert.ToInt32(ds.Tables[0].Rows[i]["UserID"])); MessageM.SendMessage(sentByEmail, user.EmailAddress, pastDueSubject, pastDueBody); } if (Convert.ToBoolean(ds.Tables[0].Rows[i]["SendReminders"]) && (difference.Days == Convert.ToInt32(ds.Tables[0].Rows[i]["ReminderWarningDays"]))) { UserM user = UserM.Load(Convert.ToInt32(ds.Tables[0].Rows[i]["UserID"])); MessageM.SendMessage(sentByEmail, user.EmailAddress, reminderSubject, reminderBody); } } } } catch (System.Exception ex) { SharedSupport.HandleError(ex); } } } catch (System.Exception ex) { SharedSupport.HandleError(ex); } finally { // reset the interval for the next event timer.Interval = millisecondsToMidnight(); // re-enable the timer timer.Enabled = true; } }