/// <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);
        }
예제 #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);
        }