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