├── .editorconfig ├── .gitattributes ├── .gitignore ├── .nuget ├── NuGet.exe ├── packages.config └── packages.lock.json ├── CONTRIBUTING.md ├── COPYING ├── COPYING.LESSER ├── Directory.Build.props ├── Hangfire.sln ├── Hangfire.sln.DotSettings ├── LICENSE.md ├── LICENSE_ROYALTYFREE ├── LICENSE_STANDARD ├── NOTICES ├── NuGet.config ├── README.md ├── SECURITY.md ├── appveyor.yml ├── build.bat ├── build.sh ├── coverity-scan.ps1 ├── nuspecs ├── Hangfire.AspNetCore.nuspec ├── Hangfire.Core.nuspec ├── Hangfire.NetCore.nuspec ├── Hangfire.SqlServer.MSMQ.nuspec ├── Hangfire.SqlServer.nuspec ├── Hangfire.nuspec └── icon.png ├── psake-project.ps1 ├── samples ├── ConsoleSample │ ├── ConsoleSample.csproj │ ├── GenericServices.cs │ ├── NewFeatures.cs │ ├── Program.cs │ ├── Services.cs │ ├── Startup.cs │ ├── app.config │ └── packages.lock.json └── NetCoreSample │ ├── NetCoreSample.csproj │ ├── Program.cs │ └── packages.lock.json ├── src ├── Directory.Build.props ├── Hangfire.AspNetCore │ ├── Dashboard │ │ ├── AspNetCoreDashboardContext.cs │ │ ├── AspNetCoreDashboardContextExtensions.cs │ │ ├── AspNetCoreDashboardMiddleware.cs │ │ ├── AspNetCoreDashboardRequest.cs │ │ └── AspNetCoreDashboardResponse.cs │ ├── Hangfire.AspNetCore.csproj │ ├── HangfireApplicationBuilderExtensions.cs │ ├── HangfireEndpointRouteBuilderExtensions.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.lock.json ├── Hangfire.Core │ ├── AppBuilderExtensions.cs │ ├── App_Packages │ │ ├── LibLog.1.4 │ │ │ └── LibLog.cs │ │ ├── StackTraceFormatter │ │ │ └── StackTraceFormatter.cs │ │ └── StackTraceParser │ │ │ └── StackTraceParser.cs │ ├── AttemptsExceededAction.cs │ ├── AutomaticRetryAttribute.cs │ ├── BackgroundJob.Instance.cs │ ├── BackgroundJob.cs │ ├── BackgroundJobClient.cs │ ├── BackgroundJobClientException.cs │ ├── BackgroundJobClientExtensions.cs │ ├── BackgroundJobServer.cs │ ├── BackgroundJobServerOptions.cs │ ├── CaptureCultureAttribute.cs │ ├── Client │ │ ├── BackgroundJobFactory.cs │ │ ├── ClientExceptionContext.cs │ │ ├── CoreBackgroundJobFactory.cs │ │ ├── CreateContext.cs │ │ ├── CreatedContext.cs │ │ ├── CreatingContext.cs │ │ ├── IBackgroundJobFactory.cs │ │ ├── IClientExceptionFilter.cs │ │ └── IClientFilter.cs │ ├── Common │ │ ├── CachedExpressionCompiler.cs │ │ ├── CancellationTokenExtentions.cs │ │ ├── ExpressionUtil │ │ │ ├── BinaryExpressionFingerprint.cs │ │ │ ├── CachedExpressionCompiler.cs │ │ │ ├── ConditionalExpressionFingerprint.cs │ │ │ ├── ConstantExpressionFingerprint.cs │ │ │ ├── DefaultExpressionFingerprint.cs │ │ │ ├── ExpressionFingerprint.cs │ │ │ ├── ExpressionFingerprintChain.cs │ │ │ ├── FingerprintingExpressionVisitor.cs │ │ │ ├── HashCodeCombiner.cs │ │ │ ├── Hoisted.cs │ │ │ ├── HoistingExpressionVisitor.cs │ │ │ ├── IndexExpressionFingerprint.cs │ │ │ ├── LambdaExpressionFingerprint.cs │ │ │ ├── MemberExpressionFingerprint.cs │ │ │ ├── MethodCallExpressionFingerprint.cs │ │ │ ├── ParameterExpressionFingerprint.cs │ │ │ ├── TypeBinaryExpressionFingerprint.cs │ │ │ └── UnaryExpressionFingerprint.cs │ │ ├── IJobFilter.cs │ │ ├── IJobFilterProvider.cs │ │ ├── Job.cs │ │ ├── JobFilter.cs │ │ ├── JobFilterAttribute.cs │ │ ├── JobFilterAttributeFilterProvider.cs │ │ ├── JobFilterCollection.cs │ │ ├── JobFilterInfo.cs │ │ ├── JobFilterProviderCollection.cs │ │ ├── JobFilterProviders.cs │ │ ├── JobFilterScope.cs │ │ ├── JobHelper.cs │ │ ├── JobLoadException.cs │ │ ├── LanguagePolyfills.cs │ │ ├── MethodInfoExtensions.cs │ │ ├── ReflectedAttributeCache.cs │ │ ├── SerializationHelper.cs │ │ ├── ShallowExceptionHelper.cs │ │ ├── TypeExtensions.cs │ │ ├── TypeHelper.cs │ │ └── TypeHelperSerializationBinder.cs │ ├── ContinuationsSupportAttribute.cs │ ├── Cron.cs │ ├── Dashboard │ │ ├── BatchCommandDispatcher.cs │ │ ├── CombinedResourceDispatcher.cs │ │ ├── CommandDispatcher.cs │ │ ├── Content │ │ │ ├── css │ │ │ │ ├── Chart.min.css │ │ │ │ ├── bootstrap.min.css │ │ │ │ ├── hangfire-dark.css │ │ │ │ └── hangfire.css │ │ │ ├── fonts │ │ │ │ ├── glyphicons-halflings-regular.eot │ │ │ │ ├── glyphicons-halflings-regular.svg │ │ │ │ ├── glyphicons-halflings-regular.ttf │ │ │ │ ├── glyphicons-halflings-regular.woff │ │ │ │ └── glyphicons-halflings-regular.woff2 │ │ │ ├── js │ │ │ │ ├── Chart.min.js │ │ │ │ ├── bootstrap.min.js │ │ │ │ ├── chartjs-plugin-streaming.min.js │ │ │ │ ├── hangfire.js │ │ │ │ ├── jquery-3.7.1.min.js │ │ │ │ └── moment-with-locales.min.js │ │ │ └── resx │ │ │ │ ├── Strings.Designer.cs │ │ │ │ ├── Strings.ca.resx │ │ │ │ ├── Strings.de.resx │ │ │ │ ├── Strings.es.resx │ │ │ │ ├── Strings.fa.resx │ │ │ │ ├── Strings.fr.resx │ │ │ │ ├── Strings.nb.resx │ │ │ │ ├── Strings.nl.resx │ │ │ │ ├── Strings.pt-BR.resx │ │ │ │ ├── Strings.pt-PT.resx │ │ │ │ ├── Strings.pt.resx │ │ │ │ ├── Strings.resx │ │ │ │ ├── Strings.sv.resx │ │ │ │ ├── Strings.tr-TR.resx │ │ │ │ ├── Strings.zh-TW.resx │ │ │ │ └── Strings.zh.resx │ │ ├── DashboardContext.cs │ │ ├── DashboardMetric.cs │ │ ├── DashboardMetrics.cs │ │ ├── DashboardRequest.cs │ │ ├── DashboardResponse.cs │ │ ├── DashboardRoutes.cs │ │ ├── EmbeddedResourceDispatcher.cs │ │ ├── HtmlHelper.cs │ │ ├── IDashboardAsyncAuthorizationFilter.cs │ │ ├── IDashboardAuthorizationFilter.cs │ │ ├── IDashboardDispatcher.cs │ │ ├── JobDetailsRenderer.cs │ │ ├── JobHistoryRenderer.cs │ │ ├── JobMethodCallRenderer.cs │ │ ├── JobsSidebarMenu.cs │ │ ├── JsonStats.cs │ │ ├── LocalRequestsOnlyAuthorizationFilter.cs │ │ ├── MenuItem.cs │ │ ├── Metric.cs │ │ ├── NavigationMenu.cs │ │ ├── NonEscapedString.cs │ │ ├── Owin │ │ │ ├── IOwinDashboardAntiforgery.cs │ │ │ ├── MiddlewareExtensions.cs │ │ │ ├── OwinDashboardContext.cs │ │ │ ├── OwinDashboardContextExtensions.cs │ │ │ ├── OwinDashboardRequest.cs │ │ │ └── OwinDashboardResponse.cs │ │ ├── Pager.cs │ │ ├── Pages │ │ │ ├── AwaitingJobsPage.cshtml │ │ │ ├── AwaitingJobsPage.cshtml.cs │ │ │ ├── DeletedJobsPage.cshtml │ │ │ ├── DeletedJobsPage.cshtml.cs │ │ │ ├── EnqueuedJobsPage.cs │ │ │ ├── EnqueuedJobsPage.cshtml │ │ │ ├── EnqueuedJobsPage.cshtml.cs │ │ │ ├── FailedJobsPage.cshtml │ │ │ ├── FailedJobsPage.cshtml.cs │ │ │ ├── FetchedJobsPage.cs │ │ │ ├── FetchedJobsPage.cshtml │ │ │ ├── FetchedJobsPage.cshtml.cs │ │ │ ├── HomePage.cs │ │ │ ├── HomePage.cshtml │ │ │ ├── HomePage.cshtml.cs │ │ │ ├── JobDetailsPage.cs │ │ │ ├── JobDetailsPage.cshtml │ │ │ ├── JobDetailsPage.cshtml.cs │ │ │ ├── LayoutPage.cs │ │ │ ├── LayoutPage.cshtml │ │ │ ├── LayoutPage.cshtml.cs │ │ │ ├── ProcessingJobsPage.cshtml │ │ │ ├── ProcessingJobsPage.cshtml.cs │ │ │ ├── QueuesPage.cshtml │ │ │ ├── QueuesPage.cshtml.cs │ │ │ ├── RecurringJobsPage.cshtml │ │ │ ├── RecurringJobsPage.cshtml.cs │ │ │ ├── RetriesPage.cshtml │ │ │ ├── RetriesPage.cshtml.cs │ │ │ ├── ScheduledJobsPage.cshtml │ │ │ ├── ScheduledJobsPage.cshtml.cs │ │ │ ├── ServersPage.cshtml │ │ │ ├── ServersPage.cshtml.cs │ │ │ ├── SucceededJobs.cshtml │ │ │ ├── SucceededJobs.cshtml.cs │ │ │ ├── _BlockMetric.cs │ │ │ ├── _BlockMetric.cshtml │ │ │ ├── _BlockMetric.cshtml.cs │ │ │ ├── _Breadcrumbs.cs │ │ │ ├── _Breadcrumbs.cshtml │ │ │ ├── _Breadcrumbs.cshtml.cs │ │ │ ├── _ErrorAlert.cshtml │ │ │ ├── _ErrorAlert.cshtml.cs │ │ │ ├── _InlineMetric.cs │ │ │ ├── _InlineMetric.cshtml │ │ │ ├── _InlineMetric.cshtml.cs │ │ │ ├── _Navigation.cshtml │ │ │ ├── _Navigation.cshtml.cs │ │ │ ├── _Paginator.cs │ │ │ ├── _Paginator.cshtml │ │ │ ├── _Paginator.cshtml.cs │ │ │ ├── _PerPageSelector.cs │ │ │ ├── _PerPageSelector.cshtml │ │ │ ├── _PerPageSelector.cshtml.cs │ │ │ ├── _SidebarMenu.cs │ │ │ ├── _SidebarMenu.cshtml │ │ │ └── _SidebarMenu.cshtml.cs │ │ ├── RazorPage.cs │ │ ├── RazorPageDispatcher.cs │ │ ├── RouteCollection.cs │ │ ├── RouteCollectionExtensions.cs │ │ └── UrlHelper.cs │ ├── DashboardOptions.cs │ ├── DisableConcurrentExecutionAttribute.cs │ ├── ExceptionInfo.cs │ ├── ExceptionTypeHelper.cs │ ├── FromParameterAttribute.cs │ ├── FromResultAttribute.cs │ ├── GlobalConfiguration.cs │ ├── GlobalConfigurationExtensions.cs │ ├── GlobalJobFilters.cs │ ├── GlobalStateHandlers.cs │ ├── Hangfire.Core.csproj │ ├── IBackgroundJobClient.cs │ ├── IGlobalConfiguration.cs │ ├── IJobCancellationToken.cs │ ├── IRecurringJobManager.cs │ ├── ITimeZoneResolver.cs │ ├── IdempotentCompletionAttribute.cs │ ├── JobActivator.cs │ ├── JobActivatorContext.cs │ ├── JobActivatorScope.cs │ ├── JobCancellationToken.cs │ ├── JobCancellationTokenExtensions.cs │ ├── JobContinuationOptions.cs │ ├── JobDisplayNameAttribute.cs │ ├── JobParameterInjectionFilter.cs │ ├── JobStorage.cs │ ├── LatencyTimeoutAttribute.cs │ ├── MisfireHandlingMode.cs │ ├── MoreLinq │ │ └── MoreEnumerable.Pairwise.cs │ ├── Obsolete │ │ ├── BootstrapperConfigurationExtensions.cs │ │ ├── CreateJobFailedException.cs │ │ ├── DashboardMiddleware.cs │ │ ├── DashboardOwinExtensions.cs │ │ ├── IAuthorizationFilter.cs │ │ ├── IBootstrapperConfiguration.cs │ │ ├── IRequestDispatcher.cs │ │ ├── IServerComponent.cs │ │ ├── IServerProcess.cs │ │ ├── Job.Obsolete.cs │ │ ├── OwinBootstrapper.cs │ │ ├── RequestDispatcherContext.cs │ │ ├── RequestDispatcherWrapper.cs │ │ ├── ServerOwinExtensions.cs │ │ ├── ServerWatchdogOptions.cs │ │ ├── StartupConfiguration.cs │ │ └── StateContext.cs │ ├── Processing │ │ ├── AppDomainUnloadMonitor.cs │ │ ├── BackgroundDispatcher.cs │ │ ├── BackgroundDispatcherAsync.cs │ │ ├── BackgroundExecution.cs │ │ ├── BackgroundExecutionOptions.cs │ │ ├── BackgroundTaskScheduler.cs │ │ ├── IBackgroundDispatcher.cs │ │ ├── IBackgroundExecution.cs │ │ ├── InlineSynchronizationContext.cs │ │ └── TaskExtensions.cs │ ├── Profiling │ │ ├── EmptyProfiler.cs │ │ ├── IProfiler.cs │ │ ├── ProfilerExtensions.cs │ │ └── SlowLogProfiler.cs │ ├── Properties │ │ ├── Annotations.cs │ │ ├── AssemblyInfo.cs │ │ └── NamespaceDoc.cs │ ├── QueueAttribute.cs │ ├── Razor.build │ ├── RecurringJob.cs │ ├── RecurringJobEntity.cs │ ├── RecurringJobExtensions.cs │ ├── RecurringJobManager.cs │ ├── RecurringJobManagerExtensions.cs │ ├── RecurringJobOptions.cs │ ├── Server │ │ ├── AspNetShutdownDetector.cs │ │ ├── BackgroundJobPerformer.cs │ │ ├── BackgroundProcessContext.cs │ │ ├── BackgroundProcessDispatcherBuilder.cs │ │ ├── BackgroundProcessDispatcherBuilderAsync.cs │ │ ├── BackgroundProcessExtensions.cs │ │ ├── BackgroundProcessingServer.cs │ │ ├── BackgroundProcessingServerOptions.cs │ │ ├── BackgroundServerContext.cs │ │ ├── BackgroundServerProcess.cs │ │ ├── CoreBackgroundJobPerformer.cs │ │ ├── DelayedJobScheduler.cs │ │ ├── IBackgroundJobPerformer.cs │ │ ├── IBackgroundProcess.cs │ │ ├── IBackgroundProcessAsync.cs │ │ ├── IBackgroundProcessDispatcherBuilder.cs │ │ ├── IBackgroundProcessingServer.cs │ │ ├── IBackgroundServerProcess.cs │ │ ├── IServerExceptionFilter.cs │ │ ├── IServerFilter.cs │ │ ├── JobAbortedException.cs │ │ ├── JobPerformanceException.cs │ │ ├── PerformContext.cs │ │ ├── PerformedContext.cs │ │ ├── PerformingContext.cs │ │ ├── RecurringJobScheduler.cs │ │ ├── ServerContext.cs │ │ ├── ServerExceptionContext.cs │ │ ├── ServerHeartbeatProcess.cs │ │ ├── ServerJobCancellationToken.cs │ │ ├── ServerJobCancellationWatcher.cs │ │ ├── ServerProcessDispatcherBuilder.cs │ │ ├── ServerWatchdog.cs │ │ └── Worker.cs │ ├── States │ │ ├── ApplyStateContext.cs │ │ ├── AwaitingState.cs │ │ ├── BackgroundJobStateChanger.cs │ │ ├── CoreStateMachine.cs │ │ ├── DeletedState.cs │ │ ├── ElectStateContext.cs │ │ ├── EnqueuedState.cs │ │ ├── FailedState.cs │ │ ├── IApplyStateFilter.cs │ │ ├── IBackgroundJobStateChanger.cs │ │ ├── IElectStateFilter.cs │ │ ├── IState.cs │ │ ├── IStateHandler.cs │ │ ├── IStateMachine.cs │ │ ├── ProcessingState.cs │ │ ├── ScheduledState.cs │ │ ├── StateChangeContext.cs │ │ ├── StateHandlerCollection.cs │ │ ├── StateMachine.cs │ │ └── SucceededState.cs │ ├── StatisticsHistoryAttribute.cs │ ├── Storage │ │ ├── BackgroundServerGoneException.cs │ │ ├── DistributedLockTimeoutException.cs │ │ ├── IFetchedJob.cs │ │ ├── IMonitoringApi.cs │ │ ├── IStorageConnection.cs │ │ ├── IWriteOnlyTransaction.cs │ │ ├── InvocationData.cs │ │ ├── JobData.cs │ │ ├── JobStorageConnection.cs │ │ ├── JobStorageFeatures.cs │ │ ├── JobStorageMonitor.cs │ │ ├── JobStorageTransaction.cs │ │ ├── Monitoring │ │ │ ├── AwaitingJobDto.cs │ │ │ ├── DeletedJobDto.cs │ │ │ ├── EnqueuedJobDto.cs │ │ │ ├── FailedJobDto.cs │ │ │ ├── FetchedJobDto.cs │ │ │ ├── JobDetailsDto.cs │ │ │ ├── JobList.cs │ │ │ ├── ProcessingJobDto.cs │ │ │ ├── QueueWithTopEnqueuedJobsDto.cs │ │ │ ├── ScheduledJobDto.cs │ │ │ ├── ServerDto.cs │ │ │ ├── StateHistoryDto.cs │ │ │ ├── StatisticsDto.cs │ │ │ └── SucceededJobDto.cs │ │ ├── RecurringJobDto.cs │ │ ├── StateData.cs │ │ └── StorageConnectionExtensions.cs │ └── packages.lock.json ├── Hangfire.NetCore │ ├── AspNetCore │ │ ├── AspNetCoreJobActivator.cs │ │ ├── AspNetCoreJobActivatorScope.cs │ │ ├── AspNetCoreLog.cs │ │ └── AspNetCoreLogProvider.cs │ ├── BackgroundJobServerHostedService.cs │ ├── BackgroundProcessingServerHostedService.cs │ ├── DefaultClientManagerFactory.cs │ ├── Hangfire.NetCore.csproj │ ├── HangfireServiceCollectionExtensions.cs │ ├── IBackgroundJobClientFactory.cs │ ├── IRecurringJobManagerFactory.cs │ └── packages.lock.json ├── Hangfire.SqlServer.Msmq │ ├── Hangfire.SqlServer.Msmq.csproj │ ├── IMsmqTransaction.cs │ ├── MessageQueueExtensions.cs │ ├── MsmqDtcTransaction.cs │ ├── MsmqExtensions.cs │ ├── MsmqFetchedJob.cs │ ├── MsmqInternalTransaction.cs │ ├── MsmqJobQueue.cs │ ├── MsmqJobQueueMonitoringApi.cs │ ├── MsmqJobQueueProvider.cs │ ├── MsmqSqlServerStorageExtensions.cs │ ├── MsmqTransactionType.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ └── packages.lock.json ├── Hangfire.SqlServer │ ├── Constants.cs │ ├── CountersAggregator.cs │ ├── DbCommandExtensions.cs │ ├── DefaultInstall.sql │ ├── DefaultInstall.tt │ ├── EnqueuedAndFetchedCountDto.cs │ ├── Entities │ │ ├── JobParameter.cs │ │ ├── Server.cs │ │ ├── ServerData.cs │ │ ├── SqlHash.cs │ │ ├── SqlJob.cs │ │ └── SqlState.cs │ ├── ExceptionTypeHelper.cs │ ├── ExpirationManager.cs │ ├── Hangfire.SqlServer.csproj │ ├── IPersistentJobQueue.cs │ ├── IPersistentJobQueueMonitoringApi.cs │ ├── IPersistentJobQueueProvider.cs │ ├── Install.sql │ ├── PersistentJobQueueProviderCollection.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SqlCommandBatch.cs │ ├── SqlCommandSet.cs │ ├── SqlServerBootstrapperConfigurationExtensions.cs │ ├── SqlServerConnection.cs │ ├── SqlServerDistributedLock.cs │ ├── SqlServerDistributedLockException.cs │ ├── SqlServerHeartbeatProcess.cs │ ├── SqlServerJobQueue.cs │ ├── SqlServerJobQueueMonitoringApi.cs │ ├── SqlServerJobQueueProvider.cs │ ├── SqlServerMonitoringApi.cs │ ├── SqlServerObjectsInstaller.cs │ ├── SqlServerStorage.cs │ ├── SqlServerStorageExtensions.cs │ ├── SqlServerStorageOptions.cs │ ├── SqlServerTimeoutJob.cs │ ├── SqlServerTransactionJob.cs │ ├── SqlServerWriteOnlyTransaction.cs │ ├── TimestampHelper.cs │ └── packages.lock.json └── SharedAssemblyInfo.cs └── tests ├── Directory.Build.props ├── Hangfire.Core.Tests ├── BackgroundJobClientExtensionsFacts.cs ├── BackgroundJobClientFacts.cs ├── BackgroundJobFacts.cs ├── BackgroundJobServerFacts.cs ├── CaptureCultureAttributeFacts.cs ├── Client │ ├── BackgroundJobFactoryFacts.cs │ ├── ClientExceptionContextFacts.cs │ ├── CoreBackgroundJobFactoryFacts.cs │ ├── CreateContextFacts.cs │ ├── CreatedContextFacts.cs │ └── CreatingContextFacts.cs ├── Common │ ├── CancellationTokenExtentionsFacts.cs │ ├── JobArgumentFacts.cs │ ├── JobFacts.cs │ ├── JobFilterAttributeFacts.cs │ ├── JobFilterAttributeFilterProviderFacts.cs │ ├── JobFilterCollectionFacts.cs │ ├── JobFilterFacts.cs │ ├── JobFilterProviderCollectionFacts.cs │ ├── JobHelperFacts.cs │ ├── JobLoadExceptionFacts.cs │ ├── MethodInfoExtensionsFacts.cs │ ├── SerializationHelperFacts.cs │ ├── ShallowExceptionHelperFacts.cs │ └── TypeExtensionsFacts.cs ├── ContinuationsSupportAttributeFacts.cs ├── CronFacts.cs ├── Dashboard │ ├── BatchCommandDispatcherFacts.cs │ ├── CommandDispatcherFacts.cs │ ├── DashboardOptionsFacts.cs │ └── HtmlHelperFacts.cs ├── GlobalConfigurationExtensionsFacts.cs ├── GlobalStateHandlersFacts.cs ├── GlobalTestsConfiguration.cs ├── Hangfire.Core.Tests.csproj ├── Hangfire.Core.Tests.csproj.DotSettings ├── JobActivatorFacts.cs ├── JobCancellationTokenFacts.cs ├── JobParameterInjectionFilterFacts.cs ├── JobStorageFacts.cs ├── LatencyTimeoutAttributeFacts.cs ├── Mocks │ ├── ApplyStateContextMock.cs │ ├── BackgroundJobMock.cs │ ├── BackgroundProcessContextMock.cs │ ├── CreateContextMock.cs │ ├── ElectStateContextMock.cs │ ├── PerformContextMock.cs │ └── StateChangeContextMock.cs ├── Obsolete │ └── ServerWatchdogOptionsFacts.cs ├── PreserveCultureAttributeFacts.cs ├── Processing │ └── TaskExtensionsFacts.cs ├── Profiling │ └── ProfilerFacts.cs ├── QueueAttributeFacts.cs ├── RecurringJobEntityFacts.cs ├── RecurringJobManagerFacts.cs ├── RecurringJobOptionsFacts.cs ├── RetryAttributeFacts.cs ├── Server │ ├── BackgroundJobPerformerFacts.cs │ ├── BackgroundJobServerOptionsFacts.cs │ ├── BackgroundProcessContextFacts.cs │ ├── BackgroundProcessingServerFacts.cs │ ├── CoreBackgroundJobPerformerFacts.cs │ ├── DelayedJobSchedulerFacts.cs │ ├── PerformContextFacts.cs │ ├── RecurringJobSchedulerFacts.cs │ ├── ServerJobCancellationTokenFacts.cs │ ├── ServerJobCancellationWatcherFacts.cs │ ├── ServerWatchdogFacts.cs │ └── WorkerFacts.cs ├── States │ ├── ApplyStateContextFacts.cs │ ├── AwaitingStateFacts.cs │ ├── AwaitingStateHandlerFacts.cs │ ├── BackgroundJobStateChangerFacts.cs │ ├── CoreStateMachineFacts.cs │ ├── DeletedStateFacts.cs │ ├── DeletedStateHandlerFacts.cs │ ├── ElectStateContextFacts.cs │ ├── EnqueuedStateFacts.cs │ ├── EnqueuedStateHandlerFacts.cs │ ├── EnqueuedStateValidationFacts.cs │ ├── FailedStateFacts.cs │ ├── ProcessingStateFacts.cs │ ├── ScheduledStateFacts.cs │ ├── ScheduledStateHandlerFacts.cs │ ├── StateChangeContextFacts.cs │ ├── StateHandlerCollectionFacts.cs │ ├── StateMachineFacts.cs │ ├── SucceededStateFacts.cs │ └── SucceededStateHandlerFacts.cs ├── StatisticsHistoryAttributeFacts.cs ├── Storage │ ├── InvocationDataFacts.cs │ ├── MonitoringTypeFacts.cs │ └── StorageConnectionExtensionsFacts.cs ├── Stubs │ ├── DashboardContextStub.cs │ ├── DashboardResponseStub.cs │ └── JobStorageStub.cs ├── Utils │ ├── CleanSerializerSettingsAttribute.cs │ ├── CultureHelper.cs │ ├── DataCompatibilityRangeFactAttribute.cs │ ├── DataCompatibilityRangeFactDiscoverer.cs │ ├── DataCompatibilityRangeTestCase.cs │ ├── DataCompatibilityRangeTestCaseRunner.cs │ ├── DataCompatibilityRangeTestRunner.cs │ ├── DataCompatibilityRangeTheoryAttribute.cs │ ├── DataCompatibilityRangeTheoryDiscoverer.cs │ ├── DataCompatibilityRangeTheoryTestCase.cs │ ├── DataCompatibilityRangeTheoryTestCaseRunner.cs │ ├── GlobalLockAttribute.cs │ ├── PlatformHelper.cs │ ├── SequenceAttribute.cs │ ├── SerializerSettingsHelper.cs │ └── StaticLockAttribute.cs └── packages.lock.json ├── Hangfire.SqlServer.Msmq.Tests ├── Hangfire.SqlServer.Msmq.Tests.csproj ├── MessageQueueExtensionsFacts.cs ├── MsmqJobQueueFacts.cs ├── MsmqJobQueueMonitoringApiFacts.cs ├── MsmqJobQueueProviderFacts.cs ├── MsmqSqlServerStorageExtensionsFacts.cs ├── Utils │ ├── CleanMsmqQueueAttribute.cs │ └── MsmqUtils.cs └── packages.lock.json └── Hangfire.SqlServer.Tests ├── CountersAggregatorFacts.cs ├── ExpirationManagerFacts.cs ├── GlobalTestsConfiguration.cs ├── Hangfire.SqlServer.Tests.csproj ├── PersistentJobQueueProviderCollectionFacts.cs ├── SqlServerConnectionFacts.cs ├── SqlServerDistributedLockFacts.cs ├── SqlServerJobQueueFacts.cs ├── SqlServerMonitoringApiFacts.cs ├── SqlServerStorageFacts.cs ├── SqlServerTimeoutJobFacts.cs ├── SqlServerTransactionJobFacts.cs ├── SqlServerWriteOnlyTransactionFacts.cs ├── StorageOptionsFacts.cs ├── Utils ├── CleanDatabaseAttribute.cs ├── CleanSerializerSettingsAttribute.cs ├── ConnectionUtils.cs └── SerializerSettingsHelper.cs └── packages.lock.json /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*.cs,*.ps1] 4 | indent_style = space 5 | indent_size = 4 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp text 6 | *.sln merge=union text eol=crlf 7 | *.csproj merge=union text eol=crlf 8 | *.vbproj merge=union text eol=crlf 9 | *.fsproj merge=union text eol=crlf 10 | *.dbproj merge=union text eol=crlf 11 | 12 | # Standard to msysgit 13 | *.doc diff=astextplain 14 | *.DOC diff=astextplain 15 | *.docx diff=astextplain 16 | *.DOCX diff=astextplain 17 | *.dot diff=astextplain 18 | *.DOT diff=astextplain 19 | *.pdf diff=astextplain 20 | *.PDF diff=astextplain 21 | *.rtf diff=astextplain 22 | *.RTF diff=astextplain 23 | 24 | # Source code 25 | *.cshtml text 26 | *.css text 27 | *.xml text 28 | *.bat text 29 | *.ps1 text 30 | *.nuspec text 31 | *.js text 32 | *.json text 33 | *.sql text 34 | 35 | # Documentation 36 | *.md text 37 | *.txt text 38 | *.manifest text 39 | COPYING text 40 | COPYING.LESSER text 41 | 42 | # Configs 43 | *.config text 44 | .editorconfig text 45 | .gitattributes text 46 | .gitignore text 47 | *.yml text 48 | *.DotSettings text -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HangfireIO/Hangfire/d51e2c54dc49b28b3f340bb19d5fdcc394bb1b5d/.nuget/NuGet.exe -------------------------------------------------------------------------------- /.nuget/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.nuget/packages.lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": 1, 3 | "dependencies": { 4 | "Any,Version=v0.0": { 5 | "Hangfire.Build": { 6 | "type": "Direct", 7 | "requested": "[0.5.0, 0.5.0]", 8 | "resolved": "0.5.0", 9 | "contentHash": "4yRCdMaDr6cyFRmCvpFO8kBMV57KPOofugaHOsjkDEDw+G/BCGWOdrpXfkAeTEtZBPUv2jS0PYmVNK5680KxXQ==" 10 | }, 11 | "ILRepack": { 12 | "type": "Direct", 13 | "requested": "[2.0.27, 2.0.27]", 14 | "resolved": "2.0.27", 15 | "contentHash": "N5nhVwlgU2ipeonLBVuv1HpsIclJI/5QujuLeo3BW7irD2KnSFXkHa5FmXwzdCkB36D0XGOxNMxh99P7kjgU2A==" 16 | }, 17 | "psake": { 18 | "type": "Direct", 19 | "requested": "[4.4.1, 4.4.1]", 20 | "resolved": "4.4.1", 21 | "contentHash": "Hn5kdGPEoapi+wAAjaGjKEZVnuYp7fUrPK3IivLYG6Bn4adhd8l+KXXPMEmte41RmrLvfV7XGZa9KsSTc0gjDA==" 22 | }, 23 | "RazorGenerator.MsBuild": { 24 | "type": "Direct", 25 | "requested": "[2.5.0, 2.5.0]", 26 | "resolved": "2.5.0", 27 | "contentHash": "yOu2KEjDFvE20b+YK/+Ovf4czUHWH2DlBB9lIKDXdBjcMh3PXrPJTxPzi468XrFvE1dVEiWu+pGNkVFE9+VpMA==" 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | true 4 | true 5 | 6 | 7 | 8 | true 9 | 10 | 11 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | License 2 | ======== 3 | 4 | Copyright © 2013-2025 Hangfire OÜ. 5 | 6 | Hangfire software is an open-source software that is multi-licensed under the terms of the licenses listed in this file. Recipients may choose the terms under which they are want to use or distribute the software, when all the preconditions of a chosen license are satisfied. 7 | 8 | LGPL v3 License 9 | --------------- 10 | 11 | This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 12 | 13 | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. 14 | 15 | Please see COPYING.LESSER and COPYING files for details. 16 | 17 | Commercial License 18 | ------------------ 19 | 20 | Subject to the purchase of a corresponding subscription (please see https://www.hangfire.io/pricing/), you may distribute Hangfire under the terms of commercial license, that allows you to distribute private forks and modifications. Please see LICENSE_STANDARD and LICENSE_ROYALTYFREE files for details. 21 | -------------------------------------------------------------------------------- /NuGet.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | Microsoft;aspnet;dotnetframework;HangfireIO;xunit;jamesnk;kzu;castleproject;psake;ILRepack;davidebbo;StackExchange;Dapper;brady.holt;dwhelan;raboof;damianh; 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Reporting security issues 2 | 3 | In order to give the community time to respond and upgrade we strongly urge you report all security issues privately. Please email us at [security@hangfire.io](security@hangfire.io) with details and we will respond ASAP. Security issues always take precedence over bug fixes and feature work. We can and do mark releases as "urgent" if they contain serious security fixes. 4 | -------------------------------------------------------------------------------- /build.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | .nuget\NuGet.exe restore .nuget\packages.config -OutputDirectory packages -UseLockFile -LockedMode -NoCache || exit /b 666 3 | pwsh.exe -NoProfile -ExecutionPolicy RemoteSigned -Command "& {Import-Module '.\packages\psake.*\tools\psake.psm1'; invoke-psake .\psake-project.ps1 %*; if ($psake.build_success -eq $false) { exit 1 } else { exit 0 }; }" 4 | exit /B %errorlevel% 5 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -e; 4 | export Hangfire_SqlServer_ConnectionStringTemplate="Server=tcp:127.0.0.1,1433;Database={0};User Id=sa;Password=Password12!;TrustServerCertificate=True;PoolBlockingPeriod=NeverBlock"; 5 | 6 | if hash dotnet 2>/dev/null; 7 | then 8 | dotnet test -c Release -f netcoreapp3.1 tests/Hangfire.Core.Tests; 9 | dotnet test -c Release -f net6.0 tests/Hangfire.Core.Tests; 10 | if hash sqlcmd 2>/dev/null; 11 | then 12 | dotnet test -c Release -f netcoreapp3.1 tests/Hangfire.SqlServer.Tests; 13 | dotnet test -c Release -f net6.0 tests/Hangfire.SqlServer.Tests; 14 | fi 15 | fi 16 | -------------------------------------------------------------------------------- /nuspecs/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HangfireIO/Hangfire/d51e2c54dc49b28b3f340bb19d5fdcc394bb1b5d/nuspecs/icon.png -------------------------------------------------------------------------------- /samples/ConsoleSample/ConsoleSample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net451 6 | true 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /samples/ConsoleSample/GenericServices.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace ConsoleSample 4 | { 5 | public class GenericServices 6 | { 7 | public void Method(TType arg1, TMethod arg2) 8 | { 9 | Console.WriteLine($"Arg1: {arg1}, Arg2: {arg2}"); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /samples/ConsoleSample/Startup.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Hangfire; 3 | using Owin; 4 | 5 | namespace ConsoleSample 6 | { 7 | public class Startup 8 | { 9 | public void Configuration(IAppBuilder app) 10 | { 11 | app.UseErrorPage(); 12 | app.UseHangfireDashboard(String.Empty); 13 | 14 | app.UseHangfireServer(new BackgroundJobServerOptions 15 | { 16 | Queues = new[] { "critical", "default" }, 17 | TaskScheduler = null, 18 | SchedulePollingInterval = TimeSpan.FromSeconds(1) 19 | }); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /samples/ConsoleSample/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /samples/NetCoreSample/NetCoreSample.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net6.0 6 | latest 7 | NU1701;NU1702 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/Hangfire.AspNetCore/Dashboard/AspNetCoreDashboardContextExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2016 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using Hangfire.Annotations; 18 | using Microsoft.AspNetCore.Http; 19 | 20 | namespace Hangfire.Dashboard 21 | { 22 | public static class AspNetCoreDashboardContextExtensions 23 | { 24 | public static HttpContext GetHttpContext([NotNull] this DashboardContext context) 25 | { 26 | if (context == null) throw new ArgumentNullException(nameof(context)); 27 | 28 | var aspNetCoreContext = context as AspNetCoreDashboardContext; 29 | if (aspNetCoreContext == null) 30 | { 31 | throw new ArgumentException($"Context argument should be of type `{nameof(AspNetCoreDashboardContext)}`!", nameof(context)); 32 | } 33 | 34 | return aspNetCoreContext.HttpContext; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Hangfire.AspNetCore/Hangfire.AspNetCore.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net451;net461;netstandard1.3;netstandard2.0;netcoreapp3.0 4 | true 5 | $(NoWarn);1591 6 | Hangfire 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/Hangfire.AspNetCore/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | 3 | [assembly: AssemblyTitle("Hangfire.AspNetCore")] 4 | [assembly: AssemblyDescription("ASP.NET Core support for Hangfire")] 5 | -------------------------------------------------------------------------------- /src/Hangfire.Core/AttemptsExceededAction.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire 17 | { 18 | /// 19 | /// Specifies a candidate state for a background job that will be chosen 20 | /// by the filter after exceeding 21 | /// the number of retry attempts. 22 | /// 23 | public enum AttemptsExceededAction 24 | { 25 | /// 26 | /// Background job will be moved to the . 27 | /// 28 | Fail = 0, 29 | 30 | /// 31 | /// Background job will be moved to the . 32 | /// 33 | Delete 34 | } 35 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Client/IBackgroundJobFactory.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using Hangfire.Annotations; 17 | using Hangfire.States; 18 | 19 | namespace Hangfire.Client 20 | { 21 | /// 22 | /// This interface acts as extensibility point for the process 23 | /// of job creation. See the default implementation in the 24 | /// class. 25 | /// 26 | public interface IBackgroundJobFactory 27 | { 28 | /// 29 | /// Gets a state machine that's responsible for initial state change. 30 | /// 31 | [NotNull] 32 | IStateMachine StateMachine { get; } 33 | 34 | /// 35 | /// Runs the process of job creation with the specified context. 36 | /// 37 | [CanBeNull] 38 | BackgroundJob Create([NotNull] CreateContext context); 39 | } 40 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Client/IClientExceptionFilter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Client 17 | { 18 | /// 19 | /// Defines methods that are required for the client exception filter. 20 | /// 21 | public interface IClientExceptionFilter 22 | { 23 | /// 24 | /// Called when an exception occurred during the creation of the job. 25 | /// 26 | /// The filter context. 27 | void OnClientException(ClientExceptionContext filterContext); 28 | } 29 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Client/IClientFilter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Client 17 | { 18 | /// 19 | /// Defines methods that are required for a client filter. 20 | /// 21 | public interface IClientFilter 22 | { 23 | /// 24 | /// Called before the creation of the job. 25 | /// 26 | /// The filter context. 27 | void OnCreating(CreatingContext context); 28 | 29 | /// 30 | /// Called after the creation of the job. 31 | /// 32 | /// The filter context. 33 | void OnCreated(CreatedContext context); 34 | } 35 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Common/ExpressionUtil/ConditionalExpressionFingerprint.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. 2 | 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Linq.Expressions; 6 | 7 | #pragma warning disable 659 // overrides AddToHashCodeCombiner instead 8 | 9 | namespace Hangfire.Common.ExpressionUtil 10 | { 11 | // ConditionalExpression fingerprint class 12 | // Expression of form (test) ? ifTrue : ifFalse 13 | 14 | [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals", Justification = "Overrides AddToHashCodeCombiner() instead.")] 15 | [SuppressMessage("SonarLint", "S1206:OverrideGetHashCodeOnOverridingEquals", Justification = "Overrides AddToHashCodeCombiner() instead.")] 16 | [ExcludeFromCodeCoverage] 17 | internal sealed class ConditionalExpressionFingerprint : ExpressionFingerprint 18 | { 19 | public ConditionalExpressionFingerprint(ExpressionType nodeType, Type type) 20 | : base(nodeType, type) 21 | { 22 | // There are no properties on ConditionalExpression that are worth including in 23 | // the fingerprint. 24 | } 25 | 26 | public override bool Equals(object obj) 27 | { 28 | ConditionalExpressionFingerprint other = obj as ConditionalExpressionFingerprint; 29 | return (other != null) 30 | && Equals(other); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Common/ExpressionUtil/DefaultExpressionFingerprint.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. 2 | 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Linq.Expressions; 6 | 7 | #pragma warning disable 659 // overrides AddToHashCodeCombiner instead 8 | 9 | namespace Hangfire.Common.ExpressionUtil 10 | { 11 | // DefaultExpression fingerprint class 12 | // Expression of form default(T) 13 | 14 | [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals", Justification = "Overrides AddToHashCodeCombiner() instead.")] 15 | [SuppressMessage("SonarLint", "S1206:OverrideGetHashCodeOnOverridingEquals", Justification = "Overrides AddToHashCodeCombiner() instead.")] 16 | [ExcludeFromCodeCoverage] 17 | internal sealed class DefaultExpressionFingerprint : ExpressionFingerprint 18 | { 19 | public DefaultExpressionFingerprint(ExpressionType nodeType, Type type) 20 | : base(nodeType, type) 21 | { 22 | // There are no properties on DefaultExpression that are worth including in 23 | // the fingerprint. 24 | } 25 | 26 | public override bool Equals(object obj) 27 | { 28 | DefaultExpressionFingerprint other = obj as DefaultExpressionFingerprint; 29 | return (other != null) 30 | && Equals(other); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Common/ExpressionUtil/Hoisted.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. 2 | 3 | using System.Collections.Generic; 4 | 5 | namespace Hangfire.Common.ExpressionUtil 6 | { 7 | internal delegate TValue Hoisted(TModel model, List capturedConstants); 8 | } 9 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Common/ExpressionUtil/LambdaExpressionFingerprint.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information. 2 | 3 | using System; 4 | using System.Diagnostics.CodeAnalysis; 5 | using System.Linq.Expressions; 6 | 7 | #pragma warning disable 659 // overrides AddToHashCodeCombiner instead 8 | 9 | namespace Hangfire.Common.ExpressionUtil 10 | { 11 | // LambdaExpression fingerprint class 12 | // Represents a lambda expression (root element in Expression) 13 | 14 | [SuppressMessage("Microsoft.Usage", "CA2218:OverrideGetHashCodeOnOverridingEquals", Justification = "Overrides AddToHashCodeCombiner() instead.")] 15 | [SuppressMessage("SonarLint", "S1206:OverrideGetHashCodeOnOverridingEquals", Justification = "Overrides AddToHashCodeCombiner() instead.")] 16 | [ExcludeFromCodeCoverage] 17 | internal sealed class LambdaExpressionFingerprint : ExpressionFingerprint 18 | { 19 | public LambdaExpressionFingerprint(ExpressionType nodeType, Type type) 20 | : base(nodeType, type) 21 | { 22 | // There are no properties on LambdaExpression that are worth including in 23 | // the fingerprint. 24 | } 25 | 26 | public override bool Equals(object obj) 27 | { 28 | LambdaExpressionFingerprint other = obj as LambdaExpressionFingerprint; 29 | return (other != null) 30 | && Equals(other); 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Common/IJobFilter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Common 17 | { 18 | /// 19 | /// Defines members that specify the order of filters and 20 | /// whether multiple filters are allowed. 21 | /// 22 | public interface IJobFilter 23 | { 24 | /// 25 | /// When implemented in a class, gets or sets a value 26 | /// that indicates whether multiple filters are allowed. 27 | /// 28 | bool AllowMultiple { get; } 29 | 30 | /// 31 | /// When implemented in a class, gets the filter order. 32 | /// 33 | int Order { get; } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Common/IJobFilterProvider.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Collections.Generic; 17 | 18 | namespace Hangfire.Common 19 | { 20 | /// 21 | /// Provides an interface for finding filters. 22 | /// 23 | public interface IJobFilterProvider 24 | { 25 | /// 26 | /// Returns an enumerator that contains all the . 27 | /// 28 | /// 29 | /// 30 | /// The enumerator that contains all the . 31 | /// 32 | IEnumerable GetFilters(Job job); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Common/JobFilterProviders.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Common 17 | { 18 | /// 19 | /// Provides a registration point for filters. 20 | /// 21 | public static class JobFilterProviders 22 | { 23 | static JobFilterProviders() 24 | { 25 | // ReSharper disable once UseObjectOrCollectionInitializer 26 | Providers = new JobFilterProviderCollection(); 27 | Providers.Add(GlobalJobFilters.Filters); 28 | Providers.Add(new JobFilterAttributeFilterProvider()); 29 | } 30 | 31 | /// 32 | /// Provides a registration point for filters. 33 | /// 34 | public static JobFilterProviderCollection Providers { get; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Common/LanguagePolyfills.cs: -------------------------------------------------------------------------------- 1 | using System.ComponentModel; 2 | 3 | namespace System.Runtime.CompilerServices 4 | { 5 | #if !NET5_0_OR_GREATER 6 | 7 | [EditorBrowsable(EditorBrowsableState.Never)] 8 | internal static class IsExternalInit {} 9 | 10 | #endif // !NET5_0_OR_GREATER 11 | 12 | #if !NET7_0_OR_GREATER 13 | 14 | [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Field | AttributeTargets.Property, AllowMultiple = false, Inherited = false)] 15 | internal sealed class RequiredMemberAttribute : Attribute {} 16 | 17 | [AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)] 18 | internal sealed class CompilerFeatureRequiredAttribute : Attribute 19 | { 20 | public CompilerFeatureRequiredAttribute(string featureName) 21 | { 22 | FeatureName = featureName; 23 | } 24 | 25 | public string FeatureName { get; } 26 | public bool IsOptional { get; init; } 27 | 28 | public const string RefStructs = nameof(RefStructs); 29 | public const string RequiredMembers = nameof(RequiredMembers); 30 | } 31 | 32 | #endif // !NET7_0_OR_GREATER 33 | } 34 | 35 | namespace System.Diagnostics.CodeAnalysis 36 | { 37 | #if !NET7_0_OR_GREATER 38 | [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)] 39 | internal sealed class SetsRequiredMembersAttribute : Attribute {} 40 | #endif 41 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Common/MethodInfoExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2017 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Linq; 17 | using System.Reflection; 18 | 19 | namespace Hangfire.Common 20 | { 21 | internal static class MethodInfoExtensions 22 | { 23 | public static string GetNormalizedName(this MethodInfo methodInfo) 24 | { 25 | // Method names containing '.' are considered explicitly implemented interface methods 26 | // https://stackoverflow.com/a/17854048/1398672 27 | return methodInfo.Name.Contains('.') && methodInfo.IsFinal && methodInfo.IsPrivate 28 | ? methodInfo.Name.Split('.').Last() 29 | : methodInfo.Name; 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Content/css/Chart.min.css: -------------------------------------------------------------------------------- 1 | @keyframes chartjs-render-animation{from{opacity:.99}to{opacity:1}}.chartjs-render-monitor{animation:chartjs-render-animation 1ms}.chartjs-size-monitor,.chartjs-size-monitor-expand,.chartjs-size-monitor-shrink{position:absolute;direction:ltr;left:0;top:0;right:0;bottom:0;overflow:hidden;pointer-events:none;visibility:hidden;z-index:-1}.chartjs-size-monitor-expand>div{position:absolute;width:1000000px;height:1000000px;left:0;top:0}.chartjs-size-monitor-shrink>div{position:absolute;width:200%;height:200%;left:0;top:0} 2 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Content/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HangfireIO/Hangfire/d51e2c54dc49b28b3f340bb19d5fdcc394bb1b5d/src/Hangfire.Core/Dashboard/Content/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Content/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HangfireIO/Hangfire/d51e2c54dc49b28b3f340bb19d5fdcc394bb1b5d/src/Hangfire.Core/Dashboard/Content/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Content/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HangfireIO/Hangfire/d51e2c54dc49b28b3f340bb19d5fdcc394bb1b5d/src/Hangfire.Core/Dashboard/Content/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Content/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HangfireIO/Hangfire/d51e2c54dc49b28b3f340bb19d5fdcc394bb1b5d/src/Hangfire.Core/Dashboard/Content/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/DashboardMetric.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2015 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire.Dashboard 19 | { 20 | public class DashboardMetric 21 | { 22 | public DashboardMetric(string name, Func func) 23 | : this(name, name, func) 24 | { 25 | } 26 | 27 | public DashboardMetric(string name, string title, Func func) 28 | { 29 | Name = name; 30 | Title = title; 31 | Func = func; 32 | } 33 | 34 | public string Name { get; } 35 | public Func Func { get; } 36 | 37 | public string Title { get; set; } 38 | public string Url { get; set; } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/IDashboardAsyncAuthorizationFilter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2021 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Threading.Tasks; 17 | using Hangfire.Annotations; 18 | 19 | namespace Hangfire.Dashboard 20 | { 21 | public interface IDashboardAsyncAuthorizationFilter 22 | { 23 | Task AuthorizeAsync([NotNull] DashboardContext context); 24 | } 25 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/IDashboardAuthorizationFilter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2016 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using Hangfire.Annotations; 17 | 18 | namespace Hangfire.Dashboard 19 | { 20 | public interface IDashboardAuthorizationFilter 21 | { 22 | bool Authorize([NotNull] DashboardContext context); 23 | } 24 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/NonEscapedString.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Dashboard 17 | { 18 | public class NonEscapedString 19 | { 20 | private readonly string _value; 21 | 22 | public NonEscapedString(string value) 23 | { 24 | _value = value; 25 | } 26 | 27 | public override string ToString() 28 | { 29 | return _value; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Owin/IOwinDashboardAntiforgery.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2018 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Collections.Generic; 17 | 18 | namespace Hangfire.Dashboard.Owin 19 | { 20 | public interface IOwinDashboardAntiforgery 21 | { 22 | string HeaderName { get; } 23 | string GetToken(IDictionary environment); 24 | bool ValidateRequest(IDictionary environment); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Owin/OwinDashboardContext.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2016 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Annotations; 19 | 20 | namespace Hangfire.Dashboard 21 | { 22 | public sealed class OwinDashboardContext : DashboardContext 23 | { 24 | public OwinDashboardContext( 25 | [NotNull] JobStorage storage, 26 | [NotNull] DashboardOptions options, 27 | [NotNull] IDictionary environment) 28 | : base(storage, options) 29 | { 30 | if (environment == null) throw new ArgumentNullException(nameof(environment)); 31 | 32 | Environment = environment; 33 | Request = new OwinDashboardRequest(environment); 34 | Response = new OwinDashboardResponse(environment); 35 | } 36 | 37 | public IDictionary Environment { get; } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Owin/OwinDashboardContextExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2016 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Annotations; 19 | 20 | namespace Hangfire.Dashboard 21 | { 22 | public static class OwinDashboardContextExtensions 23 | { 24 | public static IDictionary GetOwinEnvironment([NotNull] this DashboardContext context) 25 | { 26 | if (context == null) throw new ArgumentNullException(nameof(context)); 27 | 28 | var owinContext = context as OwinDashboardContext; 29 | if (owinContext == null) 30 | { 31 | throw new ArgumentException($"Context argument should be of type `{nameof(OwinDashboardContext)}`!", nameof(context)); 32 | } 33 | 34 | return owinContext.Environment; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/EnqueuedJobsPage.cs: -------------------------------------------------------------------------------- 1 | namespace Hangfire.Dashboard.Pages 2 | { 3 | partial class EnqueuedJobsPage 4 | { 5 | public EnqueuedJobsPage(string queue) 6 | { 7 | Queue = queue; 8 | } 9 | 10 | public string Queue { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/FetchedJobsPage.cs: -------------------------------------------------------------------------------- 1 | namespace Hangfire.Dashboard.Pages 2 | { 3 | partial class FetchedJobsPage 4 | { 5 | public FetchedJobsPage(string queue) 6 | { 7 | Queue = queue; 8 | } 9 | 10 | public string Queue { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/HomePage.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Hangfire.Dashboard.Pages 4 | { 5 | partial class HomePage 6 | { 7 | public static readonly List Metrics = new List(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/JobDetailsPage.cs: -------------------------------------------------------------------------------- 1 | using Hangfire.Annotations; 2 | 3 | namespace Hangfire.Dashboard.Pages 4 | { 5 | partial class JobDetailsPage 6 | { 7 | public JobDetailsPage(string jobId) 8 | { 9 | JobId = jobId; 10 | } 11 | 12 | public string JobId { get; } 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/LayoutPage.cs: -------------------------------------------------------------------------------- 1 | namespace Hangfire.Dashboard.Pages 2 | { 3 | partial class LayoutPage 4 | { 5 | public LayoutPage(string title) 6 | { 7 | Title = title; 8 | } 9 | 10 | public string Title { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_BlockMetric.cs: -------------------------------------------------------------------------------- 1 | namespace Hangfire.Dashboard.Pages 2 | { 3 | partial class BlockMetric 4 | { 5 | public BlockMetric(DashboardMetric dashboardMetric) 6 | { 7 | DashboardMetric = dashboardMetric; 8 | } 9 | 10 | public DashboardMetric DashboardMetric { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_BlockMetric.cshtml: -------------------------------------------------------------------------------- 1 | @* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True TrimLeadingUnderscores : true *@ 2 | @using Hangfire.Dashboard 3 | @using Hangfire.Dashboard.Resources 4 | @inherits RazorPage 5 | @{ 6 | var metric = DashboardMetric.Func(this); 7 | var className = metric == null ? "metric-null" : metric.Style.ToClassName(); 8 | var highlighted = metric != null && metric.Highlighted ? "highlighted" : null; 9 | } 10 | 11 | @if (!string.IsNullOrEmpty(DashboardMetric.Url)) 12 | { 13 | @: 14 | } 15 |
16 |
17 | @(metric?.Value) 18 |
19 |
20 | @(Strings.ResourceManager.GetString(DashboardMetric.Title) ?? DashboardMetric.Title) 21 |
22 |
23 | @if (!string.IsNullOrEmpty(DashboardMetric.Url)) 24 | { 25 | @:
26 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_Breadcrumbs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Hangfire.Dashboard.Pages 4 | { 5 | partial class Breadcrumbs 6 | { 7 | public Breadcrumbs(string title, IDictionary items) 8 | { 9 | Title = title; 10 | Items = items; 11 | } 12 | 13 | public string Title { get; } 14 | public IDictionary Items { get; } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_Breadcrumbs.cshtml: -------------------------------------------------------------------------------- 1 | @* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True TrimLeadingUnderscores : true *@ 2 | @using Hangfire.Dashboard 3 | @inherits RazorPage 4 | 5 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_ErrorAlert.cshtml: -------------------------------------------------------------------------------- 1 | @* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True TrimLeadingUnderscores : true *@ 2 | @using Hangfire.Dashboard 3 | @inherits RazorPage 4 | 5 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_ErrorAlert.cshtml.cs: -------------------------------------------------------------------------------- 1 | #pragma warning disable 1591 2 | //------------------------------------------------------------------------------ 3 | // 4 | // This code was generated by a tool. 5 | // Runtime Version:4.0.30319.42000 6 | // 7 | // Changes to this file may cause incorrect behavior and will be lost if 8 | // the code is regenerated. 9 | // 10 | //------------------------------------------------------------------------------ 11 | 12 | namespace Hangfire.Dashboard.Pages 13 | { 14 | using System; 15 | using System.Collections.Generic; 16 | using System.Linq; 17 | using System.Text; 18 | 19 | #line 2 "..\..\Dashboard\Pages\_ErrorAlert.cshtml" 20 | using Hangfire.Dashboard; 21 | 22 | #line default 23 | #line hidden 24 | 25 | [System.CodeDom.Compiler.GeneratedCodeAttribute("RazorGenerator", "2.0.0.0")] 26 | internal partial class ErrorAlert : RazorPage 27 | { 28 | #line hidden 29 | 30 | public override void Execute() 31 | { 32 | 33 | 34 | WriteLiteral("\r\n"); 35 | 36 | 37 | 38 | WriteLiteral("\r\n
\r\n
\r\n \r\n \r\n
\r\n
"); 41 | 42 | 43 | } 44 | } 45 | } 46 | #pragma warning restore 1591 47 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_InlineMetric.cs: -------------------------------------------------------------------------------- 1 | namespace Hangfire.Dashboard.Pages 2 | { 3 | partial class InlineMetric 4 | { 5 | public InlineMetric(DashboardMetric dashboardMetric) 6 | { 7 | DashboardMetric = dashboardMetric; 8 | } 9 | 10 | public DashboardMetric DashboardMetric { get; } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_InlineMetric.cshtml: -------------------------------------------------------------------------------- 1 | @* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True TrimLeadingUnderscores : true *@ 2 | @using Hangfire.Dashboard 3 | @inherits RazorPage 4 | @{ 5 | var metric = DashboardMetric.Func(this); 6 | var className = metric == null ? "metric-null" : metric.Style.ToClassName(); 7 | var highlighted = metric != null && metric.Highlighted ? "highlighted" : null; 8 | } 9 | @(metric?.Value) -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_Navigation.cshtml: -------------------------------------------------------------------------------- 1 | @* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True TrimLeadingUnderscores : true *@ 2 | @using Hangfire.Dashboard 3 | @inherits RazorPage 4 | @if (NavigationMenu.Items.Count > 0) 5 | { 6 | 25 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_Paginator.cs: -------------------------------------------------------------------------------- 1 | namespace Hangfire.Dashboard.Pages 2 | { 3 | partial class Paginator 4 | { 5 | private readonly Pager _pager; 6 | 7 | public Paginator(Pager pager) 8 | { 9 | _pager = pager; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_PerPageSelector.cs: -------------------------------------------------------------------------------- 1 | namespace Hangfire.Dashboard.Pages 2 | { 3 | partial class PerPageSelector 4 | { 5 | private readonly Pager _pager; 6 | 7 | public PerPageSelector(Pager pager) 8 | { 9 | _pager = pager; 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_PerPageSelector.cshtml: -------------------------------------------------------------------------------- 1 | @* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True TrimLeadingUnderscores : true *@ 2 | @using Hangfire.Dashboard.Resources; 3 | @inherits Hangfire.Dashboard.RazorPage 4 | 5 | @if (_pager.TotalPageCount > 1) 6 | { 7 | 15 | } 16 |
17 | @foreach (var count in new[] { 10, 20, 50, 100, 500, 1000, 5000 }) 18 | { 19 | 999 ? "visible-lg" : null)" 20 | href="@_pager.RecordsPerPageUrl(count)">@count.ToString("N0") 21 | } 22 |
23 | 24 | 27 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_SidebarMenu.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2015 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Annotations; 19 | 20 | namespace Hangfire.Dashboard.Pages 21 | { 22 | partial class SidebarMenu 23 | { 24 | public SidebarMenu([NotNull] IEnumerable> items) 25 | { 26 | if (items == null) throw new ArgumentNullException(nameof(items)); 27 | Items = items; 28 | } 29 | 30 | public IEnumerable> Items { get; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/Pages/_SidebarMenu.cshtml: -------------------------------------------------------------------------------- 1 | @* Generator: Template TypeVisibility: Internal GeneratePrettyNames: True TrimLeadingUnderscores : true *@ 2 | @using Hangfire.Dashboard 3 | @inherits RazorPage 4 | @if (Items.Any()) 5 | { 6 | 21 | } 22 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Dashboard/RazorPageDispatcher.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Text.RegularExpressions; 18 | using System.Threading.Tasks; 19 | 20 | namespace Hangfire.Dashboard 21 | { 22 | internal sealed class RazorPageDispatcher : IDashboardDispatcher 23 | { 24 | private readonly Func _pageFunc; 25 | 26 | public RazorPageDispatcher(Func pageFunc) 27 | { 28 | _pageFunc = pageFunc; 29 | } 30 | 31 | public Task Dispatch(DashboardContext context) 32 | { 33 | context.Response.ContentType = "text/html"; 34 | 35 | var page = _pageFunc(context.UriMatch); 36 | page.Assign(context); 37 | 38 | return context.Response.WriteAsync(page.ToString()); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /src/Hangfire.Core/ExceptionTypeHelper.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2022 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire 19 | { 20 | internal static class ExceptionTypeHelper 21 | { 22 | #if !NETSTANDARD1_3 23 | private static readonly Type StackOverflowType = typeof(StackOverflowException); 24 | #endif 25 | private static readonly Type OutOfMemoryType = typeof(OutOfMemoryException); 26 | 27 | internal static bool IsCatchableExceptionType(this Exception e) 28 | { 29 | var type = e.GetType(); 30 | return 31 | #if !NETSTANDARD1_3 32 | type != StackOverflowType && 33 | #endif 34 | type != OutOfMemoryType; 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/FromParameterAttribute.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2019 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire 19 | { 20 | [AttributeUsage(AttributeTargets.Parameter)] 21 | public class FromParameterAttribute : Attribute 22 | { 23 | public FromParameterAttribute(string parameterName) 24 | { 25 | ParameterName = parameterName; 26 | } 27 | 28 | public string ParameterName { get; } 29 | } 30 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/FromResultAttribute.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2019 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire 19 | { 20 | [AttributeUsage(AttributeTargets.Parameter)] 21 | public sealed class FromResultAttribute : FromParameterAttribute 22 | { 23 | public FromResultAttribute() : base("AntecedentResult") 24 | { 25 | } 26 | } 27 | 28 | [AttributeUsage(AttributeTargets.Parameter)] 29 | public sealed class FromExceptionAttribute : FromParameterAttribute 30 | { 31 | public FromExceptionAttribute() : base("AntecedentException") 32 | { 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/GlobalStateHandlers.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Collections.Generic; 17 | using Hangfire.States; 18 | 19 | namespace Hangfire 20 | { 21 | public static class GlobalStateHandlers 22 | { 23 | static GlobalStateHandlers() 24 | { 25 | Handlers = new List 26 | { 27 | new SucceededState.Handler(), 28 | new ScheduledState.Handler(), 29 | new EnqueuedState.Handler(), 30 | new DeletedState.Handler(), 31 | new AwaitingState.Handler() 32 | }; 33 | } 34 | 35 | public static ICollection Handlers { get; } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/IGlobalConfiguration.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2015 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.ComponentModel; 17 | 18 | namespace Hangfire 19 | { 20 | [EditorBrowsable(EditorBrowsableState.Never)] 21 | public interface IGlobalConfiguration : IGlobalConfiguration 22 | { 23 | [EditorBrowsable(EditorBrowsableState.Advanced)] 24 | T Entry { get; } 25 | } 26 | 27 | [EditorBrowsable(EditorBrowsableState.Never)] 28 | public interface IGlobalConfiguration 29 | { 30 | } 31 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/IJobCancellationToken.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Threading; 17 | 18 | namespace Hangfire 19 | { 20 | public interface IJobCancellationToken 21 | { 22 | CancellationToken ShutdownToken { get; } 23 | 24 | /// 25 | /// Throws a OperationCanceledException if 26 | /// this token has had cancellation requested. 27 | /// 28 | /// 29 | /// This method provides functionality equivalent to: 30 | /// 31 | /// if (token.ShutdownToken.IsCancellationRequested) 32 | /// throw new OperationCanceledException(token); 33 | /// 34 | /// 35 | /// The token has had cancellation requested. 36 | void ThrowIfCancellationRequested(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Hangfire.Core/IRecurringJobManager.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2016 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using Hangfire.Annotations; 17 | using Hangfire.Common; 18 | 19 | namespace Hangfire 20 | { 21 | public interface IRecurringJobManagerV2 : IRecurringJobManager 22 | { 23 | [NotNull] 24 | JobStorage Storage { get; } 25 | 26 | [CanBeNull] 27 | string TriggerJob([NotNull] string recurringJobId); 28 | } 29 | 30 | public interface IRecurringJobManager 31 | { 32 | void AddOrUpdate( 33 | [NotNull] string recurringJobId, 34 | [NotNull] Job job, 35 | [NotNull] string cronExpression, 36 | [NotNull] RecurringJobOptions options); 37 | 38 | void Trigger([NotNull] string recurringJobId); 39 | void RemoveIfExists([NotNull] string recurringJobId); 40 | } 41 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/ITimeZoneResolver.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2019 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using Hangfire.Annotations; 18 | 19 | namespace Hangfire 20 | { 21 | public sealed class DefaultTimeZoneResolver : ITimeZoneResolver 22 | { 23 | public TimeZoneInfo GetTimeZoneById(string timeZoneId) 24 | { 25 | return TimeZoneInfo.FindSystemTimeZoneById(timeZoneId); 26 | } 27 | } 28 | 29 | public interface ITimeZoneResolver 30 | { 31 | [NotNull] 32 | TimeZoneInfo GetTimeZoneById([NotNull] string timeZoneId); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Hangfire.Core/JobCancellationToken.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Threading; 17 | 18 | namespace Hangfire 19 | { 20 | public class JobCancellationToken : IJobCancellationToken 21 | { 22 | private readonly bool _canceled; 23 | 24 | public JobCancellationToken(bool canceled) 25 | { 26 | _canceled = canceled; 27 | ShutdownToken = new CancellationToken(canceled); 28 | } 29 | 30 | public CancellationToken ShutdownToken { get; } 31 | 32 | public static IJobCancellationToken Null => null; 33 | 34 | /// 35 | public void ThrowIfCancellationRequested() 36 | { 37 | ShutdownToken.ThrowIfCancellationRequested(); 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/JobCancellationTokenExtensions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2019 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using Hangfire.Server; 17 | 18 | namespace Hangfire 19 | { 20 | internal static class JobCancellationTokenExtensions 21 | { 22 | public static bool IsAborted(this IJobCancellationToken jobCancellationToken) 23 | { 24 | if (jobCancellationToken is ServerJobCancellationToken serverJobCancellationToken) 25 | { 26 | // for ServerJobCancellationToken we may simply check IsAborted property 27 | // to prevent unnecessary creation of the linked CancellationTokenSource 28 | return serverJobCancellationToken.IsAborted; 29 | } 30 | 31 | return false; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Hangfire.Core/JobContinuationOptions.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire 19 | { 20 | [Flags] 21 | public enum JobContinuationOptions 22 | { 23 | OnAnyFinishedState = 0, 24 | OnlyOnSucceededState = 1, 25 | OnlyOnDeletedState = 2, 26 | } 27 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Obsolete/IAuthorizationFilter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Annotations; 19 | 20 | // ReSharper disable once CheckNamespace 21 | namespace Hangfire.Dashboard 22 | { 23 | [Obsolete("Please use `IDashboardAuthorizationFilter` instead. Will be removed in 2.0.0.")] 24 | public interface IAuthorizationFilter 25 | { 26 | bool Authorize([NotNull] IDictionary owinEnvironment); 27 | } 28 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Obsolete/IRequestDispatcher.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Threading.Tasks; 18 | 19 | // ReSharper disable once CheckNamespace 20 | namespace Hangfire.Dashboard 21 | { 22 | [Obsolete("Use the `IDashboardDispatcher` interface instead. Will be removed in 2.0.0.")] 23 | public interface IRequestDispatcher 24 | { 25 | Task Dispatch(RequestDispatcherContext context); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Obsolete/IServerComponent.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Threading; 18 | 19 | // ReSharper disable once CheckNamespace 20 | namespace Hangfire.Server 21 | { 22 | /// 23 | [Obsolete("Please use the `IBackgroundProcess` interface where you can. Will be removed in 2.0.0.")] 24 | public interface IServerComponent : IServerProcess 25 | { 26 | void Execute(CancellationToken cancellationToken); 27 | } 28 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Obsolete/IServerProcess.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | // ReSharper disable once CheckNamespace 19 | namespace Hangfire.Server 20 | { 21 | /// 22 | [Obsolete("Please use the `IBackgroundProcess` interface where you can. Will be removed in 2.0.0.")] 23 | public interface IServerProcess 24 | { 25 | } 26 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Obsolete/RequestDispatcherWrapper.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2016 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Threading.Tasks; 18 | using Hangfire.Annotations; 19 | 20 | // ReSharper disable once CheckNamespace 21 | namespace Hangfire.Dashboard 22 | { 23 | [Obsolete("Use IDashboardDispatcher-based dispatchers instead. Will be removed in 2.0.0.")] 24 | public class RequestDispatcherWrapper : IDashboardDispatcher 25 | { 26 | private readonly IRequestDispatcher _dispatcher; 27 | 28 | public RequestDispatcherWrapper([NotNull] IRequestDispatcher dispatcher) 29 | { 30 | if (dispatcher == null) throw new ArgumentNullException(nameof(dispatcher)); 31 | _dispatcher = dispatcher; 32 | } 33 | 34 | public Task Dispatch(DashboardContext context) 35 | { 36 | return _dispatcher.Dispatch(RequestDispatcherContext.FromDashboardContext(context)); 37 | } 38 | } 39 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Processing/IBackgroundDispatcher.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2017 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Threading; 18 | using System.Threading.Tasks; 19 | 20 | namespace Hangfire.Processing 21 | { 22 | // TODO Replace these methods with WaitHandle property in 2.0. 23 | public interface IBackgroundDispatcher : IDisposable 24 | { 25 | bool Wait(TimeSpan timeout); 26 | Task WaitAsync(TimeSpan timeout, CancellationToken cancellationToken); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Processing/IBackgroundExecution.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2017 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Threading.Tasks; 18 | using Hangfire.Annotations; 19 | 20 | namespace Hangfire.Processing 21 | { 22 | public interface IBackgroundExecution : IDisposable 23 | { 24 | void Run([NotNull] Action callback, [CanBeNull] object state); 25 | Task RunAsync([NotNull] Func callback, [CanBeNull] object state); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Profiling/EmptyProfiler.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2019 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire.Profiling 19 | { 20 | internal sealed class EmptyProfiler : IProfiler 21 | { 22 | internal static readonly IProfiler Instance = new EmptyProfiler(); 23 | 24 | private EmptyProfiler() 25 | { 26 | } 27 | 28 | public TResult InvokeMeasured( 29 | TInstance instance, 30 | Func action, 31 | Func messageFunc) 32 | { 33 | if (action == null) throw new ArgumentNullException(nameof(action)); 34 | return action(instance); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Profiling/IProfiler.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2019 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using Hangfire.Annotations; 18 | 19 | namespace Hangfire.Profiling 20 | { 21 | // TODO: Merge this with logging 22 | internal interface IProfiler 23 | { 24 | // TODO: Replace method with some eventId 25 | TResult InvokeMeasured( 26 | [CanBeNull] TInstance instance, 27 | [NotNull, InstantHandle] Func action, 28 | [CanBeNull] Func messageFunc = null); 29 | } 30 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Resources; 4 | using System.Runtime.CompilerServices; 5 | using System.Runtime.InteropServices; 6 | 7 | [assembly: AssemblyTitle("Hangfire")] 8 | [assembly: AssemblyDescription("Core classes of Hangfire that are independent of any framework.")] 9 | [assembly: Guid("4deecd4f-19f6-426b-aa87-6cd1a03eaa48")] 10 | [assembly: CLSCompliant(true)] 11 | [assembly: InternalsVisibleTo("Hangfire.Core.Tests")] 12 | [assembly: NeutralResourcesLanguage("en")] 13 | 14 | // Allow the generation of mocks for internal types 15 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] -------------------------------------------------------------------------------- /src/Hangfire.Core/Razor.build: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Hangfire 6 | true 7 | $(MsBuildProjectDirectory)\ 8 | 9 | 10 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Server/IBackgroundJobPerformer.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Server 17 | { 18 | public interface IBackgroundJobPerformer 19 | { 20 | object Perform(PerformContext context); 21 | } 22 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Server/IBackgroundProcessAsync.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2017 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Threading.Tasks; 17 | using Hangfire.Annotations; 18 | 19 | namespace Hangfire.Server 20 | { 21 | public interface IBackgroundProcessAsync 22 | { 23 | Task ExecuteAsync([NotNull] BackgroundProcessContext context); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Server/IBackgroundProcessDispatcherBuilder.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2017 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using Hangfire.Annotations; 17 | using Hangfire.Processing; 18 | 19 | namespace Hangfire.Server 20 | { 21 | public interface IBackgroundProcessDispatcherBuilder 22 | { 23 | IBackgroundDispatcher Create([NotNull] BackgroundServerContext context, [NotNull] BackgroundProcessingServerOptions options); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Server/IBackgroundProcessingServer.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2017 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Threading; 18 | using System.Threading.Tasks; 19 | 20 | namespace Hangfire.Server 21 | { 22 | public interface IBackgroundProcessingServer : IDisposable 23 | { 24 | void SendStop(); 25 | 26 | bool WaitForShutdown(TimeSpan timeout); 27 | Task WaitForShutdownAsync(CancellationToken cancellationToken); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Server/IBackgroundServerProcess.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2017 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Threading; 18 | using Hangfire.Processing; 19 | 20 | namespace Hangfire.Server 21 | { 22 | internal interface IBackgroundServerProcess 23 | { 24 | void Execute( 25 | Guid executionId, 26 | BackgroundExecution execution, 27 | CancellationToken stoppingToken, 28 | CancellationToken stoppedToken, 29 | CancellationToken shutdownToken); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Server/IServerExceptionFilter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Server 17 | { 18 | /// 19 | /// Defines methods that are required for the server exception filter. 20 | /// 21 | public interface IServerExceptionFilter 22 | { 23 | /// 24 | /// Called when an exception occurred during the performance of the job. 25 | /// 26 | /// The filter context. 27 | void OnServerException(ServerExceptionContext filterContext); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Server/IServerFilter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Server 17 | { 18 | /// 19 | /// Defines methods that are required for a server filter. 20 | /// 21 | public interface IServerFilter 22 | { 23 | /// 24 | /// Called before the performance of the job. 25 | /// 26 | /// The filter context. 27 | void OnPerforming(PerformingContext context); 28 | 29 | /// 30 | /// Called after the performance of the job. 31 | /// 32 | /// The filter context. 33 | void OnPerformed(PerformedContext context); 34 | } 35 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Server/PerformingContext.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Server 17 | { 18 | /// 19 | /// Provides the context for the 20 | /// method of the interface. 21 | /// 22 | public class PerformingContext : PerformContext 23 | { 24 | public PerformingContext(PerformContext context) 25 | : base(context) 26 | { 27 | } 28 | 29 | /// 30 | /// Gets or sets a value that indicates that this 31 | /// object was canceled. 32 | /// 33 | public bool Canceled { get; set; } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Server/ServerContext.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Server 17 | { 18 | public class ServerContext 19 | { 20 | public ServerContext() 21 | { 22 | Queues = []; 23 | WorkerCount = -1; 24 | } 25 | 26 | public int WorkerCount { get; set; } 27 | public string[] Queues { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/States/IApplyStateFilter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using Hangfire.Storage; 17 | 18 | namespace Hangfire.States 19 | { 20 | /// 21 | /// Provides methods that are required for a state changed filter. 22 | /// 23 | public interface IApplyStateFilter 24 | { 25 | /// 26 | /// Called after the specified state was applied 27 | /// to the job within the given transaction. 28 | /// 29 | void OnStateApplied( 30 | ApplyStateContext context, IWriteOnlyTransaction transaction); 31 | 32 | /// 33 | /// Called when the state with specified state was 34 | /// unapplied from the job within the given transaction. 35 | /// 36 | void OnStateUnapplied( 37 | ApplyStateContext context, IWriteOnlyTransaction transaction); 38 | } 39 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/States/IBackgroundJobStateChanger.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.States 17 | { 18 | public interface IBackgroundJobStateChanger 19 | { 20 | /// 21 | /// Attempts to change the state of a job, respecting any applicable job filters and state handlers. 22 | /// 23 | /// Null if a constraint has failed, otherwise the final applied state 24 | /// Also ensures that the job data can be loaded for this job 25 | IState ChangeState(StateChangeContext context); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/States/IElectStateFilter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.States 17 | { 18 | /// 19 | /// Defines methods that are required for a state changing filter. 20 | /// 21 | public interface IElectStateFilter 22 | { 23 | /// 24 | /// Called when the current state of the job is being changed to the 25 | /// specified candidate state. 26 | /// This state change could be intercepted and the final state could 27 | /// be changed through setting the different state in the context 28 | /// in an implementation of this method. 29 | /// 30 | void OnStateElection(ElectStateContext context); 31 | } 32 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/States/IStateMachine.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.States 17 | { 18 | /// 19 | /// Provides a mechanism for running state election and state applying processes. 20 | /// 21 | /// 22 | /// 23 | public interface IStateMachine 24 | { 25 | /// 26 | /// Performs the state applying process, where a current background job 27 | /// will be moved to the elected state. 28 | /// 29 | /// The context of a state applying process. 30 | IState ApplyState(ApplyStateContext context); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/IFetchedJob.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire.Storage 19 | { 20 | public interface IFetchedJob : IDisposable 21 | { 22 | string JobId { get; } 23 | 24 | void RemoveFromQueue(); 25 | void Requeue(); 26 | } 27 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/JobData.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Common; 19 | 20 | namespace Hangfire.Storage 21 | { 22 | public class JobData 23 | { 24 | public string State { get; set; } 25 | public Job Job { get; set; } 26 | public InvocationData InvocationData { get; set; } 27 | public DateTime CreatedAt { get; set; } 28 | public IReadOnlyDictionary ParametersSnapshot { get; set; } 29 | 30 | public JobLoadException LoadException { get; set; } 31 | 32 | public void EnsureLoaded() 33 | { 34 | if (LoadException != null) 35 | { 36 | throw LoadException; 37 | } 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/AwaitingJobDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2022 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Common; 19 | 20 | namespace Hangfire.Storage.Monitoring 21 | { 22 | public class AwaitingJobDto 23 | { 24 | public AwaitingJobDto() 25 | { 26 | InAwaitingState = true; 27 | } 28 | 29 | public Job Job { get; set; } 30 | public JobLoadException LoadException { get; set; } 31 | public InvocationData InvocationData { get; set; } 32 | public DateTime? AwaitingAt { get; set; } 33 | public bool InAwaitingState { get; set; } 34 | public IDictionary StateData { get; set; } 35 | public string ParentStateName { get; set; } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/DeletedJobDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Common; 19 | 20 | namespace Hangfire.Storage.Monitoring 21 | { 22 | public class DeletedJobDto 23 | { 24 | public DeletedJobDto() 25 | { 26 | InDeletedState = true; 27 | } 28 | 29 | public Job Job { get; set; } 30 | public JobLoadException LoadException { get; set; } 31 | public InvocationData InvocationData { get; set; } 32 | public DateTime? DeletedAt { get; set; } 33 | public bool InDeletedState { get; set; } 34 | public IDictionary StateData { get; set; } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/EnqueuedJobDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Common; 19 | 20 | namespace Hangfire.Storage.Monitoring 21 | { 22 | public class EnqueuedJobDto 23 | { 24 | public EnqueuedJobDto() 25 | { 26 | InEnqueuedState = true; 27 | } 28 | 29 | public Job Job { get; set; } 30 | public JobLoadException LoadException { get; set; } 31 | public InvocationData InvocationData { get; set; } 32 | public string State { get; set; } 33 | public DateTime? EnqueuedAt { get; set; } 34 | public bool InEnqueuedState { get; set; } 35 | public IDictionary StateData { get; set; } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/FailedJobDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Common; 19 | 20 | namespace Hangfire.Storage.Monitoring 21 | { 22 | public class FailedJobDto 23 | { 24 | public FailedJobDto() 25 | { 26 | InFailedState = true; 27 | } 28 | 29 | public Job Job { get; set; } 30 | public JobLoadException LoadException { get; set; } 31 | public InvocationData InvocationData { get; set; } 32 | public string Reason { get; set; } 33 | public DateTime? FailedAt { get; set; } 34 | public string ExceptionType { get; set; } 35 | public string ExceptionMessage { get; set; } 36 | public string ExceptionDetails { get; set; } 37 | public bool InFailedState { get; set; } 38 | public IDictionary StateData { get; set; } 39 | } 40 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/FetchedJobDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using Hangfire.Common; 18 | 19 | namespace Hangfire.Storage.Monitoring 20 | { 21 | public class FetchedJobDto 22 | { 23 | public Job Job { get; set; } 24 | public JobLoadException LoadException { get; set; } 25 | public InvocationData InvocationData { get; set; } 26 | public string State { get; set; } 27 | public DateTime? FetchedAt { get; set; } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/JobDetailsDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Common; 19 | 20 | namespace Hangfire.Storage.Monitoring 21 | { 22 | public class JobDetailsDto 23 | { 24 | public Job Job { get; set; } 25 | public JobLoadException LoadException { get; set; } 26 | public InvocationData InvocationData { get; set; } 27 | public DateTime? CreatedAt { get; set; } 28 | public IDictionary Properties { get; set; } 29 | public IList History { get; set; } 30 | public DateTime? ExpireAt { get; set; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/JobList.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Collections.Generic; 17 | 18 | namespace Hangfire.Storage.Monitoring 19 | { 20 | public class JobList : List> 21 | { 22 | public JobList(IEnumerable> source) 23 | : base(source) 24 | { 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/ProcessingJobDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Common; 19 | 20 | namespace Hangfire.Storage.Monitoring 21 | { 22 | public class ProcessingJobDto 23 | { 24 | public ProcessingJobDto() 25 | { 26 | InProcessingState = true; 27 | } 28 | 29 | public Job Job { get; set; } 30 | public JobLoadException LoadException { get; set; } 31 | public InvocationData InvocationData { get; set; } 32 | public bool InProcessingState { get; set; } 33 | public string ServerId { get; set; } 34 | public DateTime? StartedAt { get; set; } 35 | public IDictionary StateData { get; set; } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/QueueWithTopEnqueuedJobsDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Storage.Monitoring 17 | { 18 | public class QueueWithTopEnqueuedJobsDto 19 | { 20 | public string Name { get; set; } 21 | public long Length { get; set; } 22 | public long? Fetched { get; set; } 23 | public JobList FirstJobs { get; set; } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/ScheduledJobDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Common; 19 | 20 | namespace Hangfire.Storage.Monitoring 21 | { 22 | public class ScheduledJobDto 23 | { 24 | public ScheduledJobDto() 25 | { 26 | InScheduledState = true; 27 | } 28 | 29 | public Job Job { get; set; } 30 | public JobLoadException LoadException { get; set; } 31 | public InvocationData InvocationData { get; set; } 32 | public DateTime EnqueueAt { get; set; } 33 | public DateTime? ScheduledAt { get; set; } 34 | public bool InScheduledState { get; set; } 35 | public IDictionary StateData { get; set; } 36 | } 37 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/ServerDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | 19 | namespace Hangfire.Storage.Monitoring 20 | { 21 | public class ServerDto 22 | { 23 | public string Name { get; set; } 24 | public int WorkersCount { get; set; } 25 | public DateTime StartedAt { get; set; } 26 | public IList Queues { get; set; } 27 | public DateTime? Heartbeat { get; set; } 28 | } 29 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/StateHistoryDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | 19 | namespace Hangfire.Storage.Monitoring 20 | { 21 | public class StateHistoryDto 22 | { 23 | public string StateName { get; set; } 24 | public string Reason { get; set; } 25 | public DateTime CreatedAt { get; set; } 26 | public IDictionary Data { get; set; } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/StatisticsDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.Storage.Monitoring 17 | { 18 | public class StatisticsDto 19 | { 20 | public long Servers { get; set; } 21 | public long Recurring { get; set; } 22 | public long Enqueued { get; set; } 23 | public long Queues { get; set; } 24 | public long Scheduled { get; set; } 25 | public long Processing { get; set; } 26 | public long Succeeded { get; set; } 27 | public long Failed { get; set; } 28 | public long Deleted { get; set; } 29 | public long? Retries { get; set; } 30 | public long? Awaiting { get; set; } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/Monitoring/SucceededJobDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Collections.Generic; 18 | using Hangfire.Common; 19 | 20 | namespace Hangfire.Storage.Monitoring 21 | { 22 | public class SucceededJobDto 23 | { 24 | public SucceededJobDto() 25 | { 26 | InSucceededState = true; 27 | } 28 | 29 | public Job Job { get; set; } 30 | public JobLoadException LoadException { get; set; } 31 | public InvocationData InvocationData { get; set; } 32 | public object Result { get; set; } 33 | public long? TotalDuration { get; set; } 34 | public DateTime? SucceededAt { get; set; } 35 | public bool InSucceededState { get; set; } 36 | public IDictionary StateData { get; set; } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/RecurringJobDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using Hangfire.Common; 18 | 19 | namespace Hangfire.Storage 20 | { 21 | public class RecurringJobDto 22 | { 23 | public string Id { get; set; } 24 | public string Cron { get; set; } 25 | public string Queue { get; set; } 26 | public Job Job { get; set; } 27 | public JobLoadException LoadException { get; set; } 28 | public DateTime? NextExecution { get; set; } 29 | public string LastJobId { get; set; } 30 | public string LastJobState { get; set; } 31 | public DateTime? LastExecution { get; set; } 32 | public DateTime? CreatedAt { get; set; } 33 | public bool Removed { get; set; } 34 | public string TimeZoneId { get; set; } 35 | public string Error { get; set; } 36 | public int RetryAttempt { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/Hangfire.Core/Storage/StateData.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Collections.Generic; 17 | using Hangfire.Annotations; 18 | 19 | // ReSharper disable NotNullMemberIsNotInitialized - Let's trust them! 20 | 21 | namespace Hangfire.Storage 22 | { 23 | public class StateData 24 | { 25 | [NotNull] 26 | public string Name { get; set; } 27 | 28 | [CanBeNull] 29 | public string Reason { get; set; } 30 | 31 | [NotNull] 32 | public IDictionary Data { get; set; } 33 | } 34 | } -------------------------------------------------------------------------------- /src/Hangfire.NetCore/AspNetCore/AspNetCoreLogProvider.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2016 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using Hangfire.Annotations; 18 | using Hangfire.Logging; 19 | using Microsoft.Extensions.Logging; 20 | 21 | namespace Hangfire.AspNetCore 22 | { 23 | public class AspNetCoreLogProvider : ILogProvider 24 | { 25 | private readonly ILoggerFactory _loggerFactory; 26 | 27 | public AspNetCoreLogProvider([NotNull] ILoggerFactory loggerFactory) 28 | { 29 | if (loggerFactory == null) throw new ArgumentNullException(nameof(loggerFactory)); 30 | _loggerFactory = loggerFactory; 31 | } 32 | 33 | public ILog GetLogger(string name) 34 | { 35 | return new AspNetCoreLog(_loggerFactory.CreateLogger(name)); 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /src/Hangfire.NetCore/IBackgroundJobClientFactory.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2021 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire 17 | { 18 | public interface IBackgroundJobClientFactoryV2 : IBackgroundJobClientFactory 19 | { 20 | IBackgroundJobClientV2 GetClientV2(JobStorage storage); 21 | } 22 | 23 | public interface IBackgroundJobClientFactory 24 | { 25 | IBackgroundJobClient GetClient(JobStorage storage); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Hangfire.NetCore/IRecurringJobManagerFactory.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2021 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire 17 | { 18 | public interface IRecurringJobManagerFactoryV2 : IRecurringJobManagerFactory 19 | { 20 | IRecurringJobManagerV2 GetManagerV2(JobStorage storage); 21 | } 22 | 23 | public interface IRecurringJobManagerFactory 24 | { 25 | IRecurringJobManager GetManager(JobStorage storage); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Hangfire.SqlServer.Msmq/Hangfire.SqlServer.Msmq.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | net451 4 | true 5 | Hangfire.SqlServer.Msmq 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /src/Hangfire.SqlServer.Msmq/IMsmqTransaction.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | using System.Messaging; 18 | 19 | namespace Hangfire.SqlServer.Msmq 20 | { 21 | internal interface IMsmqTransaction : IDisposable 22 | { 23 | Message Receive(MessageQueue queue, TimeSpan timeout); 24 | 25 | void Commit(); 26 | void Abort(); 27 | } 28 | } -------------------------------------------------------------------------------- /src/Hangfire.SqlServer.Msmq/MsmqJobQueueProvider.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Collections.Generic; 17 | 18 | namespace Hangfire.SqlServer.Msmq 19 | { 20 | internal sealed class MsmqJobQueueProvider : IPersistentJobQueueProvider 21 | { 22 | private readonly MsmqJobQueue _jobQueue; 23 | private readonly MsmqJobQueueMonitoringApi _monitoringApi; 24 | 25 | public MsmqJobQueueProvider(string pathPattern, IEnumerable queues, MsmqTransactionType transactionType) 26 | { 27 | _jobQueue = new MsmqJobQueue(pathPattern, transactionType); 28 | _monitoringApi = new MsmqJobQueueMonitoringApi(pathPattern, queues); 29 | } 30 | 31 | public IPersistentJobQueue GetJobQueue() 32 | { 33 | return _jobQueue; 34 | } 35 | 36 | public IPersistentJobQueueMonitoringApi GetJobQueueMonitoringApi() 37 | { 38 | return _monitoringApi; 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /src/Hangfire.SqlServer.Msmq/MsmqTransactionType.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.SqlServer.Msmq 17 | { 18 | public enum MsmqTransactionType 19 | { 20 | /// 21 | /// Internal (MSMQ) transaction will be used to fetch pending background 22 | /// jobs, does not support remote queues. 23 | /// 24 | Internal, 25 | 26 | /// 27 | /// External (DTC) transaction will be used to fetch pending background 28 | /// jobs. Supports remote queues, but requires running MSDTC Service. 29 | /// 30 | Dtc 31 | } 32 | } -------------------------------------------------------------------------------- /src/Hangfire.SqlServer.Msmq/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | [assembly: AssemblyTitle("Hangfire.SqlServer.MSMQ")] 7 | [assembly: AssemblyDescription("Hangfire MSMQ job queue for SQL Server storage implementation")] 8 | [assembly: Guid("03092b5c-0dfc-4c6c-8422-556bd1cb291e")] 9 | [assembly: CLSCompliant(true)] 10 | 11 | [assembly: InternalsVisibleTo("Hangfire.SqlServer.Msmq.Tests")] 12 | // Allow the generation of mocks for internal types 13 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/Constants.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2015 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.SqlServer 17 | { 18 | internal sealed class Constants 19 | { 20 | public static readonly string DefaultSchema = "HangFire"; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/DefaultInstall.tt: -------------------------------------------------------------------------------- 1 | <#@ template debug="false" hostspecific="false" language="C#" #> 2 | <#@ assembly name="System.Core" #> 3 | <#@ assembly name="$(TargetPath)" #> 4 | <#@ import namespace="System.Linq" #> 5 | <#@ import namespace="System.Text" #> 6 | <#@ import namespace="System.Collections.Generic" #> 7 | <#@ output extension=".sql" #> 8 | 9 | <# 10 | var script = GetStringResource( 11 | typeof(Hangfire.SqlServer.IPersistentJobQueue).Assembly, 12 | "Hangfire.SqlServer.Install.sql"); 13 | 14 | script = script.Replace("$(HangFireSchema)", "HangFire"); 15 | 16 | Write(script); 17 | #> 18 | 19 | <#+ 20 | private string GetStringResource(System.Reflection.Assembly assembly, string resourceName) 21 | { 22 | using (var stream = assembly.GetManifestResourceStream(resourceName)) 23 | { 24 | if (stream == null) 25 | { 26 | throw new InvalidOperationException(String.Format( 27 | "Requested resource `{0}` was not found in the assembly `{1}`.", 28 | resourceName, 29 | assembly)); 30 | } 31 | 32 | using (var reader = new System.IO.StreamReader(stream)) 33 | { 34 | return reader.ReadToEnd(); 35 | } 36 | } 37 | } 38 | #> 39 | -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/EnqueuedAndFetchedCountDto.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.SqlServer 17 | { 18 | public class EnqueuedAndFetchedCountDto 19 | { 20 | public int? EnqueuedCount { get; set; } 21 | public int? FetchedCount { get; set; } 22 | } 23 | } -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/Entities/JobParameter.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.SqlServer.Entities 17 | { 18 | internal sealed class JobParameter 19 | { 20 | public long JobId { get; set; } 21 | public string Name { get; set; } 22 | public string Value { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/Entities/Server.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire.SqlServer.Entities 19 | { 20 | internal sealed class Server 21 | { 22 | public string Id { get; set; } 23 | public string Data { get; set; } 24 | public DateTime LastHeartbeat { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/Entities/ServerData.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire.SqlServer.Entities 19 | { 20 | internal sealed class ServerData 21 | { 22 | public int WorkerCount { get; set; } 23 | public string[] Queues { get; set; } 24 | public DateTime? StartedAt { get; set; } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/Entities/SqlHash.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire.SqlServer.Entities 19 | { 20 | internal sealed class SqlHash 21 | { 22 | public string Key { get; set; } 23 | public string Field { get; set; } 24 | public string Value { get; set; } 25 | public DateTime? ExpireAt { get; set; } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/Entities/SqlJob.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire.SqlServer.Entities 19 | { 20 | internal sealed class SqlJob 21 | { 22 | public long Id { get; set; } 23 | public string InvocationData { get; set; } 24 | public string Arguments { get; set; } 25 | public DateTime CreatedAt { get; set; } 26 | public DateTime? ExpireAt { get; set; } 27 | 28 | public DateTime? FetchedAt { get; set; } 29 | 30 | public string StateName { get; set; } 31 | public string StateReason { get; set; } 32 | public string StateData { get; set; } 33 | public DateTime? StateChanged { get; set; } 34 | } 35 | } -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/Entities/SqlState.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire.SqlServer.Entities 19 | { 20 | internal sealed class SqlState 21 | { 22 | public long JobId { get; set; } 23 | public string Name { get; set; } 24 | public string Reason { get; set; } 25 | public DateTime CreatedAt { get; set; } 26 | public string Data { get; set; } 27 | } 28 | } -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/IPersistentJobQueue.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Diagnostics.CodeAnalysis; 17 | using System.Threading; 18 | using Hangfire.Storage; 19 | 20 | namespace Hangfire.SqlServer 21 | { 22 | [SuppressMessage("Naming", "CA1711:Identifiers should not have incorrect suffix", Justification = "This interface represents a persistent queue by design.")] 23 | public interface IPersistentJobQueue 24 | { 25 | IFetchedJob Dequeue(string[] queues, CancellationToken cancellationToken); 26 | 27 | #if FEATURE_TRANSACTIONSCOPE 28 | void Enqueue(System.Data.IDbConnection connection, string queue, string jobId); 29 | #else 30 | void Enqueue( 31 | System.Data.Common.DbConnection connection, 32 | System.Data.Common.DbTransaction transaction, 33 | string queue, 34 | string jobId); 35 | #endif 36 | } 37 | } -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/IPersistentJobQueueMonitoringApi.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System.Collections.Generic; 17 | 18 | namespace Hangfire.SqlServer 19 | { 20 | public interface IPersistentJobQueueMonitoringApi 21 | { 22 | IEnumerable GetQueues(); 23 | 24 | IEnumerable GetEnqueuedJobIds(string queue, int from, int perPage); 25 | 26 | // TODO: Extend return type by including DateTime to allow getting the FetchedAt value in 2.0 27 | IEnumerable GetFetchedJobIds(string queue, int from, int perPage); 28 | 29 | EnqueuedAndFetchedCountDto GetEnqueuedAndFetchedCount(string queue); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/IPersistentJobQueueProvider.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2013-2014 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | namespace Hangfire.SqlServer 17 | { 18 | public interface IPersistentJobQueueProvider 19 | { 20 | IPersistentJobQueue GetJobQueue(); 21 | IPersistentJobQueueMonitoringApi GetJobQueueMonitoringApi(); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.CompilerServices; 4 | using System.Runtime.InteropServices; 5 | 6 | [assembly: AssemblyTitle("Hangfire.SqlServer")] 7 | [assembly: AssemblyDescription("SQL Server job storage for Hangfire")] 8 | [assembly: Guid("3d96bf2f-8854-4872-aee3-faf81d121a4d")] 9 | [assembly: CLSCompliant(true)] 10 | 11 | [assembly: InternalsVisibleTo("Hangfire.SqlServer.Tests")] 12 | // Allow the generation of mocks for internal types 13 | [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] 14 | -------------------------------------------------------------------------------- /src/Hangfire.SqlServer/TimestampHelper.cs: -------------------------------------------------------------------------------- 1 | // This file is part of Hangfire. Copyright © 2021 Hangfire OÜ. 2 | // 3 | // Hangfire is free software: you can redistribute it and/or modify 4 | // it under the terms of the GNU Lesser General Public License as 5 | // published by the Free Software Foundation, either version 3 6 | // of the License, or any later version. 7 | // 8 | // Hangfire is distributed in the hope that it will be useful, 9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | // GNU Lesser General Public License for more details. 12 | // 13 | // You should have received a copy of the GNU Lesser General Public 14 | // License along with Hangfire. If not, see . 15 | 16 | using System; 17 | 18 | namespace Hangfire.SqlServer 19 | { 20 | internal static class TimestampHelper 21 | { 22 | public static long GetTimestamp() 23 | { 24 | #if NETCOREAPP3_0 25 | return Environment.TickCount64; 26 | #else 27 | return Environment.TickCount; 28 | #endif 29 | } 30 | 31 | public static TimeSpan Elapsed(long timestamp) 32 | { 33 | var now = GetTimestamp(); 34 | return Elapsed(now, timestamp); 35 | } 36 | 37 | public static TimeSpan Elapsed(long now, long timestamp) 38 | { 39 | #if NETCOREAPP3_0 40 | return TimeSpan.FromMilliseconds(now - timestamp); 41 | #else 42 | return TimeSpan.FromMilliseconds(unchecked((int)now - (int)timestamp)); 43 | #endif 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/SharedAssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | 4 | [assembly: AssemblyProduct("Hangfire")] 5 | [assembly: AssemblyCompany("Hangfire OÜ")] 6 | [assembly: AssemblyCopyright("Copyright © 2013-2025 Hangfire OÜ")] 7 | [assembly: AssemblyCulture("")] 8 | 9 | [assembly: ComVisible(false)] 10 | 11 | // Please don't edit it manually, use the `build.bat version` command instead. 12 | [assembly: AssemblyVersion("1.8.20")] 13 | -------------------------------------------------------------------------------- /tests/Directory.Build.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | false 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Common/JobLoadExceptionFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Hangfire.Common; 3 | using Xunit; 4 | 5 | namespace Hangfire.Core.Tests.Common 6 | { 7 | public class JobLoadExceptionFacts 8 | { 9 | [Fact] 10 | public void Ctor_CreatesException_WithGivenMessageAnInnerException() 11 | { 12 | var innerException = new Exception(); 13 | var exception = new JobLoadException("1", innerException); 14 | 15 | Assert.Equal("1", exception.Message); 16 | Assert.Same(innerException, exception.InnerException); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Common/MethodInfoExtensionsFacts.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using System.Reflection; 3 | using Hangfire.Common; 4 | using Xunit; 5 | 6 | namespace Hangfire.Core.Tests.Common 7 | { 8 | public class MethodInfoExtensionsFacts 9 | { 10 | [Fact] 11 | public void GetNormalizedName_ReturnsNormalizedName_ForRegularMethod() 12 | { 13 | var service = new RegularInterfaceImplementation(); 14 | var normalizedName = service.GetType().GetRuntimeMethods().First().GetNormalizedName(); 15 | 16 | Assert.Equal("Method", normalizedName); 17 | } 18 | 19 | [Fact] 20 | public void GetNormalizedName_ReturnsNormalizedName_ForExplicitlyImplementedMethod() 21 | { 22 | var service = new ExplicitInterfaceImplementation(); 23 | var normalizedName = service.GetType().GetRuntimeMethods().First().GetNormalizedName(); 24 | 25 | Assert.Equal("Method", normalizedName); 26 | } 27 | 28 | private interface IService 29 | { 30 | void Method(); 31 | } 32 | 33 | private class RegularInterfaceImplementation : IService 34 | { 35 | public void Method() 36 | { 37 | } 38 | } 39 | 40 | private class ExplicitInterfaceImplementation : IService 41 | { 42 | void IService.Method() 43 | { 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Common/ShallowExceptionHelperFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Hangfire.Common; 3 | using Xunit; 4 | 5 | namespace Hangfire.Core.Tests.Common 6 | { 7 | public class ShallowExceptionHelperFacts 8 | { 9 | [Fact] 10 | public void PreserveOriginalStackTrace_CanBeCalledTwice_WithoutThrowingAnyException() 11 | { 12 | try 13 | { 14 | throw new InvalidOperationException("Hello, world!"); 15 | } 16 | catch (Exception ex) 17 | { 18 | ex.PreserveOriginalStackTrace(); 19 | ex.PreserveOriginalStackTrace(); 20 | } 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Dashboard/BatchCommandDispatcherFacts.cs: -------------------------------------------------------------------------------- 1 | using Hangfire.Core.Tests.Stubs; 2 | using Hangfire.Dashboard; 3 | using Xunit; 4 | 5 | namespace Hangfire.Core.Tests.Dashboard 6 | { 7 | public class BatchCommandDispatcherFacts 8 | { 9 | [Fact] 10 | public void Dispatch_Sets401StatusCode_WhenNotPermitted() 11 | { 12 | var options = new DashboardOptions 13 | { 14 | IsReadOnlyFunc = _ => true 15 | }; 16 | var context = new DashboardContextStub(options); 17 | var dispatcher = new BatchCommandDispatcher((DashboardContext ctx, string str) => { }); 18 | dispatcher.Dispatch(context); 19 | Assert.Equal(401, context.Response.StatusCode); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Dashboard/CommandDispatcherFacts.cs: -------------------------------------------------------------------------------- 1 | using Hangfire.Core.Tests.Stubs; 2 | using Hangfire.Dashboard; 3 | using Xunit; 4 | 5 | namespace Hangfire.Core.Tests.Dashboard 6 | { 7 | public class CommandDispatcherFacts 8 | { 9 | [Fact] 10 | public void Dispatch_Sets401StatusCode_WhenNotPermitted() 11 | { 12 | var options = new DashboardOptions 13 | { 14 | IsReadOnlyFunc = _ => true 15 | }; 16 | var context = new DashboardContextStub(options); 17 | var dispatcher = new CommandDispatcher((DashboardContext _) => false); 18 | dispatcher.Dispatch(context); 19 | Assert.Equal(401, context.Response.StatusCode); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Dashboard/DashboardOptionsFacts.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Hangfire.Dashboard; 3 | using Xunit; 4 | 5 | namespace Hangfire.Core.Tests.Dashboard 6 | { 7 | public class DashboardOptionsFacts 8 | { 9 | [Fact] 10 | public void Ctor_SetsDefaultValues_ForAllOptions() 11 | { 12 | var options = new DashboardOptions(); 13 | Assert.Equal("/", options.AppPath); 14 | Assert.Equal("", options.PrefixPath); 15 | Assert.NotNull(options.Authorization); 16 | Assert.IsType(options.Authorization.FirstOrDefault()); 17 | Assert.Equal(2000, options.StatsPollingInterval); 18 | Assert.True(options.DisplayStorageConnectionString); 19 | Assert.Equal("Hangfire Dashboard", options.DashboardTitle); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Dashboard/HtmlHelperFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Hangfire.Dashboard; 3 | using Moq; 4 | using Xunit; 5 | 6 | namespace Hangfire.Core.Tests.Dashboard 7 | { 8 | public class HtmlHelperFacts 9 | { 10 | private readonly Mock _page; 11 | 12 | public HtmlHelperFacts() 13 | { 14 | _page = new Mock(); 15 | } 16 | 17 | [Fact] 18 | public void ToHumanDuration_FormatsFractionalSeconds() 19 | { 20 | var helper = CreateHelper(); 21 | var result = helper.ToHumanDuration(TimeSpan.FromSeconds(1.087)); 22 | Assert.Equal("+1.087s", result); 23 | } 24 | 25 | private HtmlHelper CreateHelper() 26 | { 27 | return new HtmlHelper(_page.Object); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/GlobalConfigurationExtensionsFacts.cs: -------------------------------------------------------------------------------- 1 | using Hangfire.Common; 2 | using Newtonsoft.Json; 3 | using Newtonsoft.Json.Serialization; 4 | using Xunit; 5 | 6 | namespace Hangfire.Core.Tests 7 | { 8 | public class GloabalConfigurationExtensionsFacts 9 | { 10 | [Fact, CleanSerializerSettings] 11 | public void UseSerializationSettings_AffectSerializationWithUserSettings() 12 | { 13 | GlobalConfiguration.Configuration.UseSerializerSettings(new JsonSerializerSettings 14 | { 15 | ContractResolver = new CamelCasePropertyNamesContractResolver() 16 | }); 17 | 18 | var result = SerializationHelper.Serialize(new CustomClass { StringProperty = "Value" }, SerializationOption.User); 19 | Assert.Equal(@"{""stringProperty"":""Value""}", result); 20 | } 21 | 22 | [Fact, CleanSerializerSettings] 23 | public void UseSerializationSettingsWithCallback_AffectSerializationWithUserSettings() 24 | { 25 | GlobalConfiguration.Configuration.UseRecommendedSerializerSettings(settings => 26 | { 27 | settings.ContractResolver = new CamelCasePropertyNamesContractResolver(); 28 | }); 29 | 30 | var result = SerializationHelper.Serialize(new CustomClass { StringProperty = "Value" }, SerializationOption.User); 31 | Assert.Equal(@"{""stringProperty"":""Value""}", result); 32 | } 33 | 34 | public class CustomClass 35 | { 36 | public string StringProperty { get; set; } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/GlobalStateHandlersFacts.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Hangfire.States; 3 | using Xunit; 4 | 5 | namespace Hangfire.Core.Tests 6 | { 7 | public class GlobalStateHandlersFacts 8 | { 9 | [Fact] 10 | public void AllBasicHandlersShouldBeIncluded() 11 | { 12 | var handlerTypes = GlobalStateHandlers.Handlers.Select(x => x.GetType()).ToArray(); 13 | 14 | Assert.Contains(typeof(SucceededState.Handler), handlerTypes); 15 | Assert.Contains(typeof(ScheduledState.Handler), handlerTypes); 16 | Assert.Contains(typeof(EnqueuedState.Handler), handlerTypes); 17 | Assert.Contains(typeof(DeletedState.Handler), handlerTypes); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/GlobalTestsConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | [assembly: CollectionBehavior(MaxParallelThreads = 1)] 4 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Hangfire.Core.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net452;net461;netcoreapp3.1;net6.0 5 | 0618 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | ReferencedCronos 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Hangfire.Core.Tests.csproj.DotSettings: -------------------------------------------------------------------------------- 1 |  2 | True -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/JobActivatorFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | namespace Hangfire.Core.Tests 5 | { 6 | public class JobActivatorFacts 7 | { 8 | [Fact, GlobalLock] 9 | public void SetCurrent_ThrowsAnException_WhenValueIsNull() 10 | { 11 | Assert.Throws(() => JobActivator.Current = null); 12 | } 13 | 14 | [Fact, GlobalLock] 15 | public void GetCurrent_ReturnsPreviouslySetValue() 16 | { 17 | var activator = new JobActivator(); 18 | JobActivator.Current = activator; 19 | 20 | Assert.Same(activator, JobActivator.Current); 21 | } 22 | 23 | [Fact] 24 | public void DefaultActivator_CanCreateInstanceOfClassWithDefaultConstructor() 25 | { 26 | var activator = new JobActivator(); 27 | 28 | var instance = activator.ActivateJob(typeof (DefaultConstructor)); 29 | 30 | Assert.NotNull(instance); 31 | } 32 | 33 | [Fact] 34 | public void DefaultActivator_ThrowAnException_IfThereIsNoDefaultConstructor() 35 | { 36 | var activator = new JobActivator(); 37 | 38 | Assert.Throws( 39 | () => activator.ActivateJob(typeof (CustomConstructor))); 40 | } 41 | 42 | public class DefaultConstructor 43 | { 44 | } 45 | 46 | public class CustomConstructor 47 | { 48 | // ReSharper disable once UnusedParameter.Local 49 | public CustomConstructor(string arg) 50 | { 51 | } 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/JobCancellationTokenFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | namespace Hangfire.Core.Tests 5 | { 6 | public class JobCancellationTokenFacts 7 | { 8 | [Fact] 9 | public void ShutdownToken_IsInCanceledState_WhenPassingTrueValue() 10 | { 11 | var token = new JobCancellationToken(true); 12 | Assert.True(token.ShutdownToken.IsCancellationRequested); 13 | } 14 | 15 | [Fact] 16 | public void ThrowIfCancellationRequested_DoesNotThrowOnFalseValue() 17 | { 18 | var token = new JobCancellationToken(false); 19 | 20 | // Does not throw 21 | token.ThrowIfCancellationRequested(); 22 | } 23 | 24 | [Fact] 25 | public void ThrowIfCancellationRequested_ThrowsOnTrueValue() 26 | { 27 | var token = new JobCancellationToken(true); 28 | 29 | Assert.Throws( 30 | () => token.ThrowIfCancellationRequested()); 31 | } 32 | 33 | [Fact] 34 | public void Null_ReturnsNullValue() 35 | { 36 | Assert.Null(JobCancellationToken.Null); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Mocks/BackgroundJobMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Hangfire.Common; 3 | 4 | namespace Hangfire.Core.Tests 5 | { 6 | public class BackgroundJobMock 7 | { 8 | private readonly Lazy _object; 9 | 10 | public BackgroundJobMock() 11 | { 12 | Id = "JobId"; 13 | Job = Job.FromExpression(() => SomeMethod()); 14 | CreatedAt = DateTime.UtcNow; 15 | 16 | _object = new Lazy( 17 | () => new BackgroundJob(Id, Job, CreatedAt)); 18 | } 19 | 20 | public string Id { get; set; } 21 | public Job Job { get; set; } 22 | public DateTime CreatedAt { get; set; } 23 | 24 | public BackgroundJob Object => _object.Value; 25 | 26 | public static void SomeMethod() { } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Mocks/BackgroundProcessContextMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Threading; 4 | using Hangfire.Server; 5 | using Moq; 6 | 7 | namespace Hangfire.Core.Tests 8 | { 9 | public class BackgroundProcessContextMock 10 | { 11 | private readonly Lazy _context; 12 | 13 | public BackgroundProcessContextMock() 14 | { 15 | ServerId = "server"; 16 | Storage = new Mock(); 17 | Properties = new Dictionary(); 18 | ExecutionId = Guid.NewGuid(); 19 | StoppingTokenSource = new CancellationTokenSource(); 20 | StoppedTokenSource = new CancellationTokenSource(); 21 | ShutdownTokenSource = new CancellationTokenSource(); 22 | 23 | _context = new Lazy( 24 | () => new BackgroundProcessContext(ServerId, Storage.Object, Properties, ExecutionId, 25 | StoppingTokenSource.Token, StoppedTokenSource.Token, ShutdownTokenSource.Token)); 26 | } 27 | 28 | public BackgroundProcessContext Object => _context.Value; 29 | 30 | public string ServerId { get; set; } 31 | public Mock Storage { get; set; } 32 | public IDictionary Properties { get; set; } 33 | public Guid ExecutionId { get; set; } 34 | public CancellationTokenSource StoppingTokenSource { get; set; } 35 | public CancellationTokenSource StoppedTokenSource { get; set; } 36 | public CancellationTokenSource ShutdownTokenSource { get; set; } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Mocks/ElectStateContextMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Hangfire.States; 3 | 4 | namespace Hangfire.Core.Tests 5 | { 6 | public class ElectStateContextMock 7 | { 8 | private readonly Lazy _context; 9 | 10 | public ElectStateContextMock() 11 | { 12 | ApplyContext = new ApplyStateContextMock(); 13 | 14 | _context = new Lazy( 15 | () => new ElectStateContext(ApplyContext.Object)); 16 | } 17 | 18 | public ApplyStateContextMock ApplyContext { get; set; } 19 | 20 | public ElectStateContext Object => _context.Value; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Mocks/PerformContextMock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Hangfire.Server; 3 | using Hangfire.Storage; 4 | using Moq; 5 | 6 | namespace Hangfire.Core.Tests 7 | { 8 | public class PerformContextMock 9 | { 10 | private readonly Lazy _context; 11 | 12 | public PerformContextMock() 13 | { 14 | Storage = new Mock(); 15 | Connection = new Mock(); 16 | BackgroundJob = new BackgroundJobMock(); 17 | CancellationToken = new Mock(); 18 | 19 | _context = new Lazy( 20 | () => new PerformContext(Storage.Object, Connection.Object, BackgroundJob.Object, CancellationToken.Object)); 21 | } 22 | 23 | public Mock Storage { get; set; } 24 | public Mock Connection { get; set; } 25 | public BackgroundJobMock BackgroundJob { get; set; } 26 | public Mock CancellationToken { get; set; } 27 | 28 | public PerformContext Object => _context.Value; 29 | 30 | public static void SomeMethod() 31 | { 32 | } 33 | 34 | public PerformingContext GetPerformingContext() 35 | { 36 | return new PerformingContext(Object); 37 | } 38 | 39 | public PerformedContext GetPerformedContext(object result = null, bool canceled = false, Exception exception = null) 40 | { 41 | return new PerformedContext(Object, result, canceled, exception); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/QueueAttributeFacts.cs: -------------------------------------------------------------------------------- 1 | using Hangfire.States; 2 | using Moq; 3 | using Xunit; 4 | 5 | namespace Hangfire.Core.Tests 6 | { 7 | public class QueueAttributeFacts 8 | { 9 | private readonly ElectStateContextMock _context; 10 | 11 | public QueueAttributeFacts() 12 | { 13 | _context = new ElectStateContextMock 14 | { 15 | ApplyContext = { NewStateObject = new EnqueuedState("queue") } 16 | }; 17 | } 18 | 19 | [Fact] 20 | public void Ctor_CorrectlySets_AllPropertyValues() 21 | { 22 | var filter = new QueueAttribute("hello"); 23 | Assert.Equal("hello", filter.Queue); 24 | } 25 | 26 | [Fact] 27 | public void OnStateElection_OverridesTheQueue_OfTheCandidateState() 28 | { 29 | var filter = new QueueAttribute("override"); 30 | filter.OnStateElection(_context.Object); 31 | 32 | Assert.Equal("override", ((EnqueuedState)_context.Object.CandidateState).Queue); 33 | } 34 | 35 | [Fact] 36 | public void OnStateElection_DoesNotDoAnything_IfStateIsNotEnqueuedState() 37 | { 38 | var filter = new QueueAttribute("override"); 39 | var context = new ElectStateContextMock 40 | { 41 | ApplyContext = { NewState = new Mock() } 42 | }; 43 | 44 | // Does not throw 45 | filter.OnStateElection(context.Object); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/RecurringJobOptionsFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | // ReSharper disable AssignNullToNotNullAttribute 5 | 6 | namespace Hangfire.Core.Tests 7 | { 8 | public class RecurringJobOptionsFacts 9 | { 10 | [Fact] 11 | public void Ctor_SetTheDefaultValues_ForProperties() 12 | { 13 | var options = new RecurringJobOptions(); 14 | 15 | Assert.Equal(TimeZoneInfo.Utc, options.TimeZone); 16 | Assert.Equal("default", options.QueueName); 17 | Assert.Equal(MisfireHandlingMode.Relaxed, options.MisfireHandling); 18 | } 19 | 20 | [Fact] 21 | public void SetTimeZone_ThrowsAnException_WhenValueIsNull() 22 | { 23 | var options = new RecurringJobOptions(); 24 | 25 | Assert.Throws(() => options.TimeZone = null); 26 | } 27 | 28 | [Fact] 29 | public void SetQueueName_ThrowsAnException_WhenValueIsNull() 30 | { 31 | var options = new RecurringJobOptions(); 32 | 33 | Assert.Throws(() => options.QueueName = null); 34 | } 35 | 36 | [Fact] 37 | public void SetQueueName_ThrowsAnException_WhenQueueNameHasInvalidFormat() 38 | { 39 | var options = new RecurringJobOptions(); 40 | 41 | var exception = Assert.Throws( 42 | () => options.QueueName = "UPPER_CASE"); 43 | 44 | Assert.Equal("value", exception.ParamName); 45 | } 46 | } 47 | } -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Server/ServerWatchdogFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using Hangfire.Server; 4 | using Hangfire.Storage; 5 | using Moq; 6 | using Xunit; 7 | 8 | namespace Hangfire.Core.Tests.Server 9 | { 10 | public class ServerWatchdogFacts 11 | { 12 | private readonly Mock _connection; 13 | private readonly BackgroundProcessContextMock _context; 14 | private readonly TimeSpan _checkInterval; 15 | private readonly TimeSpan _serverTimeout; 16 | 17 | public ServerWatchdogFacts() 18 | { 19 | _checkInterval = Timeout.InfiniteTimeSpan; 20 | _serverTimeout = TimeSpan.FromSeconds(5); 21 | 22 | _context = new BackgroundProcessContextMock(); 23 | _context.StoppingTokenSource.Cancel(); 24 | 25 | _connection = new Mock(); 26 | _context.Storage.Setup(x => x.GetConnection()).Returns(_connection.Object); 27 | } 28 | 29 | [Fact] 30 | public void Execute_DelegatesRemovalToStorageConnection() 31 | { 32 | _connection.Setup(x => x.RemoveTimedOutServers(It.IsAny())).Returns(1); 33 | var watchdog = new ServerWatchdog(_checkInterval, _serverTimeout); 34 | 35 | Assert.Throws(() => watchdog.Execute(_context.Object)); 36 | 37 | _connection.Verify(x => x.RemoveTimedOutServers(_serverTimeout)); 38 | _connection.Verify(x => x.Dispose(), Times.Once); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/States/AwaitingStateHandlerFacts.cs: -------------------------------------------------------------------------------- 1 | using Hangfire.States; 2 | using Hangfire.Storage; 3 | using Moq; 4 | using Xunit; 5 | 6 | namespace Hangfire.Core.Tests.States 7 | { 8 | public class AwaitingStateHandlerFacts 9 | { 10 | private readonly ApplyStateContextMock _context; 11 | private readonly Mock _transactionMock 12 | = new Mock(); 13 | 14 | public AwaitingStateHandlerFacts() 15 | { 16 | _context = new ApplyStateContextMock(); 17 | } 18 | 19 | [Fact] 20 | public void ShouldWorkOnlyWithAwaitingState() 21 | { 22 | var handler = new AwaitingState.Handler(); 23 | Assert.Equal(AwaitingState.StateName, handler.StateName); 24 | } 25 | 26 | [Fact] 27 | public void Apply_ShouldAddToSet_Awaiting() 28 | { 29 | var handler = new AwaitingState.Handler(); 30 | handler.Apply(_context.Object, _transactionMock.Object); 31 | 32 | _transactionMock.Verify(x => x.AddToSet("awaiting", "JobId", It.IsAny()), Times.Once); 33 | } 34 | 35 | [Fact] 36 | public void Unapply_ShouldRemoveFromSet_Awaiting() 37 | { 38 | var handler = new AwaitingState.Handler(); 39 | handler.Unapply(_context.Object, _transactionMock.Object); 40 | 41 | _transactionMock.Verify(x => x.RemoveFromSet("awaiting", "JobId"), Times.Once); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/States/DeletedStateHandlerFacts.cs: -------------------------------------------------------------------------------- 1 | using Hangfire.States; 2 | using Hangfire.Storage; 3 | using Moq; 4 | using Xunit; 5 | 6 | namespace Hangfire.Core.Tests.States 7 | { 8 | public class DeletedStateHandlerFacts 9 | { 10 | private readonly ApplyStateContextMock _context; 11 | private readonly Mock _transactionMock 12 | = new Mock(); 13 | 14 | public DeletedStateHandlerFacts() 15 | { 16 | _context = new ApplyStateContextMock(); 17 | } 18 | 19 | [Fact] 20 | public void ShouldWorkOnlyWithDeletedState() 21 | { 22 | var handler = new DeletedState.Handler(); 23 | Assert.Equal(DeletedState.StateName, handler.StateName); 24 | } 25 | 26 | [Fact] 27 | public void Apply_ShouldIncrease_DeletedCounter() 28 | { 29 | var handler = new DeletedState.Handler(); 30 | handler.Apply(_context.Object, _transactionMock.Object); 31 | 32 | _transactionMock.Verify(x => x.IncrementCounter("stats:deleted"), Times.Once); 33 | } 34 | 35 | [Fact] 36 | public void Unapply_ShouldDecrementStatistics() 37 | { 38 | var handler = new DeletedState.Handler(); 39 | handler.Unapply(_context.Object, _transactionMock.Object); 40 | 41 | _transactionMock.Verify(x => x.DecrementCounter("stats:deleted"), Times.Once); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/States/SucceededStateHandlerFacts.cs: -------------------------------------------------------------------------------- 1 | using Hangfire.States; 2 | using Hangfire.Storage; 3 | using Moq; 4 | using Xunit; 5 | 6 | namespace Hangfire.Core.Tests.States 7 | { 8 | public class SucceededStateHandlerFacts 9 | { 10 | private readonly ApplyStateContextMock _context; 11 | private readonly Mock _transactionMock 12 | = new Mock(); 13 | 14 | public SucceededStateHandlerFacts() 15 | { 16 | _context = new ApplyStateContextMock(); 17 | } 18 | 19 | [Fact] 20 | public void ShouldWorkOnlyWithSucceededState() 21 | { 22 | var handler = new SucceededState.Handler(); 23 | Assert.Equal(SucceededState.StateName, handler.StateName); 24 | } 25 | 26 | [Fact] 27 | public void Apply_ShouldIncrease_SucceededCounter() 28 | { 29 | var handler = new SucceededState.Handler(); 30 | handler.Apply(_context.Object, _transactionMock.Object); 31 | 32 | _transactionMock.Verify(x => x.IncrementCounter("stats:succeeded"), Times.Once); 33 | } 34 | 35 | [Fact] 36 | public void Unapply_ShouldDecrementStatistics() 37 | { 38 | var handler = new SucceededState.Handler(); 39 | handler.Unapply(_context.Object, _transactionMock.Object); 40 | 41 | _transactionMock.Verify(x => x.DecrementCounter("stats:succeeded"), Times.Once); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Storage/MonitoringTypeFacts.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using Hangfire.Storage.Monitoring; 3 | using Xunit; 4 | 5 | namespace Hangfire.Core.Tests.Storage 6 | { 7 | public class MonitoringTypeFacts 8 | { 9 | [Fact] 10 | public void EnqueuedJobDto_Ctor_SetsInEnqueuedState() 11 | { 12 | Assert.True(new EnqueuedJobDto().InEnqueuedState); 13 | } 14 | 15 | [Fact] 16 | public void FailedJobDto_Ctor_SetsInFailedState() 17 | { 18 | Assert.True(new FailedJobDto().InFailedState); 19 | } 20 | 21 | [Fact] 22 | public void ProcessingJobDto_Ctor_SetsInProcessingState() 23 | { 24 | Assert.True(new ProcessingJobDto().InProcessingState); 25 | } 26 | 27 | [Fact] 28 | public void ScheduledJobDto_Ctor_SetsInScheduledState() 29 | { 30 | Assert.True(new ScheduledJobDto().InScheduledState); 31 | } 32 | 33 | [Fact] 34 | public void SucceededJobDto_Ctor_SetsInSucceededState() 35 | { 36 | Assert.True(new SucceededJobDto().InSucceededState); 37 | } 38 | 39 | [Fact] 40 | public void DeletedJobDto_Ctor_SetsInDeletedState() 41 | { 42 | Assert.True(new DeletedJobDto().InDeletedState); 43 | } 44 | 45 | [Fact] 46 | public void JobList_Ctor_ShouldInitializeCollection() 47 | { 48 | var list = new JobList(new Dictionary { { "1", 2 } }); 49 | Assert.Single(list); 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Stubs/DashboardContextStub.cs: -------------------------------------------------------------------------------- 1 | using Hangfire.Dashboard; 2 | 3 | namespace Hangfire.Core.Tests.Stubs 4 | { 5 | class DashboardContextStub : DashboardContext 6 | { 7 | public DashboardContextStub(DashboardOptions options) : base(new JobStorageStub(), options) 8 | { 9 | Response = new DashboardResponseStub(); 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Stubs/DashboardResponseStub.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Threading.Tasks; 4 | using Hangfire.Dashboard; 5 | 6 | namespace Hangfire.Core.Tests.Stubs 7 | { 8 | class DashboardResponseStub : DashboardResponse 9 | { 10 | public override string ContentType { get; set; } 11 | public override int StatusCode { get; set; } 12 | public override Stream Body { get; } 13 | public override void SetExpire(DateTimeOffset? value) 14 | { 15 | throw new NotImplementedException(); 16 | } 17 | 18 | public override Task WriteAsync(string text) 19 | { 20 | throw new NotImplementedException(); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Stubs/JobStorageStub.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Hangfire.Storage; 3 | 4 | namespace Hangfire.Core.Tests.Stubs 5 | { 6 | class JobStorageStub : JobStorage 7 | { 8 | public override IMonitoringApi GetMonitoringApi() 9 | { 10 | throw new NotImplementedException(); 11 | } 12 | 13 | public override IStorageConnection GetConnection() 14 | { 15 | throw new NotImplementedException(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/CleanSerializerSettingsAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Hangfire.Common; 3 | using Newtonsoft.Json; 4 | using Xunit.Sdk; 5 | 6 | namespace Hangfire.Core.Tests 7 | { 8 | internal sealed class CleanSerializerSettingsAttribute : BeforeAfterTestAttribute 9 | { 10 | public override void Before(MethodInfo methodUnderTest) 11 | { 12 | ClearSettings(); 13 | } 14 | 15 | public override void After(MethodInfo methodUnderTest) 16 | { 17 | ClearSettings(); 18 | } 19 | 20 | private static void ClearSettings() 21 | { 22 | #pragma warning disable 618 23 | JobHelper.SetSerializerSettings(null); 24 | #pragma warning restore 618 25 | SerializationHelper.SetUserSerializerSettings(null); 26 | #if !NET452 && !NET461 27 | JsonConvert.DefaultSettings = null; 28 | #endif 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/CultureHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | using System.Threading; 3 | 4 | namespace Hangfire.Core.Tests 5 | { 6 | internal static class CultureHelper 7 | { 8 | public static void SetCurrentCulture(CultureInfo cultureInfo) 9 | { 10 | #if !NETCOREAPP1_0 11 | Thread.CurrentThread.CurrentCulture = cultureInfo; 12 | #else 13 | CultureInfo.CurrentCulture = cultureInfo; 14 | #endif 15 | } 16 | 17 | public static void SetCurrentUICulture(CultureInfo cultureInfo) 18 | { 19 | #if !NETCOREAPP1_0 20 | Thread.CurrentThread.CurrentUICulture = cultureInfo; 21 | #else 22 | CultureInfo.CurrentUICulture = cultureInfo; 23 | #endif 24 | } 25 | 26 | public static void SetCurrentCulture(string id) 27 | { 28 | #if !NETCOREAPP1_0 29 | Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo(id); 30 | #else 31 | CultureInfo.CurrentCulture = new CultureInfo(id); 32 | #endif 33 | } 34 | 35 | public static void SetCurrentUICulture(string id) 36 | { 37 | #if !NETCOREAPP1_0 38 | Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo(id); 39 | #else 40 | CultureInfo.CurrentUICulture = new CultureInfo(id); 41 | #endif 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/DataCompatibilityRangeFactAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Xunit; 4 | using Xunit.Sdk; 5 | 6 | namespace Hangfire.Core.Tests 7 | { 8 | [XunitTestCaseDiscoverer("Hangfire.Core.Tests.DataCompatibilityRangeFactDiscoverer", "Hangfire.Core.Tests")] 9 | [AttributeUsage(AttributeTargets.Method)] 10 | internal sealed class DataCompatibilityRangeFactAttribute : FactAttribute 11 | { 12 | internal static readonly CompatibilityLevel PossibleMinLevel; 13 | internal static readonly CompatibilityLevel PossibleMaxExcludingLevel; 14 | 15 | static DataCompatibilityRangeFactAttribute() 16 | { 17 | var compatibilityLevels = Enum.GetValues(typeof(CompatibilityLevel)) 18 | .Cast() 19 | .ToArray(); 20 | 21 | PossibleMinLevel = compatibilityLevels.Min(); 22 | PossibleMaxExcludingLevel = compatibilityLevels.Max() + 1; 23 | } 24 | 25 | public DataCompatibilityRangeFactAttribute() 26 | { 27 | MinLevel = PossibleMinLevel; 28 | MaxExcludingLevel = PossibleMaxExcludingLevel; 29 | } 30 | 31 | public CompatibilityLevel MinLevel { get; set; } 32 | public CompatibilityLevel MaxExcludingLevel { get; set; } 33 | } 34 | } -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/DataCompatibilityRangeTestCase.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Xunit.Abstractions; 4 | using Xunit.Sdk; 5 | 6 | namespace Hangfire.Core.Tests 7 | { 8 | internal sealed class DataCompatibilityRangeTestCase : XunitTestCase 9 | { 10 | #pragma warning disable 618 11 | public DataCompatibilityRangeTestCase() 12 | #pragma warning restore 618 13 | { 14 | } 15 | 16 | public DataCompatibilityRangeTestCase( 17 | IMessageSink diagnosticMessageSink, 18 | TestMethodDisplay defaultMethodDisplay, 19 | ITestMethod testMethod, 20 | object[] testMethodArguments) 21 | : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, testMethodArguments) 22 | { 23 | } 24 | 25 | public override Task RunAsync( 26 | IMessageSink diagnosticMessageSink, 27 | IMessageBus messageBus, 28 | object[] constructorArguments, 29 | ExceptionAggregator aggregator, 30 | CancellationTokenSource cancellationTokenSource) 31 | { 32 | return new DataCompatibilityRangeTestCaseRunner( 33 | this, 34 | DisplayName, 35 | SkipReason, 36 | constructorArguments, 37 | TestMethodArguments, 38 | messageBus, 39 | aggregator, 40 | cancellationTokenSource) 41 | .RunAsync(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/DataCompatibilityRangeTestCaseRunner.cs: -------------------------------------------------------------------------------- 1 | using System.Threading; 2 | using System.Threading.Tasks; 3 | using Xunit.Sdk; 4 | 5 | namespace Hangfire.Core.Tests 6 | { 7 | internal sealed class DataCompatibilityRangeTestCaseRunner : XunitTestCaseRunner 8 | { 9 | public DataCompatibilityRangeTestCaseRunner( 10 | IXunitTestCase testCase, 11 | string displayName, 12 | string skipReason, 13 | object[] constructorArguments, 14 | object[] testMethodArguments, 15 | IMessageBus messageBus, 16 | ExceptionAggregator aggregator, 17 | CancellationTokenSource cancellationTokenSource) 18 | : base(testCase, displayName, skipReason, constructorArguments, testMethodArguments, messageBus, aggregator, 19 | cancellationTokenSource) 20 | { 21 | } 22 | 23 | protected override Task RunTestAsync() 24 | { 25 | return new DataCompatibilityRangeTestRunner(new XunitTest(TestCase, DisplayName), MessageBus, TestClass, ConstructorArguments, TestMethod, TestMethodArguments, SkipReason, BeforeAfterAttributes, new ExceptionAggregator(Aggregator), CancellationTokenSource) 26 | .RunAsync(); 27 | } 28 | } 29 | } -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/DataCompatibilityRangeTheoryAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | using Xunit.Sdk; 4 | 5 | namespace Hangfire.Core.Tests 6 | { 7 | [XunitTestCaseDiscoverer("Hangfire.Core.Tests.DataCompatibilityRangeTheoryDiscoverer", "Hangfire.Core.Tests")] 8 | [AttributeUsage(AttributeTargets.Method)] 9 | internal sealed class DataCompatibilityRangeTheoryAttribute : TheoryAttribute 10 | { 11 | public DataCompatibilityRangeTheoryAttribute() 12 | { 13 | MinLevel = DataCompatibilityRangeFactAttribute.PossibleMinLevel; 14 | MaxExcludingLevel = DataCompatibilityRangeFactAttribute.PossibleMaxExcludingLevel; 15 | } 16 | 17 | public CompatibilityLevel MinLevel { get; set; } 18 | public CompatibilityLevel MaxExcludingLevel { get; set; } 19 | } 20 | } -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/DataCompatibilityRangeTheoryTestCase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Threading.Tasks; 4 | using Hangfire.Annotations; 5 | using Xunit.Abstractions; 6 | using Xunit.Sdk; 7 | 8 | namespace Hangfire.Core.Tests 9 | { 10 | internal sealed class DataCompatibilityRangeTheoryTestCase : XunitTestCase 11 | { 12 | [Obsolete("Called by the de-serializer; should only be called by deriving classes for de-serialization purposes")] 13 | [UsedImplicitly] 14 | public DataCompatibilityRangeTheoryTestCase() 15 | { 16 | } 17 | 18 | public DataCompatibilityRangeTheoryTestCase( 19 | CompatibilityLevel compatibilityLevel, 20 | IMessageSink diagnosticMessageSink, 21 | TestMethodDisplay defaultMethodDisplay, 22 | ITestMethod testMethod) 23 | : base(diagnosticMessageSink, defaultMethodDisplay, testMethod, new object[] { compatibilityLevel }) 24 | { 25 | } 26 | 27 | public override Task RunAsync( 28 | IMessageSink diagnosticMessageSink, 29 | IMessageBus messageBus, 30 | object[] constructorArguments, 31 | ExceptionAggregator aggregator, 32 | CancellationTokenSource cancellationTokenSource) 33 | { 34 | return new DataCompatibilityRangeTheoryTestCaseRunner(this, DisplayName, SkipReason, constructorArguments, TestMethodArguments, diagnosticMessageSink, messageBus, aggregator, cancellationTokenSource).RunAsync(); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/GlobalLockAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Threading; 3 | using Xunit.Sdk; 4 | 5 | namespace Hangfire.Core.Tests 6 | { 7 | internal sealed class GlobalLockAttribute : BeforeAfterTestAttribute 8 | { 9 | private readonly object _globalLock = new object(); 10 | 11 | public string Reason { get; set; } 12 | 13 | public override void Before(MethodInfo methodUnderTest) 14 | { 15 | Monitor.Enter(_globalLock); 16 | } 17 | 18 | public override void After(MethodInfo methodUnderTest) 19 | { 20 | Monitor.Exit(_globalLock); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/PlatformHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | #if NETCOREAPP1_0 4 | using System.Runtime.InteropServices; 5 | #endif 6 | 7 | namespace Hangfire.Core.Tests 8 | { 9 | internal static class PlatformHelper 10 | { 11 | public static bool IsRunningOnWindows() 12 | { 13 | #if !NETCOREAPP1_0 14 | return Environment.OSVersion.Platform == PlatformID.Win32NT; 15 | #else 16 | return RuntimeInformation.IsOSPlatform(OSPlatform.Windows); 17 | #endif 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/SequenceAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using Moq.Sequences; 4 | using Xunit; 5 | using Xunit.Sdk; 6 | 7 | namespace Hangfire.Core.Tests 8 | { 9 | public class SequenceAttribute : BeforeAfterTestAttribute 10 | { 11 | private IDisposable _sequence; 12 | 13 | public override void Before(MethodInfo methodUnderTest) 14 | { 15 | _sequence = Sequence.Create(); 16 | } 17 | 18 | public override void After(MethodInfo methodUnderTest) 19 | { 20 | _sequence.Dispose(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/SerializerSettingsHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization.Formatters; 2 | using Newtonsoft.Json; 3 | 4 | namespace Hangfire.Core.Tests 5 | { 6 | public static class SerializerSettingsHelper 7 | { 8 | public static JsonSerializerSettings DangerousSettings = new JsonSerializerSettings 9 | { 10 | TypeNameHandling = TypeNameHandling.All, 11 | TypeNameAssemblyFormat = FormatterAssemblyStyle.Full, 12 | 13 | DateFormatHandling = DateFormatHandling.MicrosoftDateFormat, 14 | 15 | Formatting = Formatting.Indented, 16 | 17 | NullValueHandling = NullValueHandling.Ignore, 18 | DefaultValueHandling = DefaultValueHandling.Ignore, 19 | }; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /tests/Hangfire.Core.Tests/Utils/StaticLockAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Concurrent; 3 | using System.Reflection; 4 | using System.Threading; 5 | using Xunit.Sdk; 6 | 7 | namespace Hangfire.Core.Tests 8 | { 9 | internal sealed class StaticLockAttribute : BeforeAfterTestAttribute 10 | { 11 | private readonly ConcurrentDictionary _locks 12 | = new ConcurrentDictionary(); 13 | 14 | public override void Before(MethodInfo methodUnderTest) 15 | { 16 | var type = GetType(methodUnderTest); 17 | _locks.TryAdd(type, new object()); 18 | 19 | Monitor.Enter(_locks[type]); 20 | } 21 | 22 | public override void After(MethodInfo methodUnderTest) 23 | { 24 | Monitor.Exit(_locks[GetType(methodUnderTest)]); 25 | } 26 | 27 | private static Type GetType(MethodInfo methodInfo) 28 | { 29 | return methodInfo.DeclaringType; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /tests/Hangfire.SqlServer.Msmq.Tests/Hangfire.SqlServer.Msmq.Tests.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net452 5 | 0618 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /tests/Hangfire.SqlServer.Msmq.Tests/MessageQueueExtensionsFacts.cs: -------------------------------------------------------------------------------- 1 | using MQTools; 2 | using Xunit; 3 | 4 | namespace Hangfire.SqlServer.Msmq.Tests 5 | { 6 | public class MessageQueueExtensionsFacts 7 | { 8 | [Theory] 9 | [InlineData(@"ComputerName\Private$\QueueName", "ComputerName", "Private$", "QueueName")] 10 | [InlineData(@"ComputerName\QueueName", "ComputerName", "", "QueueName")] 11 | [InlineData(@".\Private$\QueueName", ".", "Private$", "QueueName")] 12 | [InlineData(@".\QueueName", ".", "", "QueueName")] 13 | [InlineData(@"FormatName:Direct=OS:ComputerName\QueueName", "ComputerName", "", "QueueName")] 14 | [InlineData(@"FormatName:Direct=OS:ComputerName\Private$\QueueName", "ComputerName", "Private$", "QueueName")] 15 | public void QueueRegex_CorrectlyParsesPublicAndPrivateQueuePaths( 16 | string queuePath, 17 | string expectedComputerName, 18 | string expectedQueueType, 19 | string expectedQueueName) 20 | { 21 | var match = MessageQueueExtensions.GetQueuePathMatch(queuePath); 22 | 23 | Assert.NotNull(match); 24 | Assert.Equal(expectedComputerName, match.Groups["computerName"].Value); 25 | Assert.Equal(expectedQueueType, match.Groups["queueType"].Value); 26 | Assert.Equal(expectedQueueName, match.Groups["queue"].Value); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/Hangfire.SqlServer.Msmq.Tests/MsmqJobQueueProviderFacts.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | namespace Hangfire.SqlServer.Msmq.Tests 4 | { 5 | public class MsmqJobQueueProviderFacts 6 | { 7 | private static readonly string[] Queues = { "default" }; 8 | 9 | [Fact] 10 | public void GetJobQueue_ReturnsNonNullInstance() 11 | { 12 | var provider = CreateProvider(); 13 | 14 | var jobQueue = provider.GetJobQueue(); 15 | 16 | Assert.NotNull(jobQueue); 17 | } 18 | 19 | [Fact] 20 | public void GetMonitoringApi_ReturnsNonNullInstance() 21 | { 22 | var provider = CreateProvider(); 23 | 24 | var monitoring = provider.GetJobQueueMonitoringApi(); 25 | 26 | Assert.NotNull(monitoring); 27 | } 28 | 29 | private static MsmqJobQueueProvider CreateProvider() 30 | { 31 | return new MsmqJobQueueProvider( 32 | CleanMsmqQueueAttribute.PathPattern, 33 | Queues, 34 | MsmqTransactionType.Internal); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/Hangfire.SqlServer.Msmq.Tests/MsmqSqlServerStorageExtensionsFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq; 3 | using Xunit; 4 | 5 | // ReSharper disable AssignNullToNotNullAttribute 6 | 7 | namespace Hangfire.SqlServer.Msmq.Tests 8 | { 9 | public class MsmqSqlServerStorageExtensionsFacts 10 | { 11 | private readonly SqlServerStorage _storage; 12 | 13 | public MsmqSqlServerStorageExtensionsFacts() 14 | { 15 | _storage = new SqlServerStorage( 16 | @"Server=.\sqlexpress;Database=TheDatabase;Trusted_Connection=True;", 17 | new SqlServerStorageOptions { PrepareSchemaIfNecessary = false }); 18 | } 19 | 20 | [Fact] 21 | public void UseMsmqQueues_ThrowsAnException_WhenStorageIsNull() 22 | { 23 | var exception = Assert.Throws( 24 | () => MsmqSqlServerStorageExtensions.UseMsmqQueues(null, CleanMsmqQueueAttribute.PathPattern)); 25 | 26 | Assert.Equal("storage", exception.ParamName); 27 | } 28 | 29 | [Fact] 30 | public void UseMsmqQueues_AddsMsmqJobQueueProvider() 31 | { 32 | _storage.UseMsmqQueues(CleanMsmqQueueAttribute.PathPattern); 33 | 34 | var providerTypes = _storage.QueueProviders.Select(x => x.GetType()); 35 | Assert.Contains(typeof(MsmqJobQueueProvider), providerTypes); 36 | } 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /tests/Hangfire.SqlServer.Msmq.Tests/Utils/MsmqUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Messaging; 3 | 4 | // ReSharper disable PossibleNullReferenceException 5 | 6 | namespace Hangfire.SqlServer.Msmq.Tests 7 | { 8 | internal sealed class MsmqUtils 9 | { 10 | public static void EnqueueJobId(string queue, string jobId) 11 | { 12 | using (var messageQueue = CleanMsmqQueueAttribute.GetMessageQueue(queue)) 13 | using (var message = new Message { Body = jobId, Label = jobId, Formatter = new BinaryMessageFormatter() }) 14 | using (var transaction = new MessageQueueTransaction()) 15 | { 16 | transaction.Begin(); 17 | messageQueue.Send(message, transaction); 18 | transaction.Commit(); 19 | } 20 | } 21 | 22 | public static string DequeueJobId(string queue, TimeSpan timeout) 23 | { 24 | using (var messageQueue = CleanMsmqQueueAttribute.GetMessageQueue(queue)) 25 | using (var transaction = new MessageQueueTransaction()) 26 | { 27 | transaction.Begin(); 28 | 29 | using (var message = messageQueue.Receive(timeout, transaction)) 30 | { 31 | message.Formatter = new BinaryMessageFormatter(); 32 | transaction.Commit(); 33 | 34 | return (string)message.Body; 35 | } 36 | } 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /tests/Hangfire.SqlServer.Tests/GlobalTestsConfiguration.cs: -------------------------------------------------------------------------------- 1 | using Xunit; 2 | 3 | [assembly: CollectionBehavior(MaxParallelThreads = 1)] 4 | -------------------------------------------------------------------------------- /tests/Hangfire.SqlServer.Tests/SqlServerMonitoringApiFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Hangfire.Common; 3 | using Hangfire.SqlServer.Entities; 4 | using Xunit; 5 | 6 | namespace Hangfire.SqlServer.Tests 7 | { 8 | public class SqlServerMonitoringApiFacts 9 | { 10 | [Fact, CleanSerializerSettings] 11 | public void HandlesChangingProcessOfServerDataSerialization() 12 | { 13 | GlobalConfiguration.Configuration.UseSerializerSettings(SerializerSettingsHelper.DangerousSettings); 14 | 15 | var serverData = new ServerData 16 | { 17 | WorkerCount = 5, 18 | Queues = new[] { "default", "critical" }, 19 | StartedAt = new DateTime(2016, 12, 01, 14, 33, 00) 20 | }; 21 | var serializedServerData = SerializationHelper.Serialize(serverData, SerializationOption.User); 22 | 23 | var deserializedServerData = SerializationHelper.Deserialize(serializedServerData); 24 | 25 | Assert.Equal(5, deserializedServerData.WorkerCount); 26 | Assert.Equal(new[] { "default", "critical" }, deserializedServerData.Queues); 27 | Assert.Equal(new DateTime(2016, 12, 01, 14, 33, 00), deserializedServerData.StartedAt); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tests/Hangfire.SqlServer.Tests/StorageOptionsFacts.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using Xunit; 3 | 4 | namespace Hangfire.SqlServer.Tests 5 | { 6 | public class StorageOptionsFacts 7 | { 8 | [Fact] 9 | public void Ctor_SetsTheDefaultOptions() 10 | { 11 | var options = new SqlServerStorageOptions(); 12 | 13 | Assert.True(options.QueuePollInterval == TimeSpan.Zero); 14 | #pragma warning disable 618 15 | Assert.True(options.InvisibilityTimeout > TimeSpan.Zero); 16 | #pragma warning restore 618 17 | Assert.True(options.JobExpirationCheckInterval > TimeSpan.Zero); 18 | Assert.True(options.PrepareSchemaIfNecessary); 19 | } 20 | 21 | [Fact] 22 | public void Set_QueuePollInterval_DoesNotThrow_WhenGivenIntervalIsEqualToZero() 23 | { 24 | var options = new SqlServerStorageOptions(); 25 | options.QueuePollInterval = TimeSpan.Zero; 26 | } 27 | 28 | [Fact] 29 | public void Set_QueuePollInterval_ShouldThrowAnException_WhenGivenIntervalIsNegative() 30 | { 31 | var options = new SqlServerStorageOptions(); 32 | Assert.Throws( 33 | () => options.QueuePollInterval = TimeSpan.FromSeconds(-1)); 34 | } 35 | 36 | [Fact] 37 | public void Set_QueuePollInterval_SetsTheValue() 38 | { 39 | var options = new SqlServerStorageOptions { QueuePollInterval = TimeSpan.FromSeconds(1) }; 40 | Assert.Equal(TimeSpan.FromSeconds(1), options.QueuePollInterval); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/Hangfire.SqlServer.Tests/Utils/CleanSerializerSettingsAttribute.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using Hangfire.Common; 3 | using Newtonsoft.Json; 4 | using Xunit.Sdk; 5 | 6 | namespace Hangfire.SqlServer.Tests 7 | { 8 | internal sealed class CleanSerializerSettingsAttribute : BeforeAfterTestAttribute 9 | { 10 | public override void Before(MethodInfo methodUnderTest) 11 | { 12 | ClearSettings(); 13 | } 14 | 15 | public override void After(MethodInfo methodUnderTest) 16 | { 17 | ClearSettings(); 18 | } 19 | 20 | private static void ClearSettings() 21 | { 22 | #pragma warning disable 618 23 | JobHelper.SetSerializerSettings(null); 24 | #pragma warning restore 618 25 | GlobalConfiguration.Configuration.UseSerializerSettings(null); 26 | #if !NET452 && !NET461 27 | JsonConvert.DefaultSettings = null; 28 | #endif 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/Hangfire.SqlServer.Tests/Utils/SerializerSettingsHelper.cs: -------------------------------------------------------------------------------- 1 | using System.Runtime.Serialization.Formatters; 2 | using Newtonsoft.Json; 3 | 4 | namespace Hangfire.SqlServer.Tests 5 | { 6 | public static class SerializerSettingsHelper 7 | { 8 | public static JsonSerializerSettings DangerousSettings = new JsonSerializerSettings 9 | { 10 | TypeNameHandling = TypeNameHandling.All, 11 | TypeNameAssemblyFormat = FormatterAssemblyStyle.Full, 12 | 13 | DateFormatHandling = DateFormatHandling.MicrosoftDateFormat, 14 | 15 | Formatting = Formatting.Indented, 16 | 17 | NullValueHandling = NullValueHandling.Ignore, 18 | DefaultValueHandling = DefaultValueHandling.Ignore, 19 | }; 20 | } 21 | } 22 | --------------------------------------------------------------------------------