Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Remove a menu item from the cluster menu.
        /// </summary>
        /// <param name="clusterName">Name of cluster to remove.</param>
        private void RemoveClusterName(string clusterName)
        {
            var config = ClusterConfiguration.RemoveKnownCluster(clusterName);

            if (config is CacheClusterConfiguration)
            {
                (config as CacheClusterConfiguration).StopCaching();
            }

            for (int i = 0; i < this.clusterToolStripMenuItem.DropDownItems.Count; i++)
            {
                var item = this.clusterToolStripMenuItem.DropDownItems[i];
                if (item.Text == clusterName)
                {
                    this.clusterToolStripMenuItem.DropDownItems.RemoveAt(i);
                    return;
                }
            }
            //throw new ArgumentException("Menu does not contain cluster " + clusterName);
        }