コード例 #1
0
        /// <summary>
        /// Process an Operation
        /// </summary>
        private void ProcessPreOperations()
        {
            //Process Pre Operations
            // Get the necessary objects.
            var config = SyncServiceFactory.GetService <IConfigurationService>().GetConfiguration(Document);

            testReportOperation = SyncServiceFactory.CreateWord2007TestReportAdapter(Document, config);
            // Create Report helper
            var operation        = config.ConfigurationTest.GetPreOperationsForTestSpecification();
            var testReportHelper = new TestReportHelper(TestAdapter, testReportOperation, config, CancellationPending);

            testReportOperation.PrepareDocumentForLongTermOperation();
            testReportHelper.ProcessOperations(operation);
        }
コード例 #2
0
        /// <summary>
        /// Background method to import the work items from TFS.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">A <see cref="DoWorkEventArgs"/> that contains the event data.</param>
        public void DoImport(object sender, DoWorkEventArgs e)
        {
            SyncServiceTrace.I(Resources.ImportWorkItems);
            var workItemSyncService = SyncServiceFactory.GetService <IWorkItemSyncService>();
            var configService       = SyncServiceFactory.GetService <IConfigurationService>();

            // save query configuration to document
            DocumentModel.SaveQueryConfiguration(_queryConfiguration);
            DocumentModel.Save();

            // set actual selected configuration
            var configuration = configService.GetConfiguration(WordDocument);

            _importTestReport = SyncServiceFactory.CreateWord2007TestReportAdapter(WordDocument, configuration);

            var ignoreFormatting  = configuration.IgnoreFormatting;
            var conflictOverwrite = configuration.ConflictOverwrite;

            configuration.ActivateMapping(DocumentModel.MappingShowName);
            DocumentModel.Configuration.IgnoreFormatting = ignoreFormatting;
            configuration.ConflictOverwrite = conflictOverwrite;
            configuration.IgnoreFormatting  = ignoreFormatting;

            var source          = SyncServiceFactory.CreateTfs2008WorkItemSyncAdapter(DocumentModel.TfsServer, DocumentModel.TfsProject, null, configuration);
            var destination     = SyncServiceFactory.CreateWord2007TableWorkItemSyncAdapter(WordDocument, configuration);
            var importWorkItems = (from wim in FoundWorkItems
                                   where wim.IsChecked
                                   select wim.Item).ToList();

            if (!(source.Open(importWorkItems.Select(x => x.TfsItem.Id).ToArray()) && destination.Open(null)))
            {
                return;
            }

            // Check for test cases.
            var expandSharedsteps = configuration.ConfigurationTest.ExpandSharedSteps;
            var testCases         = GetTestCasesFromWorkItems(importWorkItems, expandSharedsteps);

            // Check for shared steps
            var sharedSteps = GetSharedStepsFromWorkItems(importWorkItems);

            //Get any pre and post operations for the reports
            var preOperations  = configuration.ConfigurationTest.GetPreOperationsForTestSpecification();
            var postOperations = configuration.ConfigurationTest.GetPostOperationsForTestSpecification();

            var testReportHelper = new TestReportHelper(_testAdapter, _importTestReport, configuration, () => !IsImporting);

            _importTestReport.PrepareDocumentForLongTermOperation();
            testReportHelper.ProcessOperations(preOperations);

            if (testCases.Count > 0 && sharedSteps.Count > 0)
            {
                throw new ConfigurationException("Function can only be used for either shared steps or test cases. Select only work items of one Type.");
            }
            if (testCases.Count > 0)
            {
                workItemSyncService.RefreshAndSubstituteTestItems(source, destination, importWorkItems.Select(x => x.TfsItem), configuration, testReportHelper, testCases);
            }
            if (sharedSteps.Count > 0)
            {
                workItemSyncService.RefreshAndSubstituteSharedStepItems(source, destination, importWorkItems.Select(x => x.TfsItem), configuration, testReportHelper, sharedSteps);
            }
            // when cancelled by the user skip further steps
            var progressService = SyncServiceFactory.GetService <IProgressService>();

            if (null != progressService && !progressService.ProgressCanceled)
            {
                testReportHelper.CreateSummaryPage(WordDocument, null);
                testReportHelper.ProcessOperations(postOperations);
            }
            else
            {
                SyncServiceTrace.I("Skipped");
            }

            DocumentModel.TestReportGenerated = true;
        }