/// <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);
        }
Ejemplo n.º 2
0
        private bool PerformDataIntegrityCheck(List <EnterpriseScenario> scenarios)
        {
            bool result = true;

            foreach (EnterpriseScenario scenario in scenarios)
            {
                result = result && WizardPageManager.PerformScenarioIntegrityCheck(scenario);
            }

            return(result);
        }
        private bool PerformDataIntegrityCheck(EnterpriseTestContext context, Guid scenarioId)
        {
            EnterpriseScenario scenario = EnterpriseScenario.Select(context, scenarioId);

            if (platform_RadioButton.Checked)
            {
                return(WizardPageManager.PerformScenarioIntegrityCheck(scenario, (FrameworkClientPlatform)platform_ComboBox.SelectedItem));
            }
            else if (holdId_RadioButton.Checked)
            {
                return(WizardPageManager.PerformScenarioIntegrityCheck(scenario, (string)holdId_ComboBox.SelectedItem));
            }
            else
            {
                return(WizardPageManager.PerformScenarioIntegrityCheck(scenario));
            }
        }
Ejemplo n.º 4
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 LoadScenario(Guid scenarioId, EnterpriseTestContext context)
        {
            EnterpriseScenario scenario = EnterpriseScenario.Select(context, scenarioId);

            if (scenario != null)
            {
                Ticket.ScenarioIds = new List <Guid>()
                {
                    scenarioId
                };
                _scenario = scenario;
                selectedScenario_TextBox.Text = scenario.Name;

                runtime_NumericUpDown.Value = Math.Min(scenario.EstimatedRuntime, runtime_NumericUpDown.Maximum); //Ensure we don't exceed the NumericUpDown.Maximum.

                //Populate Associated Products
                _scenarioProducts = WizardPageManager.GetAssociatedProducts(context, scenario);
                scenarioProductBindingSource.DataSource = _scenarioProducts;
                scenarioProductBindingSource.ResetBindings(true);
            }
        }
Ejemplo n.º 6
0
        private void SetAssociatedProducts(EnterpriseTestContext context, IEnumerable <EnterpriseScenario> scenarios)
        {
            // We have to track what has already been added to the Ticket.  List of Guids seems the most efficient way,
            // given the fact that the list is potentially growing with each loop.  Array.Contains is faster than List.Contains,
            // but List<> is better suited to the changing collection size.
            List <Guid> added = new List <Guid>();

            Ticket.AssociatedProductList.Clear();

            try
            {
                IEnumerable <ScenarioProduct> scenarioProducts = null;
                foreach (EnterpriseScenario scenario in scenarios)
                {
                    scenarioProducts = WizardPageManager.GetAssociatedProducts(context, scenario);
                    foreach (ScenarioProduct assocProduct in scenarioProducts)
                    {
                        if (!added.Contains(assocProduct.ProductId))
                        {
                            var item = new AssociatedProductSerializable()
                            {
                                AssociatedProductId = assocProduct.ProductId,
                                Vendor  = assocProduct.Vendor,
                                Name    = assocProduct.Name,
                                Version = assocProduct.Version,
                                Active  = assocProduct.Active
                            };
                            Ticket.AssociatedProductList.Add(item);
                            added.Add(assocProduct.ProductId);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error("Error loading Associated Products.", ex);
            }
        }
        private void LoadComboBoxes(EnterpriseTestContext context)
        {
            sessionName_ComboBox.DataSource    = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.SessionName.ToString());
            sessionName_ComboBox.SelectedIndex = -1;
            sessionType_ComboBox.DataSource    = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.SessionType.ToString());
            sessionType_ComboBox.SelectedIndex = -1;
            sessionCycle_ComboBox.DataSource   = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.SessionCycle.ToString());


            retention_ComboBox.DataSource    = SessionLogRetentionHelper.ExpirationList;
            retention_ComboBox.SelectedIndex = retention_ComboBox.FindString(EnumUtil.GetDescription(WizardPageManager.GetDefaultLogRetention()));

            Dictionary <string, int> failureItems = new Dictionary <string, int>();
            List <TimeSpan>          failTimes    = new List <TimeSpan>();

            using (AssetInventoryContext assetContext = DbConnect.AssetInventoryContext())
            {
                string powerState   = EnumUtil.GetDescription(VMPowerState.PoweredOff);
                var    availableVMs = assetContext.FrameworkClients.Where(n => n.PowerState == powerState);

                platform_ComboBox.DataSource = null;
                platform_ComboBox.Items.Clear();
                platform_ComboBox.DisplayMember = "Name";
                platform_ComboBox.ValueMember   = "FrameworkClientPlatformId";
                platform_ComboBox.DataSource    = assetContext.FrameworkClientPlatforms.Where(n => n.Active).OrderBy(n => n.FrameworkClientPlatformId).ToList();

                holdId_ComboBox.DataSource = null;
                holdId_ComboBox.Items.Clear();
                holdId_ComboBox.DataSource = availableVMs.Select(n => n.HoldId).Distinct().Where(n => n != null).ToList();
            }
            failureItems.Add("1 Failure", 1);
            failureItems.Add("2 Failures", 2);
            failureItems.Add("5 Failures", 5);
            failureItems.Add("10 Failures", 10);
            failureItems.Add("15 Failures", 15);
            failureItems.Add("20 Failures", 20);

            threshold_comboBox.DataSource    = new BindingSource(failureItems, null);
            threshold_comboBox.DisplayMember = "Key";
            threshold_comboBox.ValueMember   = "Value";

            failTimes.Add(TimeSpan.FromMinutes(15));
            failTimes.Add(TimeSpan.FromMinutes(30));
            failTimes.Add(TimeSpan.FromHours(1));
            failTimes.Add(TimeSpan.FromHours(2));
            failTimes.Add(TimeSpan.FromHours(6));
            failTimes.Add(TimeSpan.FromHours(12));
            failureTime_comboBox.DataSource = new BindingSource(failTimes, null);


            if (Ticket.SessionId != null && _scenario != null)
            {
                if (!string.IsNullOrEmpty(_scenario.ScenarioSettings))
                {
                    var scenarioSettings = LegacySerializer.DeserializeDataContract <ScenarioSettings>(_scenario.ScenarioSettings);
                    //Populate boxes from selected settings
                    dartLog_CheckBox.Checked           = scenarioSettings.NotificationSettings.CollectDartLogs;
                    email_textBox.Text                 = scenarioSettings.NotificationSettings.Emails;
                    failureTime_comboBox.SelectedIndex = failTimes.FindIndex(x => x == scenarioSettings.NotificationSettings.FailureTime);
                    threshold_comboBox.SelectedIndex   = failureItems.ToList().FindIndex(x => x.Value == scenarioSettings.NotificationSettings.FailureCount);
                    triggerList_TextBox.Lines          = scenarioSettings.NotificationSettings.TriggerList;
                    runtime_NumericUpDown.Value        = Math.Min(scenarioSettings.EstimatedRunTime, runtime_NumericUpDown.Maximum); // scenarioSettings.EstimatedRunTime;
                    logLocation_TextBox.Text           = scenarioSettings.LogLocation;
                    eventLog_CheckBox.Checked          = scenarioSettings.CollectEventLogs;
                }

                sessionName_ComboBox.Text = string.IsNullOrEmpty(Ticket.SessionName) ? _scenario.Name : Ticket.SessionName;
            }

            //TraceFactory.Logger.Debug($"initial:{_initial}");
            if (!_initial)
            {
                sessionType_ComboBox.SelectedText   = Ticket.SessionType;
                sessionCycle_ComboBox.SelectedIndex = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.SessionCycle.ToString()).Select(x => x.Name).ToList().IndexOf(Ticket.SessionCycle);


                //TraceFactory.Logger.Debug($"email:{_ticket.EmailAddresses}");
                if (!string.IsNullOrEmpty(Ticket.EmailAddresses))
                {
                    dartLog_CheckBox.Checked           = Ticket.CollectDARTLogs;
                    email_textBox.Text                 = Ticket.EmailAddresses;
                    failureTime_comboBox.SelectedIndex = failTimes.FindIndex(x => x == Ticket.FailureTime);
                    threshold_comboBox.SelectedIndex   = failureItems.ToList().FindIndex(x => x.Value == Ticket.FailureCount);
                    triggerList_TextBox.Lines          = Ticket.TriggerList;
                    runtime_NumericUpDown.Value        = Math.Min(Ticket.DurationHours, runtime_NumericUpDown.Maximum);
                    eventLog_CheckBox.Checked          = Ticket.CollectEventLogs;
                    email_textBox.Text                 = Ticket.EmailAddresses;
                }
                if (Ticket.FailureTime != TimeSpan.MaxValue)
                {
                    failureTime_comboBox.SelectedIndex = failTimes.FindIndex(x => x == Ticket.FailureTime);
                }
                if (Ticket.FailureCount != -1)
                {
                    threshold_comboBox.SelectedIndex = failureItems.ToList().FindIndex(x => x.Value == Ticket.FailureCount);
                }
                if (!string.IsNullOrEmpty(Ticket.LogLocation))
                {
                    logLocation_TextBox.Text = Ticket.LogLocation;
                }
                if (Ticket.TriggerList != null)
                {
                    triggerList_TextBox.Lines = Ticket.TriggerList;
                }
                dartLog_CheckBox.Checked    = Ticket.CollectDARTLogs;
                eventLog_CheckBox.Checked   = Ticket.CollectEventLogs;
                runtime_NumericUpDown.Value = Math.Min(Ticket.DurationHours, runtime_NumericUpDown.Maximum);
            }
        }
Ejemplo n.º 8
0
        private void LoadComboBoxes(EnterpriseTestContext context)
        {
            sessionName_ComboBox.DataSource    = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.SessionName.ToString());
            sessionName_ComboBox.SelectedIndex = -1;

            sessionType_ComboBox.DataSource    = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.SessionType.ToString());
            sessionType_ComboBox.SelectedIndex = -1;

            sessionCycle_ComboBox.DataSource    = ResourceWindowsCategory.Select(context, ResourceWindowsCategoryType.SessionCycle.ToString());
            sessionCycle_ComboBox.SelectedIndex = sessionCycle_ComboBox.FindString(Ticket.SessionCycle);

            retention_ComboBox.DataSource    = SessionLogRetentionHelper.ExpirationList;
            retention_ComboBox.SelectedIndex = retention_ComboBox.FindString(EnumUtil.GetDescription(WizardPageManager.GetDefaultLogRetention()));
        }