예제 #1
0
        private void tsmiRestartService_Click(object sender, EventArgs e)
        {
            if (tvManager.SelectedNode == null || tvManager.SelectedNode.Tag is Business.Instance == false)
            {
                return;
            }

            Business.Instance instance = (Business.Instance)tvManager.SelectedNode.Tag;
            Business.Server   server   = (Business.Server)tvManager.SelectedNode.Parent.Tag;

            if (MessageBox.Show("Would you like to start the service?", "Are you sure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                Cursor = Cursors.WaitCursor;
                try
                {
                    instance.Stop(server, SetStatusLabel);

                    Thread.Sleep(1000);

                    instance.Start(server, SetStatusLabel);

                    _instanceMonitor.RefreshServerStatistics();
                }
                finally
                {
                    Cursor = Cursors.Default;
                }

                ResetInstanceMonitor();
            }
        }
예제 #2
0
        public void Edit(MemCacheDManager.Business.EditableEntityBase entityToEdit, MemCacheDManager.Business.EditableEntityBase parentEntity)
        {
            _instance = (Business.Instance)entityToEdit;
            _server   = (Business.Server)parentEntity;

            txtInstanceName.Text          = _instance.DisplayName;
            txtChunkSizeGrowthFactor.Text = _instance.ChunkSizeGrowthFactor.ToString();
            txtDefaultKeySize.Text        = _instance.DefaultKeySize.ToString();
            chkMaximizeCoreFile.Checked   = _instance.MaximizeCoreFile;
            txtMaximumConnections.Text    = _instance.MaximumConnections.ToString();
            txtMemoryLimit.Text           = _instance.MemoryLimit.ToString();
            txtTcpPort.Text = _instance.TcpPort.ToString();

            if (_instance.IpAddress != null && _instance.IpAddress != String.Empty)
            {
                chkUseSpecificIPAddress.Checked = true;
                txtIpAddress.Text = _instance.IpAddress;
            }
            else
            {
                chkUseSpecificIPAddress.Checked = false;
                txtIpAddress.Text = "";
            }


            if (_instance.UdpPort > 0)
            {
                chkUseUDP.Checked = true;
                txtUdpPort.Text   = _instance.UdpPort.ToString();
            }
            else
            {
                chkUseUDP.Checked = false;
                txtUdpPort.Text   = String.Empty;
            }

            chkUseManagedInstance.Checked = _instance.UseManagedInstance;

            btnApply.Enabled = false;

            if (_instance != null)
            {
                btnCancel.Enabled = false;
            }
            else
            {
                btnCancel.Enabled = true;
            }
        }
예제 #3
0
        public void CreateNew(Business.EditableEntityBase parent)
        {
            _instance = null;
            _server = (Business.Server)parent;

            txtInstanceName.Text = "";

            int newTcpPort = 11211;
            foreach (Business.Instance instance in _server.Instances)
            {
                if (instance.TcpPort >= newTcpPort)
                    newTcpPort = instance.TcpPort + 1;
            }

            txtTcpPort.Text = newTcpPort.ToString();

            btnApply.Enabled = false;
        }
예제 #4
0
        public void CreateNew(Business.EditableEntityBase parent)
        {
            _instance = null;
            _server   = (Business.Server)parent;

            txtInstanceName.Text = "";

            int newTcpPort = 11211;

            foreach (Business.Instance instance in _server.Instances)
            {
                if (instance.TcpPort >= newTcpPort)
                {
                    newTcpPort = instance.TcpPort + 1;
                }
            }

            txtTcpPort.Text = newTcpPort.ToString();

            btnApply.Enabled = false;
        }
예제 #5
0
        private void deleteInstanceToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you wish to remove " + tvManager.SelectedNode.Text + " from this server?", "Are you sure?", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK)
            {
                try
                {
                    this.Cursor = Cursors.WaitCursor;

                    Business.Instance instance = (Business.Instance)tvManager.SelectedNode.Tag;
                    Business.Server   server   = (Business.Server)tvManager.SelectedNode.Parent.Tag;

                    instance.RemoveFromServer(server, SetStatusLabel);
                    server.Instances.Remove(instance);

                    _serverConfiguration.Save(Configuration.Default.LastConfigFile);
                    LoadUI();
                }
                finally
                {
                    this.Cursor = Cursors.Default;
                }
            }
        }
예제 #6
0
        public void Edit(MemCacheDManager.Business.EditableEntityBase entityToEdit, MemCacheDManager.Business.EditableEntityBase parentEntity)
        {
            _instance = (Business.Instance)entityToEdit;
            _server = (Business.Server)parentEntity;

            txtInstanceName.Text = _instance.DisplayName;
            txtChunkSizeGrowthFactor.Text = _instance.ChunkSizeGrowthFactor.ToString();
            txtDefaultKeySize.Text = _instance.DefaultKeySize.ToString();
            chkMaximizeCoreFile.Checked = _instance.MaximizeCoreFile;
            txtMaximumConnections.Text = _instance.MaximumConnections.ToString();
            txtMemoryLimit.Text = _instance.MemoryLimit.ToString();
            txtTcpPort.Text = _instance.TcpPort.ToString();

            if (_instance.IpAddress != null && _instance.IpAddress != String.Empty)
            {
                chkUseSpecificIPAddress.Checked = true;
                txtIpAddress.Text = _instance.IpAddress;
            }
            else
            {
                chkUseSpecificIPAddress.Checked = false;
                txtIpAddress.Text = "";
            }

            if (_instance.UdpPort > 0)
            {
                chkUseUDP.Checked = true;
                txtUdpPort.Text = _instance.UdpPort.ToString();
            }
            else
            {
                chkUseUDP.Checked = false;
                txtUdpPort.Text = String.Empty;
            }

            chkUseManagedInstance.Checked = _instance.UseManagedInstance;

            btnApply.Enabled = false;

            if(_instance != null)
                btnCancel.Enabled = false;
            else
                btnCancel.Enabled = true;
        }
예제 #7
0
        private void SaveChanges()
        {
            if (chkUseSpecificIPAddress.Checked == true && IsIpAddressValid() == false)
            {
                MessageBox.Show("IP address specified is not a legal IP address.");
                return;
            }

            //if (VerifyFieldValues() == false)
            //{
            //    MessageBox.Show("IP address specified is not a legal IP address.");
            //    return;
            //}

            if (AreIpAndTcpAndUdpPortUniqueForInstance() == false)
            {
                MessageBox.Show("You must specify a unique TCP/IP IP address and port combination.", "IP address or port duplication error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (IsInstanceNameUnique() == false)
            {
                MessageBox.Show("Instance name is not unique.");
                return;
            }

            Cursor = Cursors.WaitCursor;
            SetStatusLabel("Saving.");

            //ImpersonateUser impersonateUser = null;

            try
            {

                //if (_server.UseImpersonation == true)
                //{
                //    SetStatusLabel("Saving: Setting up impersonation.");
                //    impersonateUser = new ImpersonateUser(_server.UserName, Encryption.Decrypt(_server.Password));
                //}

                //
                //string networkPath = null;
                //try
                //{
                //    networkPath = "\\\\" + _server.ServerName + "\\c$";
                //    Directory.GetDirectories(networkPath);
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show("Couldn't establish connection on network path: " + networkPath + "\n\n" + ex.Message);
                //    return;
                //}

                bool isNewInstance = false;

                try
                {
                    if (_instance == null)
                    {
                        string nextInstanceServiceName = GetNextMemcachedInstanceName();

                        _instance = new MemCacheDManager.Business.Instance();

                        _instance.ServiceName = nextInstanceServiceName;
                        _instance.ImageBasePath = _server.BinaryPath;

                        _server.Instances.Add(_instance);

                        isNewInstance = true;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Couldn't get a list of instances on this server. Please check server connectivity and user credentials and try again.\n" + ex.Message, "Error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // TODO: Add rest of fields here.
                _instance.DisplayName = txtInstanceName.Text;

                decimal chunkSizeGrowthFactor = 0;
                string chunkSizeString = ConvertDecimalUserInputToLocalizedString(txtChunkSizeGrowthFactor.Text);
                if (Decimal.TryParse(chunkSizeString, out chunkSizeGrowthFactor) == true)
                    _instance.ChunkSizeGrowthFactor = chunkSizeGrowthFactor;

                int defaultKeySize = 0;
                if (Int32.TryParse(txtDefaultKeySize.Text, out defaultKeySize) == true)
                    _instance.DefaultKeySize = defaultKeySize;

                _instance.MaximizeCoreFile = chkMaximizeCoreFile.Checked;

                int maximumConnections = 0;
                if (Int32.TryParse(txtMaximumConnections.Text, out maximumConnections) == true)
                    _instance.MaximumConnections = maximumConnections;

                int memoryLimit = 0;
                if (Int32.TryParse(txtMemoryLimit.Text, out memoryLimit) == true)
                    _instance.MemoryLimit = memoryLimit;

                _instance.UseManagedInstance = chkUseManagedInstance.Checked;

                if (chkUseSpecificIPAddress.Checked == true)
                    _instance.IpAddress = txtIpAddress.Text;
                else
                    _instance.IpAddress = null;

                if (chkUseUDP.Checked == true)
                {
                    int udpPort = 0;
                    if (Int32.TryParse(txtUdpPort.Text, out udpPort) == true)
                        _instance.UdpPort = udpPort;
                }
                else
                {
                    _instance.UdpPort = 0;
                }

                int tcpPort;
                Int32.TryParse(txtTcpPort.Text, out tcpPort);
                _instance.TcpPort = tcpPort;

                _instance.UpdateInstanceOnServer(_server, this.SetStatusLabel);

                if (isNewInstance == true)
                {
                    if (MessageBox.Show("Would you like to start the new instance now?", "Start Service?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        string userName = null;
                        string password = null;

                        if (_server.UseImpersonation == true)
                        {
                            userName = _server.UserName;
                            password = Encryption.Decrypt(_server.Password);
                        }

                        SetStatusLabel("Starting service.");
                        Cursor.Current = Cursors.WaitCursor;
                        try
                        {
                            WmiService.Start(_server.ServerName, userName, password, _instance.ServiceName);
                        }
                        finally
                        {
                            SetStatusLabel("Service started.");
                            Cursor.Current = Cursors.Default;
                        }
                    }
                }

                btnApply.Enabled = false;

                SetStatusLabel("Updating cofiguration file.");

                ServerConfiguration.Save(Configuration.Default.LastConfigFile);

                SetStatusLabel("Refreshing UI.");

                if (Save != null)
                    Save(this, EventArgs.Empty);
            }
            finally
            {
                //if (impersonateUser != null && impersonateUser.IsImpersonating == true)
                //    impersonateUser.Undo();

                Cursor = Cursors.Default;
                SetStatusLabel("Ready.");
            }
        }
예제 #8
0
        private void SaveChanges()
        {
            if (chkUseSpecificIPAddress.Checked == true && IsIpAddressValid() == false)
            {
                MessageBox.Show("IP address specified is not a legal IP address.");
                return;
            }

            //if (VerifyFieldValues() == false)
            //{
            //    MessageBox.Show("IP address specified is not a legal IP address.");
            //    return;
            //}

            if (AreIpAndTcpAndUdpPortUniqueForInstance() == false)
            {
                MessageBox.Show("You must specify a unique TCP/IP IP address and port combination.", "IP address or port duplication error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (IsInstanceNameUnique() == false)
            {
                MessageBox.Show("Instance name is not unique.");
                return;
            }

            Cursor = Cursors.WaitCursor;
            SetStatusLabel("Saving.");

            //ImpersonateUser impersonateUser = null;

            try
            {
                //if (_server.UseImpersonation == true)
                //{
                //    SetStatusLabel("Saving: Setting up impersonation.");
                //    impersonateUser = new ImpersonateUser(_server.UserName, Encryption.Decrypt(_server.Password));
                //}

                //
                //string networkPath = null;
                //try
                //{
                //    networkPath = "\\\\" + _server.ServerName + "\\c$";
                //    Directory.GetDirectories(networkPath);
                //}
                //catch (Exception ex)
                //{
                //    MessageBox.Show("Couldn't establish connection on network path: " + networkPath + "\n\n" + ex.Message);
                //    return;
                //}

                bool isNewInstance = false;

                try
                {
                    if (_instance == null)
                    {
                        string nextInstanceServiceName = GetNextMemcachedInstanceName();

                        _instance = new MemCacheDManager.Business.Instance();

                        _instance.ServiceName   = nextInstanceServiceName;
                        _instance.ImageBasePath = _server.BinaryPath;

                        _server.Instances.Add(_instance);

                        isNewInstance = true;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Couldn't get a list of instances on this server. Please check server connectivity and user credentials and try again.\n" + ex.Message, "Error.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // TODO: Add rest of fields here.
                _instance.DisplayName = txtInstanceName.Text;

                decimal chunkSizeGrowthFactor = 0;
                string  chunkSizeString       = ConvertDecimalUserInputToLocalizedString(txtChunkSizeGrowthFactor.Text);
                if (Decimal.TryParse(chunkSizeString, out chunkSizeGrowthFactor) == true)
                {
                    _instance.ChunkSizeGrowthFactor = chunkSizeGrowthFactor;
                }

                int defaultKeySize = 0;
                if (Int32.TryParse(txtDefaultKeySize.Text, out defaultKeySize) == true)
                {
                    _instance.DefaultKeySize = defaultKeySize;
                }


                _instance.MaximizeCoreFile = chkMaximizeCoreFile.Checked;

                int maximumConnections = 0;
                if (Int32.TryParse(txtMaximumConnections.Text, out maximumConnections) == true)
                {
                    _instance.MaximumConnections = maximumConnections;
                }

                int memoryLimit = 0;
                if (Int32.TryParse(txtMemoryLimit.Text, out memoryLimit) == true)
                {
                    _instance.MemoryLimit = memoryLimit;
                }

                _instance.UseManagedInstance = chkUseManagedInstance.Checked;

                if (chkUseSpecificIPAddress.Checked == true)
                {
                    _instance.IpAddress = txtIpAddress.Text;
                }
                else
                {
                    _instance.IpAddress = null;
                }

                if (chkUseUDP.Checked == true)
                {
                    int udpPort = 0;
                    if (Int32.TryParse(txtUdpPort.Text, out udpPort) == true)
                    {
                        _instance.UdpPort = udpPort;
                    }
                }
                else
                {
                    _instance.UdpPort = 0;
                }

                int tcpPort;
                Int32.TryParse(txtTcpPort.Text, out tcpPort);
                _instance.TcpPort = tcpPort;

                _instance.UpdateInstanceOnServer(_server, this.SetStatusLabel);

                if (isNewInstance == true)
                {
                    if (MessageBox.Show("Would you like to start the new instance now?", "Start Service?", MessageBoxButtons.YesNo) == DialogResult.Yes)
                    {
                        string userName = null;
                        string password = null;

                        if (_server.UseImpersonation == true)
                        {
                            userName = _server.UserName;
                            password = Encryption.Decrypt(_server.Password);
                        }

                        SetStatusLabel("Starting service.");
                        Cursor.Current = Cursors.WaitCursor;
                        try
                        {
                            WmiService.Start(_server.ServerName, userName, password, _instance.ServiceName);
                        }
                        finally
                        {
                            SetStatusLabel("Service started.");
                            Cursor.Current = Cursors.Default;
                        }
                    }
                }

                btnApply.Enabled = false;

                SetStatusLabel("Updating cofiguration file.");

                ServerConfiguration.Save(Configuration.Default.LastConfigFile);

                SetStatusLabel("Refreshing UI.");

                if (Save != null)
                {
                    Save(this, EventArgs.Empty);
                }
            }
            finally
            {
                //if (impersonateUser != null && impersonateUser.IsImpersonating == true)
                //    impersonateUser.Undo();

                Cursor = Cursors.Default;
                SetStatusLabel("Ready.");
            }
        }
예제 #9
0
 private void EditInstance(Business.Instance instance)
 {
     TryToChangeView(instance, (Business.Server)tvManager.SelectedNode.Parent.Tag, _instanceDetails);
 }