Skip to content

Instantly share code, notes, and snippets.

View bgokoglu's full-sized avatar

Burak Gokoglu bgokoglu

  • Overland Park, KS
View GitHub Profile
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[__MigrationJournal](
[Id] [int] IDENTITY(1,1) NOT NULL,
[ScriptName] [nvarchar](255) NOT NULL,
[Applied] [datetime] NOT NULL,
CONSTRAINT [PK___MigrationJournal_Id] PRIMARY KEY CLUSTERED
(
TRUNCATE TABLE [HangFire].[AggregatedCounter]
TRUNCATE TABLE [HangFire].[Counter]
TRUNCATE TABLE [HangFire].[JobParameter]
TRUNCATE TABLE [HangFire].[JobQueue]
TRUNCATE TABLE [HangFire].[List]
TRUNCATE TABLE [HangFire].[State]
DELETE FROM [HangFire].[Job]
DBCC CHECKIDENT ('[HangFire].[Job]', reseed, 0)
UPDATE [HangFire].[Hash] SET Value = 1 WHERE Field = 'LastJobId'
@bgokoglu
bgokoglu / StronglyTypedIdHelper.cs
Last active February 18, 2022 04:00
Strongly Typed Ids
[StronglyTypedId(jsonConverter: StronglyTypedIdJsonConverter.SystemTextJson)]
public partial struct UserId
{
}
public class StronglyTypedIdHelper
{
public UserId CreateUserId()
{
return new UserId(Guid.NewGuid());
@bgokoglu
bgokoglu / HangfireJobExpirationAttribute.cs
Created February 18, 2022 03:55
Hangfire Job Expiration Attr
[AttributeUsage(AttributeTargets.All)]
public sealed class HangfireCustomExpirationAttribute : JobFilterAttribute, IApplyStateFilter
{
private readonly int _jobExpirationInMinutes;
public HangfireCustomExpirationAttribute(int jobExpirationTimeoutInMinutes = 60)
{
_jobExpirationInMinutes = jobExpirationTimeoutInMinutes;
}
@bgokoglu
bgokoglu / HangfireProlongJobExpirationAttribute.cs
Created February 18, 2022 03:51
Hangfire Prolong Job Expiration Attr
[AttributeUsage(AttributeTargets.All)]
public sealed class HangfireProlongJobExpirationAttribute : JobFilterAttribute, IApplyStateFilter
{
private readonly int _expirationTimeoutInDays;
public HangfireProlongJobExpirationAttribute(int expirationTimeoutInDays = 30)
{
_expirationTimeoutInDays = expirationTimeoutInDays;
}
@bgokoglu
bgokoglu / HangfireConfig.cs
Last active February 18, 2022 03:50
Configure Hangfire
public static class HangfireConfig
{
public static void AddHangfire(this IServiceCollection services, IConfiguration configuration)
{
Log.Information("Configuring hangfire...");
services.AddScoped<IBackgroundJobWorker, HangfireBackgroundJobManager>();
services.AddHangfire(config => config
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)