Exemplo n.º 1
0
        public void LoadGroups(EnterpriseScenarioContract contract)
        {
            _groups = contract.UserGroups;

            using (EnterpriseTestContext context = new EnterpriseTestContext())
            {
                editorGroups_CheckedListBox.Items.Clear();
                foreach (UserGroup group in context.UserGroups.OrderBy(x => x.GroupName))
                {
                    editorGroups_CheckedListBox.Items.Add(group);
                }
            }

            var listBoxItems  = editorGroups_CheckedListBox.Items.Cast <UserGroup>().Select(x => x.GroupName).ToList();
            var missingGroups = _groups.Where(x => !listBoxItems.Contains(x)).ToList();

            foreach (var group in missingGroups)
            {
                _groups.Remove(group);
            }

            foreach (var groupName in listBoxItems)
            {
                if (_groups.Contains(groupName))
                {
                    int index = listBoxItems.IndexOf(groupName);
                    editorGroups_CheckedListBox.SetItemCheckState(index, CheckState.Checked);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Loads the TestDocumentContract list from the specified EnterpriseScenarioContract.
        /// </summary>
        /// <param name="contract"></param>
        public void LoadContract(EnterpriseScenarioContract contract)
        {
            _data = new SortableBindingList <TestDocumentContract>(contract.TestDocuments.Where(x => x.ResolutionRequired).ToList());

            resolveDataGridView.DataSource = null;
            resolveDataGridView.DataSource = _data;
        }
        public void UpdateContractData(EnterpriseScenarioContract contract)
        {
            scenarioNameTextBox.DataBindings.Clear();
            descriptionTextBox.DataBindings.Clear();

            _contract = contract;

            scenarioNameTextBox.Text = contract.Name;
            descriptionTextBox.Text  = contract.Description;

            scenarioNameTextBox.DataBindings.Add("Text", _contract, "Name");
            descriptionTextBox.DataBindings.Add("Text", _contract, "Description");
        }
        /// <summary>
        /// Creates the folders within a scenario during import
        /// </summary>
        /// <param name="contract">The contract.</param>
        /// <param name="scenario">The scenario.</param>
        /// <param name="context">The context.</param>
        /// <param name="importMaps">The import maps.</param>
        private void CreateFolders(EnterpriseScenarioContract contract, EnterpriseScenario scenario, EnterpriseTestContext context, List <ContractFactory.ImportMap> importMaps)
        {
            try
            {
                foreach (var folder in contract.Folders)
                {
                    // create the folder with parent defaulted to scenario
                    var newFolderEntity = ConfigurationTreeFolder.CreateConfigurationTreeFolder(SequentialGuid.NewGuid(), folder.Name, folder.FolderType);
                    newFolderEntity.ParentId = scenario.EnterpriseScenarioId;
                    context.AddToConfigurationTreeFolders(newFolderEntity);

                    // set children for folder based on import mapping
                    var childMaps = (from c in folder.ChildIds
                                     join i in importMaps on c equals i.OldId
                                     select i);

                    if (childMaps.Any())
                    {
                        newFolderEntity.ParentId = childMaps.First().NewParentId;

                        switch (folder.FolderType)
                        {
                        case "ResourceFolder":
                            var vr = (from e in scenario.VirtualResources
                                      join c in childMaps on e.VirtualResourceId equals c.NewId
                                      select e).ToList();
                            vr.ForEach(x => x.FolderId = newFolderEntity.ConfigurationTreeFolderId);
                            break;

                        case "MetadataFolder":
                            var md = (from e in scenario.VirtualResources.SelectMany(x => x.VirtualResourceMetadataSet)
                                      join c in childMaps on e.VirtualResourceMetadataId equals c.NewId
                                      select e).ToList();
                            md.ForEach(x => x.FolderId = newFolderEntity.ConfigurationTreeFolderId);
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                TraceFactory.Logger.Error("Error creating folders within scenario", ex);
            }
        }
Exemplo n.º 5
0
 public void LoadContract(EnterpriseScenarioContract contract)
 {
 }
        private void ProcessNext(WizardPage page)
        {
            if (page == welcomeWizardPage)
            {
                try
                {
                    using (new BusyCursor())
                    {
                        if (string.IsNullOrEmpty(_welcomeControl.ImportFile))
                        {
                            MessageBox.Show("Select an import file before continuing");
                            return;
                        }

                        if (_welcomeControl.IsFileReloaded)
                        {
                            var fileData = XElement.Parse(File.ReadAllText(_welcomeControl.ImportFile));

                            // Reset key components that are currently persisting information from a
                            // possible prior import file.
                            _finalScenarioEntity = null;
                            _platformsControl.Reset();
                            _assetPoolControl.Reset();
                            _assetPoolFirstPass  = true;
                            _platformFirstPass   = true;
                            _displayPlatformPage = false;

                            // If this is a composite contract file it may contain printer and document
                            // information in addition to the base scenario data.
                            if (fileData.Name.LocalName == "Composite")
                            {
                                _compositeContract = Serializer.Deserialize <EnterpriseScenarioCompositeContract>(fileData);
                                _scenarioContract  = _compositeContract.Scenario;

                                // Swap the OfficeWorker and SolutionTester as needed so that the import process is targeting the
                                // right virtual resource.
                                if (GlobalSettings.IsDistributedSystem)
                                {
                                    foreach (var resource in _scenarioContract.ResourceDetails.Where(x => x.ResourceType == VirtualResourceType.SolutionTester))
                                    {
                                        resource.ResourceType = VirtualResourceType.OfficeWorker;
                                    }
                                }
                                else
                                {
                                    foreach (var resource in _scenarioContract.ResourceDetails.Where(x => x.ResourceType == VirtualResourceType.OfficeWorker))
                                    {
                                        resource.ResourceType = VirtualResourceType.SolutionTester;
                                    }
                                }

                                if (!ImportExportUtil.ProcessCompositeContractFile(_compositeContract))
                                {
                                    return;
                                }
                            }
                            else
                            {
                                _scenarioContract = Serializer.Deserialize <EnterpriseScenarioContract>(fileData);
                            }

                            EvaluateUsageAgents();

                            var invalidTypes = _scenarioContract.InvalidResourceTypes;
                            if (invalidTypes.Count > 0)
                            {
                                string types = string.Join(", ", invalidTypes.ToArray());
                                var    msg   = "The following resource types are not supported on this system ({0}).  They will be skipped and not imported.  Do you want to continue?"
                                               .FormatWith(types);
                                var result = MessageBox.Show(msg, "Invalid Resource Types", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
                                if (result == DialogResult.No)
                                {
                                    return;
                                }
                            }

                            _scenarioContract.ScanTestDocuments();

                            _resolutionControl.LoadContract(_scenarioContract);
                            _documentControl.LoadContract(_scenarioContract);
                            _masterCompositeControl.UpdateContractData(_scenarioContract);
                        }

                        // Determine the next stop when moving forward
                        if (AssetPoolResolutionRequired())
                        {
                            return;
                        }
                        if (ResourceResolutionRequired())
                        {
                            return;
                        }
                        if (DocumentResolutionRequired())
                        {
                            return;
                        }
                        if (PlatformResolutionRequired())
                        {
                            return;
                        }
                        if (UserGroupResolutionRequired())
                        {
                            return;
                        }
                        GotoCompletionPage();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("There was an error loading and configuring the Import File.  Check with your application administrator to solve the problem.  Error: {0}".FormatWith(ex.Message)
                                    , "Unable to Read Data File", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    TraceFactory.Logger.Error(ex);
                    return;
                }
            }
            else if (page == assetPoolWizardPage)
            {
                EvaluateUsageAgents();

                // Determine the next stop when moving forward
                if (ResourceResolutionRequired())
                {
                    return;
                }
                if (DocumentResolutionRequired())
                {
                    return;
                }
                if (PlatformResolutionRequired())
                {
                    return;
                }
                if (UserGroupResolutionRequired())
                {
                    return;
                }
                GotoCompletionPage();
            }
            else if (page == resolutionWizardPage)
            {
                // Determine the next stop when moving forward
                if (DocumentResolutionRequired())
                {
                    return;
                }
                if (PlatformResolutionRequired())
                {
                    return;
                }
                if (UserGroupResolutionRequired())
                {
                    return;
                }
                GotoCompletionPage();
            }
            else if (page == documentWizardPage)
            {
                // Determine the next stop when moving forward
                if (PlatformResolutionRequired())
                {
                    return;
                }
                if (UserGroupResolutionRequired())
                {
                    return;
                }
                GotoCompletionPage();
            }
            else if (page == platformWizardPage)
            {
                // Only place left to go is the completion page
                if (UserGroupResolutionRequired())
                {
                    return;
                }
                GotoCompletionPage();
            }
            else if (page == groupWizardPage)
            {
                GotoCompletionPage();
            }
        }