Permalink
Browse files

add support for deleting all orphan jobs at once

  • Loading branch information...
1 parent 12b6782 commit 9d6b7f0c05c46846d82fc8329bebbb06e2cebe90 @jvilalta jvilalta committed Feb 1, 2012
View
6 ClickForensics.Quartz.Manager/ClickForensics.Quartz.Manager.csproj
@@ -54,12 +54,12 @@
<Reference Include="Common.Logging">
<HintPath>..\lib\Common.Logging.dll</HintPath>
</Reference>
- <Reference Include="Quartz">
- <HintPath>..\lib\Quartz.dll</HintPath>
- </Reference>
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.1.2.10\lib\2.0\log4net.dll</HintPath>
</Reference>
+ <Reference Include="Quartz">
+ <HintPath>..\lib\Quartz.dll</HintPath>
+ </Reference>
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Core">
View
20 ClickForensics.Quartz.Manager/MainForm.Designer.cs
@@ -58,6 +58,7 @@ private void InitializeComponent()
this.listView_RunningJobs = new System.Windows.Forms.ListView();
this.JobName = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
this.JobDuration = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.deleteToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.mainMenuStrip.SuspendLayout();
this.statusStrip1.SuspendLayout();
this.ctxScheduler.SuspendLayout();
@@ -86,7 +87,7 @@ private void InitializeComponent()
// connectToolStripMenuItem
//
this.connectToolStripMenuItem.Name = "connectToolStripMenuItem";
- this.connectToolStripMenuItem.Size = new System.Drawing.Size(119, 22);
+ this.connectToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.connectToolStripMenuItem.Text = "Connect";
this.connectToolStripMenuItem.Click += new System.EventHandler(this.connectToolStripMenuItem_Click);
//
@@ -102,7 +103,7 @@ private void InitializeComponent()
// addJobToolStripMenuItem
//
this.addJobToolStripMenuItem.Name = "addJobToolStripMenuItem";
- this.addJobToolStripMenuItem.Size = new System.Drawing.Size(96, 22);
+ this.addJobToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.addJobToolStripMenuItem.Text = "Add";
this.addJobToolStripMenuItem.Click += new System.EventHandler(this.addJobToolStripMenuItem_Click);
//
@@ -273,14 +274,15 @@ private void InitializeComponent()
// ctxScheduler
//
this.ctxScheduler.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.backupToolStripMenuItem});
+ this.backupToolStripMenuItem,
+ this.deleteToolStripMenuItem});
this.ctxScheduler.Name = "ctxScheduler";
- this.ctxScheduler.Size = new System.Drawing.Size(109, 26);
+ this.ctxScheduler.Size = new System.Drawing.Size(153, 70);
//
// backupToolStripMenuItem
//
this.backupToolStripMenuItem.Name = "backupToolStripMenuItem";
- this.backupToolStripMenuItem.Size = new System.Drawing.Size(108, 22);
+ this.backupToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
this.backupToolStripMenuItem.Text = "Backup";
this.backupToolStripMenuItem.Click += new System.EventHandler(this.backupToolStripMenuItem_Click);
//
@@ -311,6 +313,13 @@ private void InitializeComponent()
//
this.JobDuration.Text = "Duration";
//
+ // deleteToolStripMenuItem
+ //
+ this.deleteToolStripMenuItem.Name = "deleteToolStripMenuItem";
+ this.deleteToolStripMenuItem.Size = new System.Drawing.Size(152, 22);
+ this.deleteToolStripMenuItem.Text = "Delete";
+ this.deleteToolStripMenuItem.Click += new System.EventHandler(this.deleteToolStripMenuItem_Click);
+ //
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -374,6 +383,7 @@ private void InitializeComponent()
private System.Windows.Forms.ToolStripMenuItem jobAssembliesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem addAssemblyMenuItem;
private System.Windows.Forms.ToolStripMenuItem deleteAssemblyMenuItem;
+ private System.Windows.Forms.ToolStripMenuItem deleteToolStripMenuItem;
}
}
View
37 ClickForensics.Quartz.Manager/MainForm.cs
@@ -128,7 +128,7 @@ private void loadJobGroups(QuartzScheduler scheduler)
{
jobGroupsTreeView.Nodes.RemoveByKey(schedulerNode.Name);
}
-
+
schedulerNode.ContextMenuStrip = ctxScheduler;
jobGroupsTreeView.Nodes.Add(schedulerNode);
TreeNode jobGroupsNode = schedulerNode.Nodes.Add("Job Groups");
@@ -212,6 +212,14 @@ void jobGroupsTreeView_MouseDown(object sender, MouseEventArgs e)
if (node != null)
{
jobGroupsTreeView.SelectedNode = node;
+ if (node.Text == "Orphan Jobs")
+ {
+ ctxScheduler.Items["deleteToolStripMenuItem"].Enabled = true;
+ }
+ else
+ {
+ ctxScheduler.Items["deleteToolStripMenuItem"].Enabled = false;
+ }
ctxScheduler.Show(jobGroupsTreeView, e.Location);
}
}
@@ -309,10 +317,10 @@ private void updateRunningJobs()
timer_Refresh_Running_Jobs.Start();
}
- catch(Exception ex)
- {
- _Log.Error("Unable to load running jobs", ex);
- }
+ catch (Exception ex)
+ {
+ _Log.Error("Unable to load running jobs", ex);
+ }
finally
{
this.Cursor = Cursors.Default;
@@ -343,7 +351,7 @@ private void addJobToolStripMenuItem_Click(object sender, EventArgs e)
private QuartzScheduler getSelectedScheduler()
{
- TreeNode node= jobGroupsTreeView.SelectedNode;
+ TreeNode node = jobGroupsTreeView.SelectedNode;
return getScheduler(node);
}
@@ -464,6 +472,21 @@ private void deleteAssemblyMenuItem_Click(object sender, EventArgs e)
form.Close();
}
}
- private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
+ {
+ QuartzScheduler scheduler = ((SchedulerNode)((TreeView)((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl).SelectedNode.Parent).Scheduler;
+ var node = ((TreeView)((ContextMenuStrip)((ToolStripMenuItem)sender).Owner).SourceControl).SelectedNode;
+ foreach (var item in node.Nodes)
+ {
+ if (item is JobNode)
+ {
+ scheduler.GetScheduler().DeleteJob(((JobNode)item).Detail.Name, ((JobNode)item).Detail.Group);
+ node.Nodes.Remove((JobNode)item);
+ }
+ }
+
+ }
}
}

0 comments on commit 9d6b7f0

Please sign in to comment.