예제 #1
0
        /// <summary>
        /// Performs a connection test to the remote host as well as validating the right permissions are set for the credentials provided by the user.
        /// </summary>
        /// <param name="forceTest">Indicates whether the test is performed regardless of the current status of the machine.</param>
        /// <returns>True if no problems were found during the test.</returns>
        private bool TestConnectionAndPermissionsSet(bool forceTest)
        {
            if (!EntriesAreValid)
            {
                return(false);
            }

            if (forceTest || !NewMachine.IsOnline)
            {
                NewMachine.TestConnection(true, false);
            }

            return(NewMachine.IsOnline);
        }
예제 #2
0
        /// <summary>
        /// Event delegate method fired when the <see cref="MachineSelectionComboBox"/> selected index changes.
        /// </summary>
        /// <param name="sender">Sender object.</param>
        /// <param name="e">Event arguments.</param>
        private void MachineSelectionComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            EditButton.Enabled   = MachineSelectionComboBox.SelectedIndex > 2;
            DeleteButton.Enabled = MachineSelectionComboBox.SelectedIndex > 2;
            switch (MachineSelectionComboBox.SelectedIndex)
            {
            case 0:
                MachineLocationType = Machine.LocationType.Local;
                if (MachineSelectionComboBox.SelectedItem is Machine)
                {
                    NewMachine = MachineSelectionComboBox.SelectedItem as Machine;
                }
                else
                {
                    NewMachine = MachinesList.LocalMachine;
                    MachineSelectionComboBox.Items[0] = NewMachine;
                }
                break;

            case 1:
                MachineLocationType = Machine.LocationType.Remote;
                using (var windowsConnectionDialog = new WindowsConnectionDialog(MachinesList, null))
                {
                    if (windowsConnectionDialog.ShowDialog() == DialogResult.Cancel)
                    {
                        MachineSelectionComboBox.SelectedIndex = 0;
                    }
                    else
                    {
                        NewMachine = windowsConnectionDialog.NewMachine;
                        NewMachine.LoadServicesParameters(false);
                        int index = -1;
                        for (int machineIndex = 3; machineIndex < MachineSelectionComboBox.Items.Count && index < 0; machineIndex++)
                        {
                            string machineName = MachineSelectionComboBox.Items[machineIndex].ToString();
                            if (machineName == NewMachine.Name)
                            {
                                index = machineIndex;
                            }
                        }

                        if (index == -1)
                        {
                            MachineSelectionComboBox.Items.Add(NewMachine);
                            MachineSelectionComboBox.SelectedIndex = MachineSelectionComboBox.Items.Count - 1;
                        }
                        else
                        {
                            MachineSelectionComboBox.SelectedIndex = index <= 0 ? 0 : index;
                        }
                    }
                }
                return;

            case 2:
                if (NewMachine.IsLocal)
                {
                    MachineSelectionComboBox.SelectedIndex = 0;
                    return;
                }

                int mIndex = -1;
                for (int machineIndex = 3; machineIndex < MachineSelectionComboBox.Items.Count; machineIndex++)
                {
                    string machineName = MachineSelectionComboBox.Items[machineIndex].ToString();
                    if (machineName == NewMachine.Name)
                    {
                        mIndex = machineIndex;
                        break;
                    }
                }

                MachineSelectionComboBox.SelectedIndex = mIndex < 0 ? 0 : mIndex;
                return;

            default:
                MachineLocationType = Machine.LocationType.Remote;
                NewMachine          = (Machine)MachineSelectionComboBox.SelectedItem;
                if (!NewMachine.IsOnline)
                {
                    var infoProperties = InfoDialogProperties.GetYesNoDialogProperties(
                        InfoDialog.InfoType.Warning,
                        Resources.MachineUnavailableTitle,
                        Resources.MachineUnavailableYesNoDetail,
                        null,
                        Resources.MachineUnavailableExtendedMessage);
                    infoProperties.CommandAreaProperties.DefaultButton        = InfoDialog.DefaultButtonType.Button2;
                    infoProperties.CommandAreaProperties.DefaultButtonTimeout = 30;
                    var infoResult = InfoDialog.ShowDialog(infoProperties);
                    if (infoResult.DialogResult == DialogResult.Yes)
                    {
                        NewMachine.TestConnection(true, false);
                    }

                    if (!NewMachine.IsOnline)
                    {
                        ServicesListView.SelectedItems.Clear();
                    }
                }
                break;
            }

            ServicesListView.Enabled = NewMachine.IsOnline;
            Machine servicesMachine = ServicesListView.Tag as Machine;

            if (servicesMachine != NewMachine)
            {
                RefreshList();
            }
        }