1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-06-10 15:20:48 -05:00

a ton of stuff and fix migations

This commit is contained in:
RaidMax
2018-09-23 19:45:54 -05:00
parent 134f16861e
commit 6b8c112ccf
45 changed files with 706 additions and 461 deletions

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
{
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<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,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;

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>