public static fApptNotification Instance(FileManager FM, DataTable dt) { if (_instance == null) { _instance = new fApptNotification(FM, dt); } return(_instance); }
public void EnableReminders() { try { DateTime currentDate = DateTime.Now; int dueInMinutes; notificationDT = new DataTable("AppointmentNotification"); notificationDT.Columns.Add("AttendeeId", typeof(int)); notificationDT.Columns.Add("Subject", typeof(string)); notificationDT.Columns.Add("DueIn", typeof(string)); notificationDT.Columns.Add("StartDateLocal", typeof(DateTime)); notificationDT.Columns.Add("Interval", typeof(int)); //foreach (atriumDB.AttendeeRow attrow in myFMCal.DB.Attendee.Rows) atriumDB.AttendeeRow[] attrs = (atriumDB.AttendeeRow[])myFMCal.DB.Attendee.Select("ContactId=" + myOfficerId.ToString()); foreach (atriumDB.AttendeeRow attrow in attrs) { if (!attrow.IsIntervalNull() && !attrow.IsNotificationDismissNull()) { atriumDB.AppointmentRow appr = attrow.AppointmentRow; if (appr != null && appr.RowState != DataRowState.Deleted) { dueInMinutes = appr.StartDateLocal.Subtract(DateTime.Now).Minutes; if (attrow.Interval > 0 && dueInMinutes <= attrow.Interval) { if (!attrow.NotificationDismiss) { string sDueIn = GetStringDueIn(dueInMinutes, appr.StartDateLocal.Subtract(DateTime.Now)); notificationDT.Rows.Add(attrow.AttendeeId, appr.Subject, sDueIn, appr.StartDateLocal, attrow.Interval); notificationDT.AcceptChanges(); } } } } } if (notificationDT.Rows.Count > 0) { // if (fApp == null ) if (!VerifyOpenForm("fApptNotification")) { fApp = new fApptNotification(myFMCal, notificationDT); fApp.Show(); fApp.WindowState = FormWindowState.Normal; } else { fApp.Datasource = notificationDT; fApp.Refresh(); } } } catch (Exception x) { UIHelper.HandleUIException(x); } }