Last active
February 22, 2021 01:55
-
-
Save tiagocrizanto/e3de12d6bfa145b981dfcc9fdc10217d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// startup e configuração de autenticação | |
GlobalConfiguration.Configuration.UseSqlServerStorage(ConfigurationManager.ConnectionStrings["ConnectionsString"].ConnectionString); | |
app.UseHangfireDashboard("/hangfire", new DashboardOptions | |
{ | |
Authorization = new[] { new HangfireSecurityFilter() } | |
}); | |
app.UseHangfireServer(); | |
// exemplo do filtro | |
public class HangfireSecurityFilter : IDashboardAuthorizationFilter | |
{ | |
public bool Authorize(DashboardContext context) | |
{ | |
// In case you need an OWIN context, use the next line, `OwinContext` class | |
// is the part of the `Microsoft.Owin` package. | |
var owinContext = new OwinContext(context.GetOwinEnvironment()); | |
// Allow all authenticated users to see the Dashboard (potentially dangerous). | |
//return owinContext.Authentication.User.Identity.IsAuthenticated; | |
return true; | |
} | |
} | |
// Configuação de um job que executa a cada X minutos. RecurringJob Está no namespace Hangfire | |
public ActionResult AddMinuteJob(int minute) | |
{ | |
RecurringJob.AddOrUpdate("Store-every-X-minutes", () => _myDomainServivice.MethodToExecute(), $"0/{minute} * * * *"); | |
return RedirectToAction(nameof(Index)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment