コード例 #1
0
 private void btnShutDownAndStopJob_Click(object sender, EventArgs e)
 {
     if (SchedulerManager.GetScheduler().IsStarted)
     {
         SchedulerManager.GetScheduler().Shutdown(true);
     }
 }
コード例 #2
0
 private void btnStart_Click(object sender, EventArgs e)
 {
     if (!SchedulerManager.GetScheduler().IsStarted)
     {
         SchedulerManager.GetScheduler().Start();
     }
 }
コード例 #3
0
 public void UpdateUI()
 {
     if (SchedulerManager.GetScheduler() != null)
     {
         this.lblScheduleName.Text = SchedulerManager.GetScheduler().SchedulerName;
         this.lblScheduleID.Text   = SchedulerManager.GetScheduler().SchedulerInstanceId;
         if (!SchedulerManager.GetScheduler().IsStarted)
         {
             this.lblScheduleState.Text         = "未启动";
             this.btnShutDown.Enabled           = false;
             this.btnShutDownAndStopJob.Enabled = false;
             this.btnStart.Enabled = true;
         }
         else if (!SchedulerManager.GetScheduler().IsShutdown)
         {
             this.lblScheduleState.Text         = "执行中";
             this.btnShutDown.Enabled           = true;
             this.btnShutDownAndStopJob.Enabled = true;
             this.btnStart.Enabled = false;
         }
         else
         {
             this.lblScheduleState.Text         = "已关闭";
             this.btnShutDown.Enabled           = false;
             this.btnShutDownAndStopJob.Enabled = false;
             this.btnStart.Enabled = true;
         }
     }
 }
コード例 #4
0
 private void AddJob()
 {
     if (jobDetail == null)
     {
         MessageBox.Show("任务不能为空!", "出错", MessageBoxButtons.OK);
         return;
     }
     if (trigger == null)
     {
         MessageBox.Show("触发器不能为空!", "出错", MessageBoxButtons.OK);
         return;
     }
     SchedulerManager.GetScheduler().ScheduleJob(jobDetail, trigger);
 }
コード例 #5
0
        public void UpdateUI()
        {
            if (SchedulerManager.GetScheduler() != null)
            {
                lbJobRunning.Items.Clear();
                foreach (string group in SchedulerManager.GetScheduler().JobGroupNames)
                {
                    //lbJobRunning.Items.Add(group);

                    foreach (string job in SchedulerManager.GetScheduler().GetJobNames(group))
                    {
                        lbJobRunning.Items.Add("触发器组名:" + group + "\t触发器名:" + SchedulerManager.GetScheduler().GetJobDetail(job, group));
                    }
                }
            }
        }
コード例 #6
0
        public mainForm()
        {
            InitializeComponent();

            //绑定日志记录源
            QuartzLogger.LogWindow   = winLog;
            QuartzLogger.ErrorWindow = winError;

            //
            m_deserializeDockContent = new DeserializeDockContent(GetContentFromPersistString);
            sf = SchedulerManager.GetSchedulerFactory();
            //获取默认调度器
            scheduler = SchedulerManager.GetScheduler();
            //打开
            scheduler.Start();
            //两秒钟更新一次
            updateTimer.Interval = 2000;
            updateTimer.Tick    += new EventHandler(updateTimer_Tick);
            updateTimer.Start();
        }
コード例 #7
0
        private void mainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            string configFile = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "DockPanel.config");

            if (m_bSaveLayout)
            {
                dockPanel.SaveAsXml(configFile);
            }
            else if (File.Exists(configFile))
            {
                File.Delete(configFile);
            }

            //关闭
            updateTimer.Stop();
            SchedulerManager.GetScheduler().Shutdown(false);
            try
            {
                this.Close();
            }
            catch { }
        }
コード例 #8
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            switch (guideStep)
            {
            case GuideStep.ChooseJob:
                if (JobConfigPanel != null)
                {
                    if (!pnlJob.Controls.Contains(JobConfigPanel))
                    {
                        pnlJob.Controls.Add(JobConfigPanel);
                        JobConfigPanel.Dock = DockStyle.Fill;
                    }
                    pnlJob.Controls.SetChildIndex(JobConfigPanel, 0);

                    guideStep       = GuideStep.ConfigJob;
                    btnPre.Enabled  = true;
                    btnNext.Enabled = true;
                }
                break;

            case GuideStep.ConfigJob:
                if (defaultTriggerPanel != null)
                {
                    jobDetail = (JobConfigPanel as IJobConfigPanel).GetJobDetail();
                    if (jobDetail == null)
                    {
                        return;
                    }

                    foreach (string jobNames in SchedulerManager.GetScheduler().GetJobNames(jobDetail.Group))
                    {
                        if (jobNames == jobDetail.Name)
                        {
                            MessageBox.Show("任务组名、任务名不能同时重复,请修改");
                            return;
                        }
                    }

                    if (!pnlJob.Controls.Contains(defaultTriggerPanel))
                    {
                        pnlJob.Controls.Add(defaultTriggerPanel);
                        defaultTriggerPanel.Dock = DockStyle.Fill;
                    }
                    pnlJob.Controls.SetChildIndex(defaultTriggerPanel, 0);

                    guideStep       = GuideStep.ConfigTrigger;
                    btnPre.Enabled  = true;
                    btnNext.Enabled = true;
                }
                break;

            case GuideStep.ConfigTrigger:
                if (!pnlJob.Controls.Contains(oKPanel))
                {
                    pnlJob.Controls.Add(oKPanel);
                    oKPanel.Dock = DockStyle.Fill;
                }
                pnlJob.Controls.SetChildIndex(oKPanel, 0);

                defaultTriggerPanel.JobName      = jobDetail.Name;
                defaultTriggerPanel.JobGroupName = jobDetail.Group;
                trigger = defaultTriggerPanel.GetTrigger();

                guideStep       = GuideStep.OK;
                btnPre.Enabled  = true;
                btnNext.Enabled = true;
                btnNext.Text    = "完成";
                break;

            case GuideStep.OK:
                AddJob();
                btnPre.Enabled    = true;
                btnNext.Enabled   = false;
                btnAddNew.Visible = true;
                break;
            }
        }