コード例 #1
0
ファイル: NewsFeedWidget.cs プロジェクト: windygu/AW-master
        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);
            }
        }
コード例 #2
0
        static void _desktopAlert_DesktopAlertLinkClicked(object sender, DesktopAlertLinkClickedEventArgs e)
        {
            DataTable lDataTable = new TaskSchedulesDAO().GetAppointmentById((int)e.WindowInfo.Data);

            object rawAppointmentData = lDataTable.Rows[0][1];

            if (rawAppointmentData is byte[] == false)
            {
                return;
            }

            byte[]      appointmentBytes = rawAppointmentData as byte[];
            Appointment appointment      = Appointment.FromBytes(appointmentBytes);

            MessageBox.Show(
                appointment.StartDateTime.AddMinutes(1).ToString() + Environment.NewLine + Environment.NewLine + appointment.Description,
                appointment.Subject,
                MessageBoxButtons.OK,
                MessageBoxIcon.Information);
        }
コード例 #3
0
 public FormTasks()
 {
     InitializeComponent();
     lTaskSchedulesDAO = new TaskSchedulesDAO();
 }