示例#1
0
        private void LogFinalStatus()
        {
            var createdWorkItems = this.context.WorkItemsMigrationState.Where(w => w.MigrationState == WorkItemMigrationState.State.Create);

            if (createdWorkItems.Any())
            {
                Logger.LogSuccess(LogDestination.All, $"Created {createdWorkItems.Count()} work item(s)");
                Logger.LogInformation(LogDestination.File, "Created WorkItems");
                Logger.LogInformation(LogDestination.File, "Source Id   :: Target Id");
                foreach (var item in createdWorkItems)
                {
                    Logger.LogInformation(LogDestination.File, $"{item.SourceId} :: {item.TargetId}");
                }
            }

            var updatedWorkItems = this.context.WorkItemsMigrationState.Where(w => w.MigrationState == WorkItemMigrationState.State.Existing && w.Requirement.HasFlag(WorkItemMigrationState.RequirementForExisting.UpdatePhase1));

            if (updatedWorkItems.Any())
            {
                Logger.LogSuccess(LogDestination.All, $"Updated {updatedWorkItems.Count()} work item(s)");
                Logger.LogInformation(LogDestination.File, "Updated WorkItems");
                Logger.LogInformation(LogDestination.File, "Source Id   :: Target Id");
                foreach (var item in updatedWorkItems)
                {
                    Logger.LogInformation(LogDestination.File, $"{item.SourceId} :: {item.TargetId}");
                }
            }

            Dictionary <int, FailureReason> notMigratedWorkItems = ClientHelpers.GetNotMigratedWorkItemsFromWorkItemsMigrationState(context.WorkItemsMigrationState);

            if (notMigratedWorkItems.Any())
            {
                //Log breakdown of not migrated work items by FailureReason
                Logger.LogError(LogDestination.All, $"{notMigratedWorkItems.Count} total work item(s) failed.");

                FailureReason[] failureReasons            = (FailureReason[])Enum.GetValues(typeof(FailureReason));
                FailureReason[] failureReasonsWithoutNone = failureReasons.SubArray(1, failureReasons.Length - 1);

                foreach (FailureReason failureReason in failureReasonsWithoutNone)
                {
                    int failureCount = notMigratedWorkItems.Where(a => a.Value.HasFlag(failureReason)).Count();
                    if (failureCount > 0)
                    {
                        Logger.LogError(LogDestination.All, $"   {failureCount} work item(s) failed for this reason: {failureReason}.");
                    }
                }

                //Log all the not migrated work items to both console and file
                foreach (var item in notMigratedWorkItems)
                {
                    Logger.LogInformation(LogDestination.File, $"{item.Key} :: {item.Value}");
                }
            }

            Logger.LogInformation(LogDestination.All, "Migration complete");
        }
示例#2
0
        public void GetNotMigratedWorkItemsFromWorkItemsMigrationState_ReturnsCorrectResult()
        {
            WorkItemMigrationState notMigratedState = new WorkItemMigrationState();

            notMigratedState.SourceId       = 1;
            notMigratedState.FailureReason |= FailureReason.UnsupportedWorkItemType;

            WorkItemMigrationState migratedState = new WorkItemMigrationState();

            migratedState.SourceId = 2;

            ConcurrentBag <WorkItemMigrationState> workItemsMigrationState = new ConcurrentBag <WorkItemMigrationState>();

            workItemsMigrationState.Add(notMigratedState);
            workItemsMigrationState.Add(migratedState);

            Dictionary <int, FailureReason> result = ClientHelpers.GetNotMigratedWorkItemsFromWorkItemsMigrationState(workItemsMigrationState);

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual(1, result.First().Key);
        }