コード例 #1
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string PlexContent(JobSettings s)
 {
     return(Get(s.PlexContentSync, Cron.Daily(2)));
 }
コード例 #2
0
        /// <summary>
        /// Setup the Hangfire jobs.
        /// </summary>
        /// <param name="app"></param>
        private void SetupHangfireJobs(IApplicationBuilder app)
        {
            try
            {
                using (var serviceScope = app.ApplicationServices.GetRequiredService <IServiceScopeFactory>().CreateScope())
                {
                    // _logger.LogInformation("Creating Hangfire jobs for License issuance check ...");
                    GenericRequest id = new GenericRequest()
                    {
                        Id = Guid.NewGuid().ToString()
                    };
                    RecurringJob.AddOrUpdate(() => new OrgBookController(Configuration, _loggerFactory).SyncLicencesToOrgbook(id, null), Cron.Hourly());
                    RecurringJob.AddOrUpdate(() => new OrgBookController(Configuration, _loggerFactory).SyncOrgbookToLicences(id, null), Cron.Hourly());
                    RecurringJob.AddOrUpdate(() => new OrgBookController(Configuration, _loggerFactory).SyncOrgbookToAccounts(id, null), Cron.Daily());
                }
            }
            catch (Exception e)
            {
                StringBuilder msg = new StringBuilder();
                msg.AppendLine("Failed to setup Hangfire job.");

                // _logger.LogCritical(new EventId(-1, "Hangfire job setup failed"), e, msg.ToString());
            }
        }
コード例 #3
0
        /// <inheritdoc />
        public Task StartAsync(CancellationToken cancellationToken)
        {
            RecurringJob.AddOrUpdate <MaintenanceService>(x => x.PerformMaintenance(CancellationToken.None), Cron.Daily(4));

            // Initialize provider
            // TODO: Find a better way
            Task.Run(() =>
            {
                Task.Delay(TimeSpan.FromSeconds(5), cancellationToken);
                return(_ = _serverProvider.GetServer(2302));
            }, cancellationToken);


            return(Task.CompletedTask);
        }
コード例 #4
0
ファイル: TaskRegister.cs プロジェクト: zykour/TheAfterParty
 public static void RegisterDailyTasks()
 {
     RecurringJob.AddOrUpdate("update-users-owned-games", () => HangfireJobService.UpdateUserOwnedGames(System.Configuration.ConfigurationManager.AppSettings["steamAPIKey"]), Cron.Daily(0, 4), TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
     RecurringJob.AddOrUpdate("daily-roll-over", () => HangfireJobService.RolloverDailyDeal(), Cron.Daily(0, 4), TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
     RecurringJob.AddOrUpdate("daily-obj-roll-over", () => HangfireJobService.RolloverDailyBoosted(), Cron.Daily(0, 4), TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
     RecurringJob.AddOrUpdate("weekly-roll-over", () => HangfireJobService.RolloverWeeklyDeals(), Cron.Weekly(DayOfWeek.Friday, 0, 4), TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));
 }
コード例 #5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IOptions <ServiceSettings> serviceSettings)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            SerilogConfig.Configure(serviceSettings);

            app.UseMvc();
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "Warframe Market Aggregator v1");
            });

            app.UseHangfireServer();

            applicationLifetime.ApplicationStarted.Register(() =>
            {
                // Initialize the item cache from a file, if it exists
                // Otherwise, load the items normally
                BackgroundJob.Enqueue <ICacheFileManager>(cacheFileManager => cacheFileManager.RefreshItems(false));

                // Once a day, force a refresh of all items and update the cache file
                RecurringJob.AddOrUpdate <ICacheFileManager>(cacheFileManager => cacheFileManager.RefreshItems(true), Cron.Daily());
            });
        }
コード例 #6
0
        public void CreateRecurringJob()
        {
            GlobalConfiguration.Configuration.UseSqlServerStorage("db");

            RecurringJob.AddOrUpdate(() => RecurringMethod("Recurring task", 1), Cron.MinuteInterval(1), onlyIfLastFinishedOrFailed: true);
        }
コード例 #7
0
 public string CronExpression()
 {
     return(Cron.Minutely());
 }
コード例 #8
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string SickRageSync(JobSettings s)
 {
     return(Get(s.SickRageSync, Cron.Hourly(35)));
 }
コード例 #9
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string RefreshMetadata(JobSettings s)
 {
     return(Get(s.RefreshMetadata, Cron.DayInterval(3)));
 }
コード例 #10
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string UserImporter(JobSettings s)
 {
     return(Get(s.UserImporter, Cron.Daily()));
 }
コード例 #11
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string Newsletter(JobSettings s)
 {
     return(Get(s.Newsletter, Cron.Weekly(DayOfWeek.Friday, 12)));
 }
コード例 #12
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string Updater(JobSettings s)
 {
     return(Get(s.AutomaticUpdater, Cron.HourInterval(6)));
 }
コード例 #13
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string CouchPotato(JobSettings s)
 {
     return(Get(s.CouchPotatoSync, Cron.Hourly(30)));
 }
コード例 #14
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string PlexRecentlyAdded(JobSettings s)
 {
     return(Get(s.PlexRecentlyAddedSync, Cron.MinuteInterval(30)));
 }
コード例 #15
0
        public static IApplicationBuilder ConfigureHangfire(this IApplicationBuilder app, IConfiguration configuration)
        {
            // Configure
            app.UseHangfireDashboard();
            app.UseHangfireServer();

            // Background jobs
            var jobsIntervalInMinutes = int.Parse(configuration["AppSettings:JobsIntervalInMinutes"]);

            RecurringJob.AddOrUpdate <MainJob>("Main", x => x.Run(), Cron.MinuteInterval(jobsIntervalInMinutes));
            RecurringJob.AddOrUpdate <SendWhatsappNotificationsJob>("Send whatsapp notifications", x => x.Run(), Cron.MinuteInterval(jobsIntervalInMinutes));
            RecurringJob.AddOrUpdate <SendTelgramNotifications>("Send telegram notifications", x => x.Run(), Cron.MinuteInterval(jobsIntervalInMinutes));
            RecurringJob.AddOrUpdate <RemoveLinesJob>("Remove lines", x => x.Run(), Cron.MinuteInterval(jobsIntervalInMinutes));

            return(app);
        }
コード例 #16
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string LidarrArtistSync(JobSettings s)
 {
     return(Get(s.LidarrArtistSync, Cron.Hourly(40)));
 }
コード例 #17
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();
            }

            app.UseHangfireDashboard("", new DashboardOptions
            {
                Authorization = new [] { new MyAuthorizationFilter() }
            });

            app.UseHangfireServer(new BackgroundJobServerOptions {
                WorkerCount = 1
            });

            RecurringJob.AddOrUpdate <IETL_dadosabertos_camara_leg_br_Jobs>(_ => _.ExecuteLegislatura(), () => Cron.Monthly());
            RecurringJob.AddOrUpdate <IETL_dadosabertos_camara_leg_br_Jobs>(_ => _.ExecutePartido(), () => Cron.Monthly());
            RecurringJob.AddOrUpdate <IETL_dadosabertos_camara_leg_br_Jobs>(_ => _.ExecuteDeputado(), () => Cron.Monthly());
            RecurringJob.AddOrUpdate <IETL_dadosabertos_camara_leg_br_Jobs>(_ => _.ExecuteDespesa(), () => Cron.Daily(4));
            RecurringJob.AddOrUpdate <IETL_dadosabertos_camara_leg_br_Jobs>(_ => _.ExecuteDespesaLastMonth(), () => Cron.Daily(5));
        }
コード例 #18
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string IssuePurge(JobSettings s)
 {
     return(Get(s.IssuesPurge, Cron.Daily()));
 }
コード例 #19
0
        public static void ConfigureHangfire(IContainer container)
        {
            GlobalConfiguration.Configuration.UseSqlServerStorage("IposSyncContext");

            GlobalConfiguration.Configuration.UseActivator(new IposContainerJobActivator(container));

#if DEBUG
            RecurringJob.AddOrUpdate <ProcessFreshTransactionWorkflow>(workflow => workflow.TriggerOfflineTableSync(), Cron.MinuteInterval(1));

            RecurringJob.AddOrUpdate <ProcessFreshTransactionWorkflow>(workflow => workflow.SyncBatchToCloud(), Cron.MinuteInterval(2));

            RecurringJob.AddOrUpdate <ProcessSpoilWorkflow>(workflow => workflow.TriggerOfflineTableSync(), Cron.MinuteInterval(1));

            RecurringJob.AddOrUpdate <ProcessSpoilWorkflow>(workflow => workflow.SyncBatchToCloud(), Cron.MinuteInterval(2));
#else
            RecurringJob.AddOrUpdate <ProcessFreshTransactionWorkflow>(workflow => workflow.TriggerOfflineTableSync(), Cron.MinuteInterval(45));

            RecurringJob.AddOrUpdate <ProcessFreshTransactionWorkflow>(workflow => workflow.SyncBatchToCloud(), Cron.HourInterval(1));

            RecurringJob.AddOrUpdate <ProcessSpoilWorkflow>(workflow => workflow.TriggerOfflineTableSync(), Cron.HourInterval(24));

            RecurringJob.AddOrUpdate <ProcessSpoilWorkflow>(workflow => workflow.SyncBatchToCloud(), Cron.HourInterval(25));
#endif
        }
コード例 #20
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string Radarr(JobSettings s)
 {
     return(Get(s.RadarrSync, Cron.Hourly(15)));
 }
コード例 #21
0
        public IActionResult StartBirthdayNotificationBot([FromBody] StartBirthdayNotificationCommand command)
        {
            if (string.IsNullOrWhiteSpace(command.Token))
            {
                throw new UnauthorizedAccessException();
            }

            if (_authOptions.Token != command.Token)
            {
                throw new UnauthorizedAccessException();
            }

            RecurringJob.AddOrUpdate <BirthdayScheduleTelegramBotJobsHandler>(x => x.Notify(JobCancellationToken.Null), Cron.Daily(command.HoursUTC, 0));

            return(Ok());
        }
コード例 #22
0
        public void Configure()
        {
            foreach (var task in _tasks)
            {
                var attributes = task.GetType().GetCustomAttributes(typeof(TaskAttribute), true).FirstOrDefault() as TaskAttribute;

                if (attributes?.TaskType == TaskType.Recurring)
                {
                    RecurringJob.AddOrUpdate <ITask>(attributes.Name, x => x.Execute(), Cron.MinuteInterval(attributes.IntervalInMinutes));
                }
            }

            var server = new BackgroundJobServer();
        }
コード例 #23
0
 /// <summary>
 /// If there is no existing job with the specified jobId creates new one. If There is existing job, it updates the existing.
 /// </summary>
 public void SaveHealtCheckJob(string url, string jobId, int intervalInMinutes, string targetId, string userId, string userEmail)
 {
     try
     {
         RecurringJob.AddOrUpdate(jobId, () => Request(url, targetId, userId, userEmail), Cron.MinuteInterval(intervalInMinutes));
     }
     catch (Exception ex)
     {
         _logger.LogError(ex, "Exception occurred while saving recurring job. TargetId: {targetId}, UserId: {userId}, Url: {url},", targetId, userId, url);
         throw;
     }
 }
コード例 #24
0
        private void InitProcess()
        {
            var division = new Division();

            RecurringJob.AddOrUpdate(() => division.DivisionRandom(), Cron.Minutely());
        }
コード例 #25
0
 public string Get(int id)
 {
     //任务执行一次
     BackgroundJob.Enqueue(() => Console.WriteLine($"ASP.NET Core One Start LineZero{DateTime.Now},Id={id}"));
     //任务每分钟执行一次
     RecurringJob.AddOrUpdate(() => Console.WriteLine($"ASP.NET Core LineZero"), Cron.Minutely());
     //任务延时两分钟执行
     BackgroundJob.Schedule(() => Console.WriteLine($"ASP.NET Core await LineZero{DateTime.Now}"), TimeSpan.FromMinutes(2));
     return("value");
 }
コード例 #26
0
 /// <summary>
 ///  执行任务
 /// </summary>
 /// <param name="serviceProvider"></param>
 public static void RunTask()
 {
     RecurringJob.AddOrUpdate(() => ServerLocation._iServiceProvider.Resolve <IExecuteRedisService>().ExecuteDetpthRedisJob(), Cron.Minutely());
     RecurringJob.AddOrUpdate(() => ServerLocation._iServiceProvider.Resolve <IExecuteCallService>().ExecuteBalanceJob(), Cron.Daily(0), TimeZoneInfo.Local);
     RecurringJob.AddOrUpdate(() => ServerLocation._iServiceProvider.Resolve <IExecuteCallService>().ExecuteMarketDetailJob(), Cron.Daily(0), TimeZoneInfo.Local);
 }
コード例 #27
0
 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");
 }
コード例 #28
0
ファイル: Startup.cs プロジェクト: davidikin45/AngularApp
        public Task ExecuteAsync()
        {
            _recurringJobManager.AddOrUpdate("check-link", Job.FromExpression <Job1>(m => m.Execute()), Cron.Minutely(), new RecurringJobOptions());
            _recurringJobManager.Trigger("check-link");

            return(Task.CompletedTask);
        }
コード例 #29
0
        public void ConfigureServices(IServiceCollection services)
        {
            services
            .AddMiddlewareAnalysis()
            .AddHttpContextAccessor()
            .AddSingleton <IActionContextAccessor, ActionContextAccessor>()    // needed for GetUrlHelper (IUrlHelperFactory below)
            .AddScoped(sp =>
            {
                var actionContext = sp.GetRequiredService <IActionContextAccessor>()?.ActionContext;
                if (actionContext == null)
                {
                    throw new ArgumentException("UrlHelper needs an ActionContext, which is usually available in MVC components (Controller/PageModel/ViewComponent)");
                }

                var factory = sp.GetRequiredService <IUrlHelperFactory>();
                return(factory?.GetUrlHelper(actionContext));
            })
            .AddSwaggerDocument(s => s.Description = "naos")
            .AddMediatR()
            .AddMvc(o =>
            {
                // https://tahirnaushad.com/2017/08/28/asp-net-core-2-0-mvc-filters/ or use controller attribute (Authorize)
                o.Filters.Add(new AuthorizeFilter(new AuthorizationPolicyBuilder().RequireAuthenticatedUser().Build()));
                o.Filters.Add <OperationCancelledExceptionFilter>();
            })
            .AddJsonOptions(o => o.AddDefaultJsonSerializerSettings())
            .AddControllersAsServices()         // https://andrewlock.net/controller-activation-and-dependency-injection-in-asp-net-core-mvc/
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            // naos application services
            services
            .AddNaos(this.Configuration, "Product", "Capability", new[] { "All" }, n => n
                     .AddServices(s => s
                                  .AddSampleCountries()
                                  .AddSampleCustomers()
                                  .AddSampleUserAccounts())
                     .AddServiceContext()
                     .AddAuthenticationApiKeyStatic()
                     .AddRequestCorrelation()
                     .AddRequestFiltering()
                     .AddServiceExceptions()
                     .AddCommands(o => o
                                  .AddBehavior <Core.Commands.Domain.ValidateCommandBehavior>()
                                  .AddBehavior <Core.Commands.Domain.TrackCommandBehavior>())
                     .AddOperations(o => o
                                    .AddInteractiveConsole()
                                    .AddLogging(l => l
                                                .UseConsole()
                                                .UseFile()
                                                //.UseAzureBlobStorage()
                                                .UseAzureLogAnalytics())
                                    .AddRequestStorage(r => r
                                                       .UseAzureBlobStorage()))
                     //.AddQueries()
                     //.AddSwaggerDocument() // s.Description = Product.Capability\
                     .AddJobScheduling(o => o
                     //.SetEnabled(true)
                                       .Register <EchoJob>("testjob1", Cron.Minutely(), (j) => j.EchoAsync("+++ hello from testjob1 +++", CancellationToken.None))
                                       .Register("anonymousjob2", Cron.Minutely(), (j) => Console.WriteLine("+++ hello from anonymousjob2 " + j))
                                       .Register("jobevent1", Cron.Minutely(), () => new EchoJobEventData {
                Text = "+++ hello from jobevent1 +++"
            }))
                     //.Register<EchoJob>("testjob3", Cron.MinuteInterval(2), j => j.EchoAsync("+++ hello from testjob3 +++", CancellationToken.None, true), enabled: false)
                     //.Register<EchoJob>("testlongjob4", Cron.Minutely(), j => j.EchoLongAsync("+++ hello from testlongjob4 +++", CancellationToken.None)))
                     .AddServiceClient("default")
                     .AddQueueing()
                     .AddMessaging(o => o
                                   //.UseFileSystemBroker(s => s
                                   //.UseSignalRBroker(s => s
                                   //.UseRabbitMQBroker(s => s
                                   .UseServiceBusBroker(s => s
                                                        .Subscribe <EchoMessage, EchoMessageHandler>()))
                     .AddServiceDiscovery(o => o
                                          .UseFileSystemClientRegistry())
                     //.UseConsulClientRegistry())
                     //.UseRouterClientRegistry())
                     .AddServiceDiscoveryRouter(o => o
                                                .UseFileSystemRegistry()));

            // TODO: need to find a way to start the MessageBroker (done by resolving the IMessageBroker somewhere, HostedService? like scheduling)
        }
コード例 #30
0
ファイル: JobSettingsHelper.cs プロジェクト: jwor80/Ombi
 public static string EmbyContent(JobSettings s)
 {
     return(Get(s.EmbyContentSync, Cron.Hourly(5)));
 }