From 9e02a63a2f459147d2c76b1621daa3cb2ea8befe Mon Sep 17 00:00:00 2001 From: Ty Morrow Date: Sun, 16 Jun 2024 15:05:01 -0600 Subject: [PATCH] Remove hangfire. --- src/Dsp.Web/Dsp.Web.csproj | 7 -- src/Dsp.Web/Extensions/ApplicationPreload.cs | 68 -------------------- src/Dsp.Web/Global.asax.cs | 12 +--- src/Dsp.Web/Startup.cs | 20 +----- src/Dsp.Web/Web.config | 4 +- src/Dsp.Web/packages.config | 3 - 6 files changed, 5 insertions(+), 109 deletions(-) delete mode 100644 src/Dsp.Web/Extensions/ApplicationPreload.cs diff --git a/src/Dsp.Web/Dsp.Web.csproj b/src/Dsp.Web/Dsp.Web.csproj index b6585800..85535c75 100644 --- a/src/Dsp.Web/Dsp.Web.csproj +++ b/src/Dsp.Web/Dsp.Web.csproj @@ -97,12 +97,6 @@ ..\packages\EntityFramework.6.2.0\lib\net45\EntityFramework.SqlServer.dll - - ..\packages\Hangfire.Core.1.6.17\lib\net45\Hangfire.Core.dll - - - ..\packages\Hangfire.SqlServer.1.6.17\lib\net45\Hangfire.SqlServer.dll - ..\packages\MarkdownSharp.1.13.0.0\lib\35\MarkdownSharp.dll True @@ -291,7 +285,6 @@ - diff --git a/src/Dsp.Web/Extensions/ApplicationPreload.cs b/src/Dsp.Web/Extensions/ApplicationPreload.cs deleted file mode 100644 index 5dfa9625..00000000 --- a/src/Dsp.Web/Extensions/ApplicationPreload.cs +++ /dev/null @@ -1,68 +0,0 @@ -using Hangfire; -using Hangfire.SqlServer; -using System; -using System.Web.Configuration; -using System.Web.Hosting; - -namespace Dsp.Web.Extensions -{ - public class ApplicationPreload : System.Web.Hosting.IProcessHostPreloadClient - { - public void Preload(string[] parameters) - { - HangfireBootstrapper.Instance.Start(); - } - } - - public class HangfireBootstrapper : IRegisteredObject - { - public static readonly HangfireBootstrapper Instance = new HangfireBootstrapper(); - - private readonly object _lockObject = new object(); - private bool _started; - - private BackgroundJobServer _backgroundJobServer; - - private HangfireBootstrapper() - { - } - - public void Start() - { - lock (_lockObject) - { - if (_started) return; - _started = true; - - HostingEnvironment.RegisterObject(this); - - var options = new SqlServerStorageOptions - { - QueuePollInterval = TimeSpan.FromSeconds(60) - }; - var dbConnectionString = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; - GlobalConfiguration.Configuration.UseSqlServerStorage(dbConnectionString, options); - - _backgroundJobServer = new BackgroundJobServer(); - } - } - - public void Stop() - { - lock (_lockObject) - { - if (_backgroundJobServer != null) - { - _backgroundJobServer.Dispose(); - } - - HostingEnvironment.UnregisterObject(this); - } - } - - void IRegisteredObject.Stop(bool immediate) - { - Stop(); - } - } -} \ No newline at end of file diff --git a/src/Dsp.Web/Global.asax.cs b/src/Dsp.Web/Global.asax.cs index 23751b29..6dbb6b0b 100644 --- a/src/Dsp.Web/Global.asax.cs +++ b/src/Dsp.Web/Global.asax.cs @@ -1,13 +1,12 @@ namespace Dsp.Web { + using Dsp.Data; using System.Data.Entity; using System.Web; using System.Web.Http; using System.Web.Mvc; using System.Web.Optimization; using System.Web.Routing; - using Dsp.Data; - using Dsp.Web.Extensions; public class MvcApplication : HttpApplication { @@ -18,14 +17,7 @@ protected void Application_Start() GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); - BundleConfig.RegisterBundles(BundleTable.Bundles); - - HangfireBootstrapper.Instance.Start(); - } - - protected void Application_End() - { - HangfireBootstrapper.Instance.Stop(); + BundleConfig.RegisterBundles(BundleTable.Bundles); } } } \ No newline at end of file diff --git a/src/Dsp.Web/Startup.cs b/src/Dsp.Web/Startup.cs index 9b69d510..4207bcaa 100644 --- a/src/Dsp.Web/Startup.cs +++ b/src/Dsp.Web/Startup.cs @@ -1,14 +1,9 @@ -using Dsp.Web.Extensions; -using Hangfire; -using Hangfire.SqlServer; -using Microsoft.Owin; +using Microsoft.Owin; using Owin; using RazorEngine; using RazorEngine.Templating; -using System; using System.IO; using System.Net; -using System.Web.Configuration; [assembly: OwinStartupAttribute(typeof(Dsp.Web.Startup))] namespace Dsp.Web @@ -23,19 +18,6 @@ public void Configuration(IAppBuilder app) var template = File.ReadAllText(path); Engine.Razor.AddTemplate("sse", template); - var options = new SqlServerStorageOptions - { - QueuePollInterval = TimeSpan.FromSeconds(60) - }; - var dbConnectionString = WebConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString; - GlobalConfiguration.Configuration.UseSqlServerStorage(dbConnectionString, options); - - app.UseHangfireDashboard(); - app.UseHangfireServer(); - - var tz = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time"); - RecurringJob.AddOrUpdate("sober-schedule-email", () => EmailService.TryToSendSoberSchedule(), Cron.Daily(16), tz); - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; } } diff --git a/src/Dsp.Web/Web.config b/src/Dsp.Web/Web.config index f47ceb27..4df68d13 100644 --- a/src/Dsp.Web/Web.config +++ b/src/Dsp.Web/Web.config @@ -10,7 +10,7 @@ - + @@ -67,7 +67,7 @@ - + diff --git a/src/Dsp.Web/packages.config b/src/Dsp.Web/packages.config index 0c35efec..3ebd12f3 100644 --- a/src/Dsp.Web/packages.config +++ b/src/Dsp.Web/packages.config @@ -12,9 +12,6 @@ - - -