示例#1
0
        private Microsoft.Win32.TaskScheduler.Trigger GetTrigger(Schedule schedule)
        {
            switch (schedule.RepeatType.TypeOfRepeat)
            {
            case ScheduleRepeat.ScheduleRepeats.NoRepeat:
                ScheduleRepeatTypes.NoRepeat r1 = schedule.RepeatType as ScheduleRepeatTypes.NoRepeat;
                Microsoft.Win32.TaskScheduler.TimeTrigger trigger1 = new Microsoft.Win32.TaskScheduler.TimeTrigger(Njit.Common.PersianCalendar.ToDateTime(r1.StartDate, r1.StartTime, '/', ':'));
                return(trigger1);

            case ScheduleRepeat.ScheduleRepeats.Daily:
                ScheduleRepeatTypes.Daily r2 = schedule.RepeatType as ScheduleRepeatTypes.Daily;
                Microsoft.Win32.TaskScheduler.DailyTrigger trigger2 = new Microsoft.Win32.TaskScheduler.DailyTrigger();
                trigger2.StartBoundary = Njit.Common.PersianCalendar.ToDateTime(r2.StartDate, r2.ExecuteTime, '/', ':');
                trigger2.EndBoundary   = Njit.Common.PersianCalendar.ToDateTime(r2.EndDate, r2.EndTime, '/', ':');
                return(trigger2);

            case ScheduleRepeat.ScheduleRepeats.Weekly:
                ScheduleRepeatTypes.Weekly r3 = schedule.RepeatType as ScheduleRepeatTypes.Weekly;
                Microsoft.Win32.TaskScheduler.WeeklyTrigger trigger3 = new Microsoft.Win32.TaskScheduler.WeeklyTrigger();
                trigger3.StartBoundary = Njit.Common.PersianCalendar.ToDateTime(r3.StartDate, r3.ExecuteTime, '/', ':');
                trigger3.EndBoundary   = Njit.Common.PersianCalendar.ToDateTime(r3.EndDate, r3.EndTime, '/', ':');
                trigger3.DaysOfWeek    = GetDaysOfWeek(r3.WeekDays);
                return(trigger3);

            case ScheduleRepeat.ScheduleRepeats.Monthly:
                ScheduleRepeatTypes.Monthly r4 = schedule.RepeatType as ScheduleRepeatTypes.Monthly;
                Microsoft.Win32.TaskScheduler.MonthlyTrigger trigger4 = new Microsoft.Win32.TaskScheduler.MonthlyTrigger();
                trigger4.StartBoundary = Njit.Common.PersianCalendar.ToDateTime(r4.StartDate, r4.ExecuteTime, '/', ':');
                trigger4.EndBoundary   = Njit.Common.PersianCalendar.ToDateTime(r4.EndDate, r4.EndTime, '/', ':');
                trigger4.MonthsOfYear  = GetMonthsOfYear(r4.Months);
                trigger4.DaysOfMonth   = new int[] { r4.MonthDay };
                return(trigger4);

            default:
                throw new Exception();
            }
        }
示例#2
0
        public AddEditSchedule(Njit.TaskScheduler.ScheduleType.ScheduleTypes allowedScheduleTypes, Schedule schedule)
            : this(allowedScheduleTypes)
        {
            txtName.Text        = schedule.Name;
            txtDescription.Text = schedule.Description;
            comboBoxScheduleType.SelectedItem = comboBoxScheduleType.Items.Cast <ScheduleType>().Where(t => t.Title == schedule.ScheduleType.Title).Single();
            comboBoxRepeat.SelectedItem       = comboBoxRepeat.Items.Cast <ScheduleRepeat>().Where(t => t.Title == schedule.RepeatType.Title).Single();

            ScheduleRepeat selectedScheduleRepeat = (ScheduleRepeat)comboBoxRepeat.SelectedItem;
            if (selectedScheduleRepeat.TypeOfRepeat == ScheduleRepeat.ScheduleRepeats.NoRepeat)
            {
                ScheduleRepeatTypes.NoRepeat st = (schedule.RepeatType as ScheduleRepeatTypes.NoRepeat);
                txtStartDateNoRepeat.Text = st.StartDate;
                txtStartTimeNoRepeat.Text = st.StartTime;
            }
            else if (selectedScheduleRepeat.TypeOfRepeat == ScheduleRepeat.ScheduleRepeats.Daily)
            {
                ScheduleRepeatTypes.Daily st = (schedule.RepeatType as ScheduleRepeatTypes.Daily);
                txtStartDateDaily.Text = st.StartDate;
                txtEndDateDaily.Text   = st.EndDate;
                txtTimeDaily.Text      = st.ExecuteTime;
            }
            else if (selectedScheduleRepeat.TypeOfRepeat == ScheduleRepeat.ScheduleRepeats.Weekly)
            {
                ScheduleRepeatTypes.Weekly st = (schedule.RepeatType as ScheduleRepeatTypes.Weekly);
                txtStartDateWeekly.Text      = st.StartDate;
                txtStartTimeWeekly.Text      = st.StartTime;
                txtEndDateWeekly.Text        = st.EndDate;
                txtEndTimeWeekly.Text        = st.EndTime;
                txtTimeWeekly.Text           = st.ExecuteTime;
                weekdaysSelect.SelectedWeeks = st.WeekDays;
            }
            else if (selectedScheduleRepeat.TypeOfRepeat == ScheduleRepeat.ScheduleRepeats.Monthly)
            {
                ScheduleRepeatTypes.Monthly st = (schedule.RepeatType as ScheduleRepeatTypes.Monthly);
                txtStartDateMonthly.Text    = st.StartDate;
                txtStartTimeMonthly.Text    = st.StartTime;
                txtEndDateMonthly.Text      = st.EndDate;
                txtEndTimeMonthly.Text      = st.EndTime;
                txtTimeMonthly.Text         = st.ExecuteTime;
                txtMonthDay.Text            = st.MonthDay.ToString();
                monthsSelect.SelectedMonths = st.Months;
            }

            ScheduleType selectedScheduleType = (ScheduleType)comboBoxScheduleType.SelectedItem;
            if (selectedScheduleType.TypeOfSchedule == ScheduleType.ScheduleTypes.BackupDatabase)
            {
                ScheduleTypes.BackupDatabase st = (schedule.ScheduleType as ScheduleTypes.BackupDatabase);
                //SetDatabaseName(new SqlConnectionStringBuilder(ScheduleTypes.BackupDatabase.ConnectionString));
                txtBackupPath.Text = st.SaveTo;
                txtBackupName.Text = st.FileName;
                comboBoxSetBackupNameType.SelectedIndex = (int)st.SetNameType;
            }
            else if (selectedScheduleType.TypeOfSchedule == ScheduleType.ScheduleTypes.ExecuteProgram)
            {
                ScheduleTypes.ExecuteProgram st = (schedule.ScheduleType as ScheduleTypes.ExecuteProgram);
                txtProgramFilePath.Text  = st.FilePath;
                txtProgramParameter.Text = st.Parameter;
            }
            else if (selectedScheduleType.TypeOfSchedule == ScheduleType.ScheduleTypes.ShowMessage)
            {
                ScheduleTypes.ShowMessage st = (schedule.ScheduleType as ScheduleTypes.ShowMessage);
                txtMessageTitle.Text = st.MessageTitle;
                txtMessageBody.Text  = st.MessageBody;
            }
        }