void AddNewCluster(object sender, EventArgs e) { ClusterConfiguration conf = this.EditCluster(null); if (conf == null) { return; } // you cannot have two cache clusters at the same time if (conf is CacheClusterConfiguration) { foreach (var name in ClusterConfiguration.GetKnownClusterNames()) { var config = ClusterConfiguration.KnownClusterByName(name); if (config is CacheClusterConfiguration) { DialogResult res = MessageBox.Show("You cannot have two cache clusters at once: " + conf.Name + " and " + config.Name + "\nPress OK to use " + conf.Name + " instead of " + config.Name); if (res == System.Windows.Forms.DialogResult.OK) { ClusterConfiguration.RemoveKnownCluster(config.Name); (config as CacheClusterConfiguration).StopCaching(); (conf as CacheClusterConfiguration).StartCaching(); } else { return; } } } } ClusterConfiguration.AddKnownCluster(conf); this.AddClusterNameToMenu(conf.Name); }
/// <summary> /// Edit the information about the specified cluster. If null create a new cluster. /// </summary> /// <param name="clusterName">Cluster that is being edited.</param> /// <returns>The name of the edited cluster, or null if the operation is cancelled.</returns> private ClusterConfiguration EditCluster(string clusterName) { ClusterConfigEditor editor = new ClusterConfigEditor(); try { if (clusterName != null) { var config = ClusterConfiguration.KnownClusterByName(clusterName); editor.SetConfigToEdit(config); } else { editor.SetConfigToEdit(null); } } catch (Exception) { // This can happen when the cluster serialization has changed // and we can no longer read the saved properties editor.SetConfigToEdit(null); } DialogResult res = editor.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { var config = editor.GetConfiguration(); return(config); } return(null); }
private void ConfigurationChanged(ClusterConfiguration conf) { if (conf == null) { return; } // you cannot have two cache clusters at the same time if (conf is CacheClusterConfiguration) { foreach (var name in ClusterConfiguration.GetKnownClusterNames()) { var config = ClusterConfiguration.KnownClusterByName(name); if (config is CacheClusterConfiguration) { DialogResult res = MessageBox.Show("You cannot have two cache clusters at once: " + conf.Name + " and " + config.Name + "\nPress OK to use " + conf.Name + " instead of " + config.Name); if (res == System.Windows.Forms.DialogResult.OK) { ClusterConfiguration.RemoveKnownCluster(config.Name); (config as CacheClusterConfiguration).StopCaching(); (conf as CacheClusterConfiguration).StartCaching(); } else { return; } } } } ClusterConfiguration.AddKnownCluster(conf); this.AddClusterNameToMenu(conf.Name); this.Status("Added cluster " + conf.Name, StatusKind.OK); }
/// <summary> /// Form is being loaded; restore settings. /// </summary> /// <param name="sender">Unused.</param> /// <param name="e">Unused.</param> private void ClusterBrowser_Load(object sender, EventArgs e) { this.formSettings = new ClusterBrowserSettings(); Rectangle rect = System.Windows.Forms.Screen.PrimaryScreen.Bounds; // set location only if it is inside if (rect.Contains(this.formSettings.Location)) { this.Location = this.formSettings.Location; } bool maximized = this.formSettings.MaximizeWindow; if (maximized) { this.WindowState = FormWindowState.Maximized; } else { // then we care about the size this.Size = this.formSettings.Size; } this.autoRefreshToolStripMenuItem.Checked = this.formSettings.AutoRefresh; this.AddClusterNameToMenu("<add>"); this.AddClusterNameToMenu("<scan>"); ClusterConfiguration.ReconstructKnownCluster(this.formSettings.KnownClusters); int found = 0; IEnumerable <string> clusters = ClusterConfiguration.GetKnownClusterNames(); foreach (string c in clusters) { this.AddClusterNameToMenu(c); var config = ClusterConfiguration.KnownClusterByName(c); if (config is CacheClusterConfiguration) { (config as CacheClusterConfiguration).StartCaching(); } found++; } if (found == 0) { // try to find them by scanning this.ScanClusters(); } }
/// <summary> /// Edit the information about the specified cluster. If null create a new cluster. /// </summary> /// <param name="clusterName">Cluster that is being edited.</param> /// <returns>The name of the edited cluster, or null if the operation is cancelled.</returns> private ClusterConfiguration EditCluster(string clusterName) { ClusterConfigEditor editor = new ClusterConfigEditor(); if (clusterName != null) { var config = ClusterConfiguration.KnownClusterByName(clusterName); editor.SetConfigToEdit(config); } DialogResult res = editor.ShowDialog(); if (res == System.Windows.Forms.DialogResult.OK) { var config = editor.GetConfiguration(); return(config); } return(null); }
/// <summary> /// The used has selected a new cluster. /// </summary> /// <param name="clusterName">Cluster selected by the user.</param> // ReSharper disable once UnusedMethodReturnValue.Local private void ClusterSelected(string clusterName) { this.cluster = clusterName; NetworkCredential credential = null; try { ClusterConfiguration config = ClusterConfiguration.KnownClusterByName(clusterName); this.Configuration = config; this.diagnoseToolStripMenuItem.Visible = config.SupportsDiagnosis; this.diagnoseToolStripMenuItem1.Visible = config.SupportsDiagnosis; } catch (Exception ex) { this.Status("Could not connect to cluster " + clusterName + ": " + ex.Message, StatusKind.Error); if (ex.Message.Contains("Unauthorized")) { // ReSharper disable once ConditionIsAlwaysTrueOrFalse if (credential != null) { // ReSharper disable once HeuristicUnreachableCode InvalidateCredentials(credential.Domain); } } return; } this.Text = "Cluster: " + clusterName; this.clusterJobs.Clear(); { this.comboBox_virtualCluster.Enabled = false; this.label_vc.Enabled = false; this.RefreshClusterJobList(); } }