Exemple #1
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseStatusCodePagesWithReExecute("/Error/{0}");
            }

            app.UseCors(builder =>
            {
                builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
            });

            SeedDataBase.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);

            app.UseAuthentication();
            app.UseMiddleware <TokenServiceMiddleware>();
            app.UseHttpsRedirection();
            //app.UseMvc();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "areas",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
                    );
            });

            app.UseSwagger(option => { option.RouteTemplate = "swagger/{documentName}/swagger.json"; });
            app.UseSwaggerUI(option => { option.SwaggerEndpoint("v1/swagger.json", "API"); });
        }
Exemple #2
0
        private void InitializeDbData(IApplicationBuilder app, IConfiguration configuration)
        {
            try
            {
                using (var scope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
                {
                    var repositoryFactory = scope.ServiceProvider.GetRequiredService <IRepositoryFactory>();

                    SeedDataBase.MigrateDatabase(repositoryFactory);
                    SeedDataBase.SeedDatabase(repositoryFactory);
                }
            }
            catch (Exception ex)
            {
                string pathLog  = _webRootPath.Replace("wwwroot", "logs");
                string pathFile = pathLog + "\\log-InitializeDbData.txt";

                if (!Directory.Exists(pathLog))
                {
                    Directory.CreateDirectory(pathLog);
                }

                if (File.Exists(pathFile))
                {
                    File.Delete(pathFile);
                }

                File.WriteAllText(pathFile, "InitializeDbData Error: " + ex.Message);
            }
        }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseHttpsRedirection();

            SeedDataBase.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);

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

            //app.UseMvc();
            app.UseEndpoints(endpoint =>
            {
                endpoint.MapDefaultControllerRoute();
            });
        }
        protected override void Seed()
        {
            var portfolioId = SeedDataBase.CreatePortfolio("test", DateTime.Now);

            _summaryId = SeedDataBase.CreatePortfolioTransactionSummary(portfolioId);
            SeedDataBase.CreatePortfolioTransactionsConsolidation(_summaryId);
        }
Exemple #5
0
 public void Dispose()
 {
     SeedDataBase.Drop();
     if (ApplicationContext.Container != null)
     {
         ApplicationContext.Container.Dispose();
     }
 }
Exemple #6
0
        public FormInicio()
        {
            InitializeComponent();
            seed = new SeedDataBase();

            nombredb   = ConfigurationManager.AppSettings["BaseDatosNombre"].ToString();
            pathdb     = ConfigurationManager.AppSettings["UrlBaseDAtos"].ToString();
            pathImagen = ConfigurationManager.AppSettings["UrlImagen"].ToString();
        }
        protected override void Seed()
        {
            _name        = "test portfolio";
            _portfolioId = SeedDataBase.CreatePortfolio(_name, DateTime.Now);
            var x = SeedDataBase.CreatePortfolioShare("ABC");
            var y = SeedDataBase.CreatePortfolioTransactionType("Close");

            _portfolioTransactionId = SeedDataBase.GetPortfolioTransaction(_portfolioId);
        }
Exemple #8
0
        protected override void Seed()
        {
            var openDate = DateTime.Now;

            _openDate = openDate.ToString(DateFormat);

            _name        = "test portfolio";
            _portfolioId = SeedDataBase.CreatePortfolio(_name, openDate);
            _portfolioTransactionSummaryId = SeedDataBase.CreatePortfolioTransactionSummary(_portfolioId);
        }
Exemple #9
0
        public formmenu()
        {
            InitializeComponent();
            seed = new SeedDataBase();

            nombredb   = ConfigurationManager.AppSettings["BaseDatosNombre"].ToString();
            pathdb     = ConfigurationManager.AppSettings["UrlBaseDAtos"].ToString();
            pathImagen = ConfigurationManager.AppSettings["UrlImagen"].ToString();
            IsAdmin    = Convert.ToBoolean(ConfigurationManager.AppSettings["IA"].ToString());
        }
        public void Run(string scenarioTitle, string given, string when, string then)
        {
            Init();
            SeedDataBase.DropAndCreate();
            Seed();

            this.Given(_ => Given(), given)
            .When(_ => When(), when)
            .Then(_ => Then(), then)
            .BDDfy(scenarioTitle);
        }
Exemple #11
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();
            }
            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();
            }

            SeedDataBase.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);

            app.UseAuthentication();
            // app.UseHttpsRedirection();
            app.UseMvc();
        }
Exemple #12
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseStaticFiles();

            app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader().AllowCredentials());

            app.UseMvc();

            app.UseAuthentication();

            var tokenValidationParameters = new TokenValidationParameters
            {
                ValidateIssuerSigningKey = true,
                IssuerSigningKey         = new SymmetricSecurityKey(Encoding.UTF8.GetBytes("MySuperSecureKey"))
            };

            SeedDataBase.Initialize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);
        }
Exemple #13
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider provider, ApplicationDbContext context)
        {
            SeedDataBase seedDataBase = new SeedDataBase(provider, context);

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

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseCookiePolicy();

            app.UseAuthentication();

            try
            {
                seedDataBase.Seed().Wait();
                app.UseMvc(routes =>
                {
                    routes.MapRoute(
                        name: "default",
                        template: "{controller=Home}/{action=Index}/{id?}");
                });
            }
            catch
            {
                app.UseMvc(routes =>
                {
                    routes.MapRoute(
                        name: "default",
                        template: "{controller=Home}/{action=DBError}");
                });
            }
        }
Exemple #14
0
        public static async Task Main(string[] args)
        {
            var host = CreateHostBuilder(args).Build();

            using (var scope = host.Services.CreateScope())
            {
                var services = scope.ServiceProvider;

                try
                {
                    await SeedDataBase.InitializeDataBase(services);
                }
                catch (Exception ex)
                {
                    var logger = services.GetRequiredService <ILogger <Program> >();
                    logger.LogError(ex, "An error occurred seeding the DB.");
                }
            }

            host.Run();
        }
 // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
 /// <summary>
 ///
 /// </summary>
 /// <param name="app"></param>
 /// <param name="env"></param>
 /// <param name="loggerFactory"></param>
 /// <param name="serviceProvider"></param>
 /// <param name="memoryCache"></param>
 public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory,
                       IServiceProvider serviceProvider, IMemoryCache memoryCache)
 {
     if (env.IsDevelopment())
     {
         app.UseDeveloperExceptionPage();
     }
     app.UseStaticFiles();
     loggerFactory.AddDebug();
     LoggerFactory = loggerFactory;
     //app.UseMetrics();
     ConfigureSwaggerServices(app, Configuration);
     app.UseCors("CorsPolicy");
     SeedDataBase.Initilize(app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope().ServiceProvider);
     app.UseAuthentication();
     app.UseMvc();
     app.UseSwagger();
     app.UseSwaggerUI(c =>
     {
         c.SwaggerEndpoint("/swagger/v1/swagger.json", "Product API V1");
     });
 }
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UserManager <ApplicationUser> userManager, RoleManager <ApplicationRole> roleManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                SeedDataBase.SeedData();
            }

            app.UseRouting();
            app.UseStaticFiles();
            app.UseNpmStaticFiles();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(name: "orders", pattern: "orders", defaults: new { controller = "Cart", action = "GetOrders" });

                endpoints.MapControllerRoute(name: "checkout", pattern: "checkout", defaults: new { controller = "cart", action = "checkout" });
                endpoints.MapControllerRoute(name: "Cart", pattern: "cart", defaults: new { controller = "cart", action = "index" });
                endpoints.MapControllerRoute(name: "default", pattern: "{controller}/{action}/{id?}", defaults: new { controller = "home", action = "index" });
            });

            IdentityDataSeed.SeedIdentityData(userManager, roleManager, Configuration).Wait();
        }
Exemple #17
0
 protected override void Seed()
 {
     SeedDataBase.InitializeDataBase();
     ApplicationContext.Container.Resolve <IAuthenticationContext <ImportXlsPipelineResponse> >()
     .IsValidTokenProvided = true;
 }
 protected override void Seed()
 {
     SeedDataBase.CreatePortfolio("test portfolio 1", DateTime.Now);
     SeedDataBase.CreatePortfolio("test portfolio 2", DateTime.Now);
     SeedDataBase.CreatePortfolio("test portfolio 3", DateTime.Now);
 }
 protected override void Seed()
 {
     _portfolioId = SeedDataBase.CreatePortfolio("test", DateTime.Now);
     _summaryId   = SeedDataBase.CreatePortfolioTransactionSummary(_portfolioId);
 }
Exemple #20
0
 public IActionResult SeedDatabase()
 {
     SeedDataBase.EnsurePopulated(HttpContext.RequestServices);
     return(RedirectToAction(nameof(Index)));
 }
 protected override void Seed()
 {
     SeedDataBase.InitializeDataBase();
     ApplicationContext.Container.Resolve <IApplicationUserContext>().Token.IsValidTokenProvided = true;
 }
Exemple #22
0
 protected override void Seed()
 {
     SeedDataBase.InitializeDataBase();
 }
 protected override void Seed()
 {
     _portfolioId = SeedDataBase.CreatePortfolio("test", new DateTime());
     _portfolioId = SeedDataBase.CreatePortfolioShare("test");
     _portfolioId = SeedDataBase.CreatePortfolioTransactionType("test");
 }
 protected override void Seed()
 {
     SeedDataBase.InitializeDataBase();
     _leadId = SeedDataBase.CreateLead($"test{TestHelpers.UniqueName()}[email protected]");
 }