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>
 /// Scan the clusters we are subscribed to and add them to the list of known clusters.
 /// </summary>
 private void ScanClusters()
 {
     this.Status("Scanning for known clusters", StatusKind.LongOp);
     foreach (var conf in ClusterConfiguration.EnumerateSubscribedClusters())
     {
         ClusterConfiguration.AddKnownCluster(conf);
         this.AddClusterNameToMenu(conf.Name);
         this.Status("Adding cluster " + conf.Name, StatusKind.OK);
     }
     this.Status("Scan completed", StatusKind.OK);
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Edit a cluster.
        /// </summary>
        /// <param name="sender">MenuItem that is clicked.</param>
        /// <param name="e">Unused.</param>
        void editItem_Click(object sender, EventArgs e)
        {
            ToolStripItem item = sender as ToolStripItem;

            if (item == null)
            {
                return;
            }

            ToolStripItem strip  = item.OwnerItem;
            string        clus   = strip.Text;
            var           config = this.EditCluster(clus);

            if (config != null)
            {
                ClusterConfiguration.AddKnownCluster(config);
                this.AddClusterNameToMenu(config.Name);
            }
        }