Пример #1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            var seeder = new SampleDataSeeder();

            seeder.Initialize(app.ApplicationServices).Wait();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Пример #2
0
        public async Task <Unit> Handle(SeedSampleDataCommand request, CancellationToken cancellationToken)
        {
            var seeder = new SampleDataSeeder(_context, _userManager);

            await seeder.SeedAllAsync(cancellationToken);

            return(Unit.Value);
        }
Пример #3
0
 private static async Task SeedDataAsync(SocialMediaListsDbContext dbContext,
                                         IElasticClient elasticClient,
                                         DataSeedCollection seedCollection,
                                         CancellationToken cancellationToken)
 {
     var dataSeeder = new SampleDataSeeder(elasticClient, dbContext, seedCollection);
     await dataSeeder.SeedAsync(cancellationToken);
 }
        public async Task <Unit> Handle(SeedSampleDataCommand request, CancellationToken cancellationToken)
        {
            var seeder      = new SampleDataSeeder(_context);
            var profileData = await _storageProvider.GetProfileData();

            await seeder.SeedAllAsync(profileData, cancellationToken);

            return(Unit.Value);
        }
Пример #5
0
        public void ConfigureSeedData(IApplicationBuilder app, IWebHostEnvironment env)
        {
            using var serviceScope = app.ApplicationServices.CreateScope();
            using var dbContext    = serviceScope.ServiceProvider.GetService <SocialMediaListsDbContext>();
            var elasticClient = serviceScope.ServiceProvider.GetService <IElasticClient>();

            var seedSource = new DataSeedCollection();
            var dataSeeder = new SampleDataSeeder(elasticClient, dbContext, seedSource);

            dataSeeder.Seed();
        }
        private static void Main(string[] args)
        {
            Console.WriteLine("Initializing server. . .");
            var container = GetContainer();
            var seeded    = false;

            while (true)
            {
                using (var scope = container.BeginLifetimeScope())
                {
                    _logger = scope.Resolve <ILogger <Program> >();

                    if (!seeded)
                    {
                        var seeder = new SampleDataSeeder();
                        seeder.Initialize(scope.Resolve <VendingMachineDbContext>()).Wait();
                        seeded = true;
                    }

                    var requestListener = scope.Resolve <TcpRequestListener>();
                    StartRequestListener(requestListener);
                }
            }
        }
Пример #7
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public async void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, SampleDataSeeder sampleDataSeeder)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");

                // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
                try
                {
                    using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>()
                                              .CreateScope())
                    {
                        serviceScope.ServiceProvider.GetService <AppDbContext>()
                        .Database
                        .EnsureCreated();
                    }
                }
                catch { }
            }

            app.UseIISPlatformHandler();

            app.UseStaticFiles();

            app.UseIdentity();

            // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}",
                    defaults: new { controller = "Navigation", action = "Index" });
            });

            await sampleDataSeeder.InitializeSeedData();
        }