예제 #1
0
파일: Startup.cs 프로젝트: Mumes/stock
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, UpdateStocks updateStocks)
        {
            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.UseSerilogRequestLogging();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Account}/{action=Login}/{id?}");
            });
            app.UseHangfireDashboard();
            RecurringJob.AddOrUpdate("id_update_stocks", () => updateStocks.Update(), Cron.Minutely);
        }
예제 #2
0
 public async Task FullTest()
 {
     var loggerUpdateStocks = new LoggerFactory().CreateLogger <UpdateStocks>();
     var loggerStocks       = new LoggerFactory().CreateLogger <SQLStockRepository>();
     var loggerProducts     = new LoggerFactory().CreateLogger <SQLProductRepository>();
     var loggerDates        = new LoggerFactory().CreateLogger <SQLDatedPriceRepository>();
     var dbOptions          = new DbContextOptionsBuilder <AppDbContext>().UseSqlServer("Server=(localdb)\\mssqllocaldb;Database=stockDb;Trusted_Connection=True;MultipleActiveResultSets=true").Options;
     var context            = new AppDbContext(dbOptions);
     IRepository <Stock>      repositoryStock   = new SQLStockRepository(context, loggerStocks);
     IRepository <Product>    repositoryProduct = new SQLProductRepository(context, loggerProducts);
     IRepository <DatedPrice> repositoryDate    = new SQLDatedPriceRepository(context, loggerDates);
     var x = new UpdateStocks(loggerUpdateStocks, repositoryStock, repositoryProduct, repositoryDate);
     await x.Update();
 }