示例#1
0
        public ImportPipeline Build(ImportPipelineBuilder importPipelineBuilder, ExternalRepositoryDetailContract externalRepository,
                                    int importHistoryId, RepositoryImportProgressInfo progressInfo, CancellationToken cancellationToken)
        {
            var executionOptions = new ExecutionDataflowBlockOptions {
                CancellationToken = cancellationToken
            };

            var bufferBlock         = new BufferBlock <object>(executionOptions);
            var responseParserBlock =
                importPipelineBuilder.BuildResponseParserBlock(externalRepository.ExternalRepositoryType.Name, executionOptions);
            var filterBlock = importPipelineBuilder.BuildFilterBlock(externalRepository.Id, externalRepository.BibliographicFormat.Name,
                                                                     executionOptions);
            var projectParserBlock =
                importPipelineBuilder.BuildProjectParserBlock(externalRepository.BibliographicFormat.Name, executionOptions);
            var nullTargetBlock = importPipelineBuilder.BuildNullTargetBlock(progressInfo, executionOptions);
            var saveBlock       = importPipelineBuilder.BuildSaveBlock(m_importManager.UserId, importHistoryId, externalRepository.Id,
                                                                       progressInfo, executionOptions);

            var linkOptions = new DataflowLinkOptions {
                PropagateCompletion = true
            };

            bufferBlock.LinkTo(responseParserBlock, linkOptions);
            responseParserBlock.LinkTo(filterBlock, linkOptions);
            filterBlock.LinkTo(projectParserBlock, linkOptions, importedRecord => importedRecord.IsSuitable);
            filterBlock.LinkTo(nullTargetBlock, linkOptions);
            projectParserBlock.LinkTo(saveBlock, linkOptions);

            return(new ImportPipeline {
                BufferBlock = bufferBlock, LastBlock = saveBlock
            });
        }
示例#2
0
        public ImportPipelineManager(IEnumerable <IProjectImportManager> importManagers, ImportManager importManager,
                                     ILogger <ImportPipelineManager> logger, ImportPipelineBuilder importPipelineBuilder,
                                     ImportPipelineDirector importPipelineDirector, ExternalRepositoryManager externalRepositoryManager,
                                     ImportHistoryManager importHistoryManager)
        {
            m_projectImportManagers = new Dictionary <string, IProjectImportManager>();
            m_importManager         = importManager;
            m_logger = logger;
            m_importPipelineBuilder     = importPipelineBuilder;
            m_importPipelineDirector    = importPipelineDirector;
            m_externalRepositoryManager = externalRepositoryManager;
            m_importHistoryManager      = importHistoryManager;

            foreach (var manager in importManagers)
            {
                m_projectImportManagers.Add(manager.ExternalRepositoryTypeName, manager);
            }
        }