|
|
|
@ -1,15 +1,22 @@
|
|
|
|
|
using Infrastructure.Data;
|
|
|
|
|
using Hangfire;
|
|
|
|
|
using Hangfire.Dashboard.BasicAuthorization;
|
|
|
|
|
using Hangfire.MySql;
|
|
|
|
|
using Infrastructure.Data;
|
|
|
|
|
using Infrastructure.Email;
|
|
|
|
|
using Infrastructure.Sms;
|
|
|
|
|
using Infrastructure.UI;
|
|
|
|
|
using Infrastructure.Web;
|
|
|
|
|
using IoT.Shared.Services;
|
|
|
|
|
using IoTCenter.Services;
|
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
|
using Microsoft.AspNetCore.Routing;
|
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Transactions;
|
|
|
|
|
|
|
|
|
|
namespace IoTCenter
|
|
|
|
|
{
|
|
|
|
@ -30,6 +37,47 @@ namespace IoTCenter
|
|
|
|
|
services.AddTransient<DataService>();
|
|
|
|
|
services.AddHostedService<DataSyncService>();
|
|
|
|
|
base.ConfigureServices(services);
|
|
|
|
|
var connectionString = Configuration.GetConnectionString("HangfireConnection");
|
|
|
|
|
services.AddHangfire(configuration => configuration.UseStorage(new MySqlStorage(connectionString, new MySqlStorageOptions
|
|
|
|
|
{
|
|
|
|
|
TransactionIsolationLevel = IsolationLevel.ReadCommitted,
|
|
|
|
|
QueuePollInterval = TimeSpan.FromSeconds(15),
|
|
|
|
|
JobExpirationCheckInterval = TimeSpan.FromHours(1),
|
|
|
|
|
CountersAggregateInterval = TimeSpan.FromMinutes(5),
|
|
|
|
|
PrepareSchemaIfNecessary = true,
|
|
|
|
|
DashboardJobListLimit = 50000,
|
|
|
|
|
TransactionTimeout = TimeSpan.FromMinutes(1),
|
|
|
|
|
TablesPrefix = "Hangfire"
|
|
|
|
|
})));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
|
|
|
|
|
{
|
|
|
|
|
base.Configure(app, env, loggerFactory);
|
|
|
|
|
var options = new DashboardOptions
|
|
|
|
|
{
|
|
|
|
|
Authorization = new[] { new BasicAuthAuthorizationFilter(new BasicAuthAuthorizationFilterOptions
|
|
|
|
|
{
|
|
|
|
|
RequireSsl = false,
|
|
|
|
|
SslRedirect = false,
|
|
|
|
|
LoginCaseSensitive = true,
|
|
|
|
|
Users = new []
|
|
|
|
|
{
|
|
|
|
|
new BasicAuthAuthorizationUser
|
|
|
|
|
{
|
|
|
|
|
Login = Configuration["auth:usr"],
|
|
|
|
|
PasswordClear = Configuration["auth:pwd"]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}) }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
app.UseHangfireDashboard("/job", options);
|
|
|
|
|
|
|
|
|
|
app.UseHangfireServer(new BackgroundJobServerOptions
|
|
|
|
|
{
|
|
|
|
|
ServerName = $"IoTCenter:{Guid.NewGuid()}",
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ConfigureOptions(IServiceCollection services)
|
|
|
|
|