From ece519251abfa53b111d72bfa074e8b3cda95b5c Mon Sep 17 00:00:00 2001 From: RaidMax Date: Wed, 25 Apr 2018 01:38:59 -0500 Subject: [PATCH] added MySQL support fixed login bug IW3 official support --- Application/BuildScripts/PostBuild.bat | 4 +- Application/EventParsers/IW3EventParser.cs | 11 + Application/EventParsers/IW4EventParser.cs | 2 +- Application/EventParsers/IW5EventParser.cs | 2 +- Application/EventParsers/T6MEventParser.cs | 2 +- Application/Main.cs | 6 +- Application/Server.cs | 7 +- Master/Master.pyproj | 4 +- Master/runserver.py | 9 - Plugins/Login/Plugin.cs | 7 +- .../Configuration/ApplicationConfiguration.cs | 1 + SharedLibraryCore/Database/DatabaseContext.cs | 29 +- .../DatabaseContextModelSnapshot.cs | 429 ------------------ SharedLibraryCore/RCon/Connection.cs | 1 + SharedLibraryCore/Services/ClientService.cs | 4 +- .../Services/GenericRepository.cs | 5 + SharedLibraryCore/SharedLibraryCore.csproj | 1 + WebfrontCore/WebfrontCore.csproj | 2 +- 18 files changed, 63 insertions(+), 463 deletions(-) create mode 100644 Application/EventParsers/IW3EventParser.cs delete mode 100644 Master/runserver.py delete mode 100644 SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs diff --git a/Application/BuildScripts/PostBuild.bat b/Application/BuildScripts/PostBuild.bat index ca9ed7616..4494c6ceb 100644 --- a/Application/BuildScripts/PostBuild.bat +++ b/Application/BuildScripts/PostBuild.bat @@ -15,4 +15,6 @@ if not exist "%TargetDir%Plugins" ( xcopy /y "%SolutionDir%Build\Plugins" "%TargetDir%Plugins\" echo Copying plugins for publish -xcopy /Y "%SolutionDir%BUILD\Plugins" "%SolutionDir%Publish\Windows\Plugins\" \ No newline at end of file +del %SolutionDir%BUILD\Plugins\Tests.dll +xcopy /Y "%SolutionDir%BUILD\Plugins" "%SolutionDir%Publish\Windows\Plugins\" +xcopy /Y "%SolutionDir%BUILD\Plugins" "%SolutionDir%Publish\WindowsPrerelease\Plugins\" \ No newline at end of file diff --git a/Application/EventParsers/IW3EventParser.cs b/Application/EventParsers/IW3EventParser.cs new file mode 100644 index 000000000..c0f1a3751 --- /dev/null +++ b/Application/EventParsers/IW3EventParser.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace IW4MAdmin.Application.EventParsers +{ + class IW3EventParser : IW4EventParser + { + public override string GetGameDir() => "main"; + } +} diff --git a/Application/EventParsers/IW4EventParser.cs b/Application/EventParsers/IW4EventParser.cs index 3bf836007..63c3c97e4 100644 --- a/Application/EventParsers/IW4EventParser.cs +++ b/Application/EventParsers/IW4EventParser.cs @@ -6,7 +6,7 @@ using SharedLibraryCore; using SharedLibraryCore.Interfaces; using SharedLibraryCore.Objects; -namespace Application.EventParsers +namespace IW4MAdmin.Application.EventParsers { class IW4EventParser : IEventParser { diff --git a/Application/EventParsers/IW5EventParser.cs b/Application/EventParsers/IW5EventParser.cs index de5e97110..10bbabd4b 100644 --- a/Application/EventParsers/IW5EventParser.cs +++ b/Application/EventParsers/IW5EventParser.cs @@ -7,7 +7,7 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; -namespace Application.EventParsers +namespace IW4MAdmin.Application.EventParsers { class IW5EventParser : IW4EventParser { diff --git a/Application/EventParsers/T6MEventParser.cs b/Application/EventParsers/T6MEventParser.cs index b26f5985e..773034e22 100644 --- a/Application/EventParsers/T6MEventParser.cs +++ b/Application/EventParsers/T6MEventParser.cs @@ -7,7 +7,7 @@ using SharedLibraryCore; using SharedLibraryCore.Interfaces; using SharedLibraryCore.Objects; -namespace Application.EventParsers +namespace IW4MAdmin.Application.EventParsers { class T6MEventParser : IEventParser { diff --git a/Application/Main.cs b/Application/Main.cs index 9be847d1b..082506c6d 100644 --- a/Application/Main.cs +++ b/Application/Main.cs @@ -36,13 +36,13 @@ namespace IW4MAdmin.Application try { - using (var db = new DatabaseContext()) - new ContextSeed(db).Seed().Wait(); - CheckDirectories(); ServerManager = ApplicationManager.GetInstance(); + using (var db = new DatabaseContext(ServerManager.GetApplicationSettings().Configuration().ConnectionString)) + new ContextSeed(db).Seed().Wait(); + var api = API.Master.Endpoint.Get(); var version = new API.Master.VersionInfo() { diff --git a/Application/Server.cs b/Application/Server.cs index 9f62a9a79..2e1b4fe87 100644 --- a/Application/Server.cs +++ b/Application/Server.cs @@ -17,8 +17,7 @@ using SharedLibraryCore.Exceptions; using Application.Misc; using Application.RconParsers; -using Application.EventParsers; - +using IW4MAdmin.Application.EventParsers; namespace IW4MAdmin { @@ -608,7 +607,7 @@ namespace IW4MAdmin else if (GameName == Game.UKN) Logger.WriteWarning($"Game name not recognized: {version}"); else - EventParser = new IW4EventParser(); + EventParser = new IW3EventParser(); // this uses the 'main' folder for log paths var shortversion = await this.GetDvarAsync("shortversion"); var hostname = await this.GetDvarAsync("sv_hostname"); @@ -658,7 +657,7 @@ namespace IW4MAdmin CustomCallback = await ScriptLoaded(); string mainPath = EventParser.GetGameDir(); #if DEBUG - basepath.Value = @"\\192.168.88.253\Call of Duty Black Ops II"; + basepath.Value = @"\\192.168.88.253\Call of Duty 4"; #endif string logPath; if (GameName == Game.IW5) diff --git a/Master/Master.pyproj b/Master/Master.pyproj index 2a4ebb44e..78f61c93c 100644 --- a/Master/Master.pyproj +++ b/Master/Master.pyproj @@ -7,7 +7,8 @@ f5051a32-6bd0-4128-abba-c202ee15fc5c . {789894c7-04a9-4a11-a6b5-3f4435165112};{1b580a1a-fdb3-4b32-83e1-6407eb2722e6};{349c5851-65df-11da-9384-00065b846f21};{888888a0-9f3d-457c-b088-3a5042f75d52} - runserver.py + + . @@ -81,7 +82,6 @@ Code - diff --git a/Master/runserver.py b/Master/runserver.py deleted file mode 100644 index eb9215171..000000000 --- a/Master/runserver.py +++ /dev/null @@ -1,9 +0,0 @@ -""" -This script runs the Master application using a development server. -""" - -from os import environ -from master import app - -if __name__ == '__main__': - app.run(host='0.0.0.0', port=80, debug=True) diff --git a/Plugins/Login/Plugin.cs b/Plugins/Login/Plugin.cs index 47eb46c2b..70c9d4eae 100644 --- a/Plugins/Login/Plugin.cs +++ b/Plugins/Login/Plugin.cs @@ -5,6 +5,7 @@ using SharedLibraryCore; using SharedLibraryCore.Configuration; using SharedLibraryCore.Exceptions; using SharedLibraryCore.Interfaces; +using SharedLibraryCore.Objects; namespace IW4MAdmin.Plugins.Login { @@ -36,11 +37,13 @@ namespace IW4MAdmin.Plugins.Login if (E.Type == GameEvent.EventType.Command) { - if (E.Origin.Level < SharedLibraryCore.Objects.Player.Permission.Moderator) + if (E.Origin.Level < Player.Permission.Moderator) return Task.CompletedTask; + E.Owner.Manager.GetPrivilegedClients().TryGetValue(E.Origin.ClientId, out Player client); + if (((Command)E.Extra).Name == new SharedLibraryCore.Commands.CSetPassword().Name && - E.Owner.Manager.GetPrivilegedClients()[E.Origin.ClientId].Password == null) + client?.Password == null) return Task.CompletedTask; if (((Command)E.Extra).Name == new Commands.CLogin().Name) diff --git a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs index 6114bce2c..6c4d2ab5b 100644 --- a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs +++ b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs @@ -19,6 +19,7 @@ namespace SharedLibraryCore.Configuration public string WebfrontBindUrl { get; set; } public string CustomParserEncoding { get; set; } public string CustomLocale { get; set; } + public string ConnectionString { get; set; } public string Id { get; set; } public List Servers { get; set; } public int AutoMessagePeriod { get; set; } diff --git a/SharedLibraryCore/Database/DatabaseContext.cs b/SharedLibraryCore/Database/DatabaseContext.cs index c2dc28c0e..59599eb64 100644 --- a/SharedLibraryCore/Database/DatabaseContext.cs +++ b/SharedLibraryCore/Database/DatabaseContext.cs @@ -17,20 +17,35 @@ namespace SharedLibraryCore.Database public DbSet AliasLinks { get; set; } public DbSet Penalties { get; set; } + private static string _ConnectionString; + public DatabaseContext(DbContextOptions opt) : base(opt) { } + public DatabaseContext(string connStr) + { + _ConnectionString = connStr; + } + public DatabaseContext() { } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) { - string currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); - var connectionStringBuilder = new SqliteConnectionStringBuilder { DataSource = $"{currentPath}{Path.DirectorySeparatorChar}Database.db".Substring(6) }; - var connectionString = connectionStringBuilder.ToString(); - var connection = new SqliteConnection(connectionString); + if (string.IsNullOrEmpty(_ConnectionString)) + { + string currentPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase); + var connectionStringBuilder = new SqliteConnectionStringBuilder { DataSource = $"{currentPath}{Path.DirectorySeparatorChar}Database.db".Substring(6) }; + var connectionString = connectionStringBuilder.ToString(); + var connection = new SqliteConnection(connectionString); - optionsBuilder.UseSqlite(connection); + optionsBuilder.UseSqlite(connection); + } + + else + { + optionsBuilder.UseMySql(_ConnectionString); + } } @@ -98,9 +113,9 @@ namespace SharedLibraryCore.Database { continue; } - + var configurations = library.ExportedTypes.Where(c => c.GetInterfaces().FirstOrDefault(i => typeof(IModelConfiguration).IsAssignableFrom(i)) != null) - .Select( c => (IModelConfiguration)Activator.CreateInstance(c)); + .Select(c => (IModelConfiguration)Activator.CreateInstance(c)); foreach (var configurable in configurations) configurable.Configure(modelBuilder); diff --git a/SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs b/SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs deleted file mode 100644 index 9515d23d4..000000000 --- a/SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs +++ /dev/null @@ -1,429 +0,0 @@ -// -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; -using Microsoft.EntityFrameworkCore.Storage; -using Microsoft.EntityFrameworkCore.Storage.Internal; -using SharedLibraryCore.Database; -using SharedLibraryCore.Objects; -using System; - -namespace SharedLibraryCore.Migrations -{ - [DbContext(typeof(DatabaseContext))] - partial class DatabaseContextModelSnapshot : ModelSnapshot - { - protected override void BuildModel(ModelBuilder modelBuilder) - { -#pragma warning disable 612, 618 - modelBuilder - .HasAnnotation("ProductVersion", "2.0.2-rtm-10011"); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientKill", b => - { - b.Property("KillId") - .ValueGeneratedOnAdd(); - - b.Property("Active"); - - b.Property("AttackerId"); - - b.Property("Damage"); - - b.Property("DeathOriginVector3Id"); - - b.Property("DeathType"); - - b.Property("HitLoc"); - - b.Property("KillOriginVector3Id"); - - b.Property("Map"); - - b.Property("ServerId"); - - b.Property("VictimId"); - - b.Property("ViewAnglesVector3Id"); - - b.Property("Weapon"); - - b.Property("When"); - - b.HasKey("KillId"); - - b.HasIndex("AttackerId"); - - b.HasIndex("DeathOriginVector3Id"); - - b.HasIndex("KillOriginVector3Id"); - - b.HasIndex("ServerId"); - - b.HasIndex("VictimId"); - - b.HasIndex("ViewAnglesVector3Id"); - - b.ToTable("EFClientKills"); - }); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientMessage", b => - { - b.Property("MessageId") - .ValueGeneratedOnAdd(); - - b.Property("Active"); - - b.Property("ClientId"); - - b.Property("Message"); - - b.Property("ServerId"); - - b.Property("TimeSent"); - - b.HasKey("MessageId"); - - b.HasIndex("ClientId"); - - b.HasIndex("ServerId"); - - b.ToTable("EFClientMessages"); - }); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics", b => - { - b.Property("ClientId"); - - b.Property("ServerId"); - - b.Property("Active"); - - b.Property("Deaths"); - - b.Property("Kills"); - - b.Property("SPM"); - - b.Property("Skill"); - - b.Property("TimePlayed"); - - b.HasKey("ClientId", "ServerId"); - - b.HasIndex("ServerId"); - - b.ToTable("EFClientStatistics"); - }); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFHitLocationCount", b => - { - b.Property("HitLocationCountId") - .ValueGeneratedOnAdd(); - - b.Property("Active"); - - b.Property("ClientId") - .HasColumnName("EFClientStatistics_ClientId"); - - b.Property("HitCount"); - - b.Property("HitOffsetAverage"); - - b.Property("Location"); - - b.Property("ServerId") - .HasColumnName("EFClientStatistics_ServerId"); - - b.HasKey("HitLocationCountId"); - - b.HasIndex("ServerId"); - - b.HasIndex("ClientId", "ServerId"); - - b.ToTable("EFHitLocationCounts"); - }); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServer", b => - { - b.Property("ServerId"); - - b.Property("Active"); - - b.Property("Port"); - - b.HasKey("ServerId"); - - b.ToTable("EFServers"); - }); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServerStatistics", b => - { - b.Property("StatisticId") - .ValueGeneratedOnAdd(); - - b.Property("Active"); - - b.Property("ServerId"); - - b.Property("TotalKills"); - - b.Property("TotalPlayTime"); - - b.HasKey("StatisticId"); - - b.HasIndex("ServerId"); - - b.ToTable("EFServerStatistics"); - }); - - modelBuilder.Entity("SharedLibraryCore.Database.Models.EFAlias", b => - { - b.Property("AliasId") - .ValueGeneratedOnAdd(); - - b.Property("Active"); - - b.Property("DateAdded"); - - b.Property("IPAddress"); - - b.Property("LinkId"); - - b.Property("Name") - .IsRequired(); - - b.HasKey("AliasId"); - - b.HasIndex("LinkId"); - - b.ToTable("EFAlias"); - }); - - modelBuilder.Entity("SharedLibraryCore.Database.Models.EFAliasLink", b => - { - b.Property("AliasLinkId") - .ValueGeneratedOnAdd(); - - b.Property("Active"); - - b.HasKey("AliasLinkId"); - - b.ToTable("EFAliasLinks"); - }); - - modelBuilder.Entity("SharedLibraryCore.Database.Models.EFClient", b => - { - b.Property("ClientId") - .ValueGeneratedOnAdd(); - - b.Property("Active"); - - b.Property("AliasLinkId"); - - b.Property("Connections"); - - b.Property("CurrentAliasId"); - - b.Property("FirstConnection"); - - b.Property("LastConnection"); - - b.Property("Level"); - - b.Property("Masked"); - - b.Property("NetworkId"); - - b.Property("Password"); - - b.Property("PasswordSalt"); - - b.Property("TotalConnectionTime"); - - b.HasKey("ClientId"); - - b.HasIndex("AliasLinkId"); - - b.HasIndex("CurrentAliasId"); - - b.HasIndex("NetworkId") - .IsUnique(); - - b.ToTable("EFClients"); - }); - - modelBuilder.Entity("SharedLibraryCore.Database.Models.EFPenalty", b => - { - b.Property("PenaltyId") - .ValueGeneratedOnAdd(); - - b.Property("Active"); - - b.Property("Expires"); - - b.Property("LinkId"); - - b.Property("OffenderId"); - - b.Property("Offense") - .IsRequired(); - - b.Property("PunisherId"); - - b.Property("Type"); - - b.Property("When"); - - b.HasKey("PenaltyId"); - - b.HasIndex("LinkId"); - - b.HasIndex("OffenderId"); - - b.HasIndex("PunisherId"); - - b.ToTable("EFPenalties"); - }); - - modelBuilder.Entity("SharedLibraryCore.Helpers.Vector3", b => - { - b.Property("Vector3Id") - .ValueGeneratedOnAdd(); - - b.Property("X"); - - b.Property("Y"); - - b.Property("Z"); - - b.HasKey("Vector3Id"); - - b.ToTable("Vector3"); - }); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientKill", b => - { - b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Attacker") - .WithMany() - .HasForeignKey("AttackerId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("SharedLibraryCore.Helpers.Vector3", "DeathOrigin") - .WithMany() - .HasForeignKey("DeathOriginVector3Id"); - - b.HasOne("SharedLibraryCore.Helpers.Vector3", "KillOrigin") - .WithMany() - .HasForeignKey("KillOriginVector3Id"); - - b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") - .WithMany() - .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Victim") - .WithMany() - .HasForeignKey("VictimId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("SharedLibraryCore.Helpers.Vector3", "ViewAngles") - .WithMany() - .HasForeignKey("ViewAnglesVector3Id"); - }); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientMessage", b => - { - b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") - .WithMany() - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") - .WithMany() - .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics", b => - { - b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") - .WithMany() - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") - .WithMany() - .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFHitLocationCount", b => - { - b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") - .WithMany() - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") - .WithMany() - .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics") - .WithMany("HitLocations") - .HasForeignKey("ClientId", "ServerId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServerStatistics", b => - { - b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") - .WithMany() - .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("SharedLibraryCore.Database.Models.EFAlias", b => - { - b.HasOne("SharedLibraryCore.Database.Models.EFAliasLink", "Link") - .WithMany("Children") - .HasForeignKey("LinkId") - .OnDelete(DeleteBehavior.Restrict); - }); - - modelBuilder.Entity("SharedLibraryCore.Database.Models.EFClient", b => - { - b.HasOne("SharedLibraryCore.Database.Models.EFAliasLink", "AliasLink") - .WithMany() - .HasForeignKey("AliasLinkId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("SharedLibraryCore.Database.Models.EFAlias", "CurrentAlias") - .WithMany() - .HasForeignKey("CurrentAliasId") - .OnDelete(DeleteBehavior.Cascade); - }); - - modelBuilder.Entity("SharedLibraryCore.Database.Models.EFPenalty", b => - { - b.HasOne("SharedLibraryCore.Database.Models.EFAliasLink", "Link") - .WithMany("ReceivedPenalties") - .HasForeignKey("LinkId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Offender") - .WithMany("ReceivedPenalties") - .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Restrict); - - b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Punisher") - .WithMany("AdministeredPenalties") - .HasForeignKey("PunisherId") - .OnDelete(DeleteBehavior.Restrict); - }); -#pragma warning restore 612, 618 - } - } -} diff --git a/SharedLibraryCore/RCon/Connection.cs b/SharedLibraryCore/RCon/Connection.cs index 7059b2e05..9d30ed123 100644 --- a/SharedLibraryCore/RCon/Connection.cs +++ b/SharedLibraryCore/RCon/Connection.cs @@ -130,6 +130,7 @@ namespace SharedLibraryCore.RCon #if DEBUG Log.WriteDebug($"Received {bytesRead} bytes from {ServerConnection.RemoteEndPoint}"); #endif + FailedReceives = 0; connectionState.ResponseString.Append(Utilities.EncodingType.GetString(connectionState.Buffer, 0, bytesRead).TrimEnd('\0') + '\n'); if (!connectionState.Buffer.Take(4).ToArray().SequenceEqual(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF })) diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index 8966a23e4..78bfdcb6d 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -107,7 +107,7 @@ namespace SharedLibraryCore.Services { using (var context = new DatabaseContext()) { - return await new DatabaseContext().Clients + return await context.Clients .AsNoTracking() .Include(c => c.CurrentAlias) .Include(c => c.AliasLink.Children) @@ -216,7 +216,7 @@ namespace SharedLibraryCore.Services { using (var context = new DatabaseContext()) { - return await new DatabaseContext().Clients + return await context.Clients .AsNoTracking() .Include(c => c.CurrentAlias) .Where(c => c.Level >= Player.Permission.Trusted) diff --git a/SharedLibraryCore/Services/GenericRepository.cs b/SharedLibraryCore/Services/GenericRepository.cs index 4d5ee4047..146ff1d98 100644 --- a/SharedLibraryCore/Services/GenericRepository.cs +++ b/SharedLibraryCore/Services/GenericRepository.cs @@ -15,6 +15,11 @@ namespace SharedLibraryCore.Services private dynamic _context; private DbSet _dbSet; + ~GenericRepository() + { + _context.Dispose(); + } + protected DbContext Context { get diff --git a/SharedLibraryCore/SharedLibraryCore.csproj b/SharedLibraryCore/SharedLibraryCore.csproj index 952630c54..109637529 100644 --- a/SharedLibraryCore/SharedLibraryCore.csproj +++ b/SharedLibraryCore/SharedLibraryCore.csproj @@ -20,6 +20,7 @@ + diff --git a/WebfrontCore/WebfrontCore.csproj b/WebfrontCore/WebfrontCore.csproj index 58114c2ba..15ce95ab1 100644 --- a/WebfrontCore/WebfrontCore.csproj +++ b/WebfrontCore/WebfrontCore.csproj @@ -2,7 +2,7 @@ netcoreapp2.0 - false + true 2.6 RaidMax.IW4MAdmin.WebfrontCore