Exemplo n.º 1
0
        private void PopulateGrid()
        {
            DataTable lApptTable = new ReportSchedulesDAO().GetAllAppointments();

            DataTable lResultsDataTable = new DataTable();

            lResultsDataTable.Columns.Add("ReportID", typeof(int));
            lResultsDataTable.Columns.Add("Report Category", typeof(string));
            lResultsDataTable.Columns.Add("Report Name", typeof(string));
            lResultsDataTable.Columns.Add("Schedule", typeof(string));

            foreach (DataRow row in lApptTable.Rows)
            {
                object rawAppointmentData = row["_APPOINTMENTDATA"];

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

                byte[] appointmentBytes = rawAppointmentData as byte[];

                //	Create an Appointment from the byte array, using the
                //	Appointment's static 'FromBytes' method.
                Appointment appointment = Appointment.FromBytes(appointmentBytes);

                string lRecurrenceDescription = (appointment.Recurrence == null) ? "" : appointment.Recurrence.Description;
                string lReportCategory        = "";
                string lReportName            = appointment.Subject;

                if (appointment.Subject.Split('|').Length == 2)
                {
                    lReportCategory = appointment.Subject.Split('|')[0];
                    lReportName     = appointment.Subject.Split('|')[1];
                }
                else if (appointment.Subject.Split('|').Length == 3)
                {
                    lReportCategory = appointment.Subject.Split('|')[0];
                    lReportName     = appointment.Subject.Split('|')[1] + " | " + appointment.Subject.Split('|')[2];
                }
                lResultsDataTable.Rows.Add((int)row[0], lReportCategory, lReportName, lRecurrenceDescription);
            }

            ultraGridReportSchedules.DataSource = lResultsDataTable;
        }
Exemplo n.º 2
0
 public FormViewSchedules()
 {
     InitializeComponent();
     lReportSchedulesDAO = new ReportSchedulesDAO();
     _selectedAssetIds   = "";
 }
Exemplo n.º 3
0
        private void HandleCalendarEvent()
        {
            LogFile ourLog = new LogFile();

            try
            {
                SettingsDAO        lSettingsDAO        = new SettingsDAO();
                ReportSchedulesDAO lReportSchedulesDAO = new ReportSchedulesDAO();
                Appointment        appointment;
                object             rawAppointmentData;
                ultraCalendarInfo.Appointments.Clear();

                foreach (DataRow row in lReportSchedulesDAO.GetAllAppointments().Rows)
                {
                    rawAppointmentData = row["_APPOINTMENTDATA"];

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

                    appointment = Appointment.FromBytes(rawAppointmentData as byte[]);
                    ultraCalendarInfo.Appointments.Add(appointment);
                }

                string strLastReportRunTime = lSettingsDAO.GetSetting("LastReportRun", false);

                DateTime lLastReportRunDateTime = (strLastReportRunTime == "") ? DateTime.MinValue : Convert.ToDateTime(strLastReportRunTime);
                DateTime lReportRunTime         = DateTime.Now;

                AppointmentsSubsetCollection expiredAppointments = ultraCalendarInfo.GetAppointmentsInRange(lLastReportRunDateTime, lReportRunTime);
                lSettingsDAO.SetSetting("LastReportRun", lReportRunTime.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        = expiredAppointment.Subject.Split('|');
                        string   lReportCategory = "";
                        string   lReportName     = "";

                        if (lSubject.Length == 2)
                        {
                            lReportCategory = lSubject[0];
                            lReportName     = lSubject[1];
                        }
                        else if (lSubject.Length == 3)
                        {
                            lReportCategory = lSubject[0];
                            lReportName     = lSubject[1] + " | " + lSubject[2];
                        }

                        if (lReportCategory.StartsWith("Custom Report"))
                        {
                            int lReportId = Convert.ToInt32(expiredAppointment.Description);
                            emailController.SendCustomReportByEmail(expiredAppointment.Subject, lReportId, expiredAppointment.Location);
                        }
                        else if (lReportCategory.StartsWith("Compliance Report"))
                        {
                            int lReportId = Convert.ToInt32(expiredAppointment.Description);
                            emailController.SendComplianceReportByEmail(expiredAppointment.Subject, lReportId, expiredAppointment.Location);
                        }
                        else if (lReportCategory.StartsWith("User-Defined SQL Report"))
                        {
                            int lReportId = Convert.ToInt32(expiredAppointment.Description);
                            emailController.SendSQLReportByEmail(expiredAppointment.Subject, lReportId, expiredAppointment.Location);
                        }
                        else
                        {
                            emailController.SendReportByEmail(expiredAppointment.Subject, expiredAppointment.Location);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                ourLog.Write(ex.Message, true);
            }
        }