コード例 #1
0
 public void Refresh()
 {
     _scheduled  = _hangfire.ScheduledJobs(0, (int)_hangfire.ScheduledCount());
     _processing = _hangfire.ProcessingJobs(0, (int)_hangfire.ProcessingCount());
     _failed     = _hangfire.FailedJobs(0, (int)_hangfire.FailedCount());
     _succeded   = _hangfire.SucceededJobs(0, (int)_hangfire.SucceededListCount());
     _recurring  = JobStorage.Current.GetConnection().GetRecurringJobs();
 }
コード例 #2
0
        public static void CancelAllJobs()
        {
            IMonitoringApi             mon            = JobStorage.Current.GetMonitoringApi();
            JobList <ProcessingJobDto> processingJobs = mon.ProcessingJobs(0, int.MaxValue);

            foreach (KeyValuePair <string, ProcessingJobDto> job in processingJobs)
            {
                BackgroundJob.Delete(job.Key);
                LogHelper.Logger.Info($"Deleted Job {job.Key}");
            }
        }
コード例 #3
0
ファイル: Startup.cs プロジェクト: tanddcoder/SpojDebug
        public static void PurgeJobs(IMonitoringApi monitor)
        {
            var toDelete = new List <string>();

            foreach (var queue in monitor.ProcessingJobs(0, (int)monitor.ProcessingCount()))
            {
                toDelete.Add(queue.Key);
            }

            foreach (var jobId in toDelete)
            {
                BackgroundJob.Delete(jobId);
            }
        }
コード例 #4
0
        private HangfireJob CreateJobCache()
        {
            if (_jobCache.HasJobs)
            {
                return(_jobCache);
            }
            //else

            _monitor.EnqueuedJobs("default", 0, int.MaxValue).Select(x => x.Value)
            .ForEach(x => _jobCache.AddJob(x, HangfireJob.QUEUED));
            _monitor.ScheduledJobs(0, int.MaxValue).Select(x => x.Value)
            .ForEach(x => _jobCache.AddJob(x, HangfireJob.QUEUED));
            _monitor.FailedJobs(0, int.MaxValue).Select(x => x.Value)
            .ForEach(x => _jobCache.AddJob(x, HangfireJob.FAILED));
            _monitor.SucceededJobs(0, int.MaxValue).Select(x => x.Value)
            .ForEach(x => _jobCache.AddJob(x, HangfireJob.SUCCEEDED));
            _monitor.ProcessingJobs(0, int.MaxValue).Select(x => x.Value)
            .ForEach(x => _jobCache.AddJob(x, HangfireJob.PROCESSING));
            return(_jobCache);
        }
コード例 #5
0
        /// <summary>
        /// check Job is enqueued or processing
        /// </summary>
        /// <param name="actionName">full action name</param>
        /// <returns></returns>
        public static bool IsRunning(IMonitoringApi api, string actionName)
        {
            var queues = api.Queues();

            foreach (var queue in queues)
            {
                var queueName     = queue.Name;
                var enqueuedCount = Convert.ToInt32(api.EnqueuedCount(queueName));
                var enqueuedJobs  = api.EnqueuedJobs(queueName, 0, enqueuedCount);

                if (enqueuedJobs.Any(job => job.Value.Job.Method.GetFullActionName() == actionName))
                {
                    return(true);
                }
            }

            var processingCount = Convert.ToInt32(api.ProcessingCount());
            var processingJobs  = api.ProcessingJobs(0, processingCount);

            return(processingJobs.Any(job => job.Value.Job.Method.GetFullActionName() == actionName));
        }