Пример #1
0
        private void ImportMigrations(ImportOptions importOptions, int totalCount, IEnumerable <IssueMigration> issueMigrations)
        {
            var issueTypeMappingFile = importOptions.IssueTypeMappingFile;
            var statusMappingFile    = importOptions.StatusMappingFile;

            if (!issueTypeMappingFile.Exists)
            {
                _console.Out.WriteLine("issue type mapping file not found:" + issueTypeMappingFile.FullName);
                return;
            }
            if (!statusMappingFile.Exists)
            {
                _console.Out.WriteLine("status mapping file not found:" + statusMappingFile.FullName);
                return;
            }

            var issueTypeCsvMapper = new IssueTypeCsvMapper(issueTypeMappingFile);

            issueTypeCsvMapper.LoadMap();
            var statusMapper = new StatusCsvMapper(statusMappingFile);

            statusMapper.LoadMap();

            ImportMigrations(
                importOptions.Force,
                importOptions.FailFile,
                issueTypeCsvMapper,
                statusMapper,
                totalCount,
                issueMigrations);
        }
Пример #2
0
        private void ImportMigrations(
            bool force,
            FileInfo failFile,
            IssueTypeCsvMapper issueTypeCsvMapper,
            StatusCsvMapper statusMapper,
            int totalCount,
            IEnumerable <IssueMigration> issueMigrations)
        {
            var importer = new WorkItemImporter(force, _migrationRepository,
                                                _adoContext, _jiraContext,
                                                statusMapper, issueTypeCsvMapper);

            int imported = 0;

            var state = new ConsoleEnumerator.State(totalCount);

            issueMigrations.EnumerateOperation(
                state,
                "Import Issue",
                migration => migration.IssueId,
                failFile,
                _cancellationToken,
                migration =>
            {
                if (migration.ImportComplete)
                {
                    if (force)
                    {
                        Logger.Debug("Forcing import for already imported migration {issueId}", migration.IssueId);
                    }
                    else
                    {
                        return;
                    }
                }

                if (importer.TryImport(migration))
                {
                    imported++;
                }
            });

            Logger.Info(new { imported });
        }