예제 #1
0
        public static void RegisterJobs()
        {
            string cron = "0 */30 * ? * *";

            //CronJob.AddOrUpdate(GenerateJobInfo(typeof(JsonTransformationJob), cron));
            CronJob.AddOrUpdate(GenerateJobInfo(typeof(SqlTransformationJob), cron));
        }
예제 #2
0
        public void ConfigureServices(IServiceCollection services)
        {
            var appConfiguration        = Configuration.GetSection(AppConfiguration.Section).Get <AppConfiguration>();
            var csvFileHandlerJobConfig = Configuration.GetSection(CsvFileHandlerJobConfig.Section).Get <CsvFileHandlerJobConfig>();

            services.AddAppConfig(Configuration);
            services.AddAppServices();

            services.AddHangfire(x =>
            {
                x.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
                .UseSimpleAssemblyNameTypeSerializer()
                .UseRecommendedSerializerSettings()
                .UseSQLiteStorage(appConfiguration.SQLiteDBConn)
                .UseNLogLogProvider();

                var csvFileJob = JobsHelper.GenerateJobInfo(
                    typeof(TestCsvFileHandlerJob),
                    csvFileHandlerJobConfig.JobCron,
                    appConfiguration.TimeZoneId
                    );

                CronJob.AddOrUpdate(csvFileJob);
            });

            services.AddHangfireServer();
        }
        /// <summary>   Executes the schedule asynchronous operation. </summary>
        /// <typeparam name="TJob">     Type of the job. </typeparam>
        /// <typeparam name="TJobData"> Type of the job data. </typeparam>
        /// <param name="args"> The arguments. </param>
        /// <returns>   An asynchronous result. </returns>
        public Task ExecuteScheduleAsync <TJob, TJobData>(TJobData args)
            where TJob : IBackgroundJob, new()
            where TJobData : IJobData
        {
            CronJob.AddOrUpdate <TJob>(j => j.Execute(null), args);

            return(Task.FromResult(0));
        }
예제 #4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddHangfire(r =>
            {
                r.UseSqlServerStorage(Configuration.GetConnectionString("DefaultConnection"));
                r.UseConsole();

                r.UseDefaultActivator();

                CronJob.AddOrUpdate("Jobs/hangfireJobs.json");
            });
        }
        private void OnChanged(object sender, FileSystemEventArgs e)
        {
            lock (_fileWatcherLock)
            {
                _logger.Info($"File {e.Name} changed, try to reload configuration again...");

                var recurringJobInfos = Load().ToArray();

                if (recurringJobInfos == null || recurringJobInfos.Length == 0)
                {
                    return;
                }

                CronJob.AddOrUpdate(recurringJobInfos);
            }
        }
예제 #6
0
 /// <summary>
 /// Builds Hangfire.RecurringJob automatically with the array of Hangfire.RecurringJobExtensions.RecurringJobInfo.
 /// </summary>
 public void AddOrUpdate(params RecurringJobInfo[] recurringJobInfos)
 {
     CronJob.AddOrUpdate(recurringJobInfos);
 }
예제 #7
0
 /// <summary>
 ///  Builds Hangfire.RecurringJob automatically by using a JSON configuration.
 /// </summary>
 public void AddOrUpdate(string[] jsonFiles, bool reloadOnChange = true)
 {
     CronJob.AddOrUpdate(jsonFiles, reloadOnChange);
 }
예제 #8
0
 /// <summary>
 /// Builds Hangfire.RecurringJob automatically within specified interface or class.
 /// </summary>
 public void AddOrUpdate(Func <IEnumerable <Type> > typesProvider)
 {
     CronJob.AddOrUpdate(typesProvider);
 }
예제 #9
0
 /// <summary>
 /// Builds Hangfire.RecurringJob automatically within specified interface or class.
 /// </summary>
 public void AddOrUpdate(params Type[] types)
 {
     CronJob.AddOrUpdate(types);
 }
예제 #10
0
 /// <summary>
 /// Builds Hangfire.RecurringJob automatically within specified interface or class.
 /// </summary>
 public void AddOrUpdate <TJob>() where TJob : IRecurringJob
 {
     CronJob.AddOrUpdate(typeof(TJob));
 }