コード例 #1
0
        private void btnRunJobNow_Click(object sender, EventArgs e)
        {
            JobNode         node      = (JobNode)jobGroupsTreeView.SelectedNode;
            QuartzScheduler scheduler = getScheduler(node);

            scheduler.GetScheduler().TriggerJob(node.Detail.Key);
        }
コード例 #2
0
 private void connectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (ServerConnectForm form = new ServerConnectForm())
     {
         form.ShowDialog();
         if (!form.Cancelled)
         {
             try
             {
                 QuartzScheduler scheduler = new QuartzScheduler(form.Server, form.Port, form.Scheduler);
                 serverConnectStatusLabel.Text = string.Format("Connected to {0}", scheduler.Address);
                 jobsToolStripMenuItem.Enabled = true;
                 loadJobGroups(scheduler);
                 updateRunningJobs();
             }
             catch (SocketException ex)
             {
                 ErrorDialog dialog = new ErrorDialog();
                 dialog.Message     = string.Format("Unable to connect to scheduler {0} on {1}:{2}", form.Scheduler, form.Server, form.Port);
                 dialog.Description = ex.Message;
                 dialog.ShowDialog();
             }
         }
         form.Close();
     }
 }
コード例 #3
0
        private void addJobNodes(TreeNode node)
        {
            string group        = node.Parent.Text;
            var    groupMatcher = GroupMatcher <JobKey> .GroupContains(group);

            QuartzScheduler scheduler = getScheduler(node);
            var             jobKeys   = scheduler.GetScheduler().GetJobKeys(groupMatcher);

            foreach (var jobKey in jobKeys)
            {
                try
                {
                    IJobDetail detail  = scheduler.GetScheduler().GetJobDetail(jobKey);
                    JobNode    jobNode = new JobNode(detail);
                    node.Nodes.Add(jobNode);
                    addTriggerNodes(jobNode);
                }
                catch (Exception ex)
                {
                    node.Nodes.Add(string.Format("Unknown Job Type ({0})", jobKey.Name));
                    //TODO: Do something useful with this exception. Most likely cause is the client does not have a copy of a given dll and can't load the type.
                    _Log.Error("Error loading jobs.", ex);
                }
            }
        }
コード例 #4
0
        private void backupToolStripMenuItem_Click(object sender, EventArgs e)
        {
            QuartzScheduler scheduler = ((SchedulerNode)((TreeView)((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl).SelectedNode).Scheduler;
            FileDialog      dialog    = new SaveFileDialog();

            dialog.ShowDialog();
            FileInfo file = new FileInfo(dialog.FileName);

            scheduler.BackupToFile(file);
        }
コード例 #5
0
        private void addJobToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AddJobForm form = new AddJobForm();

            form.ShowDialog();
            if (form.JobDetail != null && form.Trigger != null)
            {
                QuartzScheduler scheduler = getSelectedScheduler();
                scheduler.GetScheduler().ScheduleJob(form.JobDetail, form.Trigger);
                loadJobGroups(scheduler);
            }
        }
コード例 #6
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            TriggerNode     node      = (TriggerNode)jobGroupsTreeView.SelectedNode;
            QuartzScheduler scheduler = getScheduler(node);
            AddJobForm      form      = new AddJobForm(node);

            form.ShowDialog();
            if (form.JobDetail != null && form.Trigger != null)
            {
                scheduler.GetScheduler().RescheduleJob(node.Trigger.Key, form.Trigger);
                loadJobGroups(scheduler);
            }
        }
コード例 #7
0
        private void addTriggerNodes(TreeNode treeNode)
        {
            QuartzScheduler scheduler    = getScheduler(treeNode);
            var             triggers     = scheduler.GetScheduler().GetTriggersOfJob(new JobKey(treeNode.Text, treeNode.Parent.Parent.Text));
            TreeNode        triggersNode = treeNode.Nodes.Add("Triggers");

            foreach (var trigger in triggers)
            {
                TriggerNode node = new TriggerNode(trigger);
                triggersNode.Nodes.Add(node);
                addCalendarNode(node);
            }
        }
コード例 #8
0
        private void setPauseButtonText()
        {
            TriggerNode     node      = (TriggerNode)jobGroupsTreeView.SelectedNode;
            QuartzScheduler scheduler = getScheduler(node);

            if (scheduler.GetScheduler().GetTriggerState(node.Trigger.Key) == TriggerState.Paused)
            {
                btnPause.Text = "Resume";
            }
            else
            {
                btnPause.Text = "Pause";
            }
        }
コード例 #9
0
        private void btnPause_Click(object sender, EventArgs e)
        {
            TriggerNode     node      = (TriggerNode)jobGroupsTreeView.SelectedNode;
            QuartzScheduler scheduler = getScheduler(node);

            if (scheduler.GetScheduler().GetTriggerState(node.Trigger.Key) == TriggerState.Paused)
            {
                scheduler.GetScheduler().ResumeTrigger(node.Trigger.Key);
            }
            else
            {
                scheduler.GetScheduler().PauseTrigger(node.Trigger.Key);
            }
            setPauseButtonText();
        }
コード例 #10
0
        private void btnDeleteJob_Click(object sender, EventArgs e)
        {
            TreeNode selectedNode = jobGroupsTreeView.SelectedNode;

            if (selectedNode is JobNode)
            {
                JobNode         node      = (JobNode)jobGroupsTreeView.SelectedNode;
                QuartzScheduler scheduler = getScheduler(selectedNode);
                scheduler.GetScheduler().DeleteJob(node.Detail.Key);
                jobGroupsTreeView.SelectedNode.Remove();
            }
            if (selectedNode is TriggerNode)
            {
                QuartzScheduler scheduler = getScheduler(selectedNode);
                scheduler.GetScheduler().UnscheduleJob(((TriggerNode)selectedNode).Trigger.Key);
            }
        }
コード例 #11
0
        private void loadJobGroups(QuartzScheduler scheduler)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                jobDetailsToggle(false);

                SchedulerNode schedulerNode = new SchedulerNode(scheduler);
                if (jobGroupsTreeView.Nodes.ContainsKey(schedulerNode.Name))
                {
                    jobGroupsTreeView.Nodes.RemoveByKey(schedulerNode.Name);
                }

                schedulerNode.ContextMenuStrip = ctxScheduler;
                jobGroupsTreeView.Nodes.Add(schedulerNode);
                TreeNode jobGroupsNode = schedulerNode.Nodes.Add("Job Groups");
                var      jobGroups     = scheduler.GetScheduler().GetJobGroupNames();
                foreach (string jobGroup in jobGroups)
                {
                    TreeNode jobGroupNode = jobGroupsNode.Nodes.Add(jobGroup);
                    TreeNode jobsNode     = jobGroupNode.Nodes.Add("Jobs");
                    addJobNodes(jobsNode);
                }

                jobGroupsTreeView.Nodes[0].Expand();
                jobGroupsNode.Expand();

                StripStatusLabel_Job_Groups.Text = DateTime.Now.ToString("yyyy.MM.dd HH:mm.ss");
                loadOrphanJobs(schedulerNode);
                loadStuckTriggers(schedulerNode);
                loadCalendars(schedulerNode);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #12
0
 public SchedulerNode(QuartzScheduler scheduler)
     : base()
 {
     this.Text = this.Name = scheduler.Address;
     Scheduler = scheduler;
 }
コード例 #13
0
        private void loadJobGroups(QuartzScheduler scheduler)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;

                jobDetailsToggle(false);

                SchedulerNode schedulerNode = new SchedulerNode(scheduler);
                if (jobGroupsTreeView.Nodes.ContainsKey(schedulerNode.Name))
                {
                    jobGroupsTreeView.Nodes.RemoveByKey(schedulerNode.Name);
                }

                schedulerNode.ContextMenuStrip = ctxScheduler;
                jobGroupsTreeView.Nodes.Add(schedulerNode);
                TreeNode jobGroupsNode = schedulerNode.Nodes.Add("Job Groups");
                var jobGroups = scheduler.GetScheduler().GetJobGroupNames();
                foreach (string jobGroup in jobGroups)
                {
                    TreeNode jobGroupNode = jobGroupsNode.Nodes.Add(jobGroup);
                    TreeNode jobsNode = jobGroupNode.Nodes.Add("Jobs");
                    addJobNodes(jobsNode);
                }

                jobGroupsTreeView.Nodes[0].Expand();
                jobGroupsNode.Expand();

                StripStatusLabel_Job_Groups.Text = DateTime.Now.ToString("yyyy.MM.dd HH:mm.ss");
                loadOrphanJobs(schedulerNode);
                loadStuckTriggers(schedulerNode);
                loadCalendars(schedulerNode);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
コード例 #14
0
 private void connectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (ServerConnectForm form = new ServerConnectForm())
     {
         form.ShowDialog();
         if (!form.Cancelled)
         {
             try
             {
                 QuartzScheduler scheduler = new QuartzScheduler(form.Server, form.Port, form.Scheduler);
                 serverConnectStatusLabel.Text = string.Format("Connected to {0}", scheduler.Address);
                 jobsToolStripMenuItem.Enabled = true;
                 loadJobGroups(scheduler);
                 updateRunningJobs();
             }
             catch (SocketException ex)
             {
                 ErrorDialog dialog = new ErrorDialog();
                 dialog.Message = string.Format("Unable to connect to scheduler {0} on {1}:{2}", form.Scheduler, form.Server, form.Port);
                 dialog.Description = ex.Message;
                 dialog.ShowDialog();
             }
         }
         form.Close();
     }
 }