private void CheckTasks() { UltraCalendarInfo ultraCalendarInfo = new UltraCalendarInfo(); ultraCalendarInfo.AllowRecurringAppointments = true; TaskSchedulesDAO lTaskSchedulesDAO = new TaskSchedulesDAO(); SettingsDAO lSettingsDAO = new SettingsDAO(); Appointment appointment; object rawAppointmentData; try { foreach (DataRow row in lTaskSchedulesDAO.GetAllAppointments().Rows) { rawAppointmentData = row["_APPOINTMENTDATA"]; if (rawAppointmentData is byte[] == false) { continue; } appointment = Appointment.FromBytes(rawAppointmentData as byte[]); appointment.DataKey = row[0]; ultraCalendarInfo.Appointments.Add(appointment); } string strLastReportRunTime = lSettingsDAO.GetSetting("LastTaskReportRun", false); DateTime lLastReportRunDateTime = (strLastReportRunTime == "") ? DateTime.MinValue : Convert.ToDateTime(strLastReportRunTime); DateTime lReportRunTime = DateTime.Now; AppointmentsSubsetCollection expiredAppointments = ultraCalendarInfo.GetAppointmentsInRange(lLastReportRunDateTime, lReportRunTime); lSettingsDAO.SetSetting("LastTaskReportRun", DateTime.Now.ToString(), false); foreach (Appointment expiredAppointment in expiredAppointments) { // need to re-check that this appointment is between the LastTaskReportRun date and DateTime.Now // there is a hole in the ultraCalendarInfo.GetAppointmentsInRange logic above if ((lLastReportRunDateTime < expiredAppointment.StartDateTime) && (lReportRunTime > expiredAppointment.StartDateTime)) { string lSubject = String.Format("The following task is due at {0}." + Environment.NewLine + Environment.NewLine + expiredAppointment.Subject, expiredAppointment.StartDateTime.ToString()); DesktopAlert.ShowDesktopAlertForTasks(lSubject, (int)expiredAppointment.DataKey); NewsFeed.AddNewsItem(NewsFeed.Priority.Information, "Task due: " + expiredAppointment.Subject); } } } catch (Exception ex) { logger.Error(ex.Message); } }