// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, HistoryDbContext historyDbContext) { 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.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute( name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); }); historyDbContext.Database.EnsureCreated(); }
public EventLinksController(HistoryDbContext context, IDataShaper <Event> eventDataShaper, IDataShaper <Birth> birthDataShaper, IDataShaper <Death> deathDataShaper) { _eventDataShaper = eventDataShaper; _birthDataShaper = birthDataShaper; _deathDataShaper = deathDataShaper; _context = context; unitOfWork = new UnitOfWork(_context, _eventDataShaper, _birthDataShaper, _deathDataShaper); }
public UnitOfWork(HistoryDbContext context, IDataShaper <Event> eventDataShaper, IDataShaper <Birth> birthDataShaper , IDataShaper <Death> deathDataShaper) { _context = context; _eventDataShaper = eventDataShaper; _birthDataShaper = birthDataShaper; _deathDataShaper = deathDataShaper; }
public static void Scrape(IApplicationBuilder applicationBuilder) { var scope = applicationBuilder.ApplicationServices.CreateScope(); HistoryDbContext _historyDbContext = scope.ServiceProvider.GetRequiredService <HistoryDbContext>(); PageScraper pageScraper = new PageScraper(); var months = CultureInfo.GetCultureInfo("en-us").DateTimeFormat.MonthNames; List <Event> events = new List <Event>(); List <Birth> births = new List <Birth>(); List <Death> deaths = new List <Death>(); var watch = System.Diagnostics.Stopwatch.StartNew(); if (!_historyDbContext.Event.Any()) { for (int i = 0; i < 12; i++) { for (int j = 1; j < DateTime.DaysInMonth(DateTime.Now.Year, i + 1); j++) { events = pageScraper.GetData <Event>(months[i] + "_" + j.ToString(), "1"); _historyDbContext.AddRange(events); } } _historyDbContext.SaveChanges(); } if (!_historyDbContext.Birth.Any()) { for (int i = 0; i < 12; i++) { for (int j = 1; j < DateTime.DaysInMonth(DateTime.Now.Year, i + 1); j++) { births = pageScraper.GetData <Birth>(months[i] + "_" + j.ToString(), "2"); _historyDbContext.AddRange(births); } } _historyDbContext.SaveChanges(); } if (!_historyDbContext.Death.Any()) { for (int i = 0; i < 12; i++) { for (int j = 1; j < DateTime.DaysInMonth(DateTime.Now.Year, i + 1); j++) { deaths = pageScraper.GetData <Death>(months[i] + "_" + j.ToString(), "3"); _historyDbContext.AddRange(deaths); } } _historyDbContext.SaveChanges(); } // measuring the time it takes to scrape for fun watch.Stop(); var elapsedMs = watch.ElapsedMilliseconds; System.Diagnostics.Trace.WriteLine("ScrapeData took" + elapsedMs.ToString() + " ms"); }
public void TestGetHistoryValue() { HistoryDbContext context = new HistoryDbContext(); List <HistoryValue> list = context.GetHistoryValues(new string[] { "000001G0010001", "000001G0010002" }, new string[] { "31000000000711" }, new DateTime(2018, 4, 27, 10, 30, 0)); for (int i = 0; i < list.Count; i++) { Console.WriteLine("MeterID:{0};MeterParamID:{1};Value:{2}", list[i].MeterID, list[i].MeterParamID, list[i].Value); } }
public void EventGetById_ReturnsHttpNotFound_ForInvalidId() { var optionsBuilder = new DbContextOptionsBuilder <HistoryDbContext>(); optionsBuilder.UseInMemoryDatabase(Guid.NewGuid().ToString()); var _dbContext = new HistoryDbContext(optionsBuilder.Options); var controller = new EventsController(_dbContext); // Act var result = controller.GetEventById(1, ""); Assert.IsType <NotFoundObjectResult>(result); }
public BirthsController(HistoryDbContext context) { _context = context; unitOfWork = new UnitOfWork(_context, _eventDataShaper, _birthDataShaper, _deathDataShaper); }
public ChangeRepository(HistoryDbContext context) : base(context) { }
public RepositoryImplementor(HistoryDbContext h) { this.historyDbContext = h; }
public BaseRepository(HistoryDbContext context) { this.context = context; table = context.Set <T>(); }
public GenericRepository(HistoryDbContext @object) { this.@object = @object; }
public CircuitCollectService() { context = new HistoryDbContext(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, HistoryDbContext context) { loggerFactory.AddConsole(Configuration.GetSection("Logging")); loggerFactory.AddDebug(); StartupConfigureAuth.ConfigureAuth(app); app.UseMvc(); HistoryDbInitializer.Initialize(context); }
public GenericRepository(HistoryDbContext context, IDataShaper <T> dataShaper) { _context = context; dbSet = _context.Set <T>(); _dataShaper = dataShaper; }
public EventLinksController(HistoryDbContext context) { _context = context; unitOfWork = new UnitOfWork(_context); }
public GenericRepository(HistoryDbContext context) { _context = context; dbSet = _context.Set <T>(); }
public DeathsController(HistoryDbContext context) { _context = context; unitOfWork = new UnitOfWork(_context); }
public HistoryDataService() { context = new HistoryDbContext(); }
public EventsController(HistoryDbContext dbContext) { this.dbContext = dbContext; }
public HistoryRepository(HistoryDbContext context) { _context = context; }
public UnitOfWork(HistoryDbContext context) { _context = context; }
public CustomerController(HistoryDbContext context) { _context = context; }
public static void Initialize(HistoryDbContext context) { context.Database.EnsureCreated(); }