Exemple #1
0
        private void miJobEdit_Click(object sender, EventArgs e)
        {
            JobKey job;

            if (!GetSelectedJob(out job))
            {
                return;
            }
            IJobDetail       jobDetail = scheduler.GetScheduler().GetJobDetail(job);
            ITrigger         trigger   = null;
            IList <ITrigger> triggers  = scheduler.GetScheduler().GetTriggersOfJob(job);

            if (triggers.Count > 0)
            {
                trigger = triggers[0];
            }
            IJobDetail jobDetail_Old = jobDetail;
            ITrigger   triggerOld    = trigger;

            if (frmJobAdd.Show(ref jobDetail, ref trigger))
            {
                //先停止删除
                scheduler.GetScheduler().PauseTrigger(triggerOld.Key);    // 停止触发器
                scheduler.GetScheduler().UnscheduleJob(triggerOld.Key);   // 移除触发器
                scheduler.GetScheduler().DeleteJob(jobDetail_Old.Key);    // 删除任务
                //后启动
                scheduler.GetScheduler().ScheduleJob(jobDetail, trigger); // 删除任务
                TFQuartzXml.EditJob(JobConfigFile, jobDetail, trigger);
                treeJobs.SelectedNode.Tag = jobDetail.Key.Name;
                InitJobTriggers(jobDetail.Key.Name, jobDetail.Key.Group);
            }
        }
Exemple #2
0
        private void miJobAdd_Click(object sender, EventArgs e)
        {
            IJobDetail jobDetail = null;
            ITrigger   trigger   = null;

            if (frmJobAdd.Show(ref jobDetail, ref trigger))
            {
                TFQuartzXml.AddJob(JobConfigFile, jobDetail, trigger);
                scheduler.GetScheduler().ScheduleJob(jobDetail, trigger);
                InitJobs();
                lstTrigger.Items.Clear();
            }
        }
Exemple #3
0
        private void miJobDelete_Click(object sender, EventArgs e)
        {
            JobKey job;

            if (!GetSelectedJob(out job))
            {
                return;
            }
            if ((MessageBox.Show("您确定要删除此任务吗?")) == DialogResult.Cancel)
            {
                return;
            }
            TFQuartzXml.DeleteJob(JobConfigFile, job);
            IList <ITrigger> triggers = scheduler.GetScheduler().GetTriggersOfJob(job);

            foreach (ITrigger t in triggers)
            {
                scheduler.GetScheduler().PauseTrigger(t.Key);  // 停止触发器
                scheduler.GetScheduler().UnscheduleJob(t.Key); // 移除触发器
            }
            scheduler.GetScheduler().DeleteJob(job);           // 删除任务
            InitJobs();
            lstTrigger.Items.Clear();
        }