Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ScenarioConfigurationControlForm"/> class.
 /// </summary>
 /// <param name="tag">The tag.</param>
 public ScenarioConfigurationControlForm(ConfigurationObjectTag tag, EnterpriseTestContext context)
     : this()
 {
     _control = ScenarioConfigurationControlFactory.Create(tag, context);
     _control.Initialize(tag);
     scenarioConfigurationControl_Panel.Controls.Add(_control as Control);
     (_control as Control).Dock = DockStyle.Fill;
 }
Example #2
0
        private void scenarioConfigurationTreeView_ConfigurationObjectSelected(object sender, ConfigurationTagEventArgs e)
        {
            _refreshEvent = e;
            this.Cursor   = Cursors.WaitCursor;
            resource_ToolStrip.Visible = false;
            main_StatusLabel.Text      = string.Empty;
            dataEditPanel.SuspendLayout();

            try
            {
                // Remove all controls from the data edit panel
                ClearEditPanel();

                // Load the entity object from the database
                EntityObject entity = _enterpriseTestUIController.GetEntityObject(e.Tag.Id);
                if (entity == null)
                {
                    // This will be caught by the EnterpriseScenarioTreeView as a result of the ConfigurationObjectSelected event.
                    throw new InvalidOperationException("Object does not exist.");
                }
                _currentlyDisplayedItemId = e.Tag.Id;

                try
                {
                    // Create the configuration control and add to the panel
                    IScenarioConfigurationControl control = ScenarioConfigurationControlFactory.Create(e.Tag, _enterpriseTestUIController.Context);

                    if (control != null)
                    {
                        control.Initialize(entity);
                        dataEditPanel.Controls.Add(control as Control);
                        (control as Control).Dock = DockStyle.Fill;

                        // Set the title of this edit form
                        resource_ToolStripLabel.Text = control.EditFormTitle;

                        // Configure and show the tool bar
                        resource_ToolStrip.Visible = !e.Tag.ObjectType.IsFolder();
                        executeScenario_ToolStripButton.Visible = e.Tag.ObjectType == ConfigurationObjectType.EnterpriseScenario;
                        analyze_ToolStripButton.Visible         = e.Tag.ObjectType == ConfigurationObjectType.EnterpriseScenario;
                        executeScenario_ToolStripButton.Enabled = _sessionManager.AbleToStartNewSession;
                    }
                }
                catch (ControlTypeMismatchException ex)
                {
                    MessageBox.Show(ex.Message, "Configuration Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            finally
            {
                dataEditPanel.ResumeLayout();
                this.Cursor = Cursors.Default;
            }
        }
        public static IScenarioConfigurationControl Create(ConfigurationObjectTag tag, EnterpriseTestContext context)
        {
            if (tag == null)
            {
                throw new ArgumentNullException("tag");
            }

            IScenarioConfigurationControl control = null;

            switch (tag.ObjectType)
            {
            case ConfigurationObjectType.EnterpriseScenario:
                control = new EnterpriseScenarioControl();
                break;

            case ConfigurationObjectType.VirtualResource:
                switch (tag.ResourceType)
                {
                case VirtualResourceType.OfficeWorker:
                    control = new OfficeWorkerControl();
                    break;

                case VirtualResourceType.CitrixWorker:
                    control = new CitrixWorkerControl();
                    break;

                case VirtualResourceType.AdminWorker:
                    control = new AdminWorkerControl();
                    break;

                case VirtualResourceType.EventLogCollector:
                    control = new EventLogCollectorControl();
                    break;

                case VirtualResourceType.PerfMonCollector:
                    control = new PerfMonCollectorControl();
                    break;

                case VirtualResourceType.MachineReservation:
                    control = new MachineReservationControl();
                    break;

                case VirtualResourceType.SolutionTester:
                    control = new SolutionTesterControl();
                    break;

                case VirtualResourceType.LoadTester:
                    control = new LoadTesterControl();
                    break;
                }
                break;

            case ConfigurationObjectType.ResourceMetadata:
                switch (tag.ResourceType)
                {
                case VirtualResourceType.OfficeWorker:
                case VirtualResourceType.CitrixWorker:
                case VirtualResourceType.SolutionTester:
                case VirtualResourceType.AdminWorker:
                case VirtualResourceType.LoadTester:
                    control = new WorkerActivityMetadataControl();
                    break;
                }
                break;
            }

            if (control != null)
            {
                control.Context = context;
            }

            return(control);
        }