Example #1
0
        private IEnumerable <IDisposable> GetHangfireServers()
        {
            GlobalConfiguration.Configuration
            .SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
            .UseSimpleAssemblyNameTypeSerializer()
            .UseRecommendedSerializerSettings()
            .UseSqlServerStorage(ConfigurationManager.ConnectionStrings["DefaultConnectionString"].ConnectionString, new SqlServerStorageOptions
            {
                CommandBatchMaxTimeout       = TimeSpan.FromMinutes(5),
                SlidingInvisibilityTimeout   = TimeSpan.FromMinutes(5),
                QueuePollInterval            = TimeSpan.Zero,
                UseRecommendedIsolationLevel = true,
                UsePageLocksOnDequeue        = true,
                DisableGlobalLocks           = true
            });

            using (var connection = JobStorage.Current.GetConnection())
            {
                foreach (var recurringJob in connection.GetRecurringJobs())
                {
                    RecurringJob.RemoveIfExists(recurringJob.Id);
                }
            }
            RecurringJob.AddOrUpdate(() => AutomaticPost.GetDailyFollowers(), Cron.Daily);
            RecurringJob.AddOrUpdate(() => AutomaticPost.AutomaticPosts(0, false), Cron.Hourly);
            yield return(new BackgroundJobServer());
        }
Example #2
0
        public async Task <ActionResult> Index(string Token)
        {
            await AutomaticPost.GetDailyFollowers();

            return(RedirectToAction("Index"));
        }