Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ISeeder seeder)
        {
            AutoMapperConfig.RegisterMappings(typeof(PageResultDTO <>).GetTypeInfo().Assembly);

            //Seed database with roles, users, blogs, movies, etc..

            seeder.SeedDatabase();

            app
            .UseDeveloperExceptionPage()
            .UseCors(options =>
                     options
                     .AllowAnyOrigin()
                     .AllowAnyMethod()
                     .AllowAnyHeader()
                     .AllowCredentials()
                     .WithOrigins(Configuration["ApplicationSettings:Client_URL"]))
            .UseSignalR(routes =>
            {
                routes.MapHub <CommentHub>("/api/comments");
                routes.MapHub <CommentHub>("/api/blog");
                routes.MapHub <ProfileImageHub>("/api/profile");
            })
            .UseHttpsRedirection()
            .UseHsts()
            .UseAuthentication()
            .UseMvc()
            .ConfigureCustomExceptionMiddleware();
        }
        public static void Main(string[] args)
        {
            CommandLineApplication commandLineApplication = new CommandLineApplication(false);

            commandLineApplication.OnExecute(() =>
            {
                RunLambda().ConfigureAwait(true).GetAwaiter().GetResult();
                return(0);
            });

            commandLineApplication.Command("seed", command =>
            {
                CommandOption connectionString = command.Option("-d", "TLS/RPT Connection String", CommandOptionType.SingleValue);
                CommandOption queueUrl         = command.Option("-q", "Queue Url", CommandOptionType.SingleValue);

                command.OnExecute(() =>
                {
                    ISeeder seeder = SeederFactory.Create(connectionString.Value(), queueUrl.Value());

                    seeder.SeedDomainCreated().GetAwaiter().GetResult();

                    return(0);
                });
            });

            commandLineApplication.Execute(args);
        }
Example #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              Context db,
                              ILoggerFactory loggerFactory,
                              ISeeder <Context> seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            loggerFactory.AddFile($"Logs/{nameof(ProductCatalog)}-{{Date}}.log");

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

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            db.Database.EnsureDeleted();
            db.Database.EnsureCreated();
            seeder.Seed(db);
        }
Example #4
0
        static void Complete(string filePath, int population, ISeeder seeder)
        {
            var random = new Random(0);
            var paths  = new Paths(new Complete(random, population));
            var state  = new State(population, false, 0.0f);

            var sir = SIR.Study(paths, state, seeder, 100);

            sir.Save(filePath, $"# Complete graph of size {population} with seeding {seeder.Description}");
        }
Example #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISeeder seeder, CookbookDbContext context)
        {
            app.UseCors(builder =>
                        builder
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader()
                        );

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseMiddleware <ErrorHandlingMiddleware>();

            app.UseMiddleware <RequestTimeMiddleware>();

            app.UseAuthentication();

            app.UseHttpsRedirection();

            app.UseRouting();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            app.UseOpenApi(options =>
            {
                options.DocumentName = "swagger";
                options.Path         = "/swagger/v1/swagger.json";
                options.PostProcess  = (document, _) =>
                {
                    document.Schemes.Add(OpenApiSchema.Https);
                };
            });

            app.UseSwaggerUi3(options =>
            {
                options.DocumentPath = "/swagger/v1/swagger.json";
            });


            if (context.Database.ProviderName != "Microsoft.EntityFrameworkCore.InMemory")
            {
                ConfigureAsync(seeder).Wait();
            }
        }
Example #6
0
        public int CompareTo(ISeeder other)
        {
            if (GetPriority() > other.GetPriority())
            {
                return(1);
            }
            if (GetPriority() < other.GetPriority())
            {
                return(-1);
            }

            return(0);
        }
Example #7
0
        public static SIR Study(Paths paths, ProtoState state, ISeeder seeder, int repeats, int maxIterations = 10000)
        {
            var sir = new SIR();

            for (int i = 0; i < repeats; ++i)
            {
                var susceptible = new List <int>();
                var infected    = new List <int>();
                var resolved    = new List <int>();
                state.March(paths, seeder, susceptible, infected, resolved, maxIterations);
                sir.Add(susceptible, infected, resolved);
            }

            return(sir);
        }
Example #8
0
    // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
    public void Configure(IApplicationBuilder app, ISeeder seeder, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            app.UseSession();

            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<ApplicationDbContext>()
                             .Database.Migrate();
                    }
                }
                catch { }
            }

            app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());

            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=Home}/{action=Index}/{id?}");
            });

            // Seed the database using the seeder
            seeder.EnsureSeedData();
        }
Example #9
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, ISeeder seeder, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            app.UseSession();

            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 <ApplicationDbContext>()
                        .Database.Migrate();
                    }
                }
                catch { }
            }

            app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());

            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=Home}/{action=Index}/{id?}");
            });

            // Seed the database using the seeder
            seeder.EnsureSeedData();
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ISeeder seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                seeder.DevelopmentSeed();
            }
            else
            {
                // app.UseHsts();
                // app.UseHttpsRedirection();
                seeder.ProductionSeed();
            }

            app.UseCors(config => config.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader());
            app.UseMvc();
        }
Example #11
0
        public void SeedAll()
        {
            var types = AppDomain.CurrentDomain.GetAssemblies()
                        .SelectMany(s => s.GetTypes())
                        .Where(p => p.GetInterface("ISeeder") != null);

            foreach (var sinif in types)
            {
                if (sinif.IsClass)
                {
                    ISeeder instance = Activator.CreateInstance(sinif) as ISeeder;
                    seeders.Add(instance.Oncelik, instance);
                }
            }
            foreach (var seederKey in seeders.Keys)
            {
                seeders[seederKey].Seed();
            }
        }
Example #12
0
        public void March(Paths paths, ISeeder seeder, List <int> susceptible, List <int> infected, List <int> resolved, int max_iterations)
        {
            Clear();
            seeder.Seed(this);
            susceptible.Add(_generations.Count - _current.Count);
            infected.Add(_current.Count);
            resolved.Add(0);

            var population = _generations.Count;

            for (int i = 0; i < max_iterations; ++i)
            {
                paths.Generate();
                var discarded = Increment(paths);
                if (discarded == 0 && _current.Count == infected[^ 1])
                {
                    if (_current.Count > 0 && resolved[^ 1] != 0)
                    {
                        resolved.Add(_isSIR ? resolved[^ 1] + _current.Count : 0);
        public IntegrationTestsReports(
            IReportService _ReportService,
            DataContext _db,
            IAccountService _AccountService,
            ICityService _CityService,
            ISeeder Seeder)

        {
            // Controllers Set-Up
            _ReportController = new ReportController(_db, _ReportService);
            _UserController   = new UserController(_db, _AccountService, _CityService);

            // Dependencies
            _Seeder  = Seeder;
            this._db = _db;

            // Create Temp Data Disctionary So Alerts dont throw errors.
            httpContext = new DefaultHttpContext();
        }
Example #14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISeeder seeder)
        {
            if (env.IsDevelopment())
            {
                seeder.Seed();
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();
            app.UseCors("MyPolicy");

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
                endpoints.MapGet("/", async context =>
                {
                    await context.Response.WriteAsync("Hello World!");
                });
            });
        }
Example #15
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISeeder seeder)
        {
            this._provider = app.ApplicationServices;
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRequestLocalization();

            // app.UseHttpsRedirection();

            app.UseRouting();

            app.UseCors();

            app.UseAuthentication();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            if (!env.IsDevelopment())
            {
                app.UseMiddleware <SwaggerBasicAuthMiddleware>();
            }
            app.UseSwagger(c =>
            {
                c.RouteTemplate = "swagger/{documentName}/swagger.json";
            });
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "QPANC - Quasar, PostgreSQL, ASP.NET Core and Docker");
                c.RoutePrefix = "swagger";
            });

            seeder.Execute().GetAwaiter().GetResult();
        }
Example #16
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISeeder seeder)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            if (!env.IsDevelopment())
            {
                app.UseSpaStaticFiles();
            }

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute("default", "{controller}/{action=Index}/{id?}");
                endpoints.MapHub <ChatHub>("/hub");
            });

            app.UseSpa(spa =>
            {
                spa.Options.SourcePath = "ClientApp";

                if (env.IsDevelopment())
                {
                    spa.UseAngularCliServer(npmScript: "start");
                }
            });

            seeder.Seed();
        }
Example #17
0
        public void Execute(ISeeder seeder, IConfiguration configuration, string connectionString, string providerName)
        {
            // set up the database connection
            var dialectFactory           = new DialectFactory();
            var dialect                  = dialectFactory.Create(providerName, connectionString);
            var dbProviderFactoryFactory = new DbProviderFactoryFactory();
            var dbProviderFactory        = dbProviderFactoryFactory.Create(providerName, connectionString);

            if (!dbProviderFactory.DatabaseExists(connectionString, providerName, dialect))
            {
                Log.Logger.Error("Database doesn't exist");
                return;
            }

            // run the script
            var sqlSessionCreator = new SqlDatabase(configuration, dbProviderFactory, connectionString, dialect);

            using (var session = sqlSessionCreator.BeginSession()) {
                seeder.Seed(session);
                session.Complete();
            }
        }
Example #18
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISeeder seeder)
        {
            AutoMapperConfig.RegisterMappings(typeof(LoginRequestDto).GetTypeInfo().Assembly);

            //Seed database with roles, users, etc ..

            seeder.SeedDatabase();

            app
            .UseDeveloperExceptionPage()
            .UseRouting()
            .UseCors(options => options
                     .AllowAnyOrigin()
                     .AllowAnyHeader()
                     .AllowAnyMethod())
            .UseAuthentication()
            .UseAuthorization()
            .UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
        public static async Task Main(string[] args)
        {
            AnsiConsole.Render(new FigletText("Carved Rock Software").Color(Color.Red).Alignment(Justify.Left));

            if (!Enum.TryParse <MenuOption>(args.FirstOrDefault(), true, out var choice))
            {
                var input = AnsiConsole.Prompt(new TextPrompt <string>("Select a service to seed")
                                               .AddChoice(MenuOption.AzureSearch.ToString())
                                               .AddChoice(MenuOption.AzureSql.ToString())
                                               .AddChoice(MenuOption.AzureStorageQueues.ToString())
                                               .AddChoice(MenuOption.AzureStorageTables.ToString())
                                               .AddChoice(MenuOption.CosmosDB.ToString())
                                               .InvalidChoiceMessage("[red]That's not a valid choice[/]"));
                choice = Enum.Parse <MenuOption>(input, true);
            }

            ISeeder seeder = choice switch
            {
                MenuOption.AzureSearch => new AzureSearchSeeder(),
                MenuOption.AzureSql => new AzureSqlSeeder(),
                MenuOption.AzureStorageQueues => new AzureStorageQueuesSeeder(),
                MenuOption.AzureStorageTables => new AzureStorageTablesSeeder(),
                MenuOption.CosmosDB => new CosmosDBSeeder(),
                _ => throw new NotSupportedException()
            };

            try
            {
                await seeder.RunAsync();
            }
            catch (Exception exception)
            {
                AnsiConsole.WriteException(exception, ExceptionFormats.ShortenEverything);
            }
        }
    }
 static CompanyConsoleClient()
 {
     companyDbContext = new CompanyDbContext();
     databaseSeeder = new DatabaseSeederWithRandomValues(companyDbContext);
 }
        //public MidgardContext()
        //{
        //    _seeder = new Seeder();
        //    Database.Migrate();
        //}

        public MidgardContext(ISeeder seeder = null)
        {
            _seeder = seeder ?? Locator.Current.GetService <ISeeder>();
            Database.Migrate();
        }
Example #22
0
 public MidgardContext(ISeeder seeder)
 {
     _seeder = seeder;
     Database.Migrate();
 }
Example #23
0
 public ProductsController(ISeeder seeder)
 {
     _seeder = seeder;
 }
Example #24
0
 public InitDatabase(ISeeder seeder, int amount)
 {
     _seeder = seeder;
     _amount = amount;
 }
Example #25
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, ISeeder seeder)
        {
            loggerFactory.AddConsole();
            loggerFactory.AddDebug();
            loggerFactory.AddNLog();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler();
            }

            seeder.SeedAll();
            app.UseStatusCodePages();
            app.UseMvc();
        }
Example #26
0
 public RecordCaseInitializer(ISeeder seeder)
 {
     Seeder = seeder;
 }
Example #27
0
 public Initial(ISeeder seeder)
 {
     _seeder = seeder;
 }
Example #28
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              ILoggerFactory loggerFactory, IServiceProvider serviceProvider, ISeeder seeder,
                              UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager)
        {
            /* Since there is no request yet, the service provider is not yet able to give a scoped
             *  instance of the DbContext so it otherwise creates one that will live for the lifetime of
             *  the application, thus we create a scoped one of our own just for startup */
            using (var scope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope())
            {
                using (var context = scope.ServiceProvider.GetService <QuizDbContext>())
                {
                    if (_isDevelopment)
                    {
                        seeder.Seed();
                    }
                    else
                    {
                        context.Database.Migrate();
                    }
                }
            }

            loggerFactory.AddConsole(_configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            app.UseStaticFiles();

            app.UseIdentity();

            if (_isDevelopment)
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();

                // Create a user
                var user = new ApplicationUser {
                    UserName = "******"
                };

                // Running this method asynchronously causes indefinite hang
                var userM = userManager.CreateAsync(user, _configuration["dbpassword"]).Result;

                // Add the required role
                var quizAdminRole = new IdentityRole {
                    Name = "QuizAdminRole"
                };
                var role      = roleManager.CreateAsync(quizAdminRole).Result;
                var addResult = userManager.AddToRoleAsync(user, "QuizAdminRole").Result;
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Example #29
0
 public async Task ConfigureAsync(ISeeder seeder)
 {
     await seeder.Seed().ConfigureAwait(false);
 }
Example #30
0
 public Engine(ISeeder seeder)
 {
     _seeder = seeder;
 }
 static ToyStoreEntryPoint()
 {
     toyStoreContext = new ToyStoreContext();
     consoleLogger = new ConsoleLogger();
     databaseSeeder = new DatabaseSeederWithRandomValues(toyStoreContext, consoleLogger);
 }
Example #32
0
 public DatabaseInitializer(ITodoContext todoContext, ISeeder seeder)
 {
     this.todoContext = todoContext;
     this.seeder      = seeder;
 }
        private static async Task ExecuteSeeder(ISeeder seeder)
        {
            await seeder.UpdateDb();

            await seeder.Seed();
        }