Exemplo n.º 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, AlertsDbContext db, SyncService sync)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
                app.UseHsts();
            }

            app.UseHttpsRedirection();
            app.UseStaticFiles();
            app.UseSpaStaticFiles();

            app.UseHangfireDashboard("/hangfire", new DashboardOptions
            {
                StatsPollingInterval = 60,
                Authorization        = new[] { new HangfireDashboardAuthorizationFilter() }
            });

            var options = new BackgroundJobServerOptions
            {
                WorkerCount = 1
            };

            app.UseHangfireServer(options);

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action=Index}/{id?}");
            });

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

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

            db.UpdateSchema();

            sync.ScheduleSynchronization();
        }
Exemplo n.º 2
0
        public async Task Synchronize()
        {
            Environment e = new Environment();

            AlertsDbContext db = e.Db;

            var stavanger = db.Sources.Add(new Source {
                Name = "Stavanger kommune", Url = "opengov:stavanger"
            }).Entity;
            var sandnes = db.Sources.Add(new Source {
                Name = "Sandnes kommune", Url = "opengov:sandnes"
            }).Entity;

            Observer slf = new Observer {
                Name = "SLF Nord-Jæren og Ryfylke", Emails = new string[] { "*****@*****.**" }, SmtpServer = "mail.syklistene.no", SmtpPassword = "******", SmtpSender = "*****@*****.**", SmtpPort = 587, SmtpUseSsl = true
            };

            db.Observers.Add(slf);

            var search = db.Searches.Add(new Search {
                CreatedBy = slf, Name = "Sykkel", Phrase = "sykkel", Start = DateTime.UtcNow
            }).Entity;

            search.Sources = new List <SearchSource>()
            {
                new SearchSource {
                    Source = stavanger, Search = search
                }, new SearchSource {
                    Source = sandnes, Search = search
                }
            };

            await db.SaveChangesAsync();

            OpenGovAlerts.Services.SyncService service = new OpenGovAlerts.Services.SyncService(db);
            await service.Synchronize();

            Assert.IsTrue(db.Meetings.Any(), "No meetings in DB");
            Assert.IsTrue(db.Matches.Any(), "No matches in DB");

            stavanger = db.Sources.Include(s => s.Meetings).FirstOrDefault(s => s.Name == "Stavanger kommune");
            Assert.IsTrue(stavanger.Meetings.Any(), "No meetings for Stavanger kommune in DB");

            sandnes = db.Sources.Include(s => s.Meetings).FirstOrDefault(s => s.Name == "Sandnes kommune");
            Assert.IsTrue(sandnes.Meetings.Any(), "No seen meeting for Sandnes kommune in DB");
        }
Exemplo n.º 3
0
 public SyncService(AlertsDbContext db)
 {
     this.db = db;
 }
Exemplo n.º 4
0
 public AdminController(AlertsDbContext db)
 {
     this.db = db;
 }
Exemplo n.º 5
0
 public MemberController(AlertsDbContext db)
 {
     this.db = db;
 }