示例#1
0
        public void RegenerateViewModels(AzureEventLogReader logReader, string dbConnectionString)
        {
            var commandBus = new NullCommandBus();

            Database.SetInitializer <ConferenceRegistrationDbContext>(null);

            var handlers = new List <IEventHandler>();

            handlers.Add(new ConferenceViewModelGenerator(() => new ConferenceRegistrationDbContext(dbConnectionString), commandBus));
            handlers.Add(new PricedOrderViewModelUpdater(() => new ConferenceRegistrationDbContext(dbConnectionString)));

            using (var context = new ConferenceRegistrationMigrationDbContext(dbConnectionString))
            {
                context.UpdateTables();
            }

            try
            {
                var dispatcher = new EventDispatcher(handlers);
                var events     = logReader.Query(new QueryCriteria {
                });

                dispatcher.DispatchMessages(events);
            }
            catch
            {
                using (var context = new ConferenceRegistrationMigrationDbContext(dbConnectionString))
                {
                    context.RollbackTablesMigration();
                }

                throw;
            }
        }
示例#2
0
        public void RegenerateV3ViewModels(AzureEventLogReader logReader, IBlobStorage blobStorage, string dbConnectionString, DateTime maxEventTime)
        {
            Database.SetInitializer <ConferenceRegistrationDbContext>(null);

            var handlers = new List <IEventHandler>();

            handlers.Add(new DraftOrderViewModelGenerator(() => new ConferenceRegistrationDbContext(dbConnectionString)));
            handlers.Add(new PricedOrderViewModelGenerator(() => new ConferenceRegistrationDbContext(dbConnectionString)));
            handlers.Add(
                new SeatAssignmentsViewModelGenerator(
                    new ConferenceDao(() => new ConferenceRegistrationDbContext(dbConnectionString)),
                    blobStorage,
                    new JsonTextSerializer()));

            var dispatcher = new EventDispatcher(handlers);
            var events     = logReader.Query(new QueryCriteria {
                EndDate = maxEventTime
            });

            dispatcher.DispatchMessages(events);
        }