public RegisterJobHandler(IRecurringJobManager recurringJobManager, IMediator mediator)
 {
     _recurringJobManager = recurringJobManager;
     _mediator            = mediator;
 }
 public BackgroundProcessor(IBackgroundJobClient jobClient,
                            IRecurringJobManager recurringJobManager)
 {
     _jobClient           = jobClient;
     _recurringJobManager = recurringJobManager;
 }
Example #3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app,
                              IWebHostEnvironment env,
                              IRecurringJobManager recurringJobManager,
                              IServiceProvider serviceProvider)
        {
            app.UseCors(builder =>
            {
                builder
                .AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            });

            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/V1/swagger.json", "MyApi");
            });

            var supportedCultures = new[]
            {
                new CultureInfo("uk-UA"),
                new CultureInfo("en-US"),
                new CultureInfo("en"),
                new CultureInfo("uk")
            };

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture("uk-UA"),
                // Formatting numbers, dates, etc.
                SupportedCultures = supportedCultures,
                // UI strings that we have localized.
                SupportedUICultures = supportedCultures
            });

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.ConfigureCustomExceptionMiddleware();
                // 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.UseAntiforgeryTokens();
            app.UseStatusCodePages();
            app.UseHttpsRedirection();
            app.UseRouting();
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
            app.UseHangfireDashboard();
            recurringJobManager.AddOrUpdate("Run every day",
                                            () => serviceProvider.GetService <IPlastDegreeService>().GetDergeesAsync(),
                                            "59 23 * * *",
                                            TimeZoneInfo.Local
                                            );
            recurringJobManager.AddOrUpdate("Check and change event status",
                                            () => serviceProvider.GetService <IActionManager>().CheckEventsStatusesAsync(),
                                            "59 23 * * *",
                                            TimeZoneInfo.Local
                                            );
            CreateRoles(serviceProvider).Wait();
        }
Example #4
0
 public ChronosService([NotNull] IBackgroundJobClient backgroundJobs, [NotNull] IRecurringJobManager recurringJobs, [NotNull] ILogger <RecurringJobScheduler> logger, [NotNull] IConfiguration configuration) : base(backgroundJobs, recurringJobs, logger, configuration)
 {
 }
 public override void ConfigureHangfireJobs(IRecurringJobManager recurringJobManager)
 {
     //"0 0 31 2 0"
     recurringJobManager.AddOrUpdate("check-link", Job.FromExpression <Job1>(m => m.Execute()), Cron.Never(), new RecurringJobOptions());
     recurringJobManager.Trigger("check-link");
 }
Example #6
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env,
                              ILoggerFactory loggerFactory, IApplicationLifetime lifetime,
                              IRecurringJobManager recurringJobs)
        {
            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            //  google calendar

            //app.UseAuthentication().UseMvc();  removed temporarily while I decide what to do with the Google calendar

            //

            // Sessions
            app.UseSession();

            //


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



            //added for Hangfire

            GlobalConfiguration.Configuration.UseSqlServerStorage((Configuration.GetConnectionString("DefaultConnection")));
            app.UseHangfireDashboard();
            app.UseHangfireServer();

            //start and configure recurring Hangfire jobs on startup

            app.UseMvc();
            // launch Annual Reminders Backgroind Task
            recurringJobs.AddOrUpdate("Annual_Reminders", Job.FromExpression <RemindMeController>(x => x.LaunchSendRecurringReminderTextsAnnually(null)), Cron.Daily(22, 43)); //UTC (HR, Min) time of 4 hours ahead of Eastern Time
                                                                                                                                                                               //RecurringJob.AddOrUpdate("Annual_Reminders", () => SendRecurringReminderTextsAnnually(), "44 10 * * *");  // every day at 10:44 am

            // launch annual reset of RecurringReminderDateAndTimeLastAlertSent
            // we have to set the dates to 01/01 so the logic in the SendRecurringReminderTextsAnnually() method will work correctly in a new year

            recurringJobs.AddOrUpdate("Reset_RecurringReminderDateAndTimeLastAlertSent", Job.FromExpression <RemindMeController>(x => x.LaunchResetRecurringReminderDateAndTimeLastAlertSent(null)), Cron.Yearly(01, 01, 04, 00)); //()Month,day,Hour, minute  in UTC - starts at the first minute of the hour - note UTC is +5 hours to EST


            // this one works!!
            //
            // recurringJobs.AddOrUpdate("Annual_Reminders", Job.FromExpression<RemindMeController>(x => x.LaunchBackGroundJobs(null)), Cron.Minutely());
            //
        }
Example #7
0
 public HangfireScheduledJobs(IRecurringJobManager recurringJobManager)
 {
     _recurringJobManager = recurringJobManager;
 }
Example #8
0
 private void SeedHangfireJobs(IRecurringJobManager recurringJobManager)
 {
     recurringJobManager.AddOrUpdate <CheckFeedsJob>(nameof(CheckFeedsJob), x => x.Work(null), "*/1 * * * *");
 }
 public MessagesHostedService(IRecurringJobManager recurringJob, IBus publisher, IServiceScopeFactory scopeFactory)
 {
     this.recurringJob = recurringJob;
     this.publisher    = publisher;
     this.scopeFactory = scopeFactory;
 }
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IBackgroundJobClient backgroundJobClient, IRecurringJobManager recurringJobManager, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
                app.UseHsts();
            }

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

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

            app.UseHangfireDashboard();
            //backgroundJobClient.Enqueue(() => Console.WriteLine("Sart"));
            recurringJobManager.AddOrUpdate("run every 5 Mint", () => serviceProvider.GetService <CallApiService>().CallService(), "*/60 * * * *");
            //recurringJobManager.AddOrUpdate("run every 3 Mint", () => serviceProvider.GetService<SmartEdgeServices>().CallServices(), "*/30 * * * *");
        }
Example #11
0
 public JobManager(IRecurringJobManager recurringJobManager, INotificationJob notificationJob)
 {
     _recurringJobManager = recurringJobManager;
     _notificationJob     = notificationJob;
 }
 public void ConfigureHangfireJobs(IRecurringJobManager recurringJobManager, IConfiguration configuration, IHostingEnvironment hostingEnvironment)
 {
 }
Example #13
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IRecurringJobManager recurringJobManager)
        {
            AutoMapperConfig.RegisterMappings(typeof(ErrorViewModel).GetTypeInfo().Assembly);

            // Seed data on application startup
            using (var serviceScope = app.ApplicationServices.CreateScope())
            {
                var dbContext = serviceScope.ServiceProvider.GetRequiredService<ApplicationDbContext>();
                dbContext.Database.Migrate();
                new ApplicationDbContextSeeder().SeedAsync(dbContext, serviceScope.ServiceProvider).GetAwaiter().GetResult();
            }

            this.SeedHangfireJobs(recurringJobManager);

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

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

            app.UseRouting();

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

            if (env.IsProduction())
            {
                app.UseHangfireDashboard(
                    "/hangfire",
                    new DashboardOptions { Authorization = new[] { new HangfireAuthorizationFilter() } });
            }

            app.UseEndpoints(
                endpoints =>
                    {
                        endpoints.MapControllerRoute(
                            "index.html",
                            "index.html",
                            new { controller = "Home", action = "Index" });
                        endpoints.MapControllerRoute(
                            "Blog post",
                            "Blog/{year}/{month}/{title}/{id}",
                            new { controller = "Blog", action = "Post" });
                        endpoints.MapControllerRoute(
                            "Page",
                            "Pages/{permalink}",
                            new { controller = "Pages", action = "Page" });
                        endpoints.MapControllerRoute(
                            "areaRoute",
                            "{area:exists}/{controller=Home}/{action=Index}/{id?}");
                        endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
                        endpoints.MapRazorPages();
                    });
        }
Example #14
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IBackgroundJobClient backgroundJobs, IRecurringJobManager recurringJob, ApplicationDbContext context)
        {
            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.UseRouting();

            app.UseHangfireDashboard("/hangfire", new DashboardOptions
            {
                Authorization = new[] { new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions
                    {
                        RequireSsl         = false,
                        SslRedirect        = false,
                        LoginCaseSensitive = true,
                        Users = new []
                        {
                            new BasicAuthAuthorizationUser
                            {
                                Login         = Configuration.GetValue <string>("HangFire:Username"),
                                PasswordClear = Configuration.GetValue <string>("HangFire:Password"),
                            }
                        }
                    }) }
            });

            var cron = new CronHelpers(context);

            recurringJob.AddOrUpdate("CleanInvestmentsJob", Job.FromExpression(() => cron.AwardInvestmentProfits()), Cron.Daily(17));
            recurringJob.AddOrUpdate("CleanEspionagesJob", Job.FromExpression(() => cron.RemoveEspionageInvestments()), Cron.Daily(17));

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

            app.UseOpenApi();
            app.UseSwaggerUi3();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
            });
        }
Example #15
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IRecurringJobManager recurringJobManager)
        {
            AutoMapperConfig.RegisterMappings(typeof(ErrorViewModel).GetTypeInfo().Assembly);

            // Seed data on application startup
            using (var serviceScope = app.ApplicationServices.CreateScope())
            {
                var dbContext = serviceScope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
                dbContext.Database.Migrate();
                ApplicationDbContextSeeder.Seed(dbContext, serviceScope.ServiceProvider);
                SeedHangfireJobs(recurringJobManager, dbContext);
            }

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

            app.UseHttpsRedirection();
            app.UseStaticFiles(
                new StaticFileOptions
            {
                OnPrepareResponse = ctx =>
                {
                    if (ctx.Context.Request.Path.ToString().Contains("/news/"))
                    {
                        // Cache static files for 90 days
                        ctx.Context.Response.Headers.Add("Cache-Control", "public,max-age=31536000");
                        ctx.Context.Response.Headers.Add(
                            "Expires",
                            DateTime.UtcNow.AddYears(1).ToString("R", CultureInfo.InvariantCulture));
                    }
                },
            });

            app.UseRouting();

            app.UseCookiePolicy();
            app.UseAuthentication();
            app.UseAuthorization();

            if (env.IsProduction())
            {
                app.UseHangfireDashboard(
                    "/hangfire",
                    new DashboardOptions {
                    Authorization = new[] { new HangfireAuthorizationFilter() }
                });
            }

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    "areaRoute",
                    "{area:exists}/{controller=Home}/{action=Index}/{id?}");
                endpoints.MapControllerRoute(
                    "news",
                    "News/{id:int:min(1)}/{slug:required}",
                    new { controller = "News", action = "ById", });
                endpoints.MapControllerRoute(
                    "news",
                    "News/{id:int:min(1)}",
                    new { controller = "News", action = "ById", });
                endpoints.MapControllerRoute("default", "{controller=News}/{action=List}/{id?}");
                endpoints.MapRazorPages();
            });
        }
Example #16
0
 public RotationScheduler(IRecurringJobManager recurringJobManager)
 {
     _recurringJobManager = recurringJobManager ?? throw new ArgumentNullException(nameof(recurringJobManager));
 }
Example #17
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IBackgroundJobClient backgroundJobClient, IRecurringJobManager recurringJobManager, IServiceProvider serviceProvider)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            app.UseAuthentication();
            app.UseAuthorization();
            app.UseHttpsRedirection();
            app.UseSession();
            app.UseMvc(routes =>
            {
                routes.MapRoute("Default", "{Controller=Home}/{Action=Index}/{id?}");
            });

            app.UseHttpsRedirection();

            app.UseRouting();
            app.UseStaticFiles();
            app.UseMvcWithDefaultRoute();
            app.UseHangfireDashboard("/EYEt<_1e*dj.jYpO=(");
            recurringJobManager.AddOrUpdate("Run every hour", () => serviceProvider.GetService <IVetJob>().VetCurrnetJob(), Cron.Minutely);
        }
 ScheduleRecurringMessageConsumer(IRecurringJobManager recurringJobManager, ITimeZoneResolver timeZoneResolver)
 {
     _recurringJobManager = recurringJobManager;
     _timeZoneResolver    = timeZoneResolver;
 }
 /// <summary>
 /// use SettingCronJobBuilder for preparing SettingCronJob
 /// </summary>
 /// <param name="recurringJobManager"></param>
 /// <param name="settingsManager"></param>
 /// <param name="settingCronJob"></param>
 /// <returns></returns>
 public static void WatchJobSetting(this IRecurringJobManager recurringJobManager,
                                    ISettingsManager settingsManager,
                                    SettingCronJob settingCronJob)
 {
     recurringJobManager.WatchJobSettingAsync(settingsManager, settingCronJob).GetAwaiter().GetResult();
 }
Example #20
0
 public ApplicationJobsRegistrar(IRecurringJobManager recurringJobManager)
 {
     _recurringJobManager = recurringJobManager;
 }
Example #21
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider services, IBackgroundJobClient backgroundJobs, IRecurringJobManager recurringJobs)
        {
            app.UseCors();
            app.UseHangfireDashboard();
            var mismeBackJobs = services.GetRequiredService <IMismeBackgroundService>();

            recurringJobs.AddOrUpdate <IMismeBackgroundService>("ExpiredTokens", (e) => e.CleanExpiredTokensAsync(), "0 3 * * *");
            recurringJobs.AddOrUpdate <IMismeBackgroundService>("DisabledAccount", (e) => e.RemoveDisabledAccountsAsync(), "0 3 * * *");
            //recurringJobs.AddOrUpdate<IMismeBackgroundService>("Notifications", (e) => e.SendFireBaseNotificationsRemindersAsync(), "0 18 * * *");
            recurringJobs.AddOrUpdate <IMismeBackgroundService>("HandleUserStreaksWest", (e) => e.HandleUserStreaksAsync(1), "0 10 * * *", TimeZoneInfo.Utc);
            recurringJobs.AddOrUpdate <IMismeBackgroundService>("HandleUserStreaksEast", (e) => e.HandleUserStreaksAsync(-1), "0 23 * * *", TimeZoneInfo.Utc);
            recurringJobs.AddOrUpdate <IMismeBackgroundService>("HandleSubscriptions", (e) => e.HandleSubscriptionsAsync(), "0 12 * * *", TimeZoneInfo.Utc);
            //recurringJobs.AddOrUpdate<IMismeBackgroundService>("SendPlanifyEventNotificationAsync", (e) => e.SendPlanifyEventNotificationAsync(), "0 12 ? * 3,6", TimeZoneInfo.Utc);

            recurringJobs.AddOrUpdate <IMismeBackgroundService>("SendReportsAsync", (e) => e.SendReportsAsync(), "0 7 * * 0", TimeZoneInfo.Utc);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Misme API V1");
            });

            app.UseHttpsRedirection();

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

            app.UseMiddleware(typeof(ErrorWrappingMiddleware));
            app.UseResponseCompression();
            app.UseEndpoints(endpoints =>
            {
                endpoints.MapHub <UserHub>("/userHub", map => { });

                endpoints.MapHealthChecks("/health", new HealthCheckOptions()
                {
                    ResultStatusCodes =
                    {
                        [HealthStatus.Healthy]   = StatusCodes.Status200OK,
                        [HealthStatus.Degraded]  = StatusCodes.Status200OK,
                        [HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable
                    }
                });
                endpoints.MapControllers();
            });

            DatabaseSeed.SeedDatabaseAsync(services).Wait();
        }
Example #22
0
 public ReportsController(IReportRunner reportRunner, IOptions <Config> configOptions, UloDbContext db, ICacher cacher, PortalHelpers portalHelpers, UserHelpers userHelpers, ILogger <ReportsController> logger, IRecurringJobManager rjm, IBackgroundJobClient backgroundJobClient)
     : base(db, cacher, portalHelpers, userHelpers, logger)
 {
     ReportRunner        = reportRunner;
     ConfigOptions       = configOptions;
     RJM                 = rjm;
     BackgroundJobClient = backgroundJobClient;
 }
Example #23
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IYoubike youbike, IBackgroundJobClient backgroundJob, IRecurringJobManager recurringJob, IWebHostEnvironment env)
        {
            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.UseHangfireDashboard();
            recurringJob.AddOrUpdate("6hr Get Youbike Log.", () => youbike.GetYoubikeAPI(), "0 */6 * * *");

            app.UseRouting();

            app.UseCors();

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
            });
        }
Example #24
0
 public BackgroundJobService(IBackgroundJobClient backgroundJobClient, IRecurringJobManager recurringJobManager)
 {
     _backgroundJobClient = backgroundJobClient;
     _recurringJobManager = recurringJobManager;
 }
Example #25
0
 public RecurringJobService(IRecurringJobManager recurringJobManager, ILogger <RecurringJobService> logger)
 {
     _recurringJobManager = recurringJobManager;
     _logger  = logger;
     JobsList = new List <string>();
 }
Example #26
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IWebHostEnvironment env,
            IRecurringJobManager recurringJobManager,
            IServiceProvider serviceProvider)
        {
            AutoMapperConfig.RegisterMappings(typeof(ErrorViewModel).GetTypeInfo().Assembly);

            StripeConfiguration.ApiKey = this.configuration["Stripe:SecretKey"];

            if (env.IsProduction())
            {
                app.UseHangfireServer(new BackgroundJobServerOptions {
                    WorkerCount = 2
                });
                app.UseHangfireDashboard(
                    "/hangfire",
                    new DashboardOptions {
                    Authorization = new[] { new HangfireAuthorizationFilter() }
                });
            }

            // Seed data on application startup
            using (var serviceScope = app.ApplicationServices.CreateScope())
            {
                var dbContext = serviceScope.ServiceProvider.GetRequiredService <ApplicationDbContext>();
                dbContext.Database.Migrate();
                new ApplicationDbContextSeeder(env.WebRootPath).SeedAsync(dbContext, serviceScope.ServiceProvider).GetAwaiter().GetResult();
                this.SeedHangfireJobs(recurringJobManager, serviceProvider);
            }

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

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

            app.UseRouting();

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

            app.UseSession();

            app.UseEndpoints(
                endpoints =>
            {
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapControllerRoute("areaRoute", "{area:exists}/{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();
                endpoints.MapHangfireDashboard();
            });
        }
Example #27
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IBackgroundJobClient backgroundJobClient, IRecurringJobManager recurringJobManager, IServiceProvider serviceProvider)
        {
            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.UseSession();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapAreaControllerRoute(
                    name: "MyAreaResident",
                    areaName: "Resident",
                    pattern: "Resident/{controller=User}/{action=UserLogin}/{id?}");

                endpoints.MapAreaControllerRoute(
                    name: "MyAreaRoom",
                    areaName: "Room",
                    pattern: "Room/{controller=Room}/{action=RoomList}/{id?}");

                endpoints.MapAreaControllerRoute(
                    name: "MyAreaDevice",
                    areaName: "Device",
                    pattern: "Device/{controller=Device}/{action=OpenRoomDeviceList}/{id?}");

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{area=Resident}/{controller=User}/{action=UserLogin}/{id?}");
            });

            app.UseHangfireDashboard();

            recurringJobManager.AddOrUpdate(
                "Iterates through scenarios every minute",
                () => serviceProvider.GetService <IScenarioRunService>().IterateScenarios(),
                "* * * * *"
                );
        }
Example #28
0
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IServiceProvider serviceProvider, IRecurringJobManager recurringJobManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            //.UseHttpsRedirection()
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint(SwaggerConfiguration.EndpointUrl, SwaggerConfiguration.EndpointDescription);
            });

            app.UseHangfireDashboard();

            recurringJobManager.AddOrUpdate <IChangeClaimStateService>("some-id", x => x.SendClaimsToAjuicio("Sistema"), Cron.Daily());

            app.UseCors("AllowOrigin");
            app.UseResponseCompression();
            app.UseMvc();
        }
Example #29
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider sp, IRecurringJobManager jobManager)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseMiddleware <ApplicationInsightsMiddleware>();
            app.UseStaticFiles();

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

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");
                endpoints.MapRazorPages();

                endpoints.MapGet($"/jobs/{nameof(NotificationSenderJob)}", context =>
                                 ActivatorUtilities.CreateInstance <NotificationSenderJob>(context.RequestServices).SendNotifications());

                endpoints.MapGet($"/jobs/{nameof(RetentionJob)}", context =>
                                 ActivatorUtilities.CreateInstance <RetentionJob>(context.RequestServices).RemoveOldAttachments());
            });

            //Hangfire
            jobManager.AddOrUpdate("",
                                   () => ActivatorUtilities.CreateInstance <NotificationSenderJob>(sp).SendNotifications()
                                   , Cron.Daily);

            jobManager.AddOrUpdate("",
                                   () => ActivatorUtilities.CreateInstance <RetentionJob>(sp).RemoveOldAttachments()
                                   , Cron.Daily);

            app.UseHangfireDashboard();
            app.UseHangfireServer();

            //swagger
            app.UseSwagger();
            app.UseSwaggerUI(x =>
            {
                x.SwaggerEndpoint("/swagger/docs/swagger.json", "API Documentation");
                x.DefaultModelsExpandDepth(-1);
            });
        }
Example #30
0
 private void InstanciarJobsHangFire(IRecurringJobManager recurringJobManager)
 {
     recurringJobManager.AddOrUpdate <FinalizarInativacaoCelulasJob>("efetivar-inativacao-celulas", x => x.Execute(), "00 2 * * *");
 }