Beispiel #1
0
        public void UserAdded_AppearsInContext()
        {
            SourceUser newUser;
            var        srcUser = new SourceUser
            {
                EmailAddress = "*****@*****.**",
                UserName     = "******"
            };

            using (var efContext = new SourceDbContext(_srcConnection))
            {
                efContext.Users.Add(srcUser);
                efContext.SaveChanges();
            }

            using (var source =
                       new EfDataContext <SourceDbContext>(new SourceDbContext(_srcConnection)) as IDataSource)
            {
                newUser = source.Entities <SourceUser>().Single(x => x.EmailAddress == srcUser.EmailAddress);
            }

            Assert.Multiple(() =>
            {
                Assert.That(newUser.Id, Is.EqualTo(srcUser.Id));
                Assert.That(newUser.EmailAddress, Is.EqualTo(srcUser.EmailAddress));
            });
        }
Beispiel #2
0
        private static void MigrateUserAssociation(MemberAssociation item)
        {
            var db1    = new SourceDbContext();
            var db2    = new HostDbContext();
            var member = db1.Members.FirstOrDefault(m => m.MemberId == item.MemberId);

            if (member != null)
            {
                var user = db2.User.FirstOrDefault(x => x.Phone == member.Phone.ToString());
                var unit = db2.Units.FirstOrDefault(x => x.UnitId == item.UnitId);
                if (user != null && unit != null)
                {
                    var isAssociated = db2.UserAssociation.FirstOrDefault(x => x.UnitId == unit.Id && x.IdUser == user.Id);
                    if (isAssociated == null)
                    {
                        var ua = new UserAssociation
                        {
                            IdUser = user.Id,
                            UnitId = unit.Id
                        };
                        db2.UserAssociation.Add(ua);
                        db2.SaveChanges();
                    }
                }
            }
            db1.Dispose();
            db2.Dispose();
        }
 public GameClassMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     GameClassKeyMapper gameClassKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _gameClassKeyMapper = gameClassKeyMapper;
 }
 public MailSendMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     MailSendKeyMapper mailSendKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _mailSendKeyMapper = mailSendKeyMapper;
 }
 public CommentGroupMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     CommentGroupKeyMapper commentGroupKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _commentGroupKeyMapper = commentGroupKeyMapper;
 }
Beispiel #6
0
 public FeatureToggleMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     UserKeyMapper userKeyMapper, FeatureToggleKeyMapper featureToggleKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _userKeyMapper          = userKeyMapper;
     _featureToggleKeyMapper = featureToggleKeyMapper;
 }
Beispiel #7
0
        public Migration()
        {
            var jsonString = File.ReadAllText("database.json");

            model = JsonSerializer.Deserialize <ConfigModel>(jsonString, JsonOptions);
            ctx1  = new SourceDbContext(model.SourceConfig.ConnectionString);
            ctx2  = new HostDbContext(model.HostConfig.ConnectionString);
        }
Beispiel #8
0
 public SettingMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     UserKeyMapper userKeyMapper, SettingKeyMapper settingKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _userKeyMapper    = userKeyMapper;
     _settingKeyMapper = settingKeyMapper;
 }
Beispiel #9
0
 public UserMigration(
     SourceDbContext sourceDbContext,
     TargetDbContext targetDbContext,
     UserKeyMapper userKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _userKeyMapper = userKeyMapper;
 }
Beispiel #10
0
 public ForumLastVisitMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     ForumLastVisitKeyMapper forumLastVisitKeyMapper,
     UserKeyMapper userKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _forumLastVisitKeyMapper = forumLastVisitKeyMapper;
     _userKeyMapper           = userKeyMapper;
 }
Beispiel #11
0
 public ProfileSyncMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     GameCharacterSourceKeyMapper profileSyncKeyMapper,
     UserKeyMapper userKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _profileSyncKeyMapper = profileSyncKeyMapper;
     _userKeyMapper        = userKeyMapper;
 }
 public GameGuildSyncMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     GameCharacterSourceKeyMapper gameGuildSyncKeyMapper,
     GameGuildKeyMapper gameGuildKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _gameGuildSyncKeyMapper = gameGuildSyncKeyMapper;
     _gameGuildKeyMapper     = gameGuildKeyMapper;
 }
Beispiel #13
0
 public CalendarExportMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     UserKeyMapper userKeyMapper,
     CalendarExportKeyMapper calendarExportKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _userKeyMapper           = userKeyMapper;
     _calendarExportKeyMapper = calendarExportKeyMapper;
 }
Beispiel #14
0
 public NotificationQueueItemMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     UserKeyMapper userKeyMapper,
     NotificationQueueItemKeyMapper notificationQueueItemKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _userKeyMapper = userKeyMapper;
     _notificationQueueItemKeyMapper = notificationQueueItemKeyMapper;
 }
 public ActivityQueueItemMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     UserKeyMapper userKeyMapper,
     ActivityQueueItemKeyMapper activityQueueItemKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _userKeyMapper = userKeyMapper;
     _activityQueueItemKeyMapper = activityQueueItemKeyMapper;
 }
 public PlaysGameRoleMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     GameCharacterClaimKeyMapper gameCharacterClaimKeyMapper,
     PlaysGameRoleKeyMapper playsGameRoleKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _gameCharacterClaimKeyMapper = gameCharacterClaimKeyMapper;
     _playsGameRoleKeyMapper      = playsGameRoleKeyMapper;
 }
Beispiel #17
0
 public GameRaceMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     GameRaceKeyMapper gameRaceKeyMapper,
     GameFactionKeyMapper gameFactionKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _gameRaceKeyMapper    = gameRaceKeyMapper;
     _gameFactionKeyMapper = gameFactionKeyMapper;
 }
 public GameCharacterClaimVersionMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     GameCharacterClaimKeyMapper gameCharacterClaimKeyMapper,
     GameCharacterClaimVersionKeyMapper gameCharacterClaimVersionKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _gameCharacterClaimKeyMapper        = gameCharacterClaimKeyMapper;
     _gameCharacterClaimVersionKeyMapper = gameCharacterClaimVersionKeyMapper;
 }
 public SignedForGameRoleMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     SignedForGameRoleKeyMapper signedForGameRoleKeyMapper,
     SignUpKeyMapper signUpKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _signedForGameRoleKeyMapper = signedForGameRoleKeyMapper;
     _signUpKeyMapper            = signUpKeyMapper;
 }
Beispiel #20
0
 public GameGuildMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     GameGuildKeyMapper gameGuildKeyMapper,
     GameRealmKeyMapper gameRealmKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _gameGuildKeyMapper = gameGuildKeyMapper;
     _gameRealmKeyMapper = gameRealmKeyMapper;
 }
Beispiel #21
0
 public UnreadPostMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     UnreadPostKeyMapper unreadPostKeyMapper,
     PostKeyMapper postKeyMapper,
     UserKeyMapper userKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _unreadPostKeyMapper = unreadPostKeyMapper;
     _postKeyMapper       = postKeyMapper;
     _userKeyMapper       = userKeyMapper;
 }
 public PostMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     TopicKeyMapper topicKeyMapper,
     UserKeyMapper userKeyMapper,
     PostKeyMapper postKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _topicKeyMapper = topicKeyMapper;
     _userKeyMapper  = userKeyMapper;
     _postKeyMapper  = postKeyMapper;
 }
Beispiel #23
0
 public ForumMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     ForumKeyMapper forumKeyMapper,
     TopicKeyMapper topicKeyMapper,
     UserKeyMapper userKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _forumKeyMapper = forumKeyMapper;
     _topicKeyMapper = topicKeyMapper;
     _userKeyMapper  = userKeyMapper;
 }
Beispiel #24
0
 public TrackedByMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     TrackedByKeyMapper trackedByKeyMapper,
     GameCharacterSourceKeyMapper gameCharacterSourceKeyMapper,
     GameCharacterKeyMapper gameCharacterKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _trackedByKeyMapper           = trackedByKeyMapper;
     _gameCharacterSourceKeyMapper = gameCharacterSourceKeyMapper;
     _gameCharacterKeyMapper       = gameCharacterKeyMapper;
 }
Beispiel #25
0
 public InGameGuildMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     InGameGuildKeyMapper inGameGuildKeyMapper,
     GameCharacterKeyMapper gameCharacterKeyMapper,
     GameGuildKeyMapper gameGuildKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _inGameGuildKeyMapper   = inGameGuildKeyMapper;
     _gameCharacterKeyMapper = gameCharacterKeyMapper;
     _gameGuildKeyMapper     = gameGuildKeyMapper;
 }
 public CommentMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     CommentKeyMapper commentKeyMapper,
     CommentGroupKeyMapper commentGroupKeyMapper,
     UserKeyMapper userKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _commentKeyMapper      = commentKeyMapper;
     _commentGroupKeyMapper = commentGroupKeyMapper;
     _userKeyMapper         = userKeyMapper;
 }
Beispiel #27
0
 public SignUpMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     SignUpKeyMapper signUpKeyMapper,
     EventKeyMapper eventKeyMapper,
     UserKeyMapper userKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _signUpKeyMapper = signUpKeyMapper;
     _eventKeyMapper  = eventKeyMapper;
     _userKeyMapper   = userKeyMapper;
 }
Beispiel #28
0
 public GameCharacterClaimMigration(
     SourceDbContext sourceDbContext, TargetDbContext targetDbContext,
     UserKeyMapper userKeyMapper,
     GameCharacterKeyMapper gameCharacterKeyMapper,
     GameCharacterClaimKeyMapper gameCharacterClaimKeyMapper)
     : base(sourceDbContext, targetDbContext)
 {
     _userKeyMapper               = userKeyMapper;
     _gameCharacterKeyMapper      = gameCharacterKeyMapper;
     _gameCharacterClaimKeyMapper = gameCharacterClaimKeyMapper;
 }
 protected BaseMigration(SourceDbContext sourceDbContext, TargetDbContext targetDbContext)
 {
     SourceDbContext = sourceDbContext;
     TargetDbContext = targetDbContext;
 }
Beispiel #30
0
 /// <summary>
 /// Creates a new instance.
 /// </summary>
 /// <param name="dbContext">db context to be used to access the database</param>
 /// <param name="logger">logger where to write log entries</param>
 public SourceRepository(SourceDbContext dbContext, ILogger <ISourceRepository> logger)
 {
     dbContext.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
     _dbContext = dbContext;
     _logger    = logger;
 }