コード例 #1
0
        private void InitializeEventFlowDbStructure(IServiceProvider serviceProvider)
        {
            var msSqlDatabaseMigrator = serviceProvider.GetService <IMsSqlDatabaseMigrator>();

            EventFlowEventStoresMsSql.MigrateDatabase(msSqlDatabaseMigrator);
            EventFlowSnapshotStoresMsSql.MigrateDatabase(msSqlDatabaseMigrator);
        }
コード例 #2
0
        public void GetSqlScripts()
        {
            // Act
            var sqlScripts = EventFlowSnapshotStoresMsSql.GetSqlScripts().ToDictionary(s => s.Name, s => s);

            // Assert
            sqlScripts.Should().HaveCount(1);
            sqlScripts.Should().ContainKey("SnapshotStores.Scripts.0001 - Create EventFlowSnapshots.sql");
        }
コード例 #3
0
        private static void Main(string[] args)
        {
            TradingPersistenceService tradingPersistenceService = null;

            try
            {
                Console.WriteLine(@"
                                     █████╗ ██╗       ██████╗ ██████╗ ████████╗██╗ ██████╗ ███╗   ██╗
                                    ██╔══██╗██║      ██╔═══██╗██╔══██╗╚══██╔══╝██║██╔═══██╗████╗  ██║
                                    ███████║██║█████╗██║   ██║██████╔╝   ██║   ██║██║   ██║██╔██╗ ██║
                                    ██╔══██║██║╚════╝██║   ██║██╔═══╝    ██║   ██║██║   ██║██║╚██╗██║
                                    ██║  ██║██║      ╚██████╔╝██║        ██║   ██║╚██████╔╝██║ ╚████║
                                    ╚═╝  ╚═╝╚═╝       ╚═════╝ ╚═╝        ╚═╝   ╚═╝ ╚═════╝ ╚═╝  ╚═══╝");
                var services = new ServiceCollection();
                var startup  = new Startup();
                var provider = startup.ConfigureServices(services);


                //migrate
                Task.Run(() =>
                {
                    var sql = provider.GetService <IMsSqlDatabaseMigrator>();
                    EventFlowEventStoresMsSql.MigrateDatabase(sql);
                    EventFlowSnapshotStoresMsSql.MigrateDatabase(sql);
                });


                tradingPersistenceService = provider.GetService <TradingPersistenceService>();
                tradingPersistenceService.InitializeTradingsServiceAsync().Wait();


                while (true)
                {
                    var input = Console.ReadLine();
                    switch (input)
                    {
                    case "-l": {
                        tradingPersistenceService.GetListOfSubscribe();
                        break;
                    }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.ReadLine();
            }
        }
コード例 #4
0
        protected override IRootResolver CreateRootResolver(IEventFlowOptions eventFlowOptions)
        {
            _testDatabase = MsSqlHelpz.CreateDatabase("eventflow-snapshots");

            var resolver = eventFlowOptions
                           .ConfigureMsSql(MsSqlConfiguration.New.SetConnectionString(_testDatabase.ConnectionString.Value))
                           .UseMsSqlSnapshotStore()
                           .CreateResolver();

            var databaseMigrator = resolver.Resolve <IMsSqlDatabaseMigrator>();

            EventFlowSnapshotStoresMsSql.MigrateDatabase(databaseMigrator);

            return(resolver);
        }
コード例 #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMiddleware <CommandPublishMiddleware>();
            app.UseMvc();

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Event Sourcing api V1");
            });

            var msSqlDatabaseMigrator = app.ApplicationServices.GetService <IMsSqlDatabaseMigrator>();

            EventFlowEventStoresMsSql.MigrateDatabase(msSqlDatabaseMigrator);
            EventFlowSnapshotStoresMsSql.MigrateDatabase(msSqlDatabaseMigrator);
        }