Exemplo n.º 1
0
        static void Main(string[] args)
        {
            ConfigureSerilog();

            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

            var result = CommandLine.Parser.Default.ParseArguments <Options>(args)
                         .WithParsed <Options>(opts => options = opts)
                         .WithNotParsed <Options>((errs) => HandleParseError(errs));

            if (result.Tag != ParserResultType.Parsed)
            {
                Log.Logger.Error("Command line parameters error, press a key to continue!");
                Console.ReadKey();
                return;
            }

            Connection connection = new Connection(options.ServiceAddress, options.GetAccessToken());

            var importer = new WorkItemImporter(connection, options.OriginalIdField, options.TeamProject);

            //test one item
            MigrationItem mi = new MigrationItem();

            mi.OriginalId = "AA123";
            mi.WorkItemDestinationType = "Product Backlog Item";
            mi.AddVersion(new MigrationItemVersion()
            {
                AuthorEmail      = "*****@*****.**",
                Description      = "Description",
                Title            = "Title test",
                VersionTimestamp = new DateTime(2010, 01, 23, 22, 10, 32),
            });

            mi.AddVersion(new MigrationItemVersion()
            {
                AuthorEmail      = "*****@*****.**",
                Description      = "Description",
                Title            = "Title Modified",
                VersionTimestamp = new DateTime(2011, 01, 23, 22, 10, 32),
            });

            mi.AddVersion(new MigrationItemVersion()
            {
                AuthorEmail      = "*****@*****.**",
                Description      = "Description",
                Title            = "Title Modified Again",
                VersionTimestamp = new DateTime(2012, 01, 23, 22, 10, 32),
            });

            var importResult = importer.ImportWorkItemAsync(mi).Result;

            Log.Information("import result: {importResult}", importResult);

            if (Environment.UserInteractive)
            {
                Console.WriteLine("Execution completed, press a key to continue");
                Console.ReadKey();
            }
        }
Exemplo n.º 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 });
        }