// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ISeedData seedData) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseMvc(routes => routes.MapRoute( name: "WebAPI", template: "api/{controller}/{action}/{id?}" ) //.MapRoute( // name: "WebAPIForYear", // template: "api/foryear/{year:int}/{controller}/{action}/{id?}" //) ); seedData.SeedUserData(); //var tmp1 = UnitOfWork.ContoShemeOptions; //seedData.SeedCompanyData(); //seedData.PopulateData(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISeedData seedData, UserManager <LoginAccount> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); endpoints.MapControllers(); endpoints.MapRazorPages(); }); seedData.SeedDatabase(userManager); }
public ApplicationDbContext( DbContextOptions <ApplicationDbContext> options, ISeedData seedData) : base(options) { _seedData = seedData; }
public CustomWebApplicationFactory(ApplicationUser authenticatedUser = null, ISeedData seedData = null, int?moviesPageSize = null, Func <IMovieInfoProvider> movieInfoProvider = null) { this.authenticatedUser = authenticatedUser; this.seedData = seedData ?? new DefaultSeedData(); this.moviesPageSize = moviesPageSize; this.fakeMovieInfoProviderFactory = movieInfoProvider ?? FakeMovieInfoProvider.StubFailingProvider; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ISeedData seedData) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors(x => x.AllowAnyHeader() .AllowAnyOrigin() .AllowAnyMethod()); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); seedData.EnsurePopulated(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure( IApplicationBuilder app, IWebHostEnvironment env, ISeedData seedData) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); seedData.SeedAsync().Wait(); } app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthentication(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ISeedData seedServ) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseDatabaseErrorPage(); } else { app.UseExceptionHandler("/Home/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseStaticFiles(); app.UseCookiePolicy(); app.UseAuthentication(); //seedServ.SeedAdminUser(); app.UseMvc(routes => { routes.MapRoute( name: "areas", template: "{area:exists}/{controller=Home}/{action=Index}/{id?}" ); routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); }); }
public AccountAdapter( UserManager <DALUserAccount> userManager, RoleManager <IdentityRole> roleManager, IEmailSender emailSender, ISeedData seedData) : base(roleManager, userManager, seedData) { _userManager = userManager; _emailSender = emailSender; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ISeedData seedData) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseStaticFiles(); app.UseMvc(); seedData.Seed(); }
public DatabaseSeeder(ISeedData seedData, IMoviesToGetService moviesToGetService, IMoviesToSeeService moviesToSeeService, IUserService userService, IRoleService roleService, IIdGeneratorQueue idGeneratorQueue, ILogger <DatabaseSeeder> logger) { this.seedData = seedData ?? throw new ArgumentNullException(nameof(seedData)); this.moviesToGetService = moviesToGetService ?? throw new ArgumentNullException(nameof(moviesToGetService)); this.moviesToSeeService = moviesToSeeService ?? throw new ArgumentNullException(nameof(moviesToSeeService)); this.userService = userService ?? throw new ArgumentNullException(nameof(userService)); this.roleService = roleService ?? throw new ArgumentNullException(nameof(roleService)); this.idGeneratorQueue = idGeneratorQueue ?? throw new ArgumentNullException(nameof(idGeneratorQueue)); this.logger = logger ?? throw new ArgumentNullException(nameof(logger)); }
/// <summary> /// If it's an empty database after a fresh setup we're /// inserting some initial data. /// </summary> public void Seed(ISeedData initialData) { if (initialData.Users != null && !_context.Users.Any()) { _logger.LogInformation("Data seeding initial Users."); foreach (var user in initialData.Users) { _context.Users.Add(user); _context.SaveChanges(); } } }
static void Main(string[] args) { var migrationsAssembly = typeof(Program).GetTypeInfo().Assembly.GetName().Name; var services = new ServiceCollection(); IConfigurationRoot configuration = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json") // .AddEnvironmentVariables() .Build(); var connectionString = configuration.GetConnectionString("DefaultConnection"); var serverUrl = configuration["serverUrl"]; services.AddDbContext <ApplicationDbContext>( options => // options.UseSqlite(connectionString)); // options.UseSqlServer(connectionString)); options.UseNpgsql(connectionString, a => a.MigrationsAssembly(migrationsAssembly))); services.AddIdentity <ApplicationUser, IdentityRole>().AddEntityFrameworkStores <ApplicationDbContext>() .AddDefaultTokenProviders(); // Manual Setup services.AddDbContext <ConfigurationDbContext>(options => //options.UseSqlite(Configuration.GetConnectionString("SqlLite"))); //options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); options.UseNpgsql(connectionString, a => a.MigrationsAssembly(migrationsAssembly))); services.AddTransient <IdentityServer4.EntityFramework.Options.ConfigurationStoreOptions>(); services.AddDbContext <PersistedGrantDbContext>(options => //options.UseSqlite(Configuration.GetConnectionString("SqlLite"))); //options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); options.UseNpgsql(connectionString, a => a.MigrationsAssembly(migrationsAssembly))); services.AddTransient <IdentityServer4.EntityFramework.Options.OperationalStoreOptions>(); services.AddTransient <ISeedData, SeedData>(); using (var serviceProvider = services.BuildServiceProvider()) { using (var scope = serviceProvider.GetRequiredService <IServiceScopeFactory>().CreateScope()) { ISeedData seedData = scope.ServiceProvider.GetService <ISeedData>(); seedData.SeedIdentity(); seedData.SeedIdentityServer(serverUrl); } } }
public async Task SeedAsync(ISeedData seedData) { var client = new DocumentClient(new Uri("https://localhost:8081"), "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==", new ConnectionPolicy { EnableEndpointDiscovery = false }); var database = new Database { Id = "AnimalFarm" }; await client.CreateDatabaseIfNotExistsAsync(database); foreach (SeedCollection collection in seedData.Collections) { await ClearTableAsync(client, database.Id, collection.Name, $"/{nameof(IHavePartition<string, string>.PartitionKey)}"); await SeedAsync(client, database.Id, collection.Name, collection.Entities); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ISeedData seedData) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseCors(builder => { builder.AllowAnyOrigin(); builder.AllowAnyMethod(); builder.AllowAnyHeader(); }); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } // app.UseHttpsRedirection(); app.UseMvc(); // Intialize application seedData.SeedDatabase(); }
protected AccountAdapterHelper(RoleManager <IdentityRole> roleManager, UserManager <DALUserAccount> userManager, ISeedData seedData) { _roleManager = roleManager; _userManager = userManager; _seedData = seedData; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ISeedData seedData) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(); app.UseSignalR((cfg) => { cfg.MapHub <NotificationHub>("/notifications"); }); app.UseMvc(routes => routes.MapRoute( name: "WebAPI", template: "api/{controller}/{action}/{id?}" ) //.MapRoute( // name: "WebAPIForYear", // template: "api/foryear/{year:int}/{controller}/{action}/{id?}" //) ); seedData.SeedCompanyData(); seedData.SeedUserData(); //var tmp1 = UnitOfWork.ContoShemeOptions; //seedData.PopulateData(); // Create views BankView.CreateView(); BusinessPartnerBankView.CreateView(); BusinessPartnerByConstructionSiteView.CreateView(); BusinessPartnerInstitutionView.CreateView(); BusinessPartnerLocationView.CreateView(); BusinessPartnerDocumentView.CreateView(); BusinessPartnerNoteView.CreateView(); BusinessPartnerOrganizationUnitView.CreateView(); BusinessPartnerPhoneView.CreateView(); BusinessPartnerView.CreateView(); BusinessPartnerTypeView.CreateView(); //CompanyView.CreateView(); //??? //UserView.CreateView(); InputInvoiceView.CreateView(); InputInvoiceNoteView.CreateView(); InputInvoiceDocumentView.CreateView(); OutputInvoiceDocumentView.CreateView(); OutputInvoiceView.CreateView(); OutputInvoiceNoteView.CreateView(); CountryView.CreateView(); RegionView.CreateView(); MunicipalityView.CreateView(); CityView.CreateView(); ProfessionView.CreateView(); SectorView.CreateView(); AgencyView.CreateView(); TaxAdministrationView.CreateView(); ToDoView.CreateView(); EmployeeByBusinessPartnerView.CreateView(); EmployeeByConstructionSiteView.CreateView(); EmployeeCardView.CreateView(); EmployeeView.CreateView(); EmployeeDocumentView.CreateView(); EmployeeItemView.CreateView(); EmployeeLicenceView.CreateView(); EmployeeNoteView.CreateView(); EmployeeProfessionView.CreateView(); FamilyMemberView.CreateView(); LicenceTypeView.CreateView(); PhysicalPersonView.CreateView(); PhysicalPersonItemView.CreateView(); PhysicalPersonNoteView.CreateView(); PhysicalPersonLicenceView.CreateView(); PhysicalPersonDocumentView.CreateView(); PhysicalPersonCardView.CreateView(); PhysicalPersonProfessionView.CreateView(); ConstructionSiteCalculationView.CreateView(); ConstructionSiteDocumentView.CreateView(); ConstructionSiteNoteView.CreateView(); ConstructionSiteView.CreateView(); VatView.CreateView(); ServiceDeliveryView.CreateView(); DiscountView.CreateView(); StatusView.CreateView(); ShipmentView.CreateView(); ShipmentDocumentView.CreateView(); PhonebookView.CreateView(); PhonebookDocumentView.CreateView(); PhonebookNoteView.CreateView(); PhonebookPhoneView.CreateView(); InvoiceView.CreateView(); InvoiceItemView.CreateView(); CallCentarView.CreateView(); CalendarAssignmentView.CreateView(); EmployeeAttachmentView.CreateView(); PhysicalPersonAttachmentView.CreateView(); ToDoStatusView.CreateView(); var mailingTime = new Config().GetConfiguration()["MailTime"]; Console.WriteLine("Sending mails scheduled at: {0}\nCurrent time: {1}", mailingTime, DateTime.Now.ToString("HH:mm:ss")); Thread mailThread = new Thread(() => MailTask.SendMailTime(mailingTime)); mailThread.IsBackground = true; mailThread.Start(); }
/// <summary> /// Generate default clients, identity and api resources /// </summary> private static async Task EnsureSeedIdentityServerData <TIdentityServerDbContext>(TIdentityServerDbContext context, ISeedData seedData, IAdminConfiguration adminConfiguration) where TIdentityServerDbContext : DbContext, IAdminConfigurationDbContext { if (!context.IdentityResources.Any()) { foreach (var resource in seedData.IdentityResources) { await context.IdentityResources.AddAsync(resource.ToEntity()); } await context.SaveChangesAsync(); } if (!context.ApiResources.Any()) { foreach (var resource in seedData.ApiResources) { foreach (var s in resource.ApiSecrets) { s.Value = s.Value.ToSha256(); } await context.ApiResources.AddAsync(resource.ToEntity()); } await context.SaveChangesAsync(); } if (!context.Clients.Any()) { foreach (var client in seedData.Clients) { foreach (var secret in client.ClientSecrets) { secret.Value = secret.Value.ToSha256(); } client.Claims = client.ClientClaims .Select(c => new System.Security.Claims.Claim(c.Type, c.Value)) .ToList(); await context.Clients.AddAsync(client.ToEntity()); } await context.SaveChangesAsync(); } }
public DbInitializer(PazaarDbContext db, ISeedData data, ILogger <DbInitializer> logger) { this.db = db; this.data = data; this.logger = logger; }
public SeedDataController(ISeedData seedData) { this.seedData = seedData; }