protected override void OnStart(string[] args) { #if DEBUG System.Diagnostics.Debugger.Launch(); string appdatadir = Environment.GetEnvironmentVariable("LOCALAPPDATA"); #endif try { string serviceHost = ConfigurationManager.AppSettings["HeyServiceHost"] ?? "localhost"; string servicePort = ConfigurationManager.AppSettings["HeyServicePort"] ?? "60400"; string serviceProtocol = ConfigurationManager.AppSettings["HeyServiceProtocol"] ?? "http"; var assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); XmlConfigurator.Configure(new FileInfo(Path.Combine(assemblyFolder, "log.config"))); _log = LogManager.GetLogger(GetType()); _backgroundJobServer = HangfireConfig.StartHangfire("HeyDb"); _disposable = WebApp.Start <Startup>(url: $"{serviceProtocol}://{serviceHost}:{servicePort}/"); } catch (Exception ex) { _log.Error(ex); Stop(); } }
public void SetUp() { _backgroundJobServer = HangfireConfig.StartHangfire("TestHeyDb"); GlobalJobFilters.Filters.Add(new AutomaticRetryAttribute { Attempts = 0 }); _repository = new HangfireJobRepository(); var heyService = new HeyService(_repository); _heyController = new HeyController(heyService); _scheduledId = "1"; _scheduledHeyRemember = new HeyRememberDto() { Domain = "Hey.Api.Rest.Tests", Name = "GetTests", Id = _scheduledId, DomainSpecificData = "[]", When = new[] { DateTime.Now + TimeSpan.FromMinutes(60) } }; _processingId = "2"; _processingHeyRemember = new HeyRememberDto() { Domain = "Hey.Api.Rest.Tests", Name = "GetTests", Id = _processingId, DomainSpecificData = "[]", When = new[] { DateTime.Now } }; _succededId = "3"; _succededHeyRemember = new HeyRememberDto() { Domain = "Hey.Api.Rest.Tests", Name = "GetSuccessTests", Id = _succededId, DomainSpecificData = "[]", When = new[] { DateTime.Now } }; _failedId = "3"; _failedHeyRemember = new HeyRememberDto() { Domain = "Hey.Api.Rest.Tests", Name = "FailTests", Id = _failedId, DomainSpecificData = "[]", When = new[] { DateTime.Now } }; _recurringId = "4"; _recurringHeyRemember = new HeyRememberDto() { Domain = "Hey.Api.Rest.Tests", Name = "RecurringTests", Id = _recurringId, DomainSpecificData = "[]", When = new[] { DateTime.Today }, CronExpression = "* * * * *", }; }