示例#1
0
        public override void Apply(IDbConnection db)
        {
            db.CreateTable <UserView>();

            db.ExecuteNonQuery(
                "INSERT INTO Users(Id, UserName, Email, FirstName, LastName, AcceptsEmails, ExperiencePoints, Level , CreatedTime, FollowingUserIds, FollowedByUserIds, NrOfProfiles, HighestAltitude, LowestAltitude)" +
                "SELECT Id, UserName, Email, FirstName, LastName, AcceptsEmails, ExperiencePoints, Level, CreatedTime, FollowingUserIds, FollowedByUserIds,0 , -10000, 10000" +
                " FROM UserView ");

            var view = new OrmLiteUserView(db);

            var eventStore = new NEventStoreDomainRepository("AltidudeConnection");

            var events = eventStore.GetAllEvents();


            foreach (var evt in events)
            {
                try
                {
                    if (evt is ProfileCreated)
                    {
                        view.Handle((dynamic)evt);
                    }
                }
                catch (RuntimeBinderException ex)
                {
                }
            }
        }
示例#2
0
        public override void Apply(IDbConnection db)
        {
            //db.ExecuteNonQuery("SELECT Id, UserId, Name, NrOfViews, Kudos, CreatedTime, Payload INTO ProfileBackup FROM ProfileEnvelope");

            db.CreateTable <ProfileEnvelope>(false);
            db.ExecuteNonQuery("ALTER TABLE Profiles ALTER COLUMN Track VARCHAR(MAX)");
            db.ExecuteNonQuery("ALTER TABLE Profiles ALTER COLUMN Places VARCHAR(MAX)");

            var view = new OrmLiteProfileView(db);

            var eventStore = new NEventStoreDomainRepository("AltidudeConnection");

            var events = eventStore.GetAllEvents();

            foreach (var evt in events)
            {
                try
                {
                    view.Handle((dynamic)evt);
                }
                catch (RuntimeBinderException ex)
                {
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "Replay event '{@evt}' in '{view}' failed", evt, view);
                    throw;
                }
            }
        }