a ton of stuff and fix migations

This commit is contained in:
RaidMax 2018-09-23 19:45:54 -05:00
parent 0f9d2e92e1
commit 5d93e7ac57
45 changed files with 706 additions and 461 deletions

View File

@ -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)

View File

@ -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<Player> GetActiveClients()
{
var ActiveClients = new List<Player>();
foreach (var server in _servers)
ActiveClients.AddRange(server.Players.Where(p => p != null));
return ActiveClients;
}
public IList<Player> GetActiveClients() => _servers.SelectMany(s => s.Players).Where(p => p != null).ToList();
public ClientService GetClientService() => ClientSvc;
public AliasService GetAliasService() => AliasSvc;

View File

@ -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
/// </summary>
/// <param name="E"></param>
/// <returns></returns>
override protected async Task ProcessEvent(GameEvent E)
override protected async Task<bool> 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;
}
/// <summary>
@ -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
}

View File

@ -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

View File

@ -16,9 +16,9 @@ namespace IW4MAdmin.Plugins.ProfanityDeterment
{
OffensiveWords = new List<string>()
{
"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;

View File

@ -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,

View File

@ -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<EFClientStatistics>()
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);
}
}
}
}

View File

@ -42,7 +42,7 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
public EFClientStatistics GetClientStats(int clientId, int serverId) => Servers[serverId].PlayerStats[clientId];
public Expression<Func<EFRating, bool>> GetRankingFunc(int? serverId = null)
public static Expression<Func<EFRating, bool>> 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;
}
/// <summary>
/// gets a ranking across all servers for given client id
/// </summary>
@ -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,27 +490,37 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
clientStats.HitLocations.Single(hl => hl.Location == hit.HitLoc).HitCount += 1;
}
using (var ctx = new DatabaseContext())
{
await OnProcessingPenalty.WaitAsync();
try
{
if (Plugin.Config.Configuration().StoreClientKills)
{
ctx.Set<EFClientKill>().Add(hit);
}
if (Plugin.Config.Configuration().EnableAntiCheat)
{
await ApplyPenalty(clientDetection.ProcessKill(hit, isDamage), clientDetection, attacker);
await ApplyPenalty(clientDetection.ProcessTotalRatio(clientStats), clientDetection, attacker);
await ApplyPenalty(clientDetection.ProcessKill(hit, isDamage), clientDetection, attacker, ctx);
await ApplyPenalty(clientDetection.ProcessTotalRatio(clientStats), clientDetection, attacker, ctx);
}
await ctx.SaveChangesAsync();
await clientStatsSvc.SaveChangesAsync();
}
if (Plugin.Config.Configuration().StoreClientKills)
catch (Exception ex)
{
using (var ctx = new DatabaseContext())
{
ctx.Set<EFClientKill>().Add(hit);
await ctx.SaveChangesAsync();
}
OnProcessingPenalty.Release(1);
}
}
async Task ApplyPenalty(Cheat.DetectionPenaltyResult penalty, Cheat.Detection clientDetection, Player attacker)
{
try
async Task ApplyPenalty(Cheat.DetectionPenaltyResult penalty, Cheat.Detection clientDetection, Player attacker, DatabaseContext ctx)
{
switch (penalty.ClientPenalty)
{
@ -513,10 +529,6 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
{
break;
}
if (clientDetection.Tracker.HasChanges)
{
await SaveTrackedSnapshots(clientDetection);
}
await attacker.Ban(Utilities.CurrentLocalization.LocalizationIndex["PLUGIN_STATS_CHEAT_DETECTED"], new Player()
{
ClientId = 1,
@ -530,16 +542,16 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
}
}
});
if (clientDetection.Tracker.HasChanges)
{
SaveTrackedSnapshots(clientDetection, ctx);
}
break;
case Penalty.PenaltyType.Flag:
if (attacker.Level != Player.Permission.User)
{
break;
}
if (clientDetection.Tracker.HasChanges)
{
await SaveTrackedSnapshots(clientDetection);
}
var e = new GameEvent()
{
Data = penalty.Type == Cheat.Detection.DetectionType.Bone ?
@ -560,40 +572,65 @@ namespace IW4MAdmin.Plugins.Stats.Helpers
// 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;
}
}
catch
{
}
}
async Task SaveTrackedSnapshots(Cheat.Detection clientDetection)
{
await OnProcessingPenalty.WaitAsync();
using (var ctx = new DatabaseContext(true))
void SaveTrackedSnapshots(Cheat.Detection clientDetection, DatabaseContext ctx)
{
// 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.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);
}
ctx.Add(change);
}
try
{
await ctx.SaveChangesAsync();
}
catch (Exception ex)
{
Log.WriteWarning(ex.GetExceptionInfo());
}
}
OnProcessingPenalty.Release(1);
}
public async Task AddStandardKill(Player attacker, Player victim)

View File

@ -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

View File

@ -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; }

View File

@ -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; }

View File

@ -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
/// </summary>
private static string _ConnectionString;
private static string _provider;
public DatabaseContext(DbContextOptions<DatabaseContext> 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
{
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<EFChangeHistory>(ent =>
{
ent.Property(c => c.ChangeHistoryId)
.ValueGeneratedOnAdd()
.HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
});
// force full name for database conversion
modelBuilder.Entity<EFClient>().ToTable("EFClients");
modelBuilder.Entity<EFAlias>().ToTable("EFAlias");
@ -134,9 +144,9 @@ 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)
#endif

View File

@ -14,7 +14,8 @@ namespace SharedLibraryCore.Database.Models
public enum ChangeType
{
Permission,
Ban
Ban,
Command
}
[Key]

View File

@ -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<EventInfo> RecentEvents = new Queue<EventInfo>();
static ConcurrentQueue<EventInfo> RecentEvents = new ConcurrentQueue<EventInfo>();
public static IEnumerable<EventInfo> 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);
}

View File

@ -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);
}
/// <summary>
@ -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;
}
}

View File

@ -193,7 +193,8 @@ namespace SharedLibraryCore.Migrations
b.Property<int>("LinkId");
b.Property<string>("Name")
.IsRequired();
.IsRequired()
.HasMaxLength(24);
b.HasKey("AliasId");

View File

@ -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<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false)
},
constraints: table =>
@ -25,7 +29,10 @@ namespace SharedLibraryCore.Migrations
name: "EFServers",
columns: table => new
{
ServerId = table.Column<int>(nullable: false),
ServerId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
Port = table.Column<int>(nullable: false)
},
@ -39,7 +46,9 @@ namespace SharedLibraryCore.Migrations
columns: table => new
{
Vector3Id = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
X = table.Column<float>(nullable: false),
Y = table.Column<float>(nullable: false),
Z = table.Column<float>(nullable: false)
@ -54,12 +63,14 @@ namespace SharedLibraryCore.Migrations
columns: table => new
{
AliasId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
DateAdded = table.Column<DateTime>(nullable: false),
IPAddress = table.Column<int>(nullable: false),
LinkId = table.Column<int>(nullable: false),
Name = table.Column<string>(nullable: false)
Name = table.Column<string>(maxLength: 128, nullable: false)
},
constraints: table =>
{
@ -77,7 +88,9 @@ namespace SharedLibraryCore.Migrations
columns: table => new
{
StatisticId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
ServerId = table.Column<int>(nullable: false),
TotalKills = table.Column<long>(nullable: false),
@ -99,7 +112,9 @@ namespace SharedLibraryCore.Migrations
columns: table => new
{
ClientId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
AliasLinkId = table.Column<int>(nullable: false),
Connections = table.Column<int>(nullable: false),
@ -135,7 +150,9 @@ namespace SharedLibraryCore.Migrations
columns: table => new
{
KillId = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true).
Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
AttackerId = table.Column<int>(nullable: false),
Damage = table.Column<int>(nullable: false),
@ -196,7 +213,9 @@ namespace SharedLibraryCore.Migrations
columns: table => new
{
MessageId = table.Column<long>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
ClientId = table.Column<int>(nullable: false),
Message = table.Column<string>(nullable: true),
@ -255,7 +274,9 @@ namespace SharedLibraryCore.Migrations
columns: table => new
{
PenaltyId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
Expires = table.Column<DateTime>(nullable: false),
LinkId = table.Column<int>(nullable: false),
@ -293,7 +314,9 @@ namespace SharedLibraryCore.Migrations
columns: table => new
{
HitLocationCountId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true).
Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn).
Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
EFClientStatistics_ClientId = table.Column<int>(nullable: false),
HitCount = table.Column<int>(nullable: false),

View File

@ -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<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
ClientId = table.Column<int>(nullable: false)
},
@ -38,7 +42,9 @@ namespace SharedLibraryCore.Migrations
columns: table => new
{
RatingId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
Newest = table.Column<bool>(nullable: false),
Performance = table.Column<double>(nullable: false),

View File

@ -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<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
ClientId = table.Column<int>(nullable: false),
Created = table.Column<DateTime>(nullable: false),

View File

@ -34,7 +34,7 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("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()

View File

@ -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<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
ClientId = table.Column<int>(nullable: false),
CurrentSessionLength = table.Column<int>(nullable: false),
CurrentStrain = table.Column<double>(nullable: false),
CurrentViewAngleVector3Id = table.Column<int>(nullable: true),
CurrentViewAngleId = table.Column<int>(nullable: true),
Deaths = table.Column<int>(nullable: false),
Distance = table.Column<double>(nullable: false),
EloRating = table.Column<double>(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)

View File

@ -34,7 +34,7 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("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()

View File

@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("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()

View File

@ -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<bool>(nullable: false),
ChangeHistoryId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true),
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
OriginEntityId = table.Column<int>(nullable: false),
TargetEntityId = table.Column<int>(nullable: false),
TypeOfChange = table.Column<int>(nullable: false),

View File

@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("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()

View File

@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("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()

View File

@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("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()

View File

@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("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()

View File

@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("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()

View File

@ -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)
{
}
}
}

View File

@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("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()

View File

@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("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()

View File

@ -12,6 +12,7 @@ namespace SharedLibraryCore.Migrations
nullable: true);
migrationBuilder.AddColumn<string>(
name: "PreviousValue",
table: "EFChangeHistory",
nullable: true);

View File

@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("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()

View File

@ -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<int>(
name: "ChangeHistoryId",
table: "EFChangeHistory"
).Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
}
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

View File

@ -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<int>("SnapshotId")
.ValueGeneratedOnAdd();
b.Property<bool>("Active");
b.Property<int>("ClientId");
b.Property<int>("CurrentSessionLength");
b.Property<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int>("Deaths");
b.Property<double>("Distance");
b.Property<double>("EloRating");
b.Property<int?>("HitDestinationVector3Id");
b.Property<int>("HitLocation");
b.Property<int?>("HitOriginVector3Id");
b.Property<int>("HitType");
b.Property<int>("Hits");
b.Property<int>("Kills");
b.Property<int?>("LastStrainAngleVector3Id");
b.Property<double>("SessionAngleOffset");
b.Property<double>("SessionSPM");
b.Property<int>("SessionScore");
b.Property<double>("StrainAngleBetween");
b.Property<int>("TimeSinceLastEvent");
b.Property<int>("WeaponId");
b.Property<DateTime>("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<string>("Comment")
.HasMaxLength(128);
b.Property<string>("CurrentValue");
b.Property<int>("OriginEntityId");
b.Property<string>("PreviousValue");
b.Property<int>("TargetEntityId");
b.Property<DateTime>("TimeChanged");
@ -480,8 +422,6 @@ namespace SharedLibraryCore.Migrations
b.Property<int>("Vector3Id")
.ValueGeneratedOnAdd();
b.Property<int?>("EFACSnapshotSnapshotId");
b.Property<float>("X");
b.Property<float>("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
}
}

View File

@ -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<int>(
name: "EFACSnapshotSnapshotId",
table: "Vector3",
nullable: true);
migrationBuilder.CreateTable(
name: "EFACSnapshot",
columns: table => new
{
SnapshotId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Active = table.Column<bool>(nullable: false),
ClientId = table.Column<int>(nullable: false),
CurrentSessionLength = table.Column<int>(nullable: false),
CurrentStrain = table.Column<double>(nullable: false),
CurrentViewAngleId = table.Column<int>(nullable: true),
Deaths = table.Column<int>(nullable: false),
Distance = table.Column<double>(nullable: false),
EloRating = table.Column<double>(nullable: false),
HitDestinationVector3Id = table.Column<int>(nullable: true),
HitLocation = table.Column<int>(nullable: false),
HitOriginVector3Id = table.Column<int>(nullable: true),
HitType = table.Column<int>(nullable: false),
Hits = table.Column<int>(nullable: false),
Kills = table.Column<int>(nullable: false),
LastStrainAngleVector3Id = table.Column<int>(nullable: true),
SessionAngleOffset = table.Column<double>(nullable: false),
SessionSPM = table.Column<double>(nullable: false),
SessionScore = table.Column<int>(nullable: false),
StrainAngleBetween = table.Column<double>(nullable: false),
TimeSinceLastEvent = table.Column<int>(nullable: false),
WeaponId = table.Column<int>(nullable: false),
When = table.Column<DateTime>(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);
}
}
}

View File

@ -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<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int?>("CurrentViewAngleId");
b.Property<int>("Deaths");
@ -40,11 +39,11 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("EloRating");
b.Property<int?>("HitDestinationVector3Id");
b.Property<int>("HitDestinationId");
b.Property<int>("HitLocation");
b.Property<int?>("HitOriginVector3Id");
b.Property<int>("HitOriginId");
b.Property<int>("HitType");
@ -52,7 +51,7 @@ namespace SharedLibraryCore.Migrations
b.Property<int>("Kills");
b.Property<int?>("LastStrainAngleVector3Id");
b.Property<int>("LastStrainAngleId");
b.Property<double>("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<int>("ChangeHistoryId")
.ValueGeneratedOnAdd()
.HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
.ValueGeneratedOnAdd();
b.Property<bool>("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 =>

View File

@ -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<bool>(nullable: false),
SnapshotId = table.Column<int>(nullable: false)
.Annotation("Sqlite:Autoincrement", true)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.SerialColumn)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
ClientId = table.Column<int>(nullable: false),
When = table.Column<DateTime>(nullable: false),
CurrentSessionLength = table.Column<int>(nullable: false),
TimeSinceLastEvent = table.Column<int>(nullable: false),
EloRating = table.Column<double>(nullable: false),
SessionScore = table.Column<int>(nullable: false),
SessionSPM = table.Column<double>(nullable: false),
Hits = table.Column<int>(nullable: false),
Kills = table.Column<int>(nullable: false),
Deaths = table.Column<int>(nullable: false),
CurrentStrain = table.Column<double>(nullable: false),
StrainAngleBetween = table.Column<double>(nullable: false),
SessionAngleOffset = table.Column<double>(nullable: false),
LastStrainAngleId = table.Column<int>(nullable: false),
HitOriginId = table.Column<int>(nullable: false),
HitDestinationId = table.Column<int>(nullable: false),
Distance = table.Column<double>(nullable: false),
CurrentViewAngleId = table.Column<int>(nullable: true),
WeaponId = table.Column<int>(nullable: false),
HitLocation = table.Column<int>(nullable: false),
HitType = table.Column<int>(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<int>(
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");
}
}
}

View File

@ -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<double>("CurrentStrain");
b.Property<int?>("CurrentViewAngleVector3Id");
b.Property<int>("CurrentViewAngleId");
b.Property<int>("Deaths");
@ -38,11 +40,11 @@ namespace SharedLibraryCore.Migrations
b.Property<double>("EloRating");
b.Property<int?>("HitDestinationVector3Id");
b.Property<int>("HitDestinationId");
b.Property<int>("HitLocation");
b.Property<int?>("HitOriginVector3Id");
b.Property<int>("HitOriginId");
b.Property<int>("HitType");
@ -50,7 +52,7 @@ namespace SharedLibraryCore.Migrations
b.Property<int>("Kills");
b.Property<int?>("LastStrainAngleVector3Id");
b.Property<int>("LastStrainAngleId");
b.Property<double>("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<int>("ChangeHistoryId")
.ValueGeneratedOnAdd()
.HasAnnotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn);
.ValueGeneratedOnAdd();
b.Property<bool>("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 =>

View File

@ -107,7 +107,7 @@ namespace SharedLibraryCore
/// </summary>
/// <param name="E">Event</param>
/// <returns>True on sucess</returns>
abstract protected Task ProcessEvent(GameEvent E);
abstract protected Task<bool> ProcessEvent(GameEvent E);
abstract public Task ExecuteEvent(GameEvent E);
/// <summary>

View File

@ -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());
}
}

View File

@ -21,7 +21,7 @@ namespace SharedLibraryCore.Services
{
if (_context == null)
{
_context = new DatabaseContext();
_context = new DatabaseContext(true);
}
return _context;

View File

@ -14,19 +14,26 @@
<ItemGroup>
<Compile Remove="Migrations\20180502195240_Update.cs" />
<Compile Remove="Migrations\20180923025324_FixForPostgreSQL.cs" />
<Compile Remove="Migrations\20180923025702_FixForPostgreSQL.cs" />
<Compile Remove="Migrations\20180923030248_FixForPostgreSQL.cs" />
<Compile Remove="Migrations\20180923030426_FixForPostgreSQL.cs" />
<Compile Remove="Migrations\20180923030528_FixForPostgreSQL.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Jint" Version="2.11.58" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="2.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="2.1.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.1.3" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Npgsql" Version="4.0.3" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.1.2" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="2.1.2" />
<PackageReference Include="SimpleCrypto.NetCore" Version="1.0.0" />
</ItemGroup>

View File

@ -2,7 +2,8 @@
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<MvcRazorCompileOnPublish>false</MvcRazorCompileOnPublish>
<RazorCompileOnBuild>false</RazorCompileOnBuild>
<RazorCompileOnPublish>false</RazorCompileOnPublish>
<PreserveCompilationContext>true</PreserveCompilationContext>
<TypeScriptToolsVersion>2.6</TypeScriptToolsVersion>
<PackageId>RaidMax.IW4MAdmin.WebfrontCore</PackageId>