/// <summary> /// Binds the deliveries table to the UltraCalendarInfo, and keep a table to map appointments to the part number. /// </summary> /// <param name="info">The info.</param> /// <param name="bindingContext">The binding context.</param> internal void BindDeliveries(UltraCalendarInfo info, Control bindingContext) { // setup the Appointment bindings info.DataBindingsForAppointments.BindingContextControl = bindingContext; info.DataBindingsForAppointments.SubjectMember = "Subject"; info.DataBindingsForAppointments.DescriptionMember = "Description"; info.DataBindingsForAppointments.StartDateTimeMember = "StartDateTime"; info.DataBindingsForAppointments.EndDateTimeMember = "EndDateTime"; info.DataBindingsForAppointments.AllDayEventMember = "AllDayEvent"; info.DataBindingsForAppointments.DataKeyMember = "DataKey"; info.DataBindingsForAppointments.SetDataBinding(this.data.Tables["Deliveries"], string.Empty); if (this.appointmentTable == null) { this.appointmentTable = new Dictionary <string, Appointment>(); } else { this.appointmentTable.Clear(); } // create table foreach (Appointment app in info.Appointments) { app.BarColor = Color.Transparent; this.appointmentTable[(string)app.DataKey] = app; } }
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); } }