Ejemplo n.º 1
0
        private void ReleaseSessions()
        {
            // Get the session Ids from the selected rows.
            var releaseableSessions = GetReleasableSessions(vm_GridView.SelectedRows);
            var sessionIds          = releaseableSessions.Select(x => x.SessionId).Distinct().ToList();

            string msg = "This will abort the selected sessions (if they are currently running) and release all machines and other assets used in this test.  Are you sure you want to release the following Sessions?"
                         + Environment.NewLine + string.Join(Environment.NewLine, sessionIds.ToArray());
            var result = MessageBox.Show(msg, "Release Session Resources", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            if (STFDispatcherManager.Dispatcher == null && STFDispatcherManager.ConnectToDispatcher() == false)
            {
                //The user canceled the connect dialog
                return;
            }

            SessionResetManager resetManager = new SessionResetManager();

            ReleaseSession(resetManager, sessionIds);
        }
Ejemplo n.º 2
0
        private void releaseSession_ToolStripButton_Click(object sender, EventArgs e)
        {
            _selectedSessionCell = SelectedSession;
            var sessionId = _selectedSessionCell.Value.ToString();

            if (!GlobalSettings.IsDistributedSystem)
            {
                if (sessionData_GridView.SelectedRows[0].Cells[12].Value.ToString() != Environment.MachineName.ToUpper())
                {
                    var message = MessageBox.Show($"You are trying to release a session which was run on client machine -' { sessionData_GridView.SelectedRows[0].Cells[12].Value} ' . This will not close the Virtual worker console on that client.  Do you want to continue?", "Release Session", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (message == System.Windows.Forms.DialogResult.No)
                    {
                        return;
                    }
                }
            }

            string msg    = "This will abort the session (if it is currently running) and release all machines and other assets used in this test.  Are you sure you want to release this Session?";
            var    result = MessageBox.Show(msg, "Reset Session", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);

            if (result == System.Windows.Forms.DialogResult.No)
            {
                return;
            }

            if (!string.IsNullOrEmpty(sessionId))
            {
                _sessionResetting = sessionId;

                if (STFDispatcherManager.Dispatcher == null && STFDispatcherManager.ConnectToDispatcher() == false)
                {
                    //The user canceled the connect dialog
                    return;
                }

                // For STE, require that shutdown requester be authorized
                SessionResetManager resetManager = new SessionResetManager();
                if (GlobalSettings.IsDistributedSystem)
                {
                    if (!resetManager.IsAuthorized(sessionId))
                    {
                        return;
                    }
                }

                using (SessionShutdownForm form = new SessionShutdownForm(sessionId))
                {
                    if (form.ShowDialog(this) == DialogResult.OK)
                    {
                        resetManager.LogSessionReset(sessionId);
                        SetControls(true);
                        SessionClient.Instance.ClearSessionRequestReceived += controller_SessionResetComplete;
                        SessionClient.Instance.SetUserCredential(UserManager.CurrentUser);
                        SessionClient.Instance.Close(sessionId, form.ShutdownOptions);
                    }
                }

                statusLabel.Text = "Releasing session {0} and cleaning up associated virtual machines and resources...".FormatWith(sessionId);
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Ensures the dispatcher is connected.
 /// If not connected, attempts to connect.
 /// </summary>
 /// <returns><c>true</c> if dispatcher is connected, <c>false</c> otherwise.</returns>
 public bool EnsureDispatcherConnected()
 {
     if (!STFDispatcherManager.Connected)
     {
         STFDispatcherManager.ConnectToDispatcher();
     }
     return(STFDispatcherManager.Connected);
 }
        /// <summary>
        /// Initializes the wizard page with the specified <see cref="WizardConfiguration"/>.
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        public virtual bool Initialize(WizardConfiguration configuration)
        {
            Ticket = configuration.Ticket;
            Guid scenarioId = Ticket.ScenarioIds.FirstOrDefault();

            if (STFDispatcherManager.Dispatcher == null && STFDispatcherManager.ConnectToDispatcher() == false)
            {
                //The user canceled the connect dialog
                return(false);
            }

            using (EnterpriseTestContext context = new EnterpriseTestContext())
            {
                // Load the specified scenario (if there is one)
                if (scenarioId != Guid.Empty)
                {
                    LoadScenario(scenarioId, context);
                    LoadComboBoxes(context);
                }
            }

            // If this is not the first time we have entered this step, the user
            // must have come back from some point later in the wizard.
            // Make sure the dispatcher doesn't hang onto configuration from the previous try.
            if (!_initial)
            {
                SessionClient.Instance.Close(Ticket.SessionId);
            }

            if (_scenario != null && Ticket.SessionId != null && Ticket.AssociatedProductList.Count != 0)
            {
                foreach (var item in Ticket.AssociatedProductList)
                {
                    _scenarioProducts.Where(n => n.ProductId == item.AssociatedProductId && n.Vendor == item.Vendor && n.Version == item.Version).FirstOrDefault().Active = item.Active;
                }
                scenarioProductBindingSource.Clear();
                scenarioProductBindingSource.DataSource = _scenarioProducts;
                scenarioProductBindingSource.ResetBindings(true);
            }
            deviceOffline_CheckBox.Checked = Ticket.RemoveUnresponsiveDevices;

            environment_Label.Text = "{0} {1} Environment".FormatWith(GlobalSettings.Items[Setting.Organization], GlobalSettings.Items[Setting.Environment]);

            if (string.IsNullOrEmpty(logLocation_TextBox.Text))
            {
                logLocation_TextBox.Text = GlobalSettings.WcfHosts[WcfService.DataLog];
            }
            _initial = false;

            dispatcher_Label.Text = STFDispatcherManager.Dispatcher.HostName;

            if (!GlobalSettings.IsDistributedSystem)
            {
                this.settings_TabControl.TabPages.Remove(this.virtualMachineSelection_TabPage);
            }

            return(true);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes the wizard page with the specified <see cref="WizardConfiguration"/>.
        /// </summary>
        /// <param name="configuration">The <see cref="WizardConfiguration"/>.</param>
        public bool Initialize(WizardConfiguration configuration)
        {
            Ticket     = configuration.Ticket;
            _scenarios = new BindingList <ScenarioSelectionItem>();
            scenarios_DataGridView.DataSource = null;

            if (STFDispatcherManager.Dispatcher == null && STFDispatcherManager.ConnectToDispatcher() == false)
            {
                //The user canceled the connect dialog
                return(false);
            }

            using (new BusyCursor())
            {
                using (EnterpriseTestContext context = new EnterpriseTestContext())
                {
                    foreach (EnterpriseScenario scenario in EnterpriseScenario.Select(context, Ticket.ScenarioIds))
                    {
                        _scenarios.Add(new ScenarioSelectionItem(scenario));
                    }

                    LoadComboBoxes(context);
                }

                _bindingSource = new BindingSource(_scenarios, string.Empty);
                scenarios_DataGridView.DataSource = _bindingSource;
            }

            //Set data from Ticket
            if (Ticket.SessionId != null)
            {
                SetEstimatedRunTime();
                sessionName_ComboBox.Text = string.IsNullOrEmpty(Ticket.SessionName) ? "Multiple Scenarios" : Ticket.SessionName;
            }

            if (!_initial)
            {
                SessionClient.Instance.Close(Ticket.SessionId);

                sessionType_ComboBox.SelectedText = Ticket.SessionType;

                if (!string.IsNullOrEmpty(Ticket.EmailAddresses))
                {
                    runtime_NumericUpDown.Value = Math.Min(Ticket.DurationHours, runtime_NumericUpDown.Maximum);
                }
            }

            environment_Label.Text = "{0} {1} Environment".FormatWith(GlobalSettings.Items[Setting.Organization], GlobalSettings.Items[Setting.Environment]);
            dispatcher_Label.Text  = STFDispatcherManager.Dispatcher.HostName;
            _initial = false;

            return(true);
        }
Ejemplo n.º 6
0
 private void connectDispatcher_ToolStripButton_Click(object sender, EventArgs e)
 {
     Cursor.Current = Cursors.WaitCursor;
     try
     {
         STFDispatcherManager.ConnectToDispatcher();
     }
     finally
     {
         Cursor.Current = Cursors.Default;
     }
 }
Ejemplo n.º 7
0
 private void ConnectToDispatcher()
 {
     if (string.IsNullOrEmpty(STFLoginManager.SystemDatabase))
     {
         if (STFLoginManager.Login())
         {
             _currentDatabase = STFLoginManager.SystemDatabase;
         }
         else
         {
             return;
         }
     }
     if (STFDispatcherManager.ConnectToDispatcher())
     {
         _currentDispatcher = STFDispatcherManager.Dispatcher.HostName;
     }
 }