| @@ -161,7 +161,7 @@ | |||||
| <DesignTimeSharedInput>True</DesignTimeSharedInput> | <DesignTimeSharedInput>True</DesignTimeSharedInput> | ||||
| </Compile> | </Compile> | ||||
| <Compile Include="QuartzScheduler.cs" /> | <Compile Include="QuartzScheduler.cs" /> | ||||
| <Compile Include="RegistryMRU.cs" /> | |||||
| <Compile Include="RegistryStore.cs" /> | |||||
| <Compile Include="SchedulerNode.cs" /> | <Compile Include="SchedulerNode.cs" /> | ||||
| <Compile Include="ServerConnectForm.cs"> | <Compile Include="ServerConnectForm.cs"> | ||||
| <SubType>Form</SubType> | <SubType>Form</SubType> | ||||
| @@ -7,8 +7,29 @@ namespace ClickForensics.Quartz.Manager | |||||
| { | { | ||||
| public class ConnectionInfo | public class ConnectionInfo | ||||
| { | { | ||||
| public ConnectionInfo() | |||||
| { | |||||
| } | |||||
| public static ConnectionInfo Parse(string connectionString) | |||||
| { | |||||
| if (connectionString == null) | |||||
| { | |||||
| return null; | |||||
| } | |||||
| string[] parameters = connectionString.Split(new string[] { "|" }, StringSplitOptions.None); | |||||
| if (parameters.Length != 3) | |||||
| { | |||||
| return null; | |||||
| } | |||||
| return new ConnectionInfo { ServerName = parameters[0], Port = int.Parse(parameters[1]), SchedulerName = parameters[2] }; | |||||
| } | |||||
| public string ServerName { get; set; } | public string ServerName { get; set; } | ||||
| public int Port { get; set; } | public int Port { get; set; } | ||||
| public string SchedulerName { get; set; } | public string SchedulerName { get; set; } | ||||
| public override string ToString() | |||||
| { | |||||
| return string.Format("{0}|{1}|{2}", ServerName, Port, SchedulerName); | |||||
| } | |||||
| } | } | ||||
| } | } | ||||
| @@ -96,25 +96,24 @@ namespace ClickForensics.Quartz.Manager | |||||
| using (ServerConnectForm form = new ServerConnectForm()) | using (ServerConnectForm form = new ServerConnectForm()) | ||||
| { | { | ||||
| form.ShowDialog(); | form.ShowDialog(); | ||||
| if (form.Cancelled) | |||||
| if (!form.Cancelled) | |||||
| { | { | ||||
| return; | |||||
| } | |||||
| try | |||||
| { | |||||
| Scheduler = new QuartzScheduler(form.Server, form.Port, form.Scheduler); | |||||
| serverConnectStatusLabel.Text = string.Format("Connected to {0}", Scheduler.Address); | |||||
| connectToolStripMenuItem.Enabled = false; | |||||
| jobsToolStripMenuItem.Enabled = true; | |||||
| loadJobGroups(); | |||||
| 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(); | |||||
| try | |||||
| { | |||||
| Scheduler = new QuartzScheduler(form.Server, form.Port, form.Scheduler); | |||||
| serverConnectStatusLabel.Text = string.Format("Connected to {0}", Scheduler.Address); | |||||
| connectToolStripMenuItem.Enabled = false; | |||||
| jobsToolStripMenuItem.Enabled = true; | |||||
| loadJobGroups(); | |||||
| 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(); | form.Close(); | ||||
| } | } | ||||
| @@ -18,7 +18,7 @@ namespace ClickForensics.Quartz.Manager | |||||
| { | { | ||||
| for (int i = 0; i < 5; i++) | for (int i = 0; i < 5; i++) | ||||
| { | { | ||||
| ConnectionInfo info = (ConnectionInfo)key.GetValue(string.Format("connection{0}", i), null); | |||||
| ConnectionInfo info = ConnectionInfo.Parse((key.GetValue(string.Format("connection{0}", i), null) as string)); | |||||
| if (info != null) | if (info != null) | ||||
| { | { | ||||
| lastConnections.Add(info); | lastConnections.Add(info); | ||||
| @@ -30,7 +30,20 @@ namespace ClickForensics.Quartz.Manager | |||||
| } | } | ||||
| public static void AddConnection(ConnectionInfo info) | public static void AddConnection(ConnectionInfo info) | ||||
| { | { | ||||
| RegistryKey key = Registry.CurrentUser.CreateSubKey("QuartzNetManager").CreateSubKey("MRUList"); | |||||
| if (key != null) | |||||
| { | |||||
| for (int i = 4; i > 0; i--) | |||||
| { | |||||
| var previous = key.GetValue(string.Format("connection{0}", i - 1), null); | |||||
| if (previous != null) | |||||
| { | |||||
| key.SetValue(string.Format("connection{0}", i), previous); | |||||
| } | |||||
| } | |||||
| key.SetValue("connection0", info, RegistryValueKind.String); | |||||
| } | |||||
| } | } | ||||
| private static object lockObject = new object(); | private static object lockObject = new object(); | ||||
| } | } | ||||
| @@ -126,6 +126,7 @@ | |||||
| this.Controls.Add(this.btnConnect); | this.Controls.Add(this.btnConnect); | ||||
| this.Name = "ServerConnectForm"; | this.Name = "ServerConnectForm"; | ||||
| this.Text = "ServerConnectForm"; | this.Text = "ServerConnectForm"; | ||||
| this.Load += new System.EventHandler(this.ServerConnectForm_Load); | |||||
| this.ResumeLayout(false); | this.ResumeLayout(false); | ||||
| this.PerformLayout(); | this.PerformLayout(); | ||||
| @@ -19,12 +19,12 @@ namespace ClickForensics.Quartz.Manager | |||||
| private void btnCancel_Click(object sender, EventArgs e) | private void btnCancel_Click(object sender, EventArgs e) | ||||
| { | { | ||||
| Cancelled = true; | |||||
| this.Close(); | this.Close(); | ||||
| } | } | ||||
| private void btnConnect_Click(object sender, EventArgs e) | private void btnConnect_Click(object sender, EventArgs e) | ||||
| { | { | ||||
| Cancelled = false; | |||||
| Server = cboServer.Text; | Server = cboServer.Text; | ||||
| Port = int.Parse(txtPort.Text); | Port = int.Parse(txtPort.Text); | ||||
| Scheduler = txtScheduler.Text; | Scheduler = txtScheduler.Text; | ||||
| @@ -39,5 +39,11 @@ namespace ClickForensics.Quartz.Manager | |||||
| { | { | ||||
| } | } | ||||
| private void ServerConnectForm_Load(object sender, EventArgs e) | |||||
| { | |||||
| Cancelled = true; | |||||
| } | |||||
| } | } | ||||
| } | } | ||||