mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 23:31:13 -05:00
update for database provider specific migrations
fix issues with live radar
This commit is contained in:
@ -13,9 +13,11 @@ namespace WebfrontCore.Controllers
|
||||
{
|
||||
public class PenaltyController : BaseController
|
||||
{
|
||||
public PenaltyController(IManager manager) : base(manager)
|
||||
private readonly IDatabaseContextFactory _contextFactory;
|
||||
|
||||
public PenaltyController(IManager manager, IDatabaseContextFactory contextFactory) : base(manager)
|
||||
{
|
||||
|
||||
_contextFactory = contextFactory;
|
||||
}
|
||||
|
||||
public IActionResult List(PenaltyType showOnly = PenaltyType.Any, bool hideAutomatedPenalties = true)
|
||||
@ -47,30 +49,28 @@ namespace WebfrontCore.Controllers
|
||||
{
|
||||
IList<PenaltyInfo> penalties;
|
||||
|
||||
using (var ctx = new DatabaseContext(disableTracking: true))
|
||||
{
|
||||
var iqPenalties = ctx.Penalties
|
||||
.AsNoTracking()
|
||||
.Where(p => p.Type == PenaltyType.Ban && p.Active)
|
||||
.OrderByDescending(_penalty => _penalty.When)
|
||||
.Select(p => new PenaltyInfo()
|
||||
{
|
||||
Id = p.PenaltyId,
|
||||
OffenderId = p.OffenderId,
|
||||
OffenderName = p.Offender.CurrentAlias.Name,
|
||||
OffenderNetworkId = (ulong)p.Offender.NetworkId,
|
||||
OffenderIPAddress = Authorized ? p.Offender.CurrentAlias.IPAddress.ConvertIPtoString() : null,
|
||||
Offense = p.Offense,
|
||||
PunisherId = p.PunisherId,
|
||||
PunisherNetworkId = (ulong)p.Punisher.NetworkId,
|
||||
PunisherName = p.Punisher.CurrentAlias.Name,
|
||||
PunisherIPAddress = Authorized ? p.Punisher.CurrentAlias.IPAddress.ConvertIPtoString() : null,
|
||||
TimePunished = p.When,
|
||||
AutomatedOffense = Authorized ? p.AutomatedOffense : null,
|
||||
});
|
||||
await using var ctx = _contextFactory.CreateContext(false);
|
||||
var iqPenalties = ctx.Penalties
|
||||
.AsNoTracking()
|
||||
.Where(p => p.Type == PenaltyType.Ban && p.Active)
|
||||
.OrderByDescending(_penalty => _penalty.When)
|
||||
.Select(p => new PenaltyInfo()
|
||||
{
|
||||
Id = p.PenaltyId,
|
||||
OffenderId = p.OffenderId,
|
||||
OffenderName = p.Offender.CurrentAlias.Name,
|
||||
OffenderNetworkId = (ulong)p.Offender.NetworkId,
|
||||
OffenderIPAddress = Authorized ? p.Offender.CurrentAlias.IPAddress.ConvertIPtoString() : null,
|
||||
Offense = p.Offense,
|
||||
PunisherId = p.PunisherId,
|
||||
PunisherNetworkId = (ulong)p.Punisher.NetworkId,
|
||||
PunisherName = p.Punisher.CurrentAlias.Name,
|
||||
PunisherIPAddress = Authorized ? p.Punisher.CurrentAlias.IPAddress.ConvertIPtoString() : null,
|
||||
TimePunished = p.When,
|
||||
AutomatedOffense = Authorized ? p.AutomatedOffense : null,
|
||||
});
|
||||
|
||||
penalties = await iqPenalties.ToListAsync();
|
||||
}
|
||||
penalties = await iqPenalties.ToListAsync();
|
||||
|
||||
return Json(penalties);
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SharedLibraryCore.Interfaces;
|
||||
using WebfrontCore.Middleware;
|
||||
|
||||
@ -12,15 +13,12 @@ namespace WebfrontCore
|
||||
public class Program
|
||||
{
|
||||
public static IManager Manager;
|
||||
public static IServiceCollection Services;
|
||||
public static IServiceProvider ApplicationServiceProvider;
|
||||
|
||||
static void Main()
|
||||
{
|
||||
throw new Exception("Webfront core cannot be run as a standalone application");
|
||||
}
|
||||
|
||||
public static Task Init(IManager mgr, IServiceProvider existingServiceProvider, CancellationToken cancellationToken)
|
||||
public static Task Init(IManager mgr, IServiceProvider existingServiceProvider, IServiceCollection services, CancellationToken cancellationToken)
|
||||
{
|
||||
Services = services;
|
||||
Manager = mgr;
|
||||
ApplicationServiceProvider = existingServiceProvider;
|
||||
var config = Manager.GetApplicationSettings().Configuration();
|
||||
|
@ -1,4 +1,5 @@
|
||||
using FluentValidation;
|
||||
using System;
|
||||
using FluentValidation;
|
||||
using FluentValidation.AspNetCore;
|
||||
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
@ -79,11 +80,11 @@ namespace WebfrontCore
|
||||
});
|
||||
|
||||
#if DEBUG
|
||||
/*mvcBuilder = mvcBuilder.AddRazorRuntimeCompilation();
|
||||
mvcBuilder = mvcBuilder.AddRazorRuntimeCompilation();
|
||||
services.Configure<RazorViewEngineOptions>(_options =>
|
||||
{
|
||||
_options.ViewLocationFormats.Add(@"/Views/Plugins/{1}/{0}" + RazorViewEngine.ViewExtension);
|
||||
});*/
|
||||
});
|
||||
#endif
|
||||
|
||||
foreach (var asm in pluginAssemblies())
|
||||
@ -92,10 +93,7 @@ namespace WebfrontCore
|
||||
}
|
||||
|
||||
services.AddHttpContextAccessor();
|
||||
|
||||
services.AddEntityFrameworkSqlite()
|
||||
.AddDbContext<DatabaseContext>();
|
||||
|
||||
|
||||
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
|
||||
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
|
||||
{
|
||||
@ -120,7 +118,7 @@ namespace WebfrontCore
|
||||
}
|
||||
|
||||
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory, IManager manager)
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
|
||||
{
|
||||
app.UseStatusCodePages(_context =>
|
||||
{
|
||||
@ -144,7 +142,7 @@ namespace WebfrontCore
|
||||
|
||||
if (Program.Manager.GetApplicationSettings().Configuration().EnableWebfrontConnectionWhitelist)
|
||||
{
|
||||
app.UseMiddleware<IPWhitelist>(Program.ApplicationServiceProvider.GetService<ILogger<IPWhitelist>>(), manager.GetApplicationSettings().Configuration().WebfrontConnectionWhitelist);
|
||||
app.UseMiddleware<IPWhitelist>(serviceProvider.GetService<ILogger<IPWhitelist>>(), serviceProvider.GetRequiredService<ApplicationConfiguration>().WebfrontConnectionWhitelist);
|
||||
}
|
||||
|
||||
app.UseStaticFiles();
|
||||
|
@ -28,7 +28,7 @@
|
||||
<ServerGarbageCollection>false</ServerGarbageCollection>
|
||||
<ConcurrentGarbageCollection>true</ConcurrentGarbageCollection>
|
||||
<TieredCompilation>true</TieredCompilation>
|
||||
<LangVersion>7.1</LangVersion>
|
||||
<LangVersion>Latest</LangVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
Reference in New Issue
Block a user