diff --git a/Plugins/LiveRadar/Controllers/RadarController.cs b/Plugins/LiveRadar/Controllers/RadarController.cs index d10701e22..939bdd2f6 100644 --- a/Plugins/LiveRadar/Controllers/RadarController.cs +++ b/Plugins/LiveRadar/Controllers/RadarController.cs @@ -17,7 +17,7 @@ namespace LiveRadar.Web.Controllers [HttpGet] [Route("Radar/{serverId}")] - public IActionResult Index(long? serverId = null) + public IActionResult Index([FromQuery] long? serverId = null) { ViewBag.IsFluid = true; ViewBag.Title = Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_RADAR_TITLE"]; diff --git a/Plugins/LiveRadar/Views/Radar/Index.cshtml b/Plugins/LiveRadar/Views/Radar/Index.cshtml index f8e646295..0c544cbed 100644 --- a/Plugins/LiveRadar/Views/Radar/Index.cshtml +++ b/Plugins/LiveRadar/Views/Radar/Index.cshtml @@ -303,12 +303,12 @@ }; function updateRadarData() { - $.getJSON('@Url.Action("Data", "Radar", null)', function (_radarItem) { + $.getJSON('@Url.Action("Data", "Radar", new { serverId = ViewBag.ActiveServerId })', function (_radarItem) { newRadarData = _radarItem; }); - $.getJSON('@Url.Action("Map", "Radar", null)', function (_map) { + $.getJSON('@Url.Action("Map", "Radar", new { serverId = ViewBag.ActiveServerId })', function (_map) { stateInfo.mapInfo = _map }); @@ -458,7 +458,7 @@ } $(document).ready(function () { - $.getJSON('@Url.Action("Map", "Radar", null)', function (_map) { + $.getJSON('@Url.Action("Map", "Radar", new { serverId = ViewBag.ActiveServerId })', function (_map) { stateInfo.mapInfo = _map; updateRadarData(); setInterval(updateRadarData, stateInfo.updateFrequency); diff --git a/Plugins/Stats/Cheat/Detection.cs b/Plugins/Stats/Cheat/Detection.cs index bbf9e3e78..808198ee1 100644 --- a/Plugins/Stats/Cheat/Detection.cs +++ b/Plugins/Stats/Cheat/Detection.cs @@ -125,32 +125,32 @@ namespace IW4MAdmin.Plugins.Stats.Cheat //var marginOfError = Thresholds.GetMarginOfError(sessionSnapHits); //var marginOfErrorLifetime = Thresholds.GetMarginOfError(ClientStats.SnapHitCount); - if (sessionSnapHits >= Thresholds.LowSampleMinKills && + if (sessionSnapHits >= Thresholds.MediumSampleMinKills && sessionAverageSnapAmount >= Thresholds.SnapFlagValue/* + marginOfError*/) { results.Add(new DetectionPenaltyResult() { ClientPenalty = EFPenalty.PenaltyType.Flag, Value = sessionAverageSnapAmount, - HitCount = ClientStats.SnapHitCount, + HitCount = sessionSnapHits, Type = DetectionType.Snap }); } - if (sessionSnapHits >= Thresholds.LowSampleMinKills && + if (sessionSnapHits >= Thresholds.MediumSampleMinKills && sessionAverageSnapAmount >= Thresholds.SnapBanValue/* + marginOfError*/) { results.Add(new DetectionPenaltyResult() { ClientPenalty = EFPenalty.PenaltyType.Ban, Value = sessionAverageSnapAmount, - HitCount = ClientStats.SnapHitCount, + HitCount = sessionSnapHits, Type = DetectionType.Snap }); } // lifetime - if (ClientStats.SnapHitCount >= Thresholds.MediumSampleMinKills && + if (ClientStats.SnapHitCount >= Thresholds.MediumSampleMinKills * 2 && ClientStats.AverageSnapValue >= Thresholds.SnapFlagValue/* + marginOfErrorLifetime*/) { results.Add(new DetectionPenaltyResult() @@ -162,7 +162,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat }); } - if (ClientStats.SnapHitCount >= Thresholds.MediumSampleMinKills && + if (ClientStats.SnapHitCount >= Thresholds.MediumSampleMinKills * 2 && ClientStats.AverageSnapValue >= Thresholds.SnapBanValue/* + marginOfErrorLifetime*/) { results.Add(new DetectionPenaltyResult() @@ -183,7 +183,6 @@ namespace IW4MAdmin.Plugins.Stats.Cheat int angleOffsetIndex = totalUsableAngleCount / 2; if (hit.AnglesList.Count == 5) { - double realAgainstPredict = Vector3.ViewAngleDistance(hit.AnglesList[angleOffsetIndex - 1], hit.AnglesList[angleOffsetIndex + 1], hit.ViewAngles); // LIFETIME @@ -201,15 +200,15 @@ namespace IW4MAdmin.Plugins.Stats.Cheat if (weightedLifetimeAverage > Thresholds.MaxOffset(totalHits) && hitLoc.HitCount > 100) { - Log.WriteDebug("*** Reached Max Lifetime Average for Angle Difference ***"); - Log.WriteDebug($"Lifetime Average = {newAverage}"); - Log.WriteDebug($"Bone = {hitLoc.Location}"); - Log.WriteDebug($"HitCount = {hitLoc.HitCount}"); - Log.WriteDebug($"ID = {hit.AttackerId}"); + //Log.WriteDebug("*** Reached Max Lifetime Average for Angle Difference ***"); + //Log.WriteDebug($"Lifetime Average = {newAverage}"); + //Log.WriteDebug($"Bone = {hitLoc.Location}"); + //Log.WriteDebug($"HitCount = {hitLoc.HitCount}"); + //Log.WriteDebug($"ID = {hit.AttackerId}"); results.Add(new DetectionPenaltyResult() { - ClientPenalty = EFPenalty.PenaltyType.Flag, + ClientPenalty = EFPenalty.PenaltyType.Ban, Value = hitLoc.HitOffsetAverage, HitCount = hitLoc.HitCount, Type = DetectionType.Offset @@ -236,7 +235,7 @@ namespace IW4MAdmin.Plugins.Stats.Cheat results.Add(new DetectionPenaltyResult() { - ClientPenalty = EFPenalty.PenaltyType.Flag, + ClientPenalty = EFPenalty.PenaltyType.Ban, Value = weightedSessionAverage, HitCount = HitCount, Type = DetectionType.Offset, diff --git a/Plugins/Stats/Cheat/Thresholds.cs b/Plugins/Stats/Cheat/Thresholds.cs index 7908a948d..8ef5df298 100644 --- a/Plugins/Stats/Cheat/Thresholds.cs +++ b/Plugins/Stats/Cheat/Thresholds.cs @@ -48,13 +48,13 @@ namespace IW4MAdmin.Plugins.Stats.Cheat public const int HighSampleMinKills = 100; public const double KillTimeThreshold = 0.2; public const int LowSampleMinKillsRecoil = 5; - public const double SnapFlagValue = 6.12; - public const double SnapBanValue = 9.67; + public const double SnapFlagValue = 5.5; + public const double SnapBanValue = 8.7; public const double MaxStrainBan = 0.9; - private const double _offsetMeanLog = -2.727273; - private const double _offsetSdLog = 0.458325; + private const double _offsetMeanLog = -2.3243889; + private const double _offsetSdLog = 0.5851351; public static double MaxOffset(int sampleSize) => Math.Exp(Math.Max(_offsetMeanLog + (_offsetMeanLog / Math.Sqrt(sampleSize)), _offsetMeanLog - (_offsetMeanLog / Math.Sqrt(sampleSize))) + 4 * (_offsetSdLog)); public const double MaxStrainFlag = 0.36; diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index 4ffbe4e3f..7c168bafc 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -843,7 +843,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers Active = true, Newest = true, ServerId = clientStats.ServerId, - RatingHistoryId = clientHistory.RatingHistoryId, + RatingHistory = clientHistory, ActivityAmount = currentServerTotalPlaytime, }; @@ -921,7 +921,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers Performance = performanceAverage, Ranking = overallClientRanking, ServerId = null, - RatingHistoryId = clientHistory.RatingHistoryId, + RatingHistory = clientHistory, ActivityAmount = clientStatsList.Sum(s => s.TimePlayed) }; diff --git a/Plugins/Stats/Models/EFHitLocationCount.cs b/Plugins/Stats/Models/EFHitLocationCount.cs index c1c82f038..726dc9b40 100644 --- a/Plugins/Stats/Models/EFHitLocationCount.cs +++ b/Plugins/Stats/Models/EFHitLocationCount.cs @@ -17,11 +17,13 @@ namespace IW4MAdmin.Plugins.Stats.Models [Required] public float MaxAngleDistance { get; set; } [Required] - public int ClientId { get; set; } - [ForeignKey("ClientId"), Column(Order = 0 )] + [Column("EFClientStatisticsClientId")] + public int EFClientStatisticsClientId { get; set; } + [ForeignKey("EFClientStatisticsClientId")] public EFClient Client { get; set; } - public long ServerId { get; set; } - [ForeignKey("ServerId"), Column(Order = 1)] + [Column("EFClientStatisticsServerId")] + public long EFClientStatisticsServerId { get; set; } + [ForeignKey("EFClientStatisticsServerId")] public EFServer Server { get; set; } } } diff --git a/Plugins/Stats/Models/ModelConfiguration.cs b/Plugins/Stats/Models/ModelConfiguration.cs index d02cf7fd9..a84d90879 100644 --- a/Plugins/Stats/Models/ModelConfiguration.cs +++ b/Plugins/Stats/Models/ModelConfiguration.cs @@ -13,12 +13,12 @@ namespace Stats.Models // fix linking from SQLCe builder.Entity() - .Property(c => c.ClientId) - .HasColumnName("EFClientStatistics_ClientId"); + .Property(c => c.EFClientStatisticsClientId) + .HasColumnName("EFClientStatisticsClientId"); builder.Entity() - .Property(c => c.ServerId) - .HasColumnName("EFClientStatistics_ServerId"); + .Property(c => c.EFClientStatisticsServerId) + .HasColumnName("EFClientStatisticsServerId"); builder.Entity() .HasIndex(p => new { p.Performance, p.Ranking, p.When }); diff --git a/SharedLibraryCore/Database/DatabaseContext.cs b/SharedLibraryCore/Database/DatabaseContext.cs index f1a3cf72a..58a8d89fb 100644 --- a/SharedLibraryCore/Database/DatabaseContext.cs +++ b/SharedLibraryCore/Database/DatabaseContext.cs @@ -111,13 +111,6 @@ namespace SharedLibraryCore.Database break; } } - -#if DEBUG -#pragma warning disable CS0612 // Type or member is obsolete - // optionsBuilder.UseLoggerFactory(_loggerFactory) -#pragma warning restore CS0612 // Type or member is obsolete - // .EnableSensitiveDataLogging(); -#endif } protected override void OnModelCreating(ModelBuilder modelBuilder) diff --git a/SharedLibraryCore/Migrations/20191004172550_RenameClientHitLocationCountColumns.Designer.cs b/SharedLibraryCore/Migrations/20191004172550_RenameClientHitLocationCountColumns.Designer.cs new file mode 100644 index 000000000..95944248a --- /dev/null +++ b/SharedLibraryCore/Migrations/20191004172550_RenameClientHitLocationCountColumns.Designer.cs @@ -0,0 +1,910 @@ +// +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using SharedLibraryCore.Database; + +namespace SharedLibraryCore.Migrations +{ + [DbContext(typeof(DatabaseContext))] + [Migration("20191004172550_RenameClientHitLocationCountColumns")] + partial class RenameClientHitLocationCountColumns + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("ProductVersion", "3.0.0"); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFACSnapshot", b => + { + b.Property("SnapshotId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("ClientId") + .HasColumnType("INTEGER"); + + b.Property("CurrentSessionLength") + .HasColumnType("INTEGER"); + + b.Property("CurrentStrain") + .HasColumnType("REAL"); + + b.Property("CurrentViewAngleId") + .HasColumnType("INTEGER"); + + b.Property("Deaths") + .HasColumnType("INTEGER"); + + b.Property("Distance") + .HasColumnType("REAL"); + + b.Property("EloRating") + .HasColumnType("REAL"); + + b.Property("HitDestinationId") + .HasColumnType("INTEGER"); + + b.Property("HitLocation") + .HasColumnType("INTEGER"); + + b.Property("HitOriginId") + .HasColumnType("INTEGER"); + + b.Property("HitType") + .HasColumnType("INTEGER"); + + b.Property("Hits") + .HasColumnType("INTEGER"); + + b.Property("Kills") + .HasColumnType("INTEGER"); + + b.Property("LastStrainAngleId") + .HasColumnType("INTEGER"); + + b.Property("RecoilOffset") + .HasColumnType("REAL"); + + b.Property("SessionAngleOffset") + .HasColumnType("REAL"); + + b.Property("SessionAverageSnapValue") + .HasColumnType("REAL"); + + b.Property("SessionSPM") + .HasColumnType("REAL"); + + b.Property("SessionScore") + .HasColumnType("INTEGER"); + + b.Property("SessionSnapHits") + .HasColumnType("INTEGER"); + + b.Property("StrainAngleBetween") + .HasColumnType("REAL"); + + b.Property("TimeSinceLastEvent") + .HasColumnType("INTEGER"); + + b.Property("WeaponId") + .HasColumnType("INTEGER"); + + b.Property("When") + .HasColumnType("TEXT"); + + b.HasKey("SnapshotId"); + + b.HasIndex("ClientId"); + + b.HasIndex("CurrentViewAngleId"); + + b.HasIndex("HitDestinationId"); + + b.HasIndex("HitOriginId"); + + b.HasIndex("LastStrainAngleId"); + + b.ToTable("EFACSnapshot"); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFACSnapshotVector3", b => + { + b.Property("ACSnapshotVector3Id") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("SnapshotId") + .HasColumnType("INTEGER"); + + b.Property("Vector3Id") + .HasColumnType("INTEGER"); + + b.HasKey("ACSnapshotVector3Id"); + + b.HasIndex("SnapshotId"); + + b.HasIndex("Vector3Id"); + + b.ToTable("EFACSnapshotVector3"); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientKill", b => + { + b.Property("KillId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("AttackerId") + .HasColumnType("INTEGER"); + + b.Property("Damage") + .HasColumnType("INTEGER"); + + b.Property("DeathOriginVector3Id") + .HasColumnType("INTEGER"); + + b.Property("DeathType") + .HasColumnType("INTEGER"); + + b.Property("Fraction") + .HasColumnType("REAL"); + + b.Property("HitLoc") + .HasColumnType("INTEGER"); + + b.Property("IsKill") + .HasColumnType("INTEGER"); + + b.Property("KillOriginVector3Id") + .HasColumnType("INTEGER"); + + b.Property("Map") + .HasColumnType("INTEGER"); + + b.Property("ServerId") + .HasColumnType("INTEGER"); + + b.Property("VictimId") + .HasColumnType("INTEGER"); + + b.Property("ViewAnglesVector3Id") + .HasColumnType("INTEGER"); + + b.Property("VisibilityPercentage") + .HasColumnType("REAL"); + + b.Property("Weapon") + .HasColumnType("INTEGER"); + + b.Property("When") + .HasColumnType("TEXT"); + + 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() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("ClientId") + .HasColumnType("INTEGER"); + + b.Property("Message") + .HasColumnType("TEXT"); + + b.Property("ServerId") + .HasColumnType("INTEGER"); + + b.Property("TimeSent") + .HasColumnType("TEXT"); + + b.HasKey("MessageId"); + + b.HasIndex("ClientId"); + + b.HasIndex("ServerId"); + + b.HasIndex("TimeSent"); + + b.ToTable("EFClientMessages"); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientRatingHistory", b => + { + b.Property("RatingHistoryId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("ClientId") + .HasColumnType("INTEGER"); + + b.HasKey("RatingHistoryId"); + + b.HasIndex("ClientId"); + + b.ToTable("EFClientRatingHistory"); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics", b => + { + b.Property("ClientId") + .HasColumnType("INTEGER"); + + b.Property("ServerId") + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("AverageRecoilOffset") + .HasColumnType("REAL"); + + b.Property("AverageSnapValue") + .HasColumnType("REAL"); + + b.Property("Deaths") + .HasColumnType("INTEGER"); + + b.Property("EloRating") + .HasColumnType("REAL"); + + b.Property("Kills") + .HasColumnType("INTEGER"); + + b.Property("MaxStrain") + .HasColumnType("REAL"); + + b.Property("RollingWeightedKDR") + .HasColumnType("REAL"); + + b.Property("SPM") + .HasColumnType("REAL"); + + b.Property("Skill") + .HasColumnType("REAL"); + + b.Property("SnapHitCount") + .HasColumnType("INTEGER"); + + b.Property("TimePlayed") + .HasColumnType("INTEGER"); + + b.Property("VisionAverage") + .HasColumnType("REAL"); + + b.HasKey("ClientId", "ServerId"); + + b.HasIndex("ServerId"); + + b.ToTable("EFClientStatistics"); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFHitLocationCount", b => + { + b.Property("HitLocationCountId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("EFClientStatisticsClientId") + .HasColumnName("EFClientStatisticsClientId") + .HasColumnType("INTEGER"); + + b.Property("EFClientStatisticsServerId") + .HasColumnName("EFClientStatisticsServerId") + .HasColumnType("INTEGER"); + + b.Property("HitCount") + .HasColumnType("INTEGER"); + + b.Property("HitOffsetAverage") + .HasColumnType("REAL"); + + b.Property("Location") + .HasColumnType("INTEGER"); + + b.Property("MaxAngleDistance") + .HasColumnType("REAL"); + + b.HasKey("HitLocationCountId"); + + b.HasIndex("EFClientStatisticsServerId"); + + b.HasIndex("EFClientStatisticsClientId", "EFClientStatisticsServerId"); + + b.ToTable("EFHitLocationCounts"); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFRating", b => + { + b.Property("RatingId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("ActivityAmount") + .HasColumnType("INTEGER"); + + b.Property("Newest") + .HasColumnType("INTEGER"); + + b.Property("Performance") + .HasColumnType("REAL"); + + b.Property("Ranking") + .HasColumnType("INTEGER"); + + b.Property("RatingHistoryId") + .HasColumnType("INTEGER"); + + b.Property("ServerId") + .HasColumnType("INTEGER"); + + b.Property("When") + .HasColumnType("TEXT"); + + b.HasKey("RatingId"); + + b.HasIndex("RatingHistoryId"); + + b.HasIndex("ServerId"); + + b.HasIndex("Performance", "Ranking", "When"); + + b.ToTable("EFRating"); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServer", b => + { + b.Property("ServerId") + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("EndPoint") + .HasColumnType("TEXT"); + + b.Property("GameName") + .HasColumnType("INTEGER"); + + b.Property("Port") + .HasColumnType("INTEGER"); + + b.HasKey("ServerId"); + + b.ToTable("EFServers"); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServerStatistics", b => + { + b.Property("StatisticId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("ServerId") + .HasColumnType("INTEGER"); + + b.Property("TotalKills") + .HasColumnType("INTEGER"); + + b.Property("TotalPlayTime") + .HasColumnType("INTEGER"); + + b.HasKey("StatisticId"); + + b.HasIndex("ServerId"); + + b.ToTable("EFServerStatistics"); + }); + + modelBuilder.Entity("SharedLibraryCore.Database.Models.EFAlias", b => + { + b.Property("AliasId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("DateAdded") + .HasColumnType("TEXT"); + + b.Property("IPAddress") + .HasColumnType("INTEGER"); + + b.Property("LinkId") + .HasColumnType("INTEGER"); + + b.Property("Name") + .IsRequired() + .HasColumnType("TEXT") + .HasMaxLength(24); + + b.Property("SearchableName") + .HasColumnType("TEXT") + .HasMaxLength(24); + + b.HasKey("AliasId"); + + b.HasIndex("IPAddress"); + + b.HasIndex("LinkId"); + + b.HasIndex("Name"); + + b.HasIndex("SearchableName"); + + b.ToTable("EFAlias"); + }); + + modelBuilder.Entity("SharedLibraryCore.Database.Models.EFAliasLink", b => + { + b.Property("AliasLinkId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.HasKey("AliasLinkId"); + + b.ToTable("EFAliasLinks"); + }); + + modelBuilder.Entity("SharedLibraryCore.Database.Models.EFChangeHistory", b => + { + b.Property("ChangeHistoryId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("Comment") + .HasColumnType("TEXT") + .HasMaxLength(128); + + b.Property("CurrentValue") + .HasColumnType("TEXT"); + + b.Property("OriginEntityId") + .HasColumnType("INTEGER"); + + b.Property("PreviousValue") + .HasColumnType("TEXT"); + + b.Property("TargetEntityId") + .HasColumnType("INTEGER"); + + b.Property("TimeChanged") + .HasColumnType("TEXT"); + + b.Property("TypeOfChange") + .HasColumnType("INTEGER"); + + b.HasKey("ChangeHistoryId"); + + b.ToTable("EFChangeHistory"); + }); + + modelBuilder.Entity("SharedLibraryCore.Database.Models.EFClient", b => + { + b.Property("ClientId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("AliasLinkId") + .HasColumnType("INTEGER"); + + b.Property("Connections") + .HasColumnType("INTEGER"); + + b.Property("CurrentAliasId") + .HasColumnType("INTEGER"); + + b.Property("FirstConnection") + .HasColumnType("TEXT"); + + b.Property("LastConnection") + .HasColumnType("TEXT"); + + b.Property("Level") + .HasColumnType("INTEGER"); + + b.Property("Masked") + .HasColumnType("INTEGER"); + + b.Property("NetworkId") + .HasColumnType("INTEGER"); + + b.Property("Password") + .HasColumnType("TEXT"); + + b.Property("PasswordSalt") + .HasColumnType("TEXT"); + + b.Property("TotalConnectionTime") + .HasColumnType("INTEGER"); + + b.HasKey("ClientId"); + + b.HasIndex("AliasLinkId"); + + b.HasIndex("CurrentAliasId"); + + b.HasIndex("NetworkId") + .IsUnique(); + + b.ToTable("EFClients"); + }); + + modelBuilder.Entity("SharedLibraryCore.Database.Models.EFMeta", b => + { + b.Property("MetaId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("ClientId") + .HasColumnType("INTEGER"); + + b.Property("Created") + .HasColumnType("TEXT"); + + b.Property("Extra") + .HasColumnType("TEXT"); + + b.Property("Key") + .IsRequired() + .HasColumnType("TEXT") + .HasMaxLength(32); + + b.Property("Updated") + .HasColumnType("TEXT"); + + b.Property("Value") + .IsRequired() + .HasColumnType("TEXT"); + + b.HasKey("MetaId"); + + b.HasIndex("ClientId"); + + b.HasIndex("Key"); + + b.ToTable("EFMeta"); + }); + + modelBuilder.Entity("SharedLibraryCore.Database.Models.EFPenalty", b => + { + b.Property("PenaltyId") + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); + + b.Property("Active") + .HasColumnType("INTEGER"); + + b.Property("AutomatedOffense") + .HasColumnType("TEXT"); + + b.Property("Expires") + .HasColumnType("TEXT"); + + b.Property("IsEvadedOffense") + .HasColumnType("INTEGER"); + + b.Property("LinkId") + .HasColumnType("INTEGER"); + + b.Property("OffenderId") + .HasColumnType("INTEGER"); + + b.Property("Offense") + .IsRequired() + .HasColumnType("TEXT"); + + b.Property("PunisherId") + .HasColumnType("INTEGER"); + + b.Property("Type") + .HasColumnType("INTEGER"); + + b.Property("When") + .HasColumnType("TEXT"); + + 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() + .HasColumnType("INTEGER"); + + b.Property("X") + .HasColumnType("REAL"); + + b.Property("Y") + .HasColumnType("REAL"); + + b.Property("Z") + .HasColumnType("REAL"); + + b.HasKey("Vector3Id"); + + b.ToTable("Vector3"); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFACSnapshot", b => + { + b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") + .WithMany() + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") + .WithMany() + .HasForeignKey("CurrentViewAngleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") + .WithMany() + .HasForeignKey("HitDestinationId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitOrigin") + .WithMany() + .HasForeignKey("HitOriginId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SharedLibraryCore.Helpers.Vector3", "LastStrainAngle") + .WithMany() + .HasForeignKey("LastStrainAngleId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFACSnapshotVector3", b => + { + b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFACSnapshot", "Snapshot") + .WithMany("PredictedViewAngles") + .HasForeignKey("SnapshotId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SharedLibraryCore.Helpers.Vector3", "Vector") + .WithMany() + .HasForeignKey("Vector3Id") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientKill", b => + { + b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Attacker") + .WithMany() + .HasForeignKey("AttackerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + 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) + .IsRequired(); + + b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Victim") + .WithMany() + .HasForeignKey("VictimId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + 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) + .IsRequired(); + + b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") + .WithMany() + .HasForeignKey("ServerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientRatingHistory", b => + { + b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") + .WithMany() + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics", b => + { + b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") + .WithMany() + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") + .WithMany() + .HasForeignKey("ServerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFHitLocationCount", b => + { + b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") + .WithMany() + .HasForeignKey("EFClientStatisticsClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") + .WithMany() + .HasForeignKey("EFClientStatisticsServerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics", null) + .WithMany("HitLocations") + .HasForeignKey("EFClientStatisticsClientId", "EFClientStatisticsServerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFRating", b => + { + b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFClientRatingHistory", "RatingHistory") + .WithMany("Ratings") + .HasForeignKey("RatingHistoryId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") + .WithMany() + .HasForeignKey("ServerId"); + }); + + modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServerStatistics", b => + { + b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") + .WithMany() + .HasForeignKey("ServerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SharedLibraryCore.Database.Models.EFAlias", b => + { + b.HasOne("SharedLibraryCore.Database.Models.EFAliasLink", "Link") + .WithMany("Children") + .HasForeignKey("LinkId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); + + modelBuilder.Entity("SharedLibraryCore.Database.Models.EFClient", b => + { + b.HasOne("SharedLibraryCore.Database.Models.EFAliasLink", "AliasLink") + .WithMany() + .HasForeignKey("AliasLinkId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SharedLibraryCore.Database.Models.EFAlias", "CurrentAlias") + .WithMany() + .HasForeignKey("CurrentAliasId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SharedLibraryCore.Database.Models.EFMeta", b => + { + b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") + .WithMany("Meta") + .HasForeignKey("ClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + }); + + modelBuilder.Entity("SharedLibraryCore.Database.Models.EFPenalty", b => + { + b.HasOne("SharedLibraryCore.Database.Models.EFAliasLink", "Link") + .WithMany("ReceivedPenalties") + .HasForeignKey("LinkId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Offender") + .WithMany("ReceivedPenalties") + .HasForeignKey("OffenderId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + + b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Punisher") + .WithMany("AdministeredPenalties") + .HasForeignKey("PunisherId") + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); + }); +#pragma warning restore 612, 618 + } + } +} diff --git a/SharedLibraryCore/Migrations/20191004172550_RenameClientHitLocationCountColumns.cs b/SharedLibraryCore/Migrations/20191004172550_RenameClientHitLocationCountColumns.cs new file mode 100644 index 000000000..0579c3b1a --- /dev/null +++ b/SharedLibraryCore/Migrations/20191004172550_RenameClientHitLocationCountColumns.cs @@ -0,0 +1,196 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +namespace SharedLibraryCore.Migrations +{ + public partial class RenameClientHitLocationCountColumns : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + if (migrationBuilder.ActiveProvider == "Microsoft.EntityFrameworkCore.Sqlite") + { + migrationBuilder.Sql(@"PRAGMA foreign_keys = 0; + +CREATE TABLE sqlitestudio_temp_table AS SELECT * + FROM EFHitLocationCounts; + +DROP TABLE EFHitLocationCounts; + +CREATE TABLE EFHitLocationCounts ( + HitLocationCountId INTEGER NOT NULL + CONSTRAINT PK_EFHitLocationCounts PRIMARY KEY AUTOINCREMENT, + Active INTEGER NOT NULL, + EFClientStatisticsClientId INTEGER NOT NULL, + HitCount INTEGER NOT NULL, + HitOffsetAverage REAL NOT NULL, + Location INTEGER NOT NULL, + EFClientStatisticsServerId INTEGER NOT NULL, + MaxAngleDistance REAL NOT NULL + DEFAULT 0, + CONSTRAINT FK_EFHitLocationCounts_EFClients_EFClientStatistics_ClientId FOREIGN KEY ( + EFClientStatisticsClientId + ) + REFERENCES EFClients (ClientId) ON DELETE CASCADE, + CONSTRAINT FK_EFHitLocationCounts_EFServers_EFClientStatistics_ServerId FOREIGN KEY ( + EFClientStatisticsServerId + ) + REFERENCES EFServers (ServerId) ON DELETE CASCADE, + CONSTRAINT FK_EFHitLocationCounts_EFClientStatistics_EFClientStatistics_ClientId_EFClientStatistics_ServerId FOREIGN KEY ( + EFClientStatisticsClientId, + EFClientStatisticsServerId + ) + REFERENCES EFClientStatistics (ClientId, + ServerId) ON DELETE CASCADE +); + +INSERT INTO EFHitLocationCounts ( + HitLocationCountId, + Active, + EFClientStatisticsClientId, + HitCount, + HitOffsetAverage, + Location, + EFClientStatisticsServerId, + MaxAngleDistance + ) + SELECT HitLocationCountId, + Active, + EFClientStatistics_ClientId, + HitCount, + HitOffsetAverage, + Location, + EFClientStatistics_ServerId, + MaxAngleDistance + FROM sqlitestudio_temp_table; + +DROP TABLE sqlitestudio_temp_table; + +CREATE INDEX IX_EFHitLocationCounts_EFClientStatistics_ServerId ON EFHitLocationCounts ( + EFClientStatisticsServerId +); + +CREATE INDEX IX_EFHitLocationCounts_EFClientStatistics_ClientId_EFClientStatistics_ServerId ON EFHitLocationCounts ( + EFClientStatisticsClientId, + EFClientStatisticsServerId +); + +PRAGMA foreign_keys = 1; +", true); + } + + migrationBuilder.DropForeignKey( + name: "FK_EFHitLocationCounts_EFClients_EFClientStatistics_ClientId", + table: "EFHitLocationCounts"); + + migrationBuilder.DropForeignKey( + name: "FK_EFHitLocationCounts_EFServers_EFClientStatistics_ServerId", + table: "EFHitLocationCounts"); + + migrationBuilder.DropForeignKey( + name: "FK_EFHitLocationCounts_EFClientStatistics_EFClientStatistics_ClientId_EFClientStatistics_ServerId", + table: "EFHitLocationCounts"); + + migrationBuilder.RenameColumn( + name: "EFClientStatistics_ServerId", + table: "EFHitLocationCounts", + newName: "EFClientStatisticsServerId"); + + migrationBuilder.RenameColumn( + name: "EFClientStatistics_ClientId", + table: "EFHitLocationCounts", + newName: "EFClientStatisticsClientId"); + + migrationBuilder.RenameIndex( + name: "IX_EFHitLocationCounts_EFClientStatistics_ClientId_EFClientStatistics_ServerId", + table: "EFHitLocationCounts", + newName: "IX_EFHitLocationCounts_EFClientStatisticsClientId_EFClientStatisticsServerId"); + + migrationBuilder.RenameIndex( + name: "IX_EFHitLocationCounts_EFClientStatistics_ServerId", + table: "EFHitLocationCounts", + newName: "IX_EFHitLocationCounts_EFClientStatisticsServerId"); + + migrationBuilder.AddForeignKey( + name: "FK_EFHitLocationCounts_EFClients_EFClientStatisticsClientId", + table: "EFHitLocationCounts", + column: "EFClientStatisticsClientId", + principalTable: "EFClients", + principalColumn: "ClientId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_EFHitLocationCounts_EFServers_EFClientStatisticsServerId", + table: "EFHitLocationCounts", + column: "EFClientStatisticsServerId", + principalTable: "EFServers", + principalColumn: "ServerId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_EFHitLocationCounts_EFClientStatistics_EFClientStatisticsClientId_EFClientStatisticsServerId", + table: "EFHitLocationCounts", + columns: new[] { "EFClientStatisticsClientId", "EFClientStatisticsServerId" }, + principalTable: "EFClientStatistics", + principalColumns: new[] { "ClientId", "ServerId" }, + onDelete: ReferentialAction.Cascade); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_EFHitLocationCounts_EFClients_EFClientStatisticsClientId", + table: "EFHitLocationCounts"); + + migrationBuilder.DropForeignKey( + name: "FK_EFHitLocationCounts_EFServers_EFClientStatisticsServerId", + table: "EFHitLocationCounts"); + + migrationBuilder.DropForeignKey( + name: "FK_EFHitLocationCounts_EFClientStatistics_EFClientStatisticsClientId_EFClientStatisticsServerId", + table: "EFHitLocationCounts"); + + migrationBuilder.RenameColumn( + name: "EFClientStatisticsServerId", + table: "EFHitLocationCounts", + newName: "EFClientStatistics_ServerId"); + + migrationBuilder.RenameColumn( + name: "EFClientStatisticsClientId", + table: "EFHitLocationCounts", + newName: "EFClientStatistics_ClientId"); + + migrationBuilder.RenameIndex( + name: "IX_EFHitLocationCounts_EFClientStatisticsClientId_EFClientStatisticsServerId", + table: "EFHitLocationCounts", + newName: "IX_EFHitLocationCounts_EFClientStatistics_ClientId_EFClientStatistics_ServerId"); + + migrationBuilder.RenameIndex( + name: "IX_EFHitLocationCounts_EFClientStatisticsServerId", + table: "EFHitLocationCounts", + newName: "IX_EFHitLocationCounts_EFClientStatistics_ServerId"); + + migrationBuilder.AddForeignKey( + name: "FK_EFHitLocationCounts_EFClients_EFClientStatistics_ClientId", + table: "EFHitLocationCounts", + column: "EFClientStatistics_ClientId", + principalTable: "EFClients", + principalColumn: "ClientId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_EFHitLocationCounts_EFServers_EFClientStatistics_ServerId", + table: "EFHitLocationCounts", + column: "EFClientStatistics_ServerId", + principalTable: "EFServers", + principalColumn: "ServerId", + onDelete: ReferentialAction.Cascade); + + migrationBuilder.AddForeignKey( + name: "FK_EFHitLocationCounts_EFClientStatistics_EFClientStatistics_ClientId_EFClientStatistics_ServerId", + table: "EFHitLocationCounts", + columns: new[] { "EFClientStatistics_ClientId", "EFClientStatistics_ServerId" }, + principalTable: "EFClientStatistics", + principalColumns: new[] { "ClientId", "ServerId" }, + onDelete: ReferentialAction.Cascade); + } + } +} diff --git a/SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs b/SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs index 513bdb908..066db2b63 100644 --- a/SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs +++ b/SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs @@ -14,62 +14,88 @@ namespace SharedLibraryCore.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.2.6-servicing-10079"); + .HasAnnotation("ProductVersion", "3.0.0"); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFACSnapshot", b => { b.Property("SnapshotId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("INTEGER"); - b.Property("CurrentSessionLength"); + b.Property("CurrentSessionLength") + .HasColumnType("INTEGER"); - b.Property("SessionAverageSnapValue"); + b.Property("CurrentStrain") + .HasColumnType("REAL"); - b.Property("CurrentStrain"); + b.Property("CurrentViewAngleId") + .HasColumnType("INTEGER"); - b.Property("CurrentViewAngleId"); + b.Property("Deaths") + .HasColumnType("INTEGER"); - b.Property("Deaths"); + b.Property("Distance") + .HasColumnType("REAL"); - b.Property("Distance"); + b.Property("EloRating") + .HasColumnType("REAL"); - b.Property("EloRating"); + b.Property("HitDestinationId") + .HasColumnType("INTEGER"); - b.Property("HitDestinationId"); + b.Property("HitLocation") + .HasColumnType("INTEGER"); - b.Property("HitLocation"); + b.Property("HitOriginId") + .HasColumnType("INTEGER"); - b.Property("HitOriginId"); + b.Property("HitType") + .HasColumnType("INTEGER"); - b.Property("HitType"); + b.Property("Hits") + .HasColumnType("INTEGER"); - b.Property("Hits"); + b.Property("Kills") + .HasColumnType("INTEGER"); - b.Property("Kills"); + b.Property("LastStrainAngleId") + .HasColumnType("INTEGER"); - b.Property("LastStrainAngleId"); + b.Property("RecoilOffset") + .HasColumnType("REAL"); - b.Property("RecoilOffset"); + b.Property("SessionAngleOffset") + .HasColumnType("REAL"); - b.Property("SessionAngleOffset"); + b.Property("SessionAverageSnapValue") + .HasColumnType("REAL"); - b.Property("SessionSPM"); + b.Property("SessionSPM") + .HasColumnType("REAL"); - b.Property("SessionScore"); + b.Property("SessionScore") + .HasColumnType("INTEGER"); - b.Property("SessionSnapHits"); + b.Property("SessionSnapHits") + .HasColumnType("INTEGER"); - b.Property("StrainAngleBetween"); + b.Property("StrainAngleBetween") + .HasColumnType("REAL"); - b.Property("TimeSinceLastEvent"); + b.Property("TimeSinceLastEvent") + .HasColumnType("INTEGER"); - b.Property("WeaponId"); + b.Property("WeaponId") + .HasColumnType("INTEGER"); - b.Property("When"); + b.Property("When") + .HasColumnType("TEXT"); b.HasKey("SnapshotId"); @@ -89,11 +115,14 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFACSnapshotVector3", b => { b.Property("ACSnapshotVector3Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("SnapshotId"); + b.Property("SnapshotId") + .HasColumnType("INTEGER"); - b.Property("Vector3Id"); + b.Property("Vector3Id") + .HasColumnType("INTEGER"); b.HasKey("ACSnapshotVector3Id"); @@ -107,39 +136,56 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientKill", b => { b.Property("KillId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("AttackerId"); + b.Property("AttackerId") + .HasColumnType("INTEGER"); - b.Property("Damage"); + b.Property("Damage") + .HasColumnType("INTEGER"); - b.Property("DeathOriginVector3Id"); + b.Property("DeathOriginVector3Id") + .HasColumnType("INTEGER"); - b.Property("DeathType"); + b.Property("DeathType") + .HasColumnType("INTEGER"); - b.Property("Fraction"); + b.Property("Fraction") + .HasColumnType("REAL"); - b.Property("HitLoc"); + b.Property("HitLoc") + .HasColumnType("INTEGER"); - b.Property("IsKill"); + b.Property("IsKill") + .HasColumnType("INTEGER"); - b.Property("KillOriginVector3Id"); + b.Property("KillOriginVector3Id") + .HasColumnType("INTEGER"); - b.Property("Map"); + b.Property("Map") + .HasColumnType("INTEGER"); - b.Property("ServerId"); + b.Property("ServerId") + .HasColumnType("INTEGER"); - b.Property("VictimId"); + b.Property("VictimId") + .HasColumnType("INTEGER"); - b.Property("ViewAnglesVector3Id"); + b.Property("ViewAnglesVector3Id") + .HasColumnType("INTEGER"); - b.Property("VisibilityPercentage"); + b.Property("VisibilityPercentage") + .HasColumnType("REAL"); - b.Property("Weapon"); + b.Property("Weapon") + .HasColumnType("INTEGER"); - b.Property("When"); + b.Property("When") + .HasColumnType("TEXT"); b.HasKey("KillId"); @@ -161,17 +207,23 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientMessage", b => { b.Property("MessageId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("INTEGER"); - b.Property("Message"); + b.Property("Message") + .HasColumnType("TEXT"); - b.Property("ServerId"); + b.Property("ServerId") + .HasColumnType("INTEGER"); - b.Property("TimeSent"); + b.Property("TimeSent") + .HasColumnType("TEXT"); b.HasKey("MessageId"); @@ -187,11 +239,14 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientRatingHistory", b => { b.Property("RatingHistoryId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("INTEGER"); b.HasKey("RatingHistoryId"); @@ -202,35 +257,50 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics", b => { - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("INTEGER"); - b.Property("ServerId"); + b.Property("ServerId") + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("AverageRecoilOffset"); + b.Property("AverageRecoilOffset") + .HasColumnType("REAL"); - b.Property("AverageSnapValue"); + b.Property("AverageSnapValue") + .HasColumnType("REAL"); - b.Property("Deaths"); + b.Property("Deaths") + .HasColumnType("INTEGER"); - b.Property("EloRating"); + b.Property("EloRating") + .HasColumnType("REAL"); - b.Property("Kills"); + b.Property("Kills") + .HasColumnType("INTEGER"); - b.Property("MaxStrain"); + b.Property("MaxStrain") + .HasColumnType("REAL"); - b.Property("RollingWeightedKDR"); + b.Property("RollingWeightedKDR") + .HasColumnType("REAL"); - b.Property("SPM"); + b.Property("SPM") + .HasColumnType("REAL"); - b.Property("Skill"); + b.Property("Skill") + .HasColumnType("REAL"); - b.Property("SnapHitCount"); + b.Property("SnapHitCount") + .HasColumnType("INTEGER"); - b.Property("TimePlayed"); + b.Property("TimePlayed") + .HasColumnType("INTEGER"); - b.Property("VisionAverage"); + b.Property("VisionAverage") + .HasColumnType("REAL"); b.HasKey("ClientId", "ServerId"); @@ -242,29 +312,37 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFHitLocationCount", b => { b.Property("HitLocationCountId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("ClientId") - .HasColumnName("EFClientStatistics_ClientId"); + b.Property("EFClientStatisticsClientId") + .HasColumnName("EFClientStatisticsClientId") + .HasColumnType("INTEGER"); - b.Property("HitCount"); + b.Property("EFClientStatisticsServerId") + .HasColumnName("EFClientStatisticsServerId") + .HasColumnType("INTEGER"); - b.Property("HitOffsetAverage"); + b.Property("HitCount") + .HasColumnType("INTEGER"); - b.Property("Location"); + b.Property("HitOffsetAverage") + .HasColumnType("REAL"); - b.Property("MaxAngleDistance"); + b.Property("Location") + .HasColumnType("INTEGER"); - b.Property("ServerId") - .HasColumnName("EFClientStatistics_ServerId"); + b.Property("MaxAngleDistance") + .HasColumnType("REAL"); b.HasKey("HitLocationCountId"); - b.HasIndex("ServerId"); + b.HasIndex("EFClientStatisticsServerId"); - b.HasIndex("ClientId", "ServerId"); + b.HasIndex("EFClientStatisticsClientId", "EFClientStatisticsServerId"); b.ToTable("EFHitLocationCounts"); }); @@ -272,23 +350,32 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFRating", b => { b.Property("RatingId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("ActivityAmount"); + b.Property("ActivityAmount") + .HasColumnType("INTEGER"); - b.Property("Newest"); + b.Property("Newest") + .HasColumnType("INTEGER"); - b.Property("Performance"); + b.Property("Performance") + .HasColumnType("REAL"); - b.Property("Ranking"); + b.Property("Ranking") + .HasColumnType("INTEGER"); - b.Property("RatingHistoryId"); + b.Property("RatingHistoryId") + .HasColumnType("INTEGER"); - b.Property("ServerId"); + b.Property("ServerId") + .HasColumnType("INTEGER"); - b.Property("When"); + b.Property("When") + .HasColumnType("TEXT"); b.HasKey("RatingId"); @@ -303,15 +390,20 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServer", b => { - b.Property("ServerId"); + b.Property("ServerId") + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("EndPoint"); + b.Property("EndPoint") + .HasColumnType("TEXT"); - b.Property("GameName"); + b.Property("GameName") + .HasColumnType("INTEGER"); - b.Property("Port"); + b.Property("Port") + .HasColumnType("INTEGER"); b.HasKey("ServerId"); @@ -321,15 +413,20 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServerStatistics", b => { b.Property("StatisticId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("ServerId"); + b.Property("ServerId") + .HasColumnType("INTEGER"); - b.Property("TotalKills"); + b.Property("TotalKills") + .HasColumnType("INTEGER"); - b.Property("TotalPlayTime"); + b.Property("TotalPlayTime") + .HasColumnType("INTEGER"); b.HasKey("StatisticId"); @@ -341,21 +438,28 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("SharedLibraryCore.Database.Models.EFAlias", b => { b.Property("AliasId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("DateAdded"); + b.Property("DateAdded") + .HasColumnType("TEXT"); - b.Property("IPAddress"); + b.Property("IPAddress") + .HasColumnType("INTEGER"); - b.Property("LinkId"); + b.Property("LinkId") + .HasColumnType("INTEGER"); b.Property("Name") .IsRequired() + .HasColumnType("TEXT") .HasMaxLength(24); b.Property("SearchableName") + .HasColumnType("TEXT") .HasMaxLength(24); b.HasKey("AliasId"); @@ -374,9 +478,11 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("SharedLibraryCore.Database.Models.EFAliasLink", b => { b.Property("AliasLinkId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); b.HasKey("AliasLinkId"); @@ -386,24 +492,33 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("SharedLibraryCore.Database.Models.EFChangeHistory", b => { b.Property("ChangeHistoryId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); b.Property("Comment") + .HasColumnType("TEXT") .HasMaxLength(128); - b.Property("CurrentValue"); + b.Property("CurrentValue") + .HasColumnType("TEXT"); - b.Property("OriginEntityId"); + b.Property("OriginEntityId") + .HasColumnType("INTEGER"); - b.Property("PreviousValue"); + b.Property("PreviousValue") + .HasColumnType("TEXT"); - b.Property("TargetEntityId"); + b.Property("TargetEntityId") + .HasColumnType("INTEGER"); - b.Property("TimeChanged"); + b.Property("TimeChanged") + .HasColumnType("TEXT"); - b.Property("TypeOfChange"); + b.Property("TypeOfChange") + .HasColumnType("INTEGER"); b.HasKey("ChangeHistoryId"); @@ -413,31 +528,44 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("SharedLibraryCore.Database.Models.EFClient", b => { b.Property("ClientId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("AliasLinkId"); + b.Property("AliasLinkId") + .HasColumnType("INTEGER"); - b.Property("Connections"); + b.Property("Connections") + .HasColumnType("INTEGER"); - b.Property("CurrentAliasId"); + b.Property("CurrentAliasId") + .HasColumnType("INTEGER"); - b.Property("FirstConnection"); + b.Property("FirstConnection") + .HasColumnType("TEXT"); - b.Property("LastConnection"); + b.Property("LastConnection") + .HasColumnType("TEXT"); - b.Property("Level"); + b.Property("Level") + .HasColumnType("INTEGER"); - b.Property("Masked"); + b.Property("Masked") + .HasColumnType("INTEGER"); - b.Property("NetworkId"); + b.Property("NetworkId") + .HasColumnType("INTEGER"); - b.Property("Password"); + b.Property("Password") + .HasColumnType("TEXT"); - b.Property("PasswordSalt"); + b.Property("PasswordSalt") + .HasColumnType("TEXT"); - b.Property("TotalConnectionTime"); + b.Property("TotalConnectionTime") + .HasColumnType("INTEGER"); b.HasKey("ClientId"); @@ -454,24 +582,32 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("SharedLibraryCore.Database.Models.EFMeta", b => { b.Property("MetaId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("ClientId"); + b.Property("ClientId") + .HasColumnType("INTEGER"); - b.Property("Created"); + b.Property("Created") + .HasColumnType("TEXT"); - b.Property("Extra"); + b.Property("Extra") + .HasColumnType("TEXT"); b.Property("Key") .IsRequired() + .HasColumnType("TEXT") .HasMaxLength(32); - b.Property("Updated"); + b.Property("Updated") + .HasColumnType("TEXT"); b.Property("Value") - .IsRequired(); + .IsRequired() + .HasColumnType("TEXT"); b.HasKey("MetaId"); @@ -485,28 +621,39 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("SharedLibraryCore.Database.Models.EFPenalty", b => { b.Property("PenaltyId") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("Active"); + b.Property("Active") + .HasColumnType("INTEGER"); - b.Property("AutomatedOffense"); + b.Property("AutomatedOffense") + .HasColumnType("TEXT"); - b.Property("Expires"); + b.Property("Expires") + .HasColumnType("TEXT"); - b.Property("IsEvadedOffense"); + b.Property("IsEvadedOffense") + .HasColumnType("INTEGER"); - b.Property("LinkId"); + b.Property("LinkId") + .HasColumnType("INTEGER"); - b.Property("OffenderId"); + b.Property("OffenderId") + .HasColumnType("INTEGER"); b.Property("Offense") - .IsRequired(); + .IsRequired() + .HasColumnType("TEXT"); - b.Property("PunisherId"); + b.Property("PunisherId") + .HasColumnType("INTEGER"); - b.Property("Type"); + b.Property("Type") + .HasColumnType("INTEGER"); - b.Property("When"); + b.Property("When") + .HasColumnType("TEXT"); b.HasKey("PenaltyId"); @@ -522,13 +669,17 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("SharedLibraryCore.Helpers.Vector3", b => { b.Property("Vector3Id") - .ValueGeneratedOnAdd(); + .ValueGeneratedOnAdd() + .HasColumnType("INTEGER"); - b.Property("X"); + b.Property("X") + .HasColumnType("REAL"); - b.Property("Y"); + b.Property("Y") + .HasColumnType("REAL"); - b.Property("Z"); + b.Property("Z") + .HasColumnType("REAL"); b.HasKey("Vector3Id"); @@ -540,27 +691,32 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") .WithMany() .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() .HasForeignKey("CurrentViewAngleId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() .HasForeignKey("HitDestinationId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitOrigin") .WithMany() .HasForeignKey("HitOriginId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("SharedLibraryCore.Helpers.Vector3", "LastStrainAngle") .WithMany() .HasForeignKey("LastStrainAngleId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFACSnapshotVector3", b => @@ -568,12 +724,14 @@ namespace SharedLibraryCore.Migrations b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFACSnapshot", "Snapshot") .WithMany("PredictedViewAngles") .HasForeignKey("SnapshotId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("SharedLibraryCore.Helpers.Vector3", "Vector") .WithMany() .HasForeignKey("Vector3Id") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientKill", b => @@ -581,7 +739,8 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Attacker") .WithMany() .HasForeignKey("AttackerId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("SharedLibraryCore.Helpers.Vector3", "DeathOrigin") .WithMany() @@ -594,12 +753,14 @@ namespace SharedLibraryCore.Migrations b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") .WithMany() .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Victim") .WithMany() .HasForeignKey("VictimId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("SharedLibraryCore.Helpers.Vector3", "ViewAngles") .WithMany() @@ -611,12 +772,14 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") .WithMany() .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") .WithMany() .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientRatingHistory", b => @@ -624,7 +787,8 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") .WithMany() .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics", b => @@ -632,30 +796,35 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") .WithMany() .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") .WithMany() .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFHitLocationCount", b => { b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") .WithMany() - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); + .HasForeignKey("EFClientStatisticsClientId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") .WithMany() - .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade); + .HasForeignKey("EFClientStatisticsServerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); - b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics") + b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics", null) .WithMany("HitLocations") - .HasForeignKey("ClientId", "ServerId") - .OnDelete(DeleteBehavior.Cascade); + .HasForeignKey("EFClientStatisticsClientId", "EFClientStatisticsServerId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFRating", b => @@ -663,7 +832,8 @@ namespace SharedLibraryCore.Migrations b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFClientRatingHistory", "RatingHistory") .WithMany("Ratings") .HasForeignKey("RatingHistoryId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") .WithMany() @@ -675,7 +845,8 @@ namespace SharedLibraryCore.Migrations b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server") .WithMany() .HasForeignKey("ServerId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("SharedLibraryCore.Database.Models.EFAlias", b => @@ -683,7 +854,8 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Database.Models.EFAliasLink", "Link") .WithMany("Children") .HasForeignKey("LinkId") - .OnDelete(DeleteBehavior.Restrict); + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); }); modelBuilder.Entity("SharedLibraryCore.Database.Models.EFClient", b => @@ -691,12 +863,14 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Database.Models.EFAliasLink", "AliasLink") .WithMany() .HasForeignKey("AliasLinkId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("SharedLibraryCore.Database.Models.EFAlias", "CurrentAlias") .WithMany() .HasForeignKey("CurrentAliasId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("SharedLibraryCore.Database.Models.EFMeta", b => @@ -704,7 +878,8 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") .WithMany("Meta") .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); }); modelBuilder.Entity("SharedLibraryCore.Database.Models.EFPenalty", b => @@ -712,17 +887,20 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Database.Models.EFAliasLink", "Link") .WithMany("ReceivedPenalties") .HasForeignKey("LinkId") - .OnDelete(DeleteBehavior.Cascade); + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Offender") .WithMany("ReceivedPenalties") .HasForeignKey("OffenderId") - .OnDelete(DeleteBehavior.Restrict); + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Punisher") .WithMany("AdministeredPenalties") .HasForeignKey("PunisherId") - .OnDelete(DeleteBehavior.Restrict); + .OnDelete(DeleteBehavior.Restrict) + .IsRequired(); }); #pragma warning restore 612, 618 } diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index 62e35adcf..175da7ea7 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -290,26 +290,26 @@ namespace SharedLibraryCore.Services { using (var context = new DatabaseContext(true)) { - var iqClient = from client in context.Clients + var iqClient = from _c in context.Clients .Include(c => c.CurrentAlias) .Include(c => c.AliasLink.Children) .Include(c => c.Meta) - where client.ClientId == entityID - select new - { - Client = client, - LinkedAccounts = (from linkedClient in context.Clients - where client.AliasLinkId == linkedClient.AliasLinkId - select new - { - linkedClient.ClientId, - linkedClient.NetworkId - }) - }; -#if DEBUG == true - var clientSql = iqClient.ToSql(); -#endif - var foundClient = await iqClient.FirstOrDefaultAsync(); + where _c.ClientId == entityID + select _c; + + var client = await iqClient.FirstOrDefaultAsync(); + + var foundClient = new + { + Client = client, + LinkedAccounts = await context.Clients.Where(_client => _client.AliasLinkId == client.AliasLinkId) + .Select(_linkedClient => new + { + _linkedClient.ClientId, + _linkedClient.NetworkId + }) + .ToListAsync() + }; if (foundClient == null) { @@ -585,6 +585,7 @@ namespace SharedLibraryCore.Services var iqClients = context.Clients .Where(_client => _client.CurrentAlias.IPAddress != null) .Where(_client => _client.FirstConnection >= startOfPeriod) + .OrderByDescending(_client => _client.FirstConnection) .Select(_client => new PlayerInfo() { ClientId = _client.ClientId, @@ -592,6 +593,7 @@ namespace SharedLibraryCore.Services IPAddress = _client.CurrentAlias.IPAddress.ConvertIPtoString(), LastConnection = _client.FirstConnection }); + #if DEBUG var sql = iqClients.ToSql(); #endif diff --git a/SharedLibraryCore/Utilities.cs b/SharedLibraryCore/Utilities.cs index c8f4ad571..2c6f51207 100644 --- a/SharedLibraryCore/Utilities.cs +++ b/SharedLibraryCore/Utilities.cs @@ -25,7 +25,7 @@ namespace SharedLibraryCore public static class Utilities { #if DEBUG == true - public static string OperatingDirectory => $"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}{Path.DirectorySeparatorChar}"; + public static string OperatingDirectory => $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)}{Path.DirectorySeparatorChar}"; #else public static string OperatingDirectory => $"{Path.GetDirectoryName(Assembly.GetEntryAssembly().Location)}{Path.DirectorySeparatorChar}..{Path.DirectorySeparatorChar}"; #endif @@ -850,30 +850,9 @@ namespace SharedLibraryCore public static bool ShouldHideLevel(this Permission perm) => perm == Permission.Flagged; #if DEBUG == true - - private static readonly TypeInfo QueryCompilerTypeInfo = typeof(QueryCompiler).GetTypeInfo(); - - private static readonly FieldInfo QueryCompilerField = typeof(EntityQueryProvider).GetTypeInfo().DeclaredFields.First(x => x.Name == "_queryCompiler"); - - private static readonly FieldInfo QueryModelGeneratorField = QueryCompilerTypeInfo.DeclaredFields.First(x => x.Name == "_queryModelGenerator"); - - private static readonly FieldInfo DataBaseField = QueryCompilerTypeInfo.DeclaredFields.Single(x => x.Name == "_database"); - - private static readonly PropertyInfo DatabaseDependenciesField = typeof(Microsoft.EntityFrameworkCore.Storage.Database).GetTypeInfo().DeclaredProperties.Single(x => x.Name == "Dependencies"); - public static string ToSql(this IQueryable query) where TEntity : class { - var queryCompiler = (QueryCompiler)QueryCompilerField.GetValue(query.Provider); - var modelGenerator = (QueryModelGenerator)QueryModelGeneratorField.GetValue(queryCompiler); - var queryModel = modelGenerator.ParseQuery(query.Expression); - var database = (IDatabase)DataBaseField.GetValue(queryCompiler); - var databaseDependencies = (DatabaseDependencies)DatabaseDependenciesField.GetValue(database); - var queryCompilationContext = databaseDependencies.QueryCompilationContextFactory.Create(false); - var modelVisitor = (RelationalQueryModelVisitor)queryCompilationContext.CreateQueryModelVisitor(); - modelVisitor.CreateQueryExecutor(queryModel); - var sql = modelVisitor.Queries.First().ToString(); - - return sql; + return ""; } #endif } diff --git a/WebfrontCore/Startup.cs b/WebfrontCore/Startup.cs index bc4282d18..b0ec8d816 100644 --- a/WebfrontCore/Startup.cs +++ b/WebfrontCore/Startup.cs @@ -13,7 +13,6 @@ namespace WebfrontCore { public class Startup { - private readonly IWebHostEnvironment _appHost; public static IConfigurationRoot Configuration { get; private set; } public Startup(IWebHostEnvironment env) @@ -22,8 +21,6 @@ namespace WebfrontCore .AddEnvironmentVariables(); Configuration = builder.Build(); - - _appHost = env; } // This method gets called by the runtime. Use this method to add services to the container. @@ -112,6 +109,7 @@ namespace WebfrontCore app.UseStaticFiles(); app.UseAuthentication(); + app.UseAuthorization(); app.UseCors("AllowAll"); app.UseRouting();