コード例 #1
0
        /// <summary>
        /// Saves documents from the specified composite contract to the Document Library.
        /// </summary>
        /// <param name="composite">The EnterpriseScenarioCompositeContract.</param>
        /// <returns>true if the operation completed successfully.</returns>
        public static bool ProcessCompositeContractFile(EnterpriseScenarioCompositeContract composite)
        {
            using (DocumentLibraryContext context = DbConnect.DocumentLibraryContext())
            {
                bool changesMade = false;

                foreach (DocumentContract documentContract in composite.Documents)
                {
                    if (CanInsertDocument(documentContract, context))
                    {
                        TestDocument documentEntity = ContractFactory.Create(context, documentContract);
                        WriteDocumentToServer(documentEntity, GlobalSettings.Items[Setting.DocumentLibraryServer], documentContract.Data);
                        context.TestDocuments.Add(documentEntity);
                        changesMade = true;
                    }
                }

                if (changesMade)
                {
                    context.SaveChanges();
                }
            }

            return(true);
        }
コード例 #2
0
        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();
            }
        }