/// <summary>
        /// Performs final validation before allowing the user to navigate away from the page.
        /// </summary>
        /// <returns>
        /// True if this page was successfully validated.
        /// </returns>
        public virtual bool Complete()
        {
            Guid scenarioId = Ticket.ScenarioIds.FirstOrDefault();

            if (!ValidateInput(scenarioId))
            {
                return(false);
            }

            // STE-only
            if (GlobalSettings.IsDistributedSystem)
            {
                PopulateSelectedVMs();
            }

            using (EnterpriseTestContext context = new EnterpriseTestContext())
            {
                // Perform a data integrity check on the scenario
                if (PerformDataIntegrityCheck(context, scenarioId) == false)
                {
                    Cancel?.Invoke(this, EventArgs.Empty);
                    return(false);
                }

                PopulateNotificationSettings();

                SetAssociatedProducts();

                // Populate ticket data from the UI
                Ticket.CollectEventLogs = eventLog_CheckBox.Checked;
                Ticket.SessionName      = string.IsNullOrEmpty(sessionName_ComboBox.Text) ? selectedScenario_TextBox.Text : sessionName_ComboBox.Text;
                Ticket.SessionType      = sessionType_ComboBox.Text;
                Ticket.SessionCycle     = sessionCycle_ComboBox.Text;
                Ticket.Reference        = WizardPageManager.GetReferenceData(reference_TextBox);
                Ticket.SessionNotes     = notes_TextBox.Text;
                Ticket.DurationHours    = (int)runtime_NumericUpDown.Value;
                SessionLogRetention selected = EnumUtil.GetByDescription <SessionLogRetention>((string)retention_ComboBox.SelectedItem);
                Ticket.ExpirationDate            = selected.GetExpirationDate(DateTime.Now);
                Ticket.LogLocation               = logLocation_TextBox.Text;
                Ticket.RemoveUnresponsiveDevices = deviceOffline_CheckBox.Checked;

                // Save session name and selected VMs
                SaveSessionName(context, scenarioId);
                context.SaveChanges();
            }

            // Save selected scenario to settings so it can be selected next time
            Properties.Settings.Default.LastExecutedScenario = scenarioId;
            Properties.Settings.Default.Save();

            // Initiate the session with the dispatcher
            TraceFactory.Logger.Debug("Calling Initiate() on {0}".FormatWith(Ticket.SessionId));
            SessionClient.Instance.InitiateSession(Ticket);

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Performs final validation before allowing the user to navigate away from the page.
        /// </summary>
        /// <returns>
        /// True if this page was successfully validated.
        /// </returns>
        public bool Complete()
        {
            if (!ValidateInput())
            {
                return(false);
            }

            // We're gonna need a data context several times in the following lines
            using (EnterpriseTestContext context = new EnterpriseTestContext())
            {
                List <EnterpriseScenario> scenarios = EnterpriseScenario.Select(context, Ticket.ScenarioIds).ToList();

                // Perform a data integrity check on the scenarios
                if (PerformDataIntegrityCheck(scenarios) == false)
                {
                    return(false);
                }

                //PopulateNotificationSettings() TODO: What about the email list?  The ticket has an email list.  Can we repurpose it for batch operations?

                // Populate ticket data from the UI
                Ticket.ScenarioIds      = GetSelectedScenarioIds();
                Ticket.CollectEventLogs = false;
                Ticket.SessionName      = sessionName_ComboBox.Text;
                Ticket.SessionType      = sessionType_ComboBox.Text;
                Ticket.SessionCycle     = sessionCycle_ComboBox.Text;
                Ticket.Reference        = WizardPageManager.GetReferenceData(reference_TextBox);
                Ticket.SessionNotes     = notes_TextBox.Text;
                Ticket.DurationHours    = (int)runtime_NumericUpDown.Value;
                SessionLogRetention logRetention = EnumUtil.GetByDescription <SessionLogRetention>((string)retention_ComboBox.SelectedItem);
                Ticket.ExpirationDate = logRetention.GetExpirationDate(DateTime.Now);
                Ticket.LogLocation    = GlobalSettings.WcfHosts[WcfService.DataLog];

                SetAssociatedProducts(context, scenarios);

                // Doesn't make sense to save session name for batch operation.
                context.SaveChanges();
            }

            // Initiate the session with the dispatcher
            TraceFactory.Logger.Debug($"Calling Initiate() on {Ticket.SessionId}");
            SessionClient.Instance.InitiateSession(Ticket);

            return(true);
        }
        private void ExecuteSTF(string scenario, string holdId)
        {
            WriteLine("Starting session...");

            _ticket = SessionTicket.Create(scenario);
            _ticket.SessionOwner = new UserCredential(UserManager.CurrentUser, UserManager.CurrentUserCredential.Password,
                                                      UserManager.CurrentUserCredential.Domain)
            {
                Role = UserManager.CurrentUserRole
            };
            if (!string.IsNullOrEmpty(holdId))
            {
                _ticket.RequestedVMs.Add("BY_HOLDID", (from vm in SelectMachinesByHoldId(holdId) select vm.Name).ToList());
            }

            _ticket.ExpirationDate = _sessionRetention.GetExpirationDate(DateTime.Now);
            WriteLine("Created ticket {0}".FormatWith(_ticket.SessionId));
            _scenarioList.ElementAt(_currentScenarioIndex).SessionId = _ticket.SessionId;
            _startTime = DateTime.Now;
            LogSessionExecution();
            WriteLine("Initializing");
            SessionClient.Instance.Initialize(_currentDispatcher);
            SessionClient.Instance.InitiateSession(_ticket);

            UpdateStatus("Initialized");
            var assetDetails = SessionClient.Instance.Reserve(_ticket.SessionId);

            WriteLine("Reserved...{0}".FormatWith(_ticket.SessionId));
            UpdateStatus("Reserved");
            foreach (var asset in assetDetails.Where(x => x.Availability == AssetAvailability.NotAvailable))
            {
                WriteLine("Unavailable: {0}".FormatWith(asset.AssetId));
            }

            // This call to Stage() will kick off the process and as each event arrives to indicate
            // a step in the process has completed, the next step will automatically continue.
            SessionClient.Instance.Stage(_ticket.SessionId, assetDetails);
            WriteLine("Staged...{0}".FormatWith(_ticket.SessionId));
            UpdateStatus("Staged");
        }
Exemple #4
0
        private void extendToolStripButton_Click(object sender, EventArgs e)
        {
            string result = InputDialog.Show("Select expiration extension for this Session.",
                                             "Extend Expiration",
                                             EnumUtil.GetDescription(GetDefaultLogRetention()),
                                             SessionLogRetentionHelper.ExpirationList);

            if (!string.IsNullOrEmpty(result))
            {
                SessionLogRetention extension = EnumUtil.GetByDescription <SessionLogRetention>(result);

                using (DataLogContext context = DbConnect.DataLogContext())
                {
                    SessionSummary session = context.DbSessions.FirstOrDefault(s => s.SessionId == SelectedSessionId);
                    if (session != null)
                    {
                        session.ExpirationDateTime = extension.GetExpirationDate(session.ExpirationDateTime.Value);
                    }
                    context.SaveChanges();
                }

                RefreshGrid();
            }
        }