Пример #1
0
        public List <ScheduledAction> GetScheduledActions()
        {
            List <ScheduledAction> schedules = new List <ScheduledAction>();
            DataTable tmp = new DataTable();

            try
            {
                SQLiteConnection cnn = new SQLiteConnection(dbConnection);
                cnn.Open();
                SQLiteCommand mycommand = new SQLiteCommand(cnn);
                mycommand.CommandText = "SELECT * FROM schedules";
                SQLiteDataReader reader = mycommand.ExecuteReader();
                tmp.Load(reader);
                reader.Close();
                cnn.Close();
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
            if (tmp.Rows.Count > 0)
            {
                foreach (DataRow r in tmp.Rows)
                {
                    ScheduledAction tmpAction = new ScheduledAction(Int32.Parse(r["Id"].ToString()), r["Mailbox"].ToString(), Int32.Parse(r["FullBackup"].ToString()), Int32.Parse(r["LastDays"].ToString()), r["Target"].ToString(), r["Hour"].ToString(), r["Minute"].ToString(), r["DayOfWeek"].ToString(), r["DayOfMonth"].ToString(), r["Month"].ToString());
                    schedules.Add(tmpAction);
                }
            }
            return(schedules);
        }
Пример #2
0
        private void scheduleList_SelectedIndexChanged(object sender, EventArgs e)
        {
            ScheduledAction tmp = schedules[scheduleList.SelectedIndex];

            whenHourManager.Text               = (tmp.ScheduleTime.hour == -1) ? "*" : tmp.ScheduleTime.hour.ToString();
            whenMinuteManager.Text             = (tmp.ScheduleTime.minute == -1) ? "*" : tmp.ScheduleTime.minute.ToString();
            whenDayOfMonthManager.Text         = (tmp.ScheduleTime.dayofmonth == -1) ? "*" : tmp.ScheduleTime.dayofmonth.ToString();
            whenMonthManager.Text              = (tmp.ScheduleTime.month == -1) ? "*" : tmp.ScheduleTime.month.ToString();
            whenDayOfWeekManager.SelectedIndex = (tmp.ScheduleTime.dayofweek == -1) ? 7 : tmp.ScheduleTime.dayofweek;
            directoryTextBoxManager.Text       = tmp.Target;
            managerBox.Text = "Agendamento de " + tmp.Mailbox;
            fullBackupRadioManager.Checked = false;
            lastWeekRadioManager.Checked   = false;
            lastMonthManager.Checked       = false;
            lastDaysRadioManager.Checked   = false;
            lastDaysTextBox.Enabled        = false;
            fullBackupRadioManager.Checked = tmp.FullBackup;
            switch (tmp.LastDays)
            {
            case -1: fullBackupRadioManager.Checked = true; break;

            case 7: lastWeekRadioManager.Checked = true; break;

            case 30: lastMonthManager.Checked = true; break;

            default: lastDaysRadioManager.Checked = true; lastDaysTextBox.Enabled = true; break;
            }
            lastDaysTextBoxManager.Text = tmp.LastDays.ToString();
            managerBox.Visible          = true;
        }
Пример #3
0
 private void createSchedule_Click(object sender, EventArgs e)
 {
     if (directoryTextBox.Text.Trim().Length > 0)
     {
         ScheduledAction action = new ScheduledAction(SelectedMailboxName, FullBackup ? 1 : 0, LastDays, directoryTextBox.Text.Trim(), whenHour.Text, whenMinute.Text, whenDayOfWeek.SelectedIndex == 7?"*":whenDayOfWeek.SelectedIndex.ToString(), whenDayOfMonth.Text, whenMonth.Text);
         if (MessageBox.Show("Criar um agendamento para caixa \"" + SelectedMailboxName + "\" com as configurações selecionadas?", "Criar agendamento", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             dbman.AddSchedule(action);
             MessageBox.Show("Agendamento criado!");
             SelectedMailboxName     = "";
             SelectedMailboxIndex    = -1;
             LastDays                = 15;
             directoryTextBox.Text   = "";
             whenHour.Text           = "*";
             whenMinute.Text         = "*";
             whenMonth.Text          = "*";
             whenDayOfMonth.Text     = "*";
             whenDayOfWeek.Text      = "Qualquer";
             fullBackupRadio.Checked = true;
             lastMonth.Checked       = false;
             lastWeekRadio.Checked   = false;
             lastDaysRadio.Checked   = false;
             lastDaysTextBox.Enabled = false;
             scheduleBox.Visible     = false;
         }
     }
     else
     {
         MessageBox.Show("Preencha o campo \"Destino\"");
     }
 }
Пример #4
0
        public void ChangeSchedule(int id, ScheduledAction Schedule)
        {
            SQLiteParameter Mailbox    = new SQLiteParameter("@Mailbox");
            SQLiteParameter FullBackup = new SQLiteParameter("@FullBackup");
            SQLiteParameter LastDays   = new SQLiteParameter("@LastDays");
            SQLiteParameter Target     = new SQLiteParameter("@Target");
            SQLiteParameter Hour       = new SQLiteParameter("@Hour");
            SQLiteParameter Minute     = new SQLiteParameter("@Minute");
            SQLiteParameter DayOfWeek  = new SQLiteParameter("@DayOfWeek");
            SQLiteParameter DayOfMonth = new SQLiteParameter("@DayOfMonth");
            SQLiteParameter Month      = new SQLiteParameter("@Month");
            SQLiteParameter ID         = new SQLiteParameter("@Id");

            Mailbox.Value    = Schedule.Mailbox;
            FullBackup.Value = Schedule.FullBackup ? 1 : 0;
            LastDays.Value   = Schedule.LastDays;
            Target.Value     = Schedule.Target;
            Hour.Value       = Schedule.ScheduleTime.hour;
            Minute.Value     = Schedule.ScheduleTime.minute;
            DayOfWeek.Value  = Schedule.ScheduleTime.dayofweek;
            DayOfMonth.Value = Schedule.ScheduleTime.dayofmonth;
            Month.Value      = Schedule.ScheduleTime.month;

            ID.Value = id;
            SQLiteConnection cnn = new SQLiteConnection(dbConnection);

            cnn.Open();
            SQLiteCommand cmd = new SQLiteCommand(cnn);

            cmd.Parameters.Add(Mailbox);
            cmd.Parameters.Add(FullBackup);
            cmd.Parameters.Add(LastDays);
            cmd.Parameters.Add(Target);
            cmd.Parameters.Add(Hour);
            cmd.Parameters.Add(Minute);
            cmd.Parameters.Add(DayOfWeek);
            cmd.Parameters.Add(DayOfMonth);
            cmd.Parameters.Add(Month);
            cmd.Parameters.Add(ID);
            cmd.CommandText = "UPDATE schedules SET Mailbox = @Mailbox, FullBackup = @FullBackup, LastDays = @LastDays, Target = @Target, Hour = @Hour, Minute = @Minute, DayOfWeek = @DayOfWeek, DayOfMonth = @DayOfMonth, Month = @Month WHERE Id = @Id";

            cmd.ExecuteNonQuery();
            cnn.Close();
        }
Пример #5
0
        public void AddSchedule(ScheduledAction Schedule)
        {
            SQLiteParameter Mailbox    = new SQLiteParameter("@Mailbox");
            SQLiteParameter FullBackup = new SQLiteParameter("@FullBackup");
            SQLiteParameter LastDays   = new SQLiteParameter("@LastDays");
            SQLiteParameter Target     = new SQLiteParameter("@Target");
            SQLiteParameter Hour       = new SQLiteParameter("@Hour");
            SQLiteParameter Minute     = new SQLiteParameter("@Minute");
            SQLiteParameter DayOfWeek  = new SQLiteParameter("@DayOfWeek");
            SQLiteParameter DayOfMonth = new SQLiteParameter("@DayOfMonth");
            SQLiteParameter Month      = new SQLiteParameter("@Month");

            Mailbox.Value    = Schedule.Mailbox;
            FullBackup.Value = Schedule.FullBackup?1:0;
            LastDays.Value   = Schedule.LastDays;
            Target.Value     = Schedule.Target;
            Hour.Value       = Schedule.ScheduleTime.hour;
            Minute.Value     = Schedule.ScheduleTime.minute;
            DayOfWeek.Value  = Schedule.ScheduleTime.dayofweek;
            DayOfMonth.Value = Schedule.ScheduleTime.dayofmonth;
            Month.Value      = Schedule.ScheduleTime.month;

            SQLiteConnection cnn = new SQLiteConnection(dbConnection);

            cnn.Open();
            SQLiteCommand cmd = new SQLiteCommand(cnn);

            cmd.Parameters.Add(Mailbox);
            cmd.Parameters.Add(FullBackup);
            cmd.Parameters.Add(LastDays);
            cmd.Parameters.Add(Target);
            cmd.Parameters.Add(Hour);
            cmd.Parameters.Add(Minute);
            cmd.Parameters.Add(DayOfWeek);
            cmd.Parameters.Add(DayOfMonth);
            cmd.Parameters.Add(Month);
            cmd.CommandText = "INSERT INTO schedules (Mailbox, FullBackup, LastDays, Target, Hour, Minute, DayOfWeek, DayOfMonth, Month) VALUES (@Mailbox, @FullBackup, @LastDays, @Target, @Hour, @Minute, @DayOfWeek, @DayOfMonth, @Month)";

            cmd.ExecuteNonQuery();
            cnn.Close();
        }