private void addTriggerNodes(TreeNode treeNode) { TreeNode triggersNode = treeNode.Nodes.Add("Triggers"); var triggers = _schedulerProvider.Scheduler.GetTriggersOfJob(new JobKey(treeNode.Text, treeNode.Parent.Parent.Text)); foreach (var trigger in triggers) { TriggerNode node = new TriggerNode(trigger); triggersNode.Nodes.Add(node); } }
private void btnEdit_Click(object sender, EventArgs e) { TriggerNode node = (TriggerNode)jobGroupsTreeView.SelectedNode; AddJobForm form = new AddJobForm(node); form.ShowDialog(); if (form.JobDetail != null && form.Trigger != null) { _schedulerProvider.Scheduler.RescheduleJob(node.Trigger.Key, form.Trigger); loadJobGroups(); } }
private void setPauseButtonText() { TriggerNode node = (TriggerNode)jobGroupsTreeView.SelectedNode; if (_schedulerProvider.Scheduler.GetTriggerState(node.Trigger.Key) == TriggerState.Paused) { btnPause.Text = "Resume"; } else { btnPause.Text = "Pause"; } }
private void btnPause_Click(object sender, EventArgs e) { TriggerNode triggerNode = (TriggerNode)jobGroupsTreeView.SelectedNode; if (_schedulerProvider.Scheduler.GetTriggerState(triggerNode.Trigger.Key) == TriggerState.Paused) { _schedulerProvider.Scheduler.ResumeTrigger(triggerNode.Trigger.Key); } else { _schedulerProvider.Scheduler.PauseTrigger(triggerNode.Trigger.Key); } setPauseButtonText(); }
void jobGroupsTreeView_AfterSelect(object sender, TreeViewEventArgs e) { ListView lv = new ListView(); lv.Items.Clear(); jobDetailsToggle(false); if (e.Node is SchedulerNode) { pnlDetails.Controls.Add(new ScheduleDisplay(_schedulerDataProvider.Data)); } if (e.Node is TriggerNode || e.Node is JobNode) { btnDeleteJob.Enabled = true; } else { btnDeleteJob.Enabled = false; } if (e.Node is JobNode) { JobNode jobNode = (JobNode)e.Node; var jobDetailsData = _schedulerDataProvider.GetJobDetailsData(e.Node.Text, e.Node.Parent.Parent.Text); btnRunJobNow.Enabled = true; pnlDetails.Controls.Add(new NativeJobDetailDisplay(jobDetailsData)); } else { btnRunJobNow.Enabled = false; } if (e.Node is TriggerNode) { TriggerNode node = (TriggerNode)e.Node; var triggerData = _schedulerDataProvider.GetTriggerData(node.Trigger.Key); btnPause.Enabled = true; setPauseButtonText(); if (triggerData.TriggerType.Code == "cron") { pnlDetails.Controls.Add(new CronTriggerDisplay(triggerData)); } if (triggerData.TriggerType.Code == "simple") { pnlDetails.Controls.Add(new SimpleTriggerDisplay(triggerData)); } btnEdit.Enabled = true; } else { btnEdit.Enabled = false; btnPause.Enabled = false; } #region 當選擇JobGroup子節點時自動過濾出List列表內容 if (e.Node.Parent != null && e.Node.Parent.Text == "Job Groups") { ListViewItem searchItem = null; int index = 0; List <int> listIndex = new List <int>(); List <int> temp = new List <int>(); for (int i = 0; i < listView_RunningJobs.Items.Count; i++) { temp.Add(i); } do { if (index < listView_RunningJobs.Items.Count) { searchItem = listView_RunningJobs.FindItemWithText(e.Node.Text, true, index, false); if (searchItem != null) { index = searchItem.Index + 1; listIndex.Add(index); searchItem.BackColor = Color.Coral; if (temp.Exists(m => m == index - 1)) { temp.Remove(index - 1); } } } else { searchItem = null; } } while (searchItem != null); for (int i = 0; i < temp.Count; i++) { ListViewItem item = listView_RunningJobs.Items[temp[i]]; item.BackColor = Color.Empty; } } else { for (int i = 0; i < listView_RunningJobs.Items.Count; i++) { ListViewItem item = listView_RunningJobs.Items[i]; item.BackColor = Color.Empty; } } #endregion jobDetailsToggle(true); }
public AddJobForm(TriggerNode node) : this() { setTriggerData((CronTriggerImpl)node.Trigger); setJobData(((JobNode)node.Parent.Parent).Detail); }