From 5d93e7ac577e104408a78b207167ae2726b8501a Mon Sep 17 00:00:00 2001 From: RaidMax Date: Sun, 23 Sep 2018 19:45:54 -0500 Subject: [PATCH] a ton of stuff and fix migations --- Application/GameEventHandler.cs | 49 +--- Application/Manager.cs | 52 +++-- Application/Server.cs | 30 +-- GameLogServer/GameLogServer/log_reader.py | 2 +- Plugins/ProfanityDeterment/Configuration.cs | 6 +- Plugins/Stats/Cheat/Detection.cs | 10 +- Plugins/Stats/Commands/TopStats.cs | 21 +- Plugins/Stats/Helpers/StatManager.cs | 215 ++++++++++-------- Plugins/Stats/IW4Info.cs | 5 +- Plugins/Stats/Models/EFACSnapshot.cs | 8 + .../Configuration/ApplicationConfiguration.cs | 1 + SharedLibraryCore/Database/DatabaseContext.cs | 36 +-- .../Database/Models/EFChangeHistory.cs | 3 +- SharedLibraryCore/Events/EventAPI.cs | 8 +- SharedLibraryCore/Events/GameEvent.cs | 10 +- .../20180409183408_InitialCreate.Designer.cs | 3 +- .../20180409183408_InitialCreate.cs | 47 +++- ...903_AddAutomatedOffenseAndRatingHistory.cs | 12 +- .../20180602041758_AddClientMeta.cs | 8 +- ...0180605191706_AddEFACSnapshots.Designer.cs | 6 +- .../20180605191706_AddEFACSnapshots.cs | 25 +- ...20180614014303_IndexForEFAlias.Designer.cs | 6 +- ...902035612_AddFractionAndIsKill.Designer.cs | 6 +- .../20180902035612_AddFractionAndIsKill.cs | 8 +- ...154622_AddVisibilityPercentage.Designer.cs | 6 +- .../20180907020706_AddVision.Designer.cs | 6 +- ...20180908004053_AddWhenToRating.Designer.cs | 6 +- ...0180910221749_AddRatingIndexes.Designer.cs | 6 +- ...0911184224_AddEFAliasNameIndex.Designer.cs | 6 +- .../20180911190418_AddEFAliasNameMaxLength.cs | 17 -- ...0823_AddEFAliasNameMaxLength24.Designer.cs | 6 +- ...sCurrentValueToEFChangeHistory.Designer.cs | 6 +- ...ddPreviousCurrentValueToEFChangeHistory.cs | 1 + ...3111_AddIndexToMessageTimeSent.Designer.cs | 6 +- ...5164118_ForceAutoIncrementChangeHistory.cs | 25 -- ...180922231310_RemoveACSnapShot.Designer.cs} | 111 +-------- .../20180922231310_RemoveACSnapShot.cs | 139 +++++++++++ ...0180922231600_ReaddACSnapshot.Designer.cs} | 37 +-- .../20180922231600_ReaddACSnapshot.cs | 145 ++++++++++++ .../DatabaseContextModelSnapshot.cs | 37 +-- SharedLibraryCore/Server.cs | 2 +- .../Services/ChangeHistoryService.cs | 10 + .../Services/GenericRepository.cs | 2 +- SharedLibraryCore/SharedLibraryCore.csproj | 13 +- WebfrontCore/WebfrontCore.csproj | 3 +- 45 files changed, 706 insertions(+), 461 deletions(-) delete mode 100644 SharedLibraryCore/Migrations/20180911190418_AddEFAliasNameMaxLength.cs delete mode 100644 SharedLibraryCore/Migrations/20180915164118_ForceAutoIncrementChangeHistory.cs rename SharedLibraryCore/Migrations/{20180911190418_AddEFAliasNameMaxLength.Designer.cs => 20180922231310_RemoveACSnapShot.Designer.cs} (84%) create mode 100644 SharedLibraryCore/Migrations/20180922231310_RemoveACSnapShot.cs rename SharedLibraryCore/Migrations/{20180915164118_ForceAutoIncrementChangeHistory.Designer.cs => 20180922231600_ReaddACSnapshot.Designer.cs} (94%) create mode 100644 SharedLibraryCore/Migrations/20180922231600_ReaddACSnapshot.cs diff --git a/Application/GameEventHandler.cs b/Application/GameEventHandler.cs index a3481412b..7ba8069d2 100644 --- a/Application/GameEventHandler.cs +++ b/Application/GameEventHandler.cs @@ -23,20 +23,6 @@ namespace IW4MAdmin.Application public void AddEvent(GameEvent gameEvent) { - //IsProcessingEvent.Wait(); - ((Manager as ApplicationManager).OnServerEvent)(this, new GameEventArgs(null, false, gameEvent)); - //IsProcessingEvent.Release(1); - //if (gameEvent.Type == GameEvent.EventType.Connect) - //{ - // IsProcessingEvent.Wait(); - // if (!gameEvent.OnProcessed.Wait(10 * 1000)) - // { - // Manager.GetLogger().WriteError($"{Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_COMMAND_TIMEOUT"]} [{gameEvent.Id}, {gameEvent.Type}]"); - // } - // IsProcessingEvent.Release(1); - //} - - return; #if DEBUG Manager.GetLogger().WriteDebug($"Got new event of type {gameEvent.Type} for {gameEvent.Owner} with id {gameEvent.Id}"); #endif @@ -61,40 +47,11 @@ namespace IW4MAdmin.Application // event occurs if (gameEvent.Id == Interlocked.Read(ref NextEventId)) { - //#if DEBUG == true - // Manager.GetLogger().WriteDebug($"sent event with id {gameEvent.Id} to be processed"); - // IsProcessingEvent.Wait(); - //#else - // if (GameEvent.IsEventTimeSensitive(gameEvent) && - // !IsProcessingEvent.Wait(30 * 1000)) - // { - // Manager.GetLogger().WriteError($"{Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_COMMAND_TIMEOUT"]} [{gameEvent.Id}, {gameEvent.Type}]"); - // } - //#endif ((Manager as ApplicationManager).OnServerEvent)(this, new GameEventArgs(null, false, gameEvent)); - - //if (GameEvent.IsEventTimeSensitive(gameEvent)) - //{ - // if( !gameEvent.OnProcessed.Wait(30 * 1000)) - // { - // Manager.GetLogger().WriteError($"{Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_EVENT_TIMEOUT"]} [{gameEvent.Id}, {gameEvent.Type}]"); - // } - //} +#if DEBUG == true + Manager.GetLogger().WriteDebug($"notified event {gameEvent.Type} for {gameEvent.Owner} with id {gameEvent.Id}"); +#endif Interlocked.Increment(ref NextEventId); - //#if DEBUG == true - // gameEvent.OnProcessed.Wait(); - //#else - // if (GameEvent.IsEventTimeSensitive(gameEvent) && - // !gameEvent.OnProcessed.Wait(30 * 1000)) - // { - // Manager.GetLogger().WriteError($"{Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_EVENT_TIMEOUT"]} [{gameEvent.Id}, {gameEvent.Type}]"); - // } - //#endif - // Interlocked.Increment(ref NextEventId); - // if (GameEvent.IsEventTimeSensitive(gameEvent)) - // { - // IsProcessingEvent.Release(); - // } } // a "newer" event has been added before and "older" one has been added (due to threads and context switching) diff --git a/Application/Manager.cs b/Application/Manager.cs index 31bf4056d..add51aac0 100644 --- a/Application/Manager.cs +++ b/Application/Manager.cs @@ -52,6 +52,7 @@ namespace IW4MAdmin.Application GameEventHandler Handler; ManualResetEventSlim OnQuit; readonly IPageList PageList; + readonly SemaphoreSlim ProcessingEvent = new SemaphoreSlim(1, 1); private ApplicationManager() { @@ -74,6 +75,11 @@ namespace IW4MAdmin.Application private async void OnServerEventAsync(object sender, GameEventArgs args) { + //if (!await ProcessingEvent.WaitAsync(60000)) + //{ + // Logger.WriteWarning(Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_EVENT_TIMEOUT"]); + //} + var newEvent = args.Event; try @@ -90,7 +96,7 @@ namespace IW4MAdmin.Application // offload it to the player to keep newEvent.Origin.DelayedEvents.Enqueue(newEvent); newEvent.OnProcessed.Set(); - return; + goto finish; } // if the target client is not in an authorized state (detected by RCon) don't execute the event @@ -100,7 +106,7 @@ namespace IW4MAdmin.Application // offload it to the player to keep newEvent.Target.DelayedEvents.Enqueue(newEvent); newEvent.OnProcessed.Set(); - return; + goto finish; } await newEvent.Owner.ExecuteEvent(newEvent); @@ -140,7 +146,8 @@ namespace IW4MAdmin.Application if (e.Target == null) { Logger.WriteWarning($"Delayed event for {e.Origin} was removed because the target has left"); - continue; + // hack: don't do anything with the event because the target is invalid + e.Type = GameEvent.EventType.Unknown; } } Logger.WriteDebug($"Adding delayed event of type {e.Type} for {e.Origin} back for processing"); @@ -162,6 +169,7 @@ namespace IW4MAdmin.Application catch (NetworkException ex) { Logger.WriteError(ex.Message); + Logger.WriteDebug(ex.GetExceptionInfo()); } catch (ServerException ex) @@ -172,9 +180,14 @@ namespace IW4MAdmin.Application catch (Exception ex) { Logger.WriteError($"{Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_EXCEPTION"]} {newEvent.Owner}"); - Logger.WriteDebug("Error Message: " + ex.Message); - Logger.WriteDebug("Error Trace: " + ex.StackTrace); + Logger.WriteDebug(ex.GetExceptionInfo()); } + + finish: + //if (ProcessingEvent.CurrentCount < 1) + //{ + // ProcessingEvent.Release(1); + //} // tell anyone waiting for the output that we're done newEvent.OnProcessed.Set(); @@ -239,8 +252,7 @@ namespace IW4MAdmin.Application catch (Exception e) { Logger.WriteWarning($"Failed to update status for {server}"); - Logger.WriteDebug($"Exception: {e.Message}"); - Logger.WriteDebug($"StackTrace: {e.StackTrace}"); + Logger.WriteDebug(e.GetExceptionInfo()); } })); } @@ -256,6 +268,9 @@ namespace IW4MAdmin.Application await Task.Delay(ConfigHandler.Configuration().RConPollRate); #endif } + + // trigger the event processing loop to end + SetHasEvent(); } public async Task Init() @@ -263,7 +278,7 @@ namespace IW4MAdmin.Application Running = true; #region DATABASE - using (var db = new DatabaseContext(GetApplicationSettings().Configuration()?.ConnectionString)) + using (var db = new DatabaseContext(GetApplicationSettings().Configuration()?.ConnectionString, GetApplicationSettings().Configuration().DatabaseProvider)) { await new ContextSeed(db).Seed(); } @@ -340,7 +355,7 @@ namespace IW4MAdmin.Application if (string.IsNullOrEmpty(config.WebfrontBindUrl)) { - config.WebfrontBindUrl = "http://127.0.0.1:1624"; + config.WebfrontBindUrl = "http://0.0.0.0:1624"; await ConfigHandler.Save(); } } @@ -532,13 +547,11 @@ namespace IW4MAdmin.Application public void Start() { // this needs to be run seperately from the main thread -#pragma warning disable CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed #if !DEBUG // start heartbeat - Task.Run(() => SendHeartbeat(new HeartbeatState())); + var _ = Task.Run(() => SendHeartbeat(new HeartbeatState())); #endif - Task.Run(() => UpdateServerStates()); -#pragma warning restore CS4014 // Because this call is not awaited, execution of the current method continues before the call is completed + _ = Task.Run(() => UpdateServerStates()); while (Running) { @@ -551,9 +564,6 @@ namespace IW4MAdmin.Application public void Stop() { Running = false; - - // trigger the event processing loop to end - SetHasEvent(); } public ILogger GetLogger() @@ -566,15 +576,7 @@ namespace IW4MAdmin.Application return MessageTokens; } - public IList GetActiveClients() - { - var ActiveClients = new List(); - - foreach (var server in _servers) - ActiveClients.AddRange(server.Players.Where(p => p != null)); - - return ActiveClients; - } + public IList GetActiveClients() => _servers.SelectMany(s => s.Players).Where(p => p != null).ToList(); public ClientService GetClientService() => ClientSvc; public AliasService GetAliasService() => AliasSvc; diff --git a/Application/Server.cs b/Application/Server.cs index 585f60603..c8b86b5aa 100644 --- a/Application/Server.cs +++ b/Application/Server.cs @@ -286,7 +286,10 @@ namespace IW4MAdmin public override async Task ExecuteEvent(GameEvent E) { bool canExecuteCommand = true; - await ProcessEvent(E); + if (!await ProcessEvent(E)) + { + return; + } Command C = null; if (E.Type == GameEvent.EventType.Command) @@ -321,13 +324,7 @@ namespace IW4MAdmin catch (Exception Except) { Logger.WriteError($"{loc["SERVER_PLUGIN_ERROR"]} [{plugin.Name}]"); - Logger.WriteDebug(String.Format("Error Message: {0}", Except.Message)); - Logger.WriteDebug(String.Format("Error Trace: {0}", Except.StackTrace)); - while (Except.InnerException != null) - { - Except = Except.InnerException; - Logger.WriteDebug($"Inner exception: {Except.Message}"); - } + Logger.WriteDebug(Except.GetExceptionInfo()); } } @@ -346,7 +343,7 @@ namespace IW4MAdmin /// /// /// - override protected async Task ProcessEvent(GameEvent E) + override protected async Task ProcessEvent(GameEvent E) { if (E.Type == GameEvent.EventType.Connect) { @@ -355,7 +352,8 @@ namespace IW4MAdmin if (!await AddPlayer(E.Origin)) { E.Origin.State = Player.ClientState.Connecting; - throw new ServerException("client didn't pass authentication, so we are discontinuing event"); + Logger.WriteDebug("client didn't pass authentication, so we are discontinuing event"); + return false; } // hack: makes the event propgate with the correct info E.Origin = Players[E.Origin.ClientNumber]; @@ -505,6 +503,8 @@ namespace IW4MAdmin // so there will still be at least 1 client left if (ClientNum < 2) ChatHistory.Clear(); + + return true; } /// @@ -558,8 +558,8 @@ namespace IW4MAdmin } // only check every 2 minutes if the server doesn't seem to be responding - if ((DateTime.Now - LastPoll).TotalMinutes < 2 && ConnectionErrors >= 1) - return true; + /* if ((DateTime.Now - LastPoll).TotalMinutes < 0.5 && ConnectionErrors >= 1) + return true;*/ try { @@ -683,6 +683,7 @@ namespace IW4MAdmin if (e is NetworkException) { Logger.WriteError($"{loc["SERVER_ERROR_COMMUNICATION"]} {IP}:{Port}"); + Logger.WriteDebug(e.GetExceptionInfo()); } return false; @@ -691,8 +692,7 @@ namespace IW4MAdmin catch (Exception E) { Logger.WriteError($"{loc["SERVER_ERROR_EXCEPTION"]} {IP}:{Port}"); - Logger.WriteDebug("Error Message: " + E.Message); - Logger.WriteDebug("Error Trace: " + E.StackTrace); + Logger.WriteDebug(E.GetExceptionInfo()); return false; } } @@ -811,7 +811,7 @@ namespace IW4MAdmin Logger.WriteError($"{logPath} {loc["SERVER_ERROR_DNE"]}"); #if !DEBUG throw new ServerException($"{loc["SERVER_ERROR_LOG"]} {logPath}"); -#else +//#else LogEvent = new GameLogEventDetection(this, logPath, logfile.Value); #endif } diff --git a/GameLogServer/GameLogServer/log_reader.py b/GameLogServer/GameLogServer/log_reader.py index 99731ef74..0d9aee595 100644 --- a/GameLogServer/GameLogServer/log_reader.py +++ b/GameLogServer/GameLogServer/log_reader.py @@ -8,7 +8,7 @@ class LogReader(object): # (if the file changes more than this, ignore ) - 1 MB self.max_file_size_change = 1000000 # (if the time between checks is greater, ignore ) - 5 minutes - self.max_file_time_change = 300 + self.max_file_time_change = 1000 def read_file(self, path): # prevent traversing directories diff --git a/Plugins/ProfanityDeterment/Configuration.cs b/Plugins/ProfanityDeterment/Configuration.cs index 1c9b0c26f..e1e27b211 100644 --- a/Plugins/ProfanityDeterment/Configuration.cs +++ b/Plugins/ProfanityDeterment/Configuration.cs @@ -16,9 +16,9 @@ namespace IW4MAdmin.Plugins.ProfanityDeterment { OffensiveWords = new List() { - "nigger", - "nigga", - "fuck" + @"\s*n+.*i+.*g+.*e+.*r+\s*", + @"\s*n+.*i+.*g+.*a+\s*", + @"\s*f+u+.*c+.*k+.*\s*" }; var loc = Utilities.CurrentLocalization.LocalizationIndex; diff --git a/Plugins/Stats/Cheat/Detection.cs b/Plugins/Stats/Cheat/Detection.cs index 5f8f9f81a..5f281517e 100644 --- a/Plugins/Stats/Cheat/Detection.cs +++ b/Plugins/Stats/Cheat/Detection.cs @@ -139,8 +139,11 @@ namespace IW4MAdmin.Plugins.Stats.Cheat } // flag - if (currentStrain > Thresholds.MaxStrainFlag - && HitCount >= 10) + if ( +#if DEBUG == false + currentStrain > Thresholds.MaxStrainFlag && +#endif + HitCount >= 10) { result = new DetectionPenaltyResult() { @@ -356,7 +359,6 @@ namespace IW4MAdmin.Plugins.Stats.Cheat Tracker.OnChange(new EFACSnapshot() { - Active = true, When = kill.When, ClientId = ClientStats.ClientId, SessionAngleOffset = AngleDifferenceAverage, @@ -366,7 +368,9 @@ namespace IW4MAdmin.Plugins.Stats.Cheat Hits = HitCount, Kills = Kills, Deaths = ClientStats.SessionDeaths, + HitDestinationId = kill.DeathOrigin.Vector3Id, HitDestination = kill.DeathOrigin, + HitOriginId = kill.KillOrigin.Vector3Id, HitOrigin = kill.KillOrigin, EloRating = ClientStats.EloRating, HitLocation = kill.HitLoc, diff --git a/Plugins/Stats/Commands/TopStats.cs b/Plugins/Stats/Commands/TopStats.cs index 78582065b..36a343fac 100644 --- a/Plugins/Stats/Commands/TopStats.cs +++ b/Plugins/Stats/Commands/TopStats.cs @@ -23,12 +23,9 @@ namespace IW4MAdmin.Plugins.Stats.Commands $"^5--{Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_STATS_COMMANDS_TOP_TEXT"]}--" }; - using (var db = new DatabaseContext()) + using (var db = new DatabaseContext(true)) { - db.ChangeTracker.AutoDetectChangesEnabled = false; - db.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking; - - var thirtyDaysAgo = DateTime.UtcNow.AddMonths(-1); + var fifteenDaysAgo = DateTime.UtcNow.AddDays(-15); var iqStats = (from stats in db.Set() join client in db.Clients @@ -36,9 +33,9 @@ namespace IW4MAdmin.Plugins.Stats.Commands join alias in db.Aliases on client.CurrentAliasId equals alias.AliasId where stats.ServerId == serverId - where stats.TimePlayed >= 3600 + where stats.TimePlayed >= Plugin.Config.Configuration().TopPlayersMinPlayTime where client.Level != Player.Permission.Banned - where client.LastConnection >= thirtyDaysAgo + where client.LastConnection >= fifteenDaysAgo orderby stats.Performance descending select new { @@ -48,6 +45,10 @@ namespace IW4MAdmin.Plugins.Stats.Commands }) .Take(5); +#if DEBUG == true + var statsSql = iqStats.ToSql(); +#endif + var statsList = (await iqStats.ToListAsync()) .Select(stats => $"^3{stats.Name}^7 - ^5{stats.KDR} ^7{Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_STATS_TEXT_KDR"]} | ^5{stats.Performance} ^7{Utilities.CurrentLocalization.LocalizationIndex["PLUGINS_STATS_COMMANDS_PERFORMANCE"]}"); @@ -74,12 +75,18 @@ namespace IW4MAdmin.Plugins.Stats.Commands if (!E.Message.IsBroadcastCommand()) { foreach (var stat in topStats) + { await E.Origin.Tell(stat); + await Task.Delay(SharedLibraryCore.RCon.StaticHelpers.FloodProtectionInterval); + } } else { foreach (var stat in topStats) + { await E.Owner.Broadcast(stat); + await Task.Delay(SharedLibraryCore.RCon.StaticHelpers.FloodProtectionInterval); + } } } } diff --git a/Plugins/Stats/Helpers/StatManager.cs b/Plugins/Stats/Helpers/StatManager.cs index 1af751915..bde034570 100644 --- a/Plugins/Stats/Helpers/StatManager.cs +++ b/Plugins/Stats/Helpers/StatManager.cs @@ -42,7 +42,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers public EFClientStatistics GetClientStats(int clientId, int serverId) => Servers[serverId].PlayerStats[clientId]; - public Expression> GetRankingFunc(int? serverId = null) + public static Expression> GetRankingFunc(int? serverId = null) { var fifteenDaysAgo = DateTime.UtcNow.AddDays(-15); return (r) => r.ServerId == serverId && @@ -52,7 +52,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers r.ActivityAmount >= Plugin.Config.Configuration().TopPlayersMinPlayTime; } - /// /// gets a ranking across all servers for given client id /// @@ -293,7 +292,18 @@ namespace IW4MAdmin.Plugins.Stats.Helpers Location = hl }) .ToList(); - //await statsSvc.ClientStatSvc.SaveChangesAsync(); + await statsSvc.ClientStatSvc.SaveChangesAsync(); + } + + // adjusts for adding new hit location + if (clientStats.HitLocations.Count == 19) + { + clientStats.HitLocations.Add(new EFHitLocationCount() + { + Location = IW4Info.HitLocation.shield + }); + + await statsSvc.ClientStatSvc.SaveChangesAsync(); } // for stats before rating @@ -351,10 +361,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers // get individual client's stats var clientStats = playerStats[pl.ClientId]; -#if DEBUG == true - await UpdateStatHistory(pl, clientStats); -#endif - // remove the client from the stats dictionary as they're leaving playerStats.TryRemove(pl.ClientId, out EFClientStatistics removedValue3); detectionStats.TryRemove(pl.ClientId, out Cheat.Detection removedValue4); @@ -454,8 +460,8 @@ namespace IW4MAdmin.Plugins.Stats.Helpers AnglesList = snapshotAngles }; - if (hit.DeathType == IW4Info.MeansOfDeath.MOD_SUICIDE && - hit.Damage == 100000) + if ((hit.DeathType == IW4Info.MeansOfDeath.MOD_SUICIDE && + hit.Damage == 100000) || hit.HitLoc == IW4Info.HitLocation.shield) { // suicide by switching teams so let's not count it against them return; @@ -484,43 +490,49 @@ namespace IW4MAdmin.Plugins.Stats.Helpers clientStats.HitLocations.Single(hl => hl.Location == hit.HitLoc).HitCount += 1; } - if (Plugin.Config.Configuration().EnableAntiCheat) + using (var ctx = new DatabaseContext()) { - await ApplyPenalty(clientDetection.ProcessKill(hit, isDamage), clientDetection, attacker); - await ApplyPenalty(clientDetection.ProcessTotalRatio(clientStats), clientDetection, attacker); + await OnProcessingPenalty.WaitAsync(); - await clientStatsSvc.SaveChangesAsync(); - } - - if (Plugin.Config.Configuration().StoreClientKills) - { - using (var ctx = new DatabaseContext()) + try { - ctx.Set().Add(hit); + if (Plugin.Config.Configuration().StoreClientKills) + { + ctx.Set().Add(hit); + } + + if (Plugin.Config.Configuration().EnableAntiCheat) + { + await ApplyPenalty(clientDetection.ProcessKill(hit, isDamage), clientDetection, attacker, ctx); + await ApplyPenalty(clientDetection.ProcessTotalRatio(clientStats), clientDetection, attacker, ctx); + } + await ctx.SaveChangesAsync(); + await clientStatsSvc.SaveChangesAsync(); } + + catch (Exception ex) + { + + } + + OnProcessingPenalty.Release(1); } } - async Task ApplyPenalty(Cheat.DetectionPenaltyResult penalty, Cheat.Detection clientDetection, Player attacker) + async Task ApplyPenalty(Cheat.DetectionPenaltyResult penalty, Cheat.Detection clientDetection, Player attacker, DatabaseContext ctx) { - try + switch (penalty.ClientPenalty) { - switch (penalty.ClientPenalty) - { - case Penalty.PenaltyType.Ban: - if (attacker.Level == Player.Permission.Banned) - { - break; - } - if (clientDetection.Tracker.HasChanges) - { - await SaveTrackedSnapshots(clientDetection); - } - await attacker.Ban(Utilities.CurrentLocalization.LocalizationIndex["PLUGIN_STATS_CHEAT_DETECTED"], new Player() - { - ClientId = 1, - AdministeredPenalties = new List() + case Penalty.PenaltyType.Ban: + if (attacker.Level == Player.Permission.Banned) + { + break; + } + await attacker.Ban(Utilities.CurrentLocalization.LocalizationIndex["PLUGIN_STATS_CHEAT_DETECTED"], new Player() + { + ClientId = 1, + AdministeredPenalties = new List() { new EFPenalty() { @@ -529,71 +541,96 @@ namespace IW4MAdmin.Plugins.Stats.Helpers $"{penalty.Type}-{Math.Round(penalty.Value, 2)}@{penalty.HitCount}", } } - }); + }); + if (clientDetection.Tracker.HasChanges) + { + SaveTrackedSnapshots(clientDetection, ctx); + } + break; + case Penalty.PenaltyType.Flag: + if (attacker.Level != Player.Permission.User) + { break; - case Penalty.PenaltyType.Flag: - if (attacker.Level != Player.Permission.User) + } + var e = new GameEvent() + { + Data = penalty.Type == Cheat.Detection.DetectionType.Bone ? + $"{penalty.Type}-{(int)penalty.Location}-{Math.Round(penalty.Value, 2)}@{penalty.HitCount}" : + $"{penalty.Type}-{Math.Round(penalty.Value, 2)}@{penalty.HitCount}", + Origin = new Player() { - break; - } - if (clientDetection.Tracker.HasChanges) - { - await SaveTrackedSnapshots(clientDetection); - } - var e = new GameEvent() - { - Data = penalty.Type == Cheat.Detection.DetectionType.Bone ? - $"{penalty.Type}-{(int)penalty.Location}-{Math.Round(penalty.Value, 2)}@{penalty.HitCount}" : - $"{penalty.Type}-{Math.Round(penalty.Value, 2)}@{penalty.HitCount}", - Origin = new Player() - { - ClientId = 1, - Level = Player.Permission.Console, - ClientNumber = -1, - CurrentServer = attacker.CurrentServer - }, - Target = attacker, - Owner = attacker.CurrentServer, - Type = GameEvent.EventType.Flag - }; - // because we created an event it must be processed by the manager - // even if it didn't really do anything - Manager.GetEventHandler().AddEvent(e); - await new CFlag().ExecuteAsync(e); - break; - } - } - catch - { - + ClientId = 1, + Level = Player.Permission.Console, + ClientNumber = -1, + CurrentServer = attacker.CurrentServer + }, + Target = attacker, + Owner = attacker.CurrentServer, + Type = GameEvent.EventType.Flag + }; + // because we created an event it must be processed by the manager + // even if it didn't really do anything + Manager.GetEventHandler().AddEvent(e); + await new CFlag().ExecuteAsync(e); + if (clientDetection.Tracker.HasChanges) + { + SaveTrackedSnapshots(clientDetection, ctx); + } + break; } } - async Task SaveTrackedSnapshots(Cheat.Detection clientDetection) + void SaveTrackedSnapshots(Cheat.Detection clientDetection, DatabaseContext ctx) { - await OnProcessingPenalty.WaitAsync(); - - using (var ctx = new DatabaseContext(true)) + // todo: why does this cause duplicate primary key + var change = clientDetection.Tracker.GetNextChange(); + while ((change = clientDetection.Tracker.GetNextChange()) != default(EFACSnapshot)) { - // todo: why does this cause duplicate primary key - var change = clientDetection.Tracker.GetNextChange(); - while ((change = clientDetection.Tracker.GetNextChange()) != default(EFACSnapshot)) + + //if (change.HitOriginId == 0) + //{ + // change.HitOriginId = change.HitOrigin.Vector3Id; + // change.HitOrigin = null; + //} + + //if (change.HitDestinationId == 0) + //{ + // change.HitDestinationId = change.HitDestination.Vector3Id; + // change.HitDestination = null; + //} + + //if (change.CurrentViewAngleId == 0) + //{ + // change.CurrentViewAngleId = change.CurrentViewAngle.Vector3Id; + // change.CurrentViewAngle = null; + //} + + //if (change.LastStrainAngleId == 0) + //{ + // change.LastStrainAngleId = change.LastStrainAngle.Vector3Id; + // change.LastStrainAngle = null; + //} + + if (change.HitOrigin.Vector3Id > 0) { - ctx.Add(change); + ctx.Attach(change.HitOrigin); + } + if (change.HitDestination.Vector3Id > 0) + { + ctx.Attach(change.HitDestination); + } + if (change.CurrentViewAngle.Vector3Id > 0) + { + ctx.Attach(change.CurrentViewAngle); + } + if (change.LastStrainAngle.Vector3Id > 0) + { + ctx.Attach(change.LastStrainAngle); } - try - { - await ctx.SaveChangesAsync(); - } + ctx.Add(change); - catch (Exception ex) - { - Log.WriteWarning(ex.GetExceptionInfo()); - } } - - OnProcessingPenalty.Release(1); } public async Task AddStandardKill(Player attacker, Player victim) diff --git a/Plugins/Stats/IW4Info.cs b/Plugins/Stats/IW4Info.cs index b576f4a3a..3d3d8249f 100644 --- a/Plugins/Stats/IW4Info.cs +++ b/Plugins/Stats/IW4Info.cs @@ -65,6 +65,7 @@ namespace IW4MAdmin.Plugins.Stats right_foot, left_foot, gun, + shield } public enum WeaponName @@ -1369,7 +1370,9 @@ namespace IW4MAdmin.Plugins.Stats dragunov_mp, cobra_player_minigun_mp, destructible_car, - sentry_minigun_mp + sentry_minigun_mp, + cobra_20mm_mp, + shield } public enum MapName diff --git a/Plugins/Stats/Models/EFACSnapshot.cs b/Plugins/Stats/Models/EFACSnapshot.cs index fedb60bc5..567a5de09 100644 --- a/Plugins/Stats/Models/EFACSnapshot.cs +++ b/Plugins/Stats/Models/EFACSnapshot.cs @@ -30,10 +30,18 @@ namespace IW4MAdmin.Plugins.Stats.Models public double CurrentStrain { get; set; } public double StrainAngleBetween { get; set; } public double SessionAngleOffset { get; set; } + public int LastStrainAngleId { get; set; } + [ForeignKey("LastStrainAngleId")] public Vector3 LastStrainAngle { get; set; } + public int HitOriginId { get; set; } + [ForeignKey("HitOriginId")] public Vector3 HitOrigin { get; set; } + public int HitDestinationId { get; set; } + [ForeignKey("HitDestinationId")] public Vector3 HitDestination { get; set; } public double Distance { get; set; } + public int CurrentViewAngleId { get; set; } + [ForeignKey("CurrentViewAngleId")] public Vector3 CurrentViewAngle { get; set; } public IW4Info.WeaponName WeaponId { get; set; } public IW4Info.HitLocation HitLocation { get; set; } diff --git a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs index 380b1a8c5..5124995e6 100644 --- a/SharedLibraryCore/Configuration/ApplicationConfiguration.cs +++ b/SharedLibraryCore/Configuration/ApplicationConfiguration.cs @@ -18,6 +18,7 @@ namespace SharedLibraryCore.Configuration public string WebfrontBindUrl { get; set; } public string CustomParserEncoding { get; set; } public string CustomLocale { get; set; } + public string DatabaseProvider { get; set; } = "sqlite"; public string ConnectionString { get; set; } public int RConPollRate { get; set; } = 5000; public string Id { get; set; } diff --git a/SharedLibraryCore/Database/DatabaseContext.cs b/SharedLibraryCore/Database/DatabaseContext.cs index 449e09288..4b104a069 100644 --- a/SharedLibraryCore/Database/DatabaseContext.cs +++ b/SharedLibraryCore/Database/DatabaseContext.cs @@ -10,6 +10,8 @@ using SharedLibraryCore.Interfaces; using System.Runtime.InteropServices; using System.ComponentModel.DataAnnotations.Schema; using Microsoft.EntityFrameworkCore.Metadata; +using Npgsql; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace SharedLibraryCore.Database { @@ -26,6 +28,7 @@ namespace SharedLibraryCore.Database /// this only works if there's one connection string /// private static string _ConnectionString; + private static string _provider; public DatabaseContext(DbContextOptions opt) : base(opt) { } @@ -41,9 +44,10 @@ namespace SharedLibraryCore.Database } } - public DatabaseContext(string connStr) + public DatabaseContext(string connStr, string provider) { _ConnectionString = connStr; + _provider = provider; } protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) @@ -59,13 +63,26 @@ namespace SharedLibraryCore.Database var connectionStringBuilder = new SqliteConnectionStringBuilder { DataSource = $"{currentPath}{Path.DirectorySeparatorChar}Database.db".Substring(6) }; var connectionString = connectionStringBuilder.ToString(); var connection = new SqliteConnection(connectionString); - +#if DEBUG == true + optionsBuilder.UseMySql("UserId=root;Password=dev;Host=127.0.0.1;port=3306;Database=IW4MAdmin"); + // optionsBuilder.UseNpgsql("UserId=dev;Password=dev;Host=127.0.0.1;port=5432;Database=IW4MAdmin"); +#else optionsBuilder.UseSqlite(connection); +#endif } else { - optionsBuilder.UseMySql(_ConnectionString); + switch (_provider) + { + default: + case "mysql": + optionsBuilder.UseMySql(_ConnectionString); + break; + case "postgresql": + optionsBuilder.UseNpgsql(_ConnectionString); + break; + } } } @@ -105,13 +122,6 @@ namespace SharedLibraryCore.Database ent.HasIndex(a => a.Name); }); - modelBuilder.Entity(ent => - { - ent.Property(c => c.ChangeHistoryId) - .ValueGeneratedOnAdd() - .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - }); - // force full name for database conversion modelBuilder.Entity().ToTable("EFClients"); modelBuilder.Entity().ToTable("EFAlias"); @@ -134,11 +144,11 @@ namespace SharedLibraryCore.Database } } - directoryFiles = Directory.GetFiles(pluginDir).Where(f => f.Contains(".dll")); + directoryFiles = Directory.GetFiles(pluginDir).Where(f => f.EndsWith(".dll")); #if DEBUG == TRUE - foreach (string dllPath in Directory.GetFiles(@"C:\Projects\IW4M-Admin\Application\bin\Debug\netcoreapp2.1\Plugins")) + foreach (string dllPath in Directory.GetFiles(@"C:\Projects\IW4M-Admin\Application\bin\Debug\netcoreapp2.1\Plugins").Where(f => f.EndsWith(".dll"))) #else - foreach (string dllPath in directoryFiles) + foreach (string dllPath in directoryFiles) #endif { Assembly library; diff --git a/SharedLibraryCore/Database/Models/EFChangeHistory.cs b/SharedLibraryCore/Database/Models/EFChangeHistory.cs index 26e66d72c..c1b040be4 100644 --- a/SharedLibraryCore/Database/Models/EFChangeHistory.cs +++ b/SharedLibraryCore/Database/Models/EFChangeHistory.cs @@ -14,7 +14,8 @@ namespace SharedLibraryCore.Database.Models public enum ChangeType { Permission, - Ban + Ban, + Command } [Key] diff --git a/SharedLibraryCore/Events/EventAPI.cs b/SharedLibraryCore/Events/EventAPI.cs index acc124062..6cb461a84 100644 --- a/SharedLibraryCore/Events/EventAPI.cs +++ b/SharedLibraryCore/Events/EventAPI.cs @@ -1,8 +1,6 @@ using System; +using System.Collections.Concurrent; using System.Collections.Generic; -using System.Threading.Tasks; -using SharedLibraryCore.Database; -using SharedLibraryCore.Database.Models; using SharedLibraryCore.Dtos; namespace SharedLibraryCore.Events @@ -10,7 +8,7 @@ namespace SharedLibraryCore.Events public class EventApi { const int MaxEvents = 100; - static Queue RecentEvents = new Queue(); + static ConcurrentQueue RecentEvents = new ConcurrentQueue(); public static IEnumerable GetEvents(bool shouldConsume) { @@ -75,7 +73,7 @@ namespace SharedLibraryCore.Events { // remove the first added event if (RecentEvents.Count >= MaxEvents) - RecentEvents.Dequeue(); + RecentEvents.TryDequeue(out _); RecentEvents.Enqueue(info); } diff --git a/SharedLibraryCore/Events/GameEvent.cs b/SharedLibraryCore/Events/GameEvent.cs index 1bde1db78..2e34741b6 100644 --- a/SharedLibraryCore/Events/GameEvent.cs +++ b/SharedLibraryCore/Events/GameEvent.cs @@ -160,14 +160,14 @@ namespace SharedLibraryCore public static bool ShouldOriginEventBeDelayed(GameEvent queuedEvent) { return queuedEvent.Origin != null && - queuedEvent.Origin.State != Player.ClientState.Connected && + (queuedEvent.Origin.State != Player.ClientState.Connected && // we want to allow join and quit events queuedEvent.Type != EventType.Connect && queuedEvent.Type != EventType.Join && queuedEvent.Type != EventType.Quit && queuedEvent.Type != EventType.Disconnect && // we don't care about unknown events - queuedEvent.Origin.NetworkId != 0; + queuedEvent.Origin.NetworkId != 0); } /// @@ -179,10 +179,8 @@ namespace SharedLibraryCore public static bool ShouldTargetEventBeDelayed(GameEvent queuedEvent) { return queuedEvent.Target != null && - queuedEvent.Target.State != Player.ClientState.Connected && - queuedEvent.Target.NetworkId != 0; + (queuedEvent.Target.State != Player.ClientState.Connected && + queuedEvent.Target.NetworkId != 0); } - - public static bool IsEventTimeSensitive(GameEvent gameEvent) => gameEvent.Type == EventType.Connect; } } diff --git a/SharedLibraryCore/Migrations/20180409183408_InitialCreate.Designer.cs b/SharedLibraryCore/Migrations/20180409183408_InitialCreate.Designer.cs index 4beb9d71b..51200767d 100644 --- a/SharedLibraryCore/Migrations/20180409183408_InitialCreate.Designer.cs +++ b/SharedLibraryCore/Migrations/20180409183408_InitialCreate.Designer.cs @@ -193,7 +193,8 @@ namespace SharedLibraryCore.Migrations b.Property("LinkId"); b.Property("Name") - .IsRequired(); + .IsRequired() + .HasMaxLength(24); b.HasKey("AliasId"); diff --git a/SharedLibraryCore/Migrations/20180409183408_InitialCreate.cs b/SharedLibraryCore/Migrations/20180409183408_InitialCreate.cs index e713086f6..cec054675 100644 --- a/SharedLibraryCore/Migrations/20180409183408_InitialCreate.cs +++ b/SharedLibraryCore/Migrations/20180409183408_InitialCreate.cs @@ -1,4 +1,6 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using System; using System.Collections.Generic; @@ -13,7 +15,9 @@ namespace SharedLibraryCore.Migrations columns: table => new { AliasLinkId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false) }, constraints: table => @@ -25,7 +29,10 @@ namespace SharedLibraryCore.Migrations name: "EFServers", columns: table => new { - ServerId = table.Column(nullable: false), + ServerId = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), Port = table.Column(nullable: false) }, @@ -39,7 +46,9 @@ namespace SharedLibraryCore.Migrations columns: table => new { Vector3Id = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), X = table.Column(nullable: false), Y = table.Column(nullable: false), Z = table.Column(nullable: false) @@ -54,12 +63,14 @@ namespace SharedLibraryCore.Migrations columns: table => new { AliasId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), DateAdded = table.Column(nullable: false), IPAddress = table.Column(nullable: false), LinkId = table.Column(nullable: false), - Name = table.Column(nullable: false) + Name = table.Column(maxLength: 128, nullable: false) }, constraints: table => { @@ -77,7 +88,9 @@ namespace SharedLibraryCore.Migrations columns: table => new { StatisticId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), ServerId = table.Column(nullable: false), TotalKills = table.Column(nullable: false), @@ -99,7 +112,9 @@ namespace SharedLibraryCore.Migrations columns: table => new { ClientId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), AliasLinkId = table.Column(nullable: false), Connections = table.Column(nullable: false), @@ -135,7 +150,9 @@ namespace SharedLibraryCore.Migrations columns: table => new { KillId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true). + Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), AttackerId = table.Column(nullable: false), Damage = table.Column(nullable: false), @@ -196,7 +213,9 @@ namespace SharedLibraryCore.Migrations columns: table => new { MessageId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), ClientId = table.Column(nullable: false), Message = table.Column(nullable: true), @@ -255,7 +274,9 @@ namespace SharedLibraryCore.Migrations columns: table => new { PenaltyId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), Expires = table.Column(nullable: false), LinkId = table.Column(nullable: false), @@ -293,7 +314,9 @@ namespace SharedLibraryCore.Migrations columns: table => new { HitLocationCountId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true). + Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn). + Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), EFClientStatistics_ClientId = table.Column(nullable: false), HitCount = table.Column(nullable: false), diff --git a/SharedLibraryCore/Migrations/20180531212903_AddAutomatedOffenseAndRatingHistory.cs b/SharedLibraryCore/Migrations/20180531212903_AddAutomatedOffenseAndRatingHistory.cs index 79f1f6204..620eacf47 100644 --- a/SharedLibraryCore/Migrations/20180531212903_AddAutomatedOffenseAndRatingHistory.cs +++ b/SharedLibraryCore/Migrations/20180531212903_AddAutomatedOffenseAndRatingHistory.cs @@ -1,4 +1,6 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using System; using System.Collections.Generic; @@ -18,7 +20,9 @@ namespace SharedLibraryCore.Migrations columns: table => new { RatingHistoryId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), ClientId = table.Column(nullable: false) }, @@ -38,7 +42,9 @@ namespace SharedLibraryCore.Migrations columns: table => new { RatingId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), Newest = table.Column(nullable: false), Performance = table.Column(nullable: false), diff --git a/SharedLibraryCore/Migrations/20180602041758_AddClientMeta.cs b/SharedLibraryCore/Migrations/20180602041758_AddClientMeta.cs index 16a31f69e..2aa91d5af 100644 --- a/SharedLibraryCore/Migrations/20180602041758_AddClientMeta.cs +++ b/SharedLibraryCore/Migrations/20180602041758_AddClientMeta.cs @@ -1,4 +1,6 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using System; using System.Collections.Generic; @@ -13,7 +15,9 @@ namespace SharedLibraryCore.Migrations columns: table => new { MetaId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), ClientId = table.Column(nullable: false), Created = table.Column(nullable: false), diff --git a/SharedLibraryCore/Migrations/20180605191706_AddEFACSnapshots.Designer.cs b/SharedLibraryCore/Migrations/20180605191706_AddEFACSnapshots.Designer.cs index 479412937..a2c31824f 100644 --- a/SharedLibraryCore/Migrations/20180605191706_AddEFACSnapshots.Designer.cs +++ b/SharedLibraryCore/Migrations/20180605191706_AddEFACSnapshots.Designer.cs @@ -34,7 +34,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -74,7 +74,7 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); b.HasIndex("HitDestinationVector3Id"); @@ -463,7 +463,7 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() diff --git a/SharedLibraryCore/Migrations/20180605191706_AddEFACSnapshots.cs b/SharedLibraryCore/Migrations/20180605191706_AddEFACSnapshots.cs index 399ee1f95..bcd5c9460 100644 --- a/SharedLibraryCore/Migrations/20180605191706_AddEFACSnapshots.cs +++ b/SharedLibraryCore/Migrations/20180605191706_AddEFACSnapshots.cs @@ -1,4 +1,6 @@ -using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using System; using System.Collections.Generic; @@ -18,12 +20,14 @@ namespace SharedLibraryCore.Migrations columns: table => new { SnapshotId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), Active = table.Column(nullable: false), ClientId = table.Column(nullable: false), CurrentSessionLength = table.Column(nullable: false), CurrentStrain = table.Column(nullable: false), - CurrentViewAngleVector3Id = table.Column(nullable: true), + CurrentViewAngleId = table.Column(nullable: true), Deaths = table.Column(nullable: false), Distance = table.Column(nullable: false), EloRating = table.Column(nullable: false), @@ -52,8 +56,8 @@ namespace SharedLibraryCore.Migrations principalColumn: "ClientId", onDelete: ReferentialAction.Cascade); table.ForeignKey( - name: "FK_EFACSnapshot_Vector3_CurrentViewAngleVector3Id", - column: x => x.CurrentViewAngleVector3Id, + name: "FK_EFACSnapshot_Vector3_CurrentViewAngleId", + column: x => x.CurrentViewAngleId, principalTable: "Vector3", principalColumn: "Vector3Id", onDelete: ReferentialAction.Restrict); @@ -88,9 +92,9 @@ namespace SharedLibraryCore.Migrations column: "ClientId"); migrationBuilder.CreateIndex( - name: "IX_EFACSnapshot_CurrentViewAngleVector3Id", + name: "IX_EFACSnapshot_CurrentViewAngleId", table: "EFACSnapshot", - column: "CurrentViewAngleVector3Id"); + column: "CurrentViewAngleId"); migrationBuilder.CreateIndex( name: "IX_EFACSnapshot_HitDestinationVector3Id", @@ -107,13 +111,16 @@ namespace SharedLibraryCore.Migrations table: "EFACSnapshot", column: "LastStrainAngleVector3Id"); - /* migrationBuilder.AddForeignKey( + if (migrationBuilder.ActiveProvider != "Microsoft.EntityFrameworkCore.Sqlite") + { + migrationBuilder.AddForeignKey( name: "FK_Vector3_EFACSnapshot_EFACSnapshotSnapshotId", table: "Vector3", column: "EFACSnapshotSnapshotId", principalTable: "EFACSnapshot", principalColumn: "SnapshotId", - onDelete: ReferentialAction.Restrict);*/ + onDelete: ReferentialAction.Restrict); + } } protected override void Down(MigrationBuilder migrationBuilder) diff --git a/SharedLibraryCore/Migrations/20180614014303_IndexForEFAlias.Designer.cs b/SharedLibraryCore/Migrations/20180614014303_IndexForEFAlias.Designer.cs index 9d25be797..894981672 100644 --- a/SharedLibraryCore/Migrations/20180614014303_IndexForEFAlias.Designer.cs +++ b/SharedLibraryCore/Migrations/20180614014303_IndexForEFAlias.Designer.cs @@ -34,7 +34,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -74,7 +74,7 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); b.HasIndex("HitDestinationVector3Id"); @@ -463,7 +463,7 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() diff --git a/SharedLibraryCore/Migrations/20180902035612_AddFractionAndIsKill.Designer.cs b/SharedLibraryCore/Migrations/20180902035612_AddFractionAndIsKill.Designer.cs index 7ea59d814..9d0f5ab1c 100644 --- a/SharedLibraryCore/Migrations/20180902035612_AddFractionAndIsKill.Designer.cs +++ b/SharedLibraryCore/Migrations/20180902035612_AddFractionAndIsKill.Designer.cs @@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -71,7 +71,7 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); b.HasIndex("HitDestinationVector3Id"); @@ -489,7 +489,7 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() diff --git a/SharedLibraryCore/Migrations/20180902035612_AddFractionAndIsKill.cs b/SharedLibraryCore/Migrations/20180902035612_AddFractionAndIsKill.cs index 0ed888e5c..16505dd4a 100644 --- a/SharedLibraryCore/Migrations/20180902035612_AddFractionAndIsKill.cs +++ b/SharedLibraryCore/Migrations/20180902035612_AddFractionAndIsKill.cs @@ -1,5 +1,7 @@ using System; +using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; namespace SharedLibraryCore.Migrations { @@ -23,9 +25,11 @@ namespace SharedLibraryCore.Migrations name: "EFChangeHistory", columns: table => new { - Active = table.Column(nullable: false), ChangeHistoryId = table.Column(nullable: false) - .Annotation("Sqlite:Autoincrement", true), + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Active = table.Column(nullable: false), OriginEntityId = table.Column(nullable: false), TargetEntityId = table.Column(nullable: false), TypeOfChange = table.Column(nullable: false), diff --git a/SharedLibraryCore/Migrations/20180904154622_AddVisibilityPercentage.Designer.cs b/SharedLibraryCore/Migrations/20180904154622_AddVisibilityPercentage.Designer.cs index 226e330dc..d6c51939a 100644 --- a/SharedLibraryCore/Migrations/20180904154622_AddVisibilityPercentage.Designer.cs +++ b/SharedLibraryCore/Migrations/20180904154622_AddVisibilityPercentage.Designer.cs @@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -71,7 +71,7 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); b.HasIndex("HitDestinationVector3Id"); @@ -489,7 +489,7 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() diff --git a/SharedLibraryCore/Migrations/20180907020706_AddVision.Designer.cs b/SharedLibraryCore/Migrations/20180907020706_AddVision.Designer.cs index f152174d9..461dad07b 100644 --- a/SharedLibraryCore/Migrations/20180907020706_AddVision.Designer.cs +++ b/SharedLibraryCore/Migrations/20180907020706_AddVision.Designer.cs @@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -71,7 +71,7 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); b.HasIndex("HitDestinationVector3Id"); @@ -493,7 +493,7 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() diff --git a/SharedLibraryCore/Migrations/20180908004053_AddWhenToRating.Designer.cs b/SharedLibraryCore/Migrations/20180908004053_AddWhenToRating.Designer.cs index be77e226a..f72cd6da8 100644 --- a/SharedLibraryCore/Migrations/20180908004053_AddWhenToRating.Designer.cs +++ b/SharedLibraryCore/Migrations/20180908004053_AddWhenToRating.Designer.cs @@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -71,7 +71,7 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); b.HasIndex("HitDestinationVector3Id"); @@ -493,7 +493,7 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() diff --git a/SharedLibraryCore/Migrations/20180910221749_AddRatingIndexes.Designer.cs b/SharedLibraryCore/Migrations/20180910221749_AddRatingIndexes.Designer.cs index 231f84763..5dfa35a8e 100644 --- a/SharedLibraryCore/Migrations/20180910221749_AddRatingIndexes.Designer.cs +++ b/SharedLibraryCore/Migrations/20180910221749_AddRatingIndexes.Designer.cs @@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -71,7 +71,7 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); b.HasIndex("HitDestinationVector3Id"); @@ -501,7 +501,7 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() diff --git a/SharedLibraryCore/Migrations/20180911184224_AddEFAliasNameIndex.Designer.cs b/SharedLibraryCore/Migrations/20180911184224_AddEFAliasNameIndex.Designer.cs index 68ad1472e..e2f3504b6 100644 --- a/SharedLibraryCore/Migrations/20180911184224_AddEFAliasNameIndex.Designer.cs +++ b/SharedLibraryCore/Migrations/20180911184224_AddEFAliasNameIndex.Designer.cs @@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -71,7 +71,7 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); b.HasIndex("HitDestinationVector3Id"); @@ -503,7 +503,7 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() diff --git a/SharedLibraryCore/Migrations/20180911190418_AddEFAliasNameMaxLength.cs b/SharedLibraryCore/Migrations/20180911190418_AddEFAliasNameMaxLength.cs deleted file mode 100644 index 41d807db7..000000000 --- a/SharedLibraryCore/Migrations/20180911190418_AddEFAliasNameMaxLength.cs +++ /dev/null @@ -1,17 +0,0 @@ -using Microsoft.EntityFrameworkCore.Migrations; - -namespace SharedLibraryCore.Migrations -{ - public partial class AddEFAliasNameMaxLength : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/SharedLibraryCore/Migrations/20180911190823_AddEFAliasNameMaxLength24.Designer.cs b/SharedLibraryCore/Migrations/20180911190823_AddEFAliasNameMaxLength24.Designer.cs index 63ee9b549..714c1ddfd 100644 --- a/SharedLibraryCore/Migrations/20180911190823_AddEFAliasNameMaxLength24.Designer.cs +++ b/SharedLibraryCore/Migrations/20180911190823_AddEFAliasNameMaxLength24.Designer.cs @@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -71,7 +71,7 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); b.HasIndex("HitDestinationVector3Id"); @@ -504,7 +504,7 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() diff --git a/SharedLibraryCore/Migrations/20180912015012_AddPreviousCurrentValueToEFChangeHistory.Designer.cs b/SharedLibraryCore/Migrations/20180912015012_AddPreviousCurrentValueToEFChangeHistory.Designer.cs index 4db53a4f1..c8b715c42 100644 --- a/SharedLibraryCore/Migrations/20180912015012_AddPreviousCurrentValueToEFChangeHistory.Designer.cs +++ b/SharedLibraryCore/Migrations/20180912015012_AddPreviousCurrentValueToEFChangeHistory.Designer.cs @@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -71,7 +71,7 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); b.HasIndex("HitDestinationVector3Id"); @@ -508,7 +508,7 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() diff --git a/SharedLibraryCore/Migrations/20180912015012_AddPreviousCurrentValueToEFChangeHistory.cs b/SharedLibraryCore/Migrations/20180912015012_AddPreviousCurrentValueToEFChangeHistory.cs index 2ccf0c2a9..6fba7b033 100644 --- a/SharedLibraryCore/Migrations/20180912015012_AddPreviousCurrentValueToEFChangeHistory.cs +++ b/SharedLibraryCore/Migrations/20180912015012_AddPreviousCurrentValueToEFChangeHistory.cs @@ -12,6 +12,7 @@ namespace SharedLibraryCore.Migrations nullable: true); migrationBuilder.AddColumn( + name: "PreviousValue", table: "EFChangeHistory", nullable: true); diff --git a/SharedLibraryCore/Migrations/20180915163111_AddIndexToMessageTimeSent.Designer.cs b/SharedLibraryCore/Migrations/20180915163111_AddIndexToMessageTimeSent.Designer.cs index ce6881460..d13a69e8c 100644 --- a/SharedLibraryCore/Migrations/20180915163111_AddIndexToMessageTimeSent.Designer.cs +++ b/SharedLibraryCore/Migrations/20180915163111_AddIndexToMessageTimeSent.Designer.cs @@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -71,7 +71,7 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); b.HasIndex("HitDestinationVector3Id"); @@ -510,7 +510,7 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() diff --git a/SharedLibraryCore/Migrations/20180915164118_ForceAutoIncrementChangeHistory.cs b/SharedLibraryCore/Migrations/20180915164118_ForceAutoIncrementChangeHistory.cs deleted file mode 100644 index 846e6f2df..000000000 --- a/SharedLibraryCore/Migrations/20180915164118_ForceAutoIncrementChangeHistory.cs +++ /dev/null @@ -1,25 +0,0 @@ -using Microsoft.EntityFrameworkCore.Metadata; -using Microsoft.EntityFrameworkCore.Migrations; - -namespace SharedLibraryCore.Migrations -{ - public partial class ForceAutoIncrementChangeHistory : Migration - { - protected override void Up(MigrationBuilder migrationBuilder) - { - // hack: we can't alter the column on SQLite, but we need max length limit for the Index in MySQL etc - if (migrationBuilder.ActiveProvider != "Microsoft.EntityFrameworkCore.Sqlite") - { - migrationBuilder.AlterColumn( - name: "ChangeHistoryId", - table: "EFChangeHistory" - ).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); - } - } - - protected override void Down(MigrationBuilder migrationBuilder) - { - - } - } -} diff --git a/SharedLibraryCore/Migrations/20180911190418_AddEFAliasNameMaxLength.Designer.cs b/SharedLibraryCore/Migrations/20180922231310_RemoveACSnapShot.Designer.cs similarity index 84% rename from SharedLibraryCore/Migrations/20180911190418_AddEFAliasNameMaxLength.Designer.cs rename to SharedLibraryCore/Migrations/20180922231310_RemoveACSnapShot.Designer.cs index 81dafef70..b5ed15ac1 100644 --- a/SharedLibraryCore/Migrations/20180911190418_AddEFAliasNameMaxLength.Designer.cs +++ b/SharedLibraryCore/Migrations/20180922231310_RemoveACSnapShot.Designer.cs @@ -9,78 +9,14 @@ using SharedLibraryCore.Database; namespace SharedLibraryCore.Migrations { [DbContext(typeof(DatabaseContext))] - [Migration("20180911190418_AddEFAliasNameMaxLength")] - partial class AddEFAliasNameMaxLength + [Migration("20180922231310_RemoveACSnapShot")] + partial class RemoveACSnapShot { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.1.2-rtm-30932"); - - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFACSnapshot", b => - { - b.Property("SnapshotId") - .ValueGeneratedOnAdd(); - - b.Property("Active"); - - b.Property("ClientId"); - - b.Property("CurrentSessionLength"); - - b.Property("CurrentStrain"); - - b.Property("CurrentViewAngleVector3Id"); - - b.Property("Deaths"); - - b.Property("Distance"); - - b.Property("EloRating"); - - b.Property("HitDestinationVector3Id"); - - b.Property("HitLocation"); - - b.Property("HitOriginVector3Id"); - - b.Property("HitType"); - - b.Property("Hits"); - - b.Property("Kills"); - - b.Property("LastStrainAngleVector3Id"); - - b.Property("SessionAngleOffset"); - - b.Property("SessionSPM"); - - b.Property("SessionScore"); - - b.Property("StrainAngleBetween"); - - b.Property("TimeSinceLastEvent"); - - b.Property("WeaponId"); - - b.Property("When"); - - b.HasKey("SnapshotId"); - - b.HasIndex("ClientId"); - - b.HasIndex("CurrentViewAngleVector3Id"); - - b.HasIndex("HitDestinationVector3Id"); - - b.HasIndex("HitOriginVector3Id"); - - b.HasIndex("LastStrainAngleVector3Id"); - - b.ToTable("EFACSnapshot"); - }); + .HasAnnotation("ProductVersion", "2.1.3-rtm-32065"); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientKill", b => { @@ -157,6 +93,8 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ServerId"); + b.HasIndex("TimeSent"); + b.ToTable("EFClientMessages"); }); @@ -358,8 +296,12 @@ namespace SharedLibraryCore.Migrations b.Property("Comment") .HasMaxLength(128); + b.Property("CurrentValue"); + b.Property("OriginEntityId"); + b.Property("PreviousValue"); + b.Property("TargetEntityId"); b.Property("TimeChanged"); @@ -480,8 +422,6 @@ namespace SharedLibraryCore.Migrations b.Property("Vector3Id") .ValueGeneratedOnAdd(); - b.Property("EFACSnapshotSnapshotId"); - b.Property("X"); b.Property("Y"); @@ -490,35 +430,9 @@ namespace SharedLibraryCore.Migrations b.HasKey("Vector3Id"); - b.HasIndex("EFACSnapshotSnapshotId"); - b.ToTable("Vector3"); }); - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFACSnapshot", b => - { - b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client") - .WithMany() - .HasForeignKey("ClientId") - .OnDelete(DeleteBehavior.Cascade); - - b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") - .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); - - b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") - .WithMany() - .HasForeignKey("HitDestinationVector3Id"); - - b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitOrigin") - .WithMany() - .HasForeignKey("HitOriginVector3Id"); - - b.HasOne("SharedLibraryCore.Helpers.Vector3", "LastStrainAngle") - .WithMany() - .HasForeignKey("LastStrainAngleVector3Id"); - }); - modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientKill", b => { b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Attacker") @@ -667,13 +581,6 @@ namespace SharedLibraryCore.Migrations .HasForeignKey("PunisherId") .OnDelete(DeleteBehavior.Restrict); }); - - modelBuilder.Entity("SharedLibraryCore.Helpers.Vector3", b => - { - b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFACSnapshot") - .WithMany("PredictedViewAngles") - .HasForeignKey("EFACSnapshotSnapshotId"); - }); #pragma warning restore 612, 618 } } diff --git a/SharedLibraryCore/Migrations/20180922231310_RemoveACSnapShot.cs b/SharedLibraryCore/Migrations/20180922231310_RemoveACSnapShot.cs new file mode 100644 index 000000000..1b43c8f10 --- /dev/null +++ b/SharedLibraryCore/Migrations/20180922231310_RemoveACSnapShot.cs @@ -0,0 +1,139 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace SharedLibraryCore.Migrations +{ + public partial class RemoveACSnapShot : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + if (migrationBuilder.ActiveProvider != "Microsoft.EntityFrameworkCore.Sqlite") + { + migrationBuilder.DropForeignKey( + name: "FK_Vector3_EFACSnapshot_EFACSnapshotSnapshotId", + table: "Vector3"); + + migrationBuilder.DropColumn( + name: "EFACSnapshotSnapshotId", + table: "Vector3"); + } + + migrationBuilder.DropTable( + name: "EFACSnapshot"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.AddColumn( + name: "EFACSnapshotSnapshotId", + table: "Vector3", + nullable: true); + + migrationBuilder.CreateTable( + name: "EFACSnapshot", + columns: table => new + { + SnapshotId = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + Active = table.Column(nullable: false), + ClientId = table.Column(nullable: false), + CurrentSessionLength = table.Column(nullable: false), + CurrentStrain = table.Column(nullable: false), + CurrentViewAngleId = table.Column(nullable: true), + Deaths = table.Column(nullable: false), + Distance = table.Column(nullable: false), + EloRating = table.Column(nullable: false), + HitDestinationVector3Id = table.Column(nullable: true), + HitLocation = table.Column(nullable: false), + HitOriginVector3Id = table.Column(nullable: true), + HitType = table.Column(nullable: false), + Hits = table.Column(nullable: false), + Kills = table.Column(nullable: false), + LastStrainAngleVector3Id = table.Column(nullable: true), + SessionAngleOffset = table.Column(nullable: false), + SessionSPM = table.Column(nullable: false), + SessionScore = table.Column(nullable: false), + StrainAngleBetween = table.Column(nullable: false), + TimeSinceLastEvent = table.Column(nullable: false), + WeaponId = table.Column(nullable: false), + When = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EFACSnapshot", x => x.SnapshotId); + table.ForeignKey( + name: "FK_EFACSnapshot_EFClients_ClientId", + column: x => x.ClientId, + principalTable: "EFClients", + principalColumn: "ClientId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_EFACSnapshot_Vector3_CurrentViewAngleId", + column: x => x.CurrentViewAngleId, + principalTable: "Vector3", + principalColumn: "Vector3Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_EFACSnapshot_Vector3_HitDestinationVector3Id", + column: x => x.HitDestinationVector3Id, + principalTable: "Vector3", + principalColumn: "Vector3Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_EFACSnapshot_Vector3_HitOriginVector3Id", + column: x => x.HitOriginVector3Id, + principalTable: "Vector3", + principalColumn: "Vector3Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_EFACSnapshot_Vector3_LastStrainAngleVector3Id", + column: x => x.LastStrainAngleVector3Id, + principalTable: "Vector3", + principalColumn: "Vector3Id", + onDelete: ReferentialAction.Restrict); + }); + + migrationBuilder.CreateIndex( + name: "IX_Vector3_EFACSnapshotSnapshotId", + table: "Vector3", + column: "EFACSnapshotSnapshotId"); + + migrationBuilder.CreateIndex( + name: "IX_EFACSnapshot_ClientId", + table: "EFACSnapshot", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_EFACSnapshot_CurrentViewAngleId", + table: "EFACSnapshot", + column: "CurrentViewAngleId"); + + migrationBuilder.CreateIndex( + name: "IX_EFACSnapshot_HitDestinationVector3Id", + table: "EFACSnapshot", + column: "HitDestinationVector3Id"); + + migrationBuilder.CreateIndex( + name: "IX_EFACSnapshot_HitOriginVector3Id", + table: "EFACSnapshot", + column: "HitOriginVector3Id"); + + migrationBuilder.CreateIndex( + name: "IX_EFACSnapshot_LastStrainAngleVector3Id", + table: "EFACSnapshot", + column: "LastStrainAngleVector3Id"); + + migrationBuilder.AddForeignKey( + name: "FK_Vector3_EFACSnapshot_EFACSnapshotSnapshotId", + table: "Vector3", + column: "EFACSnapshotSnapshotId", + principalTable: "EFACSnapshot", + principalColumn: "SnapshotId", + onDelete: ReferentialAction.Restrict); + } + } +} diff --git a/SharedLibraryCore/Migrations/20180915164118_ForceAutoIncrementChangeHistory.Designer.cs b/SharedLibraryCore/Migrations/20180922231600_ReaddACSnapshot.Designer.cs similarity index 94% rename from SharedLibraryCore/Migrations/20180915164118_ForceAutoIncrementChangeHistory.Designer.cs rename to SharedLibraryCore/Migrations/20180922231600_ReaddACSnapshot.Designer.cs index 19b4b537e..b4238885a 100644 --- a/SharedLibraryCore/Migrations/20180915164118_ForceAutoIncrementChangeHistory.Designer.cs +++ b/SharedLibraryCore/Migrations/20180922231600_ReaddACSnapshot.Designer.cs @@ -2,7 +2,6 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; using SharedLibraryCore.Database; @@ -10,14 +9,14 @@ using SharedLibraryCore.Database; namespace SharedLibraryCore.Migrations { [DbContext(typeof(DatabaseContext))] - [Migration("20180915164118_ForceAutoIncrementChangeHistory")] - partial class ForceAutoIncrementChangeHistory + [Migration("20180922231600_ReaddACSnapshot")] + partial class ReaddACSnapshot { protected override void BuildTargetModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.1.2-rtm-30932"); + .HasAnnotation("ProductVersion", "2.1.3-rtm-32065"); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFACSnapshot", b => { @@ -32,7 +31,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -40,11 +39,11 @@ namespace SharedLibraryCore.Migrations b.Property("EloRating"); - b.Property("HitDestinationVector3Id"); + b.Property("HitDestinationId"); b.Property("HitLocation"); - b.Property("HitOriginVector3Id"); + b.Property("HitOriginId"); b.Property("HitType"); @@ -52,7 +51,7 @@ namespace SharedLibraryCore.Migrations b.Property("Kills"); - b.Property("LastStrainAngleVector3Id"); + b.Property("LastStrainAngleId"); b.Property("SessionAngleOffset"); @@ -72,13 +71,13 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); - b.HasIndex("HitDestinationVector3Id"); + b.HasIndex("HitDestinationId"); - b.HasIndex("HitOriginVector3Id"); + b.HasIndex("HitOriginId"); - b.HasIndex("LastStrainAngleVector3Id"); + b.HasIndex("LastStrainAngleId"); b.ToTable("EFACSnapshot"); }); @@ -354,8 +353,7 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("SharedLibraryCore.Database.Models.EFChangeHistory", b => { b.Property("ChangeHistoryId") - .ValueGeneratedOnAdd() - .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + .ValueGeneratedOnAdd(); b.Property("Active"); @@ -512,19 +510,22 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId"); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() - .HasForeignKey("HitDestinationVector3Id"); + .HasForeignKey("HitDestinationId") + .OnDelete(DeleteBehavior.Cascade); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitOrigin") .WithMany() - .HasForeignKey("HitOriginVector3Id"); + .HasForeignKey("HitOriginId") + .OnDelete(DeleteBehavior.Cascade); b.HasOne("SharedLibraryCore.Helpers.Vector3", "LastStrainAngle") .WithMany() - .HasForeignKey("LastStrainAngleVector3Id"); + .HasForeignKey("LastStrainAngleId") + .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientKill", b => diff --git a/SharedLibraryCore/Migrations/20180922231600_ReaddACSnapshot.cs b/SharedLibraryCore/Migrations/20180922231600_ReaddACSnapshot.cs new file mode 100644 index 000000000..3050d297e --- /dev/null +++ b/SharedLibraryCore/Migrations/20180922231600_ReaddACSnapshot.cs @@ -0,0 +1,145 @@ +using System; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; + +namespace SharedLibraryCore.Migrations +{ + public partial class ReaddACSnapshot : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + migrationBuilder.CreateTable( + name: "EFACSnapshot", + columns: table => new + { + Active = table.Column(nullable: false), + SnapshotId = table.Column(nullable: false) + .Annotation("Sqlite:Autoincrement", true) + .Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn), + ClientId = table.Column(nullable: false), + When = table.Column(nullable: false), + CurrentSessionLength = table.Column(nullable: false), + TimeSinceLastEvent = table.Column(nullable: false), + EloRating = table.Column(nullable: false), + SessionScore = table.Column(nullable: false), + SessionSPM = table.Column(nullable: false), + Hits = table.Column(nullable: false), + Kills = table.Column(nullable: false), + Deaths = table.Column(nullable: false), + CurrentStrain = table.Column(nullable: false), + StrainAngleBetween = table.Column(nullable: false), + SessionAngleOffset = table.Column(nullable: false), + LastStrainAngleId = table.Column(nullable: false), + HitOriginId = table.Column(nullable: false), + HitDestinationId = table.Column(nullable: false), + Distance = table.Column(nullable: false), + CurrentViewAngleId = table.Column(nullable: true), + WeaponId = table.Column(nullable: false), + HitLocation = table.Column(nullable: false), + HitType = table.Column(nullable: false) + }, + constraints: table => + { + table.PrimaryKey("PK_EFACSnapshot", x => x.SnapshotId); + table.ForeignKey( + name: "FK_EFACSnapshot_EFClients_ClientId", + column: x => x.ClientId, + principalTable: "EFClients", + principalColumn: "ClientId", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_EFACSnapshot_Vector3_CurrentViewAngleId", + column: x => x.CurrentViewAngleId, + principalTable: "Vector3", + principalColumn: "Vector3Id", + onDelete: ReferentialAction.Restrict); + table.ForeignKey( + name: "FK_EFACSnapshot_Vector3_HitDestinationId", + column: x => x.HitDestinationId, + principalTable: "Vector3", + principalColumn: "Vector3Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_EFACSnapshot_Vector3_HitOriginId", + column: x => x.HitOriginId, + principalTable: "Vector3", + principalColumn: "Vector3Id", + onDelete: ReferentialAction.Cascade); + table.ForeignKey( + name: "FK_EFACSnapshot_Vector3_LastStrainAngleId", + column: x => x.LastStrainAngleId, + principalTable: "Vector3", + principalColumn: "Vector3Id", + onDelete: ReferentialAction.Cascade); + }); + + if (migrationBuilder.ActiveProvider != "Microsoft.EntityFrameworkCore.Sqlite") + { + migrationBuilder.AddColumn( + name: "EFACSnapshotSnapshotId", + table: "Vector3", + nullable: true); + + migrationBuilder.AddForeignKey( + name: "FK_Vector3_EFACSnapshot_EFACSnapshotSnapshotId", + table: "Vector3", + column: "EFACSnapshotSnapshotId", + principalTable: "EFACSnapshot", + principalColumn: "SnapshotId", + onDelete: ReferentialAction.Restrict); + + } + + migrationBuilder.CreateIndex( + name: "IX_Vector3_EFACSnapshotSnapshotId", + table: "Vector3", + column: "EFACSnapshotSnapshotId"); + + migrationBuilder.CreateIndex( + name: "IX_EFACSnapshot_ClientId", + table: "EFACSnapshot", + column: "ClientId"); + + migrationBuilder.CreateIndex( + name: "IX_EFACSnapshot_CurrentViewAngleId", + table: "EFACSnapshot", + column: "CurrentViewAngleId"); + + migrationBuilder.CreateIndex( + name: "IX_EFACSnapshot_HitDestinationId", + table: "EFACSnapshot", + column: "HitDestinationId"); + + migrationBuilder.CreateIndex( + name: "IX_EFACSnapshot_HitOriginId", + table: "EFACSnapshot", + column: "HitOriginId"); + + migrationBuilder.CreateIndex( + name: "IX_EFACSnapshot_LastStrainAngleId", + table: "EFACSnapshot", + column: "LastStrainAngleId"); + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + migrationBuilder.DropForeignKey( + name: "FK_Vector3_EFACSnapshot_EFACSnapshotSnapshotId", + table: "Vector3"); + + migrationBuilder.DropTable( + name: "EFACSnapshot"); + + migrationBuilder.DropIndex( + name: "IX_Vector3_EFACSnapshotSnapshotId", + table: "Vector3"); + + migrationBuilder.DropColumn( + name: "EFACSnapshotSnapshotId", + table: "Vector3"); + } + } +} diff --git a/SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs b/SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs index f30c8183a..acce2cb5e 100644 --- a/SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs +++ b/SharedLibraryCore/Migrations/DatabaseContextModelSnapshot.cs @@ -2,8 +2,8 @@ using System; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Infrastructure; -using Microsoft.EntityFrameworkCore.Metadata; using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata; using SharedLibraryCore.Database; namespace SharedLibraryCore.Migrations @@ -15,7 +15,9 @@ namespace SharedLibraryCore.Migrations { #pragma warning disable 612, 618 modelBuilder - .HasAnnotation("ProductVersion", "2.1.2-rtm-30932"); + .HasAnnotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn) + .HasAnnotation("ProductVersion", "2.1.3-rtm-32065") + .HasAnnotation("Relational:MaxIdentifierLength", 63); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFACSnapshot", b => { @@ -30,7 +32,7 @@ namespace SharedLibraryCore.Migrations b.Property("CurrentStrain"); - b.Property("CurrentViewAngleVector3Id"); + b.Property("CurrentViewAngleId"); b.Property("Deaths"); @@ -38,11 +40,11 @@ namespace SharedLibraryCore.Migrations b.Property("EloRating"); - b.Property("HitDestinationVector3Id"); + b.Property("HitDestinationId"); b.Property("HitLocation"); - b.Property("HitOriginVector3Id"); + b.Property("HitOriginId"); b.Property("HitType"); @@ -50,7 +52,7 @@ namespace SharedLibraryCore.Migrations b.Property("Kills"); - b.Property("LastStrainAngleVector3Id"); + b.Property("LastStrainAngleId"); b.Property("SessionAngleOffset"); @@ -70,13 +72,13 @@ namespace SharedLibraryCore.Migrations b.HasIndex("ClientId"); - b.HasIndex("CurrentViewAngleVector3Id"); + b.HasIndex("CurrentViewAngleId"); - b.HasIndex("HitDestinationVector3Id"); + b.HasIndex("HitDestinationId"); - b.HasIndex("HitOriginVector3Id"); + b.HasIndex("HitOriginId"); - b.HasIndex("LastStrainAngleVector3Id"); + b.HasIndex("LastStrainAngleId"); b.ToTable("EFACSnapshot"); }); @@ -352,8 +354,7 @@ namespace SharedLibraryCore.Migrations modelBuilder.Entity("SharedLibraryCore.Database.Models.EFChangeHistory", b => { b.Property("ChangeHistoryId") - .ValueGeneratedOnAdd() - .HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn); + .ValueGeneratedOnAdd(); b.Property("Active"); @@ -510,19 +511,23 @@ namespace SharedLibraryCore.Migrations b.HasOne("SharedLibraryCore.Helpers.Vector3", "CurrentViewAngle") .WithMany() - .HasForeignKey("CurrentViewAngleVector3Id"); + .HasForeignKey("CurrentViewAngleId") + .OnDelete(DeleteBehavior.Cascade); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitDestination") .WithMany() - .HasForeignKey("HitDestinationVector3Id"); + .HasForeignKey("HitDestinationId") + .OnDelete(DeleteBehavior.Cascade); b.HasOne("SharedLibraryCore.Helpers.Vector3", "HitOrigin") .WithMany() - .HasForeignKey("HitOriginVector3Id"); + .HasForeignKey("HitOriginId") + .OnDelete(DeleteBehavior.Cascade); b.HasOne("SharedLibraryCore.Helpers.Vector3", "LastStrainAngle") .WithMany() - .HasForeignKey("LastStrainAngleVector3Id"); + .HasForeignKey("LastStrainAngleId") + .OnDelete(DeleteBehavior.Cascade); }); modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientKill", b => diff --git a/SharedLibraryCore/Server.cs b/SharedLibraryCore/Server.cs index c8f896829..45932e2bd 100644 --- a/SharedLibraryCore/Server.cs +++ b/SharedLibraryCore/Server.cs @@ -107,7 +107,7 @@ namespace SharedLibraryCore /// /// Event /// True on sucess - abstract protected Task ProcessEvent(GameEvent E); + abstract protected Task ProcessEvent(GameEvent E); abstract public Task ExecuteEvent(GameEvent E); /// diff --git a/SharedLibraryCore/Services/ChangeHistoryService.cs b/SharedLibraryCore/Services/ChangeHistoryService.cs index 097d105f6..b27a728ce 100644 --- a/SharedLibraryCore/Services/ChangeHistoryService.cs +++ b/SharedLibraryCore/Services/ChangeHistoryService.cs @@ -32,6 +32,15 @@ namespace SharedLibraryCore.Services }; break; case GameEvent.EventType.Command: + change = new EFChangeHistory() + { + OriginEntityId = e.Origin.ClientId, + TargetEntityId = e.Target?.ClientId ?? 0, + Comment = "Executed command", + PreviousValue = "", + CurrentValue = e.Message, + TypeOfChange = EFChangeHistory.ChangeType.Command + }; break; case GameEvent.EventType.ChangePermission: change = new EFChangeHistory() @@ -59,6 +68,7 @@ namespace SharedLibraryCore.Services catch (Exception ex) { + e.Owner.Logger.WriteWarning(ex.Message); e.Owner.Logger.WriteDebug(ex.GetExceptionInfo()); } } diff --git a/SharedLibraryCore/Services/GenericRepository.cs b/SharedLibraryCore/Services/GenericRepository.cs index edae65771..60abe2bce 100644 --- a/SharedLibraryCore/Services/GenericRepository.cs +++ b/SharedLibraryCore/Services/GenericRepository.cs @@ -21,7 +21,7 @@ namespace SharedLibraryCore.Services { if (_context == null) { - _context = new DatabaseContext(); + _context = new DatabaseContext(true); } return _context; diff --git a/SharedLibraryCore/SharedLibraryCore.csproj b/SharedLibraryCore/SharedLibraryCore.csproj index 3522e9b87..6e1126566 100644 --- a/SharedLibraryCore/SharedLibraryCore.csproj +++ b/SharedLibraryCore/SharedLibraryCore.csproj @@ -14,19 +14,26 @@ + + + + + - - - + + + + + diff --git a/WebfrontCore/WebfrontCore.csproj b/WebfrontCore/WebfrontCore.csproj index d92977f7d..cb3641752 100644 --- a/WebfrontCore/WebfrontCore.csproj +++ b/WebfrontCore/WebfrontCore.csproj @@ -2,7 +2,8 @@ netcoreapp2.1 - false + false + false true 2.6 RaidMax.IW4MAdmin.WebfrontCore