Пример #1
0
        public void ResetPlanSetting()
        {
            if (JobPlanSetting == null)
            {
                _jobPlanSetting = new JobPlan();
            }

            m_Job.Enable = ckEnabled.Checked;
            // 计划类型
            if (selJobType.SelectedIndex == 0)// 执行一次
            {
                JobPlanSetting.JobType            = JobPlanType.JustOnce;
                JobPlanSetting.DateTimeOfExecOnce = dateEditExecOnce.DateTime.Date + timeEditExecOnce.Time.TimeOfDay;
            }
            else
            {
                JobPlanSetting.JobType = JobPlanType.Repeat;
                // 频率
                if (selFrequencyUnit.SelectedIndex == 0) // 按天
                {
                    JobPlanSetting.Frequency.IntervalUnit = JobExecIntervalUnit.Day;
                    JobPlanSetting.Frequency.Interval     = Convert.ToInt16(edtIntervalDay.Value);
                }
                else // 按周
                {
                    JobPlanSetting.Frequency.IntervalUnit = JobExecIntervalUnit.Week;
                    JobPlanSetting.Frequency.Interval     = Convert.ToInt16(edtIntervalWeek.Value);
                    JobPlanSetting.Frequency.WeekDays     = ConvertWeekDaysToString(ckWeekDays.WeekDays);
                }
                // 每天的频率
                JobPlanSetting.FrequencyPerDay.Repeatly = radBtnInterval.Checked;
                if (JobPlanSetting.FrequencyPerDay.Repeatly)
                {
                    JobPlanSetting.FrequencyPerDay.Interval = Convert.ToUInt16(edtIntervalPerDay.Value);
                    if (selIntervalUnitPerDay.SelectedIndex == 0)
                    {
                        JobPlanSetting.FrequencyPerDay.IntervalUnit = JobExecIntervalUnit.Minute;
                    }
                    else
                    {
                        JobPlanSetting.FrequencyPerDay.IntervalUnit = JobExecIntervalUnit.Hour;
                    }
                    JobPlanSetting.FrequencyPerDay.StartTime = timeEditStart.Time.TimeOfDay;
                    JobPlanSetting.FrequencyPerDay.EndTime   = timeEditEnd.Time.TimeOfDay;
                }
                else
                {
                    JobPlanSetting.FrequencyPerDay.TimeOfExecOnce = timeEditExecOncePerDay.Time.TimeOfDay;
                }
                // 持续时间
                JobPlanSetting.Duration.StartDate  = dateEditDurationStart.DateTime;
                JobPlanSetting.Duration.HasEndDate = !radBtnEndDate.Enabled;
                JobPlanSetting.Duration.EndDate    = dateEditDurationEnd.DateTime;
            }
        }
Пример #2
0
        public void CallJobPlanSet(Job job)
        {
            if (job == null)
            {
                return;
            }
            if (String.IsNullOrEmpty(job.Name))
            {
                Text = "任务计划设置";
            }
            else
            {
                Text = "任务计划设置 -" + job.Name;
            }

            m_Job           = job;
            _jobPlanSetting = job.JobSchedule;

            SetControlValueBySetting();
        }
Пример #3
0
        private void SetControlValueBySetting()
        {
            if (JobPlanSetting == null)
            {
                _jobPlanSetting = new JobPlan();
            }

            // 仅作赋值操作,控件的启用通过下拉框和单选按钮来触发
            ckEnabled.Checked = m_Job.Enable;
            // 计划类型
            if (JobPlanSetting.JobType == JobPlanType.JustOnce)
            {
                selJobType.SelectedIndex = 0;
            }
            else
            {
                selJobType.SelectedIndex = 1;
            }
            // 执行一次
            if (JobPlanSetting.DateTimeOfExecOnce > DateTime.MinValue)
            {
                dateEditExecOnce.DateTime = JobPlanSetting.DateTimeOfExecOnce;
                timeEditExecOnce.Time     = JobPlanSetting.DateTimeOfExecOnce;
            }
            // 频率
            if (JobPlanSetting.Frequency.IntervalUnit == JobExecIntervalUnit.Day)
            {
                selFrequencyUnit.SelectedIndex = 0;
            }
            else
            {
                selFrequencyUnit.SelectedIndex = 1;
                ckWeekDays.WeekDays            = ConvertToWeekDays(JobPlanSetting.Frequency.WeekDays);
            }
            edtIntervalDay.Value  = JobPlanSetting.Frequency.Interval;
            edtIntervalWeek.Value = JobPlanSetting.Frequency.Interval;
            // 每天的频率
            radBtnExecOncePerDay.Checked = !JobPlanSetting.FrequencyPerDay.Repeatly;
            timeEditExecOncePerDay.Time  = DateTime.Now.Date + JobPlanSetting.FrequencyPerDay.TimeOfExecOnce;
            radBtnInterval.Checked       = JobPlanSetting.FrequencyPerDay.Repeatly;
            edtIntervalPerDay.Value      = JobPlanSetting.FrequencyPerDay.Interval;
            if (JobPlanSetting.FrequencyPerDay.IntervalUnit == JobExecIntervalUnit.Minute)
            {
                selIntervalUnitPerDay.SelectedIndex = 0;
            }
            else
            {
                selIntervalUnitPerDay.SelectedIndex = 1;
            }
            timeEditStart.Time = DateTime.Now.Date + JobPlanSetting.FrequencyPerDay.StartTime;
            timeEditEnd.Time   = DateTime.Now.Date + JobPlanSetting.FrequencyPerDay.EndTime;
            // 持续时间
            dateEditDurationStart.DateTime = JobPlanSetting.Duration.StartDate;
            radBtnEndDate.Checked          = JobPlanSetting.Duration.HasEndDate;
            if (JobPlanSetting.Duration.EndDate > DateTime.MinValue)
            {
                dateEditDurationEnd.DateTime = JobPlanSetting.Duration.EndDate;
            }
            else
            {
                dateEditDurationEnd.DateTime = DateTime.Now;
            }
            radBtnNotLimited.Checked = !JobPlanSetting.Duration.HasEndDate;
        }