mirror of
https://github.com/RaidMax/IW4M-Admin.git
synced 2025-06-10 15:20:48 -05:00
migrate welcome plugin to .NET Core 2.0
more fixes to stats database for migration last connection set when client connects and disconnects update GeoIP datatbase
This commit is contained in:
@ -17,6 +17,10 @@ namespace SharedLibraryCore.Database
|
||||
|
||||
public async Task Seed()
|
||||
{
|
||||
// make sure database exists
|
||||
//context.Database.EnsureCreated();
|
||||
context.Database.Migrate();
|
||||
|
||||
if (context.AliasLinks.Count() == 0)
|
||||
{
|
||||
context.AliasLinks.Add(new EFAliasLink()
|
||||
|
@ -63,6 +63,12 @@ namespace SharedLibraryCore.Database
|
||||
.OnDelete(DeleteBehavior.Restrict);
|
||||
});
|
||||
|
||||
// force full name for database conversion
|
||||
modelBuilder.Entity<EFClient>().ToTable("EFClients");
|
||||
modelBuilder.Entity<EFAlias>().ToTable("EFAlias");
|
||||
modelBuilder.Entity<EFAliasLink>().ToTable("EFAliasLinks");
|
||||
modelBuilder.Entity<EFPenalty>().ToTable("EFPenalties");
|
||||
|
||||
// https://aleemkhan.wordpress.com/2013/02/28/dynamically-adding-dbset-properties-in-dbcontext-for-entity-framework-code-first/
|
||||
#if !DEBUG
|
||||
foreach (string dllPath in Directory.GetFiles($"{Utilities.OperatingDirectory}Plugins"))
|
||||
|
@ -12,7 +12,7 @@ using System;
|
||||
namespace SharedLibraryCore.Migrations
|
||||
{
|
||||
[DbContext(typeof(DatabaseContext))]
|
||||
[Migration("20180408213153_Initial Create")]
|
||||
[Migration("20180409183408_InitialCreate")]
|
||||
partial class InitialCreate
|
||||
{
|
||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
||||
@ -66,7 +66,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasIndex("ViewAnglesVector3Id");
|
||||
|
||||
b.ToTable("EFClientKill");
|
||||
b.ToTable("EFClientKills");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientMessage", b =>
|
||||
@ -90,7 +90,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.ToTable("EFClientMessage");
|
||||
b.ToTable("EFClientMessages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics", b =>
|
||||
@ -125,9 +125,8 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.Property<bool>("Active");
|
||||
|
||||
b.Property<int?>("EFClientStatisticsClientId");
|
||||
|
||||
b.Property<int?>("EFClientStatisticsServerId");
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnName("EFClientStatistics_ClientId");
|
||||
|
||||
b.Property<int>("HitCount");
|
||||
|
||||
@ -135,11 +134,16 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.Property<int>("Location");
|
||||
|
||||
b.Property<int>("ServerId")
|
||||
.HasColumnName("EFClientStatistics_ServerId");
|
||||
|
||||
b.HasKey("HitLocationCountId");
|
||||
|
||||
b.HasIndex("EFClientStatisticsClientId", "EFClientStatisticsServerId");
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.ToTable("EFHitLocationCount");
|
||||
b.HasIndex("ClientId", "ServerId");
|
||||
|
||||
b.ToTable("EFHitLocationCounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServer", b =>
|
||||
@ -152,7 +156,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasKey("ServerId");
|
||||
|
||||
b.ToTable("EFServer");
|
||||
b.ToTable("EFServers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServerStatistics", b =>
|
||||
@ -195,7 +199,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasIndex("LinkId");
|
||||
|
||||
b.ToTable("Aliases");
|
||||
b.ToTable("EFAlias");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SharedLibraryCore.Database.Models.EFAliasLink", b =>
|
||||
@ -207,7 +211,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasKey("AliasLinkId");
|
||||
|
||||
b.ToTable("AliasLinks");
|
||||
b.ToTable("EFAliasLinks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SharedLibraryCore.Database.Models.EFClient", b =>
|
||||
@ -248,7 +252,7 @@ namespace SharedLibraryCore.Migrations
|
||||
b.HasIndex("NetworkId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Clients");
|
||||
b.ToTable("EFClients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SharedLibraryCore.Database.Models.EFPenalty", b =>
|
||||
@ -281,7 +285,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasIndex("PunisherId");
|
||||
|
||||
b.ToTable("Penalties");
|
||||
b.ToTable("EFPenalties");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SharedLibraryCore.Helpers.Vector3", b =>
|
||||
@ -358,9 +362,20 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFHitLocationCount", b =>
|
||||
{
|
||||
b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServerId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics")
|
||||
.WithMany("HitLocations")
|
||||
.HasForeignKey("EFClientStatisticsClientId", "EFClientStatisticsServerId");
|
||||
.HasForeignKey("ClientId", "ServerId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServerStatistics", b =>
|
@ -9,7 +9,7 @@ namespace SharedLibraryCore.Migrations
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "AliasLinks",
|
||||
name: "EFAliasLinks",
|
||||
columns: table => new
|
||||
{
|
||||
AliasLinkId = table.Column<int>(nullable: false)
|
||||
@ -18,11 +18,11 @@ namespace SharedLibraryCore.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_AliasLinks", x => x.AliasLinkId);
|
||||
table.PrimaryKey("PK_EFAliasLinks", x => x.AliasLinkId);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EFServer",
|
||||
name: "EFServers",
|
||||
columns: table => new
|
||||
{
|
||||
ServerId = table.Column<int>(nullable: false),
|
||||
@ -31,7 +31,7 @@ namespace SharedLibraryCore.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EFServer", x => x.ServerId);
|
||||
table.PrimaryKey("PK_EFServers", x => x.ServerId);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
@ -50,7 +50,7 @@ namespace SharedLibraryCore.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Aliases",
|
||||
name: "EFAlias",
|
||||
columns: table => new
|
||||
{
|
||||
AliasId = table.Column<int>(nullable: false)
|
||||
@ -63,11 +63,11 @@ namespace SharedLibraryCore.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Aliases", x => x.AliasId);
|
||||
table.PrimaryKey("PK_EFAlias", x => x.AliasId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Aliases_AliasLinks_LinkId",
|
||||
name: "FK_EFAlias_EFAliasLinks_LinkId",
|
||||
column: x => x.LinkId,
|
||||
principalTable: "AliasLinks",
|
||||
principalTable: "EFAliasLinks",
|
||||
principalColumn: "AliasLinkId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
@ -87,15 +87,15 @@ namespace SharedLibraryCore.Migrations
|
||||
{
|
||||
table.PrimaryKey("PK_EFServerStatistics", x => x.StatisticId);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFServerStatistics_EFServer_ServerId",
|
||||
name: "FK_EFServerStatistics_EFServers_ServerId",
|
||||
column: x => x.ServerId,
|
||||
principalTable: "EFServer",
|
||||
principalTable: "EFServers",
|
||||
principalColumn: "ServerId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Clients",
|
||||
name: "EFClients",
|
||||
columns: table => new
|
||||
{
|
||||
ClientId = table.Column<int>(nullable: false)
|
||||
@ -115,23 +115,23 @@ namespace SharedLibraryCore.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Clients", x => x.ClientId);
|
||||
table.PrimaryKey("PK_EFClients", x => x.ClientId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Clients_AliasLinks_AliasLinkId",
|
||||
name: "FK_EFClients_EFAliasLinks_AliasLinkId",
|
||||
column: x => x.AliasLinkId,
|
||||
principalTable: "AliasLinks",
|
||||
principalTable: "EFAliasLinks",
|
||||
principalColumn: "AliasLinkId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Clients_Aliases_CurrentAliasId",
|
||||
name: "FK_EFClients_EFAlias_CurrentAliasId",
|
||||
column: x => x.CurrentAliasId,
|
||||
principalTable: "Aliases",
|
||||
principalTable: "EFAlias",
|
||||
principalColumn: "AliasId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EFClientKill",
|
||||
name: "EFClientKills",
|
||||
columns: table => new
|
||||
{
|
||||
KillId = table.Column<long>(nullable: false)
|
||||
@ -152,39 +152,39 @@ namespace SharedLibraryCore.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EFClientKill", x => x.KillId);
|
||||
table.PrimaryKey("PK_EFClientKills", x => x.KillId);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFClientKill_Clients_AttackerId",
|
||||
name: "FK_EFClientKills_EFClients_AttackerId",
|
||||
column: x => x.AttackerId,
|
||||
principalTable: "Clients",
|
||||
principalTable: "EFClients",
|
||||
principalColumn: "ClientId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFClientKill_Vector3_DeathOriginVector3Id",
|
||||
name: "FK_EFClientKills_Vector3_DeathOriginVector3Id",
|
||||
column: x => x.DeathOriginVector3Id,
|
||||
principalTable: "Vector3",
|
||||
principalColumn: "Vector3Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFClientKill_Vector3_KillOriginVector3Id",
|
||||
name: "FK_EFClientKills_Vector3_KillOriginVector3Id",
|
||||
column: x => x.KillOriginVector3Id,
|
||||
principalTable: "Vector3",
|
||||
principalColumn: "Vector3Id",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFClientKill_EFServer_ServerId",
|
||||
name: "FK_EFClientKills_EFServers_ServerId",
|
||||
column: x => x.ServerId,
|
||||
principalTable: "EFServer",
|
||||
principalTable: "EFServers",
|
||||
principalColumn: "ServerId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFClientKill_Clients_VictimId",
|
||||
name: "FK_EFClientKills_EFClients_VictimId",
|
||||
column: x => x.VictimId,
|
||||
principalTable: "Clients",
|
||||
principalTable: "EFClients",
|
||||
principalColumn: "ClientId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFClientKill_Vector3_ViewAnglesVector3Id",
|
||||
name: "FK_EFClientKills_Vector3_ViewAnglesVector3Id",
|
||||
column: x => x.ViewAnglesVector3Id,
|
||||
principalTable: "Vector3",
|
||||
principalColumn: "Vector3Id",
|
||||
@ -192,7 +192,7 @@ namespace SharedLibraryCore.Migrations
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EFClientMessage",
|
||||
name: "EFClientMessages",
|
||||
columns: table => new
|
||||
{
|
||||
MessageId = table.Column<long>(nullable: false)
|
||||
@ -205,17 +205,17 @@ namespace SharedLibraryCore.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EFClientMessage", x => x.MessageId);
|
||||
table.PrimaryKey("PK_EFClientMessages", x => x.MessageId);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFClientMessage_Clients_ClientId",
|
||||
name: "FK_EFClientMessages_EFClients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalTable: "EFClients",
|
||||
principalColumn: "ClientId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFClientMessage_EFServer_ServerId",
|
||||
name: "FK_EFClientMessages_EFServers_ServerId",
|
||||
column: x => x.ServerId,
|
||||
principalTable: "EFServer",
|
||||
principalTable: "EFServers",
|
||||
principalColumn: "ServerId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
@ -237,21 +237,21 @@ namespace SharedLibraryCore.Migrations
|
||||
{
|
||||
table.PrimaryKey("PK_EFClientStatistics", x => new { x.ClientId, x.ServerId });
|
||||
table.ForeignKey(
|
||||
name: "FK_EFClientStatistics_Clients_ClientId",
|
||||
name: "FK_EFClientStatistics_EFClients_ClientId",
|
||||
column: x => x.ClientId,
|
||||
principalTable: "Clients",
|
||||
principalTable: "EFClients",
|
||||
principalColumn: "ClientId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFClientStatistics_EFServer_ServerId",
|
||||
name: "FK_EFClientStatistics_EFServers_ServerId",
|
||||
column: x => x.ServerId,
|
||||
principalTable: "EFServer",
|
||||
principalTable: "EFServers",
|
||||
principalColumn: "ServerId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Penalties",
|
||||
name: "EFPenalties",
|
||||
columns: table => new
|
||||
{
|
||||
PenaltyId = table.Column<int>(nullable: false)
|
||||
@ -267,160 +267,177 @@ namespace SharedLibraryCore.Migrations
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Penalties", x => x.PenaltyId);
|
||||
table.PrimaryKey("PK_EFPenalties", x => x.PenaltyId);
|
||||
table.ForeignKey(
|
||||
name: "FK_Penalties_AliasLinks_LinkId",
|
||||
name: "FK_EFPenalties_EFAliasLinks_LinkId",
|
||||
column: x => x.LinkId,
|
||||
principalTable: "AliasLinks",
|
||||
principalTable: "EFAliasLinks",
|
||||
principalColumn: "AliasLinkId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Penalties_Clients_OffenderId",
|
||||
name: "FK_EFPenalties_EFClients_OffenderId",
|
||||
column: x => x.OffenderId,
|
||||
principalTable: "Clients",
|
||||
principalTable: "EFClients",
|
||||
principalColumn: "ClientId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
table.ForeignKey(
|
||||
name: "FK_Penalties_Clients_PunisherId",
|
||||
name: "FK_EFPenalties_EFClients_PunisherId",
|
||||
column: x => x.PunisherId,
|
||||
principalTable: "Clients",
|
||||
principalTable: "EFClients",
|
||||
principalColumn: "ClientId",
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EFHitLocationCount",
|
||||
name: "EFHitLocationCounts",
|
||||
columns: table => new
|
||||
{
|
||||
HitLocationCountId = table.Column<int>(nullable: false)
|
||||
.Annotation("Sqlite:Autoincrement", true),
|
||||
Active = table.Column<bool>(nullable: false),
|
||||
EFClientStatisticsClientId = table.Column<int>(nullable: true),
|
||||
EFClientStatisticsServerId = table.Column<int>(nullable: true),
|
||||
EFClientStatistics_ClientId = table.Column<int>(nullable: false),
|
||||
HitCount = table.Column<int>(nullable: false),
|
||||
HitOffsetAverage = table.Column<float>(nullable: false),
|
||||
Location = table.Column<int>(nullable: false)
|
||||
Location = table.Column<int>(nullable: false),
|
||||
EFClientStatistics_ServerId = table.Column<int>(nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EFHitLocationCount", x => x.HitLocationCountId);
|
||||
table.PrimaryKey("PK_EFHitLocationCounts", x => x.HitLocationCountId);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFHitLocationCount_EFClientStatistics_EFClientStatisticsClientId_EFClientStatisticsServerId",
|
||||
columns: x => new { x.EFClientStatisticsClientId, x.EFClientStatisticsServerId },
|
||||
name: "FK_EFHitLocationCounts_EFClients_EFClientStatistics_ClientId",
|
||||
column: x => x.EFClientStatistics_ClientId,
|
||||
principalTable: "EFClients",
|
||||
principalColumn: "ClientId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFHitLocationCounts_EFServers_EFClientStatistics_ServerId",
|
||||
column: x => x.EFClientStatistics_ServerId,
|
||||
principalTable: "EFServers",
|
||||
principalColumn: "ServerId",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_EFHitLocationCounts_EFClientStatistics_EFClientStatistics_ClientId_EFClientStatistics_ServerId",
|
||||
columns: x => new { x.EFClientStatistics_ClientId, x.EFClientStatistics_ServerId },
|
||||
principalTable: "EFClientStatistics",
|
||||
principalColumns: new[] { "ClientId", "ServerId" },
|
||||
onDelete: ReferentialAction.Restrict);
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Aliases_LinkId",
|
||||
table: "Aliases",
|
||||
name: "IX_EFAlias_LinkId",
|
||||
table: "EFAlias",
|
||||
column: "LinkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Clients_AliasLinkId",
|
||||
table: "Clients",
|
||||
column: "AliasLinkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Clients_CurrentAliasId",
|
||||
table: "Clients",
|
||||
column: "CurrentAliasId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Clients_NetworkId",
|
||||
table: "Clients",
|
||||
column: "NetworkId",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientKill_AttackerId",
|
||||
table: "EFClientKill",
|
||||
name: "IX_EFClientKills_AttackerId",
|
||||
table: "EFClientKills",
|
||||
column: "AttackerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientKill_DeathOriginVector3Id",
|
||||
table: "EFClientKill",
|
||||
name: "IX_EFClientKills_DeathOriginVector3Id",
|
||||
table: "EFClientKills",
|
||||
column: "DeathOriginVector3Id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientKill_KillOriginVector3Id",
|
||||
table: "EFClientKill",
|
||||
name: "IX_EFClientKills_KillOriginVector3Id",
|
||||
table: "EFClientKills",
|
||||
column: "KillOriginVector3Id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientKill_ServerId",
|
||||
table: "EFClientKill",
|
||||
name: "IX_EFClientKills_ServerId",
|
||||
table: "EFClientKills",
|
||||
column: "ServerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientKill_VictimId",
|
||||
table: "EFClientKill",
|
||||
name: "IX_EFClientKills_VictimId",
|
||||
table: "EFClientKills",
|
||||
column: "VictimId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientKill_ViewAnglesVector3Id",
|
||||
table: "EFClientKill",
|
||||
name: "IX_EFClientKills_ViewAnglesVector3Id",
|
||||
table: "EFClientKills",
|
||||
column: "ViewAnglesVector3Id");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientMessage_ClientId",
|
||||
table: "EFClientMessage",
|
||||
name: "IX_EFClientMessages_ClientId",
|
||||
table: "EFClientMessages",
|
||||
column: "ClientId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientMessage_ServerId",
|
||||
table: "EFClientMessage",
|
||||
name: "IX_EFClientMessages_ServerId",
|
||||
table: "EFClientMessages",
|
||||
column: "ServerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClients_AliasLinkId",
|
||||
table: "EFClients",
|
||||
column: "AliasLinkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClients_CurrentAliasId",
|
||||
table: "EFClients",
|
||||
column: "CurrentAliasId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClients_NetworkId",
|
||||
table: "EFClients",
|
||||
column: "NetworkId",
|
||||
unique: true);
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFClientStatistics_ServerId",
|
||||
table: "EFClientStatistics",
|
||||
column: "ServerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFHitLocationCount_EFClientStatisticsClientId_EFClientStatisticsServerId",
|
||||
table: "EFHitLocationCount",
|
||||
columns: new[] { "EFClientStatisticsClientId", "EFClientStatisticsServerId" });
|
||||
name: "IX_EFHitLocationCounts_EFClientStatistics_ServerId",
|
||||
table: "EFHitLocationCounts",
|
||||
column: "EFClientStatistics_ServerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFHitLocationCounts_EFClientStatistics_ClientId_EFClientStatistics_ServerId",
|
||||
table: "EFHitLocationCounts",
|
||||
columns: new[] { "EFClientStatistics_ClientId", "EFClientStatistics_ServerId" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFPenalties_LinkId",
|
||||
table: "EFPenalties",
|
||||
column: "LinkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFPenalties_OffenderId",
|
||||
table: "EFPenalties",
|
||||
column: "OffenderId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFPenalties_PunisherId",
|
||||
table: "EFPenalties",
|
||||
column: "PunisherId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EFServerStatistics_ServerId",
|
||||
table: "EFServerStatistics",
|
||||
column: "ServerId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Penalties_LinkId",
|
||||
table: "Penalties",
|
||||
column: "LinkId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Penalties_OffenderId",
|
||||
table: "Penalties",
|
||||
column: "OffenderId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Penalties_PunisherId",
|
||||
table: "Penalties",
|
||||
column: "PunisherId");
|
||||
}
|
||||
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "EFClientKill");
|
||||
name: "EFClientKills");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EFClientMessage");
|
||||
name: "EFClientMessages");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EFHitLocationCount");
|
||||
name: "EFHitLocationCounts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EFPenalties");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EFServerStatistics");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Penalties");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Vector3");
|
||||
|
||||
@ -428,16 +445,16 @@ namespace SharedLibraryCore.Migrations
|
||||
name: "EFClientStatistics");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Clients");
|
||||
name: "EFClients");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EFServer");
|
||||
name: "EFServers");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Aliases");
|
||||
name: "EFAlias");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "AliasLinks");
|
||||
name: "EFAliasLinks");
|
||||
}
|
||||
}
|
||||
}
|
@ -65,7 +65,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasIndex("ViewAnglesVector3Id");
|
||||
|
||||
b.ToTable("EFClientKill");
|
||||
b.ToTable("EFClientKills");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientMessage", b =>
|
||||
@ -89,7 +89,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.ToTable("EFClientMessage");
|
||||
b.ToTable("EFClientMessages");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics", b =>
|
||||
@ -124,9 +124,8 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.Property<bool>("Active");
|
||||
|
||||
b.Property<int?>("EFClientStatisticsClientId");
|
||||
|
||||
b.Property<int?>("EFClientStatisticsServerId");
|
||||
b.Property<int>("ClientId")
|
||||
.HasColumnName("EFClientStatistics_ClientId");
|
||||
|
||||
b.Property<int>("HitCount");
|
||||
|
||||
@ -134,11 +133,16 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.Property<int>("Location");
|
||||
|
||||
b.Property<int>("ServerId")
|
||||
.HasColumnName("EFClientStatistics_ServerId");
|
||||
|
||||
b.HasKey("HitLocationCountId");
|
||||
|
||||
b.HasIndex("EFClientStatisticsClientId", "EFClientStatisticsServerId");
|
||||
b.HasIndex("ServerId");
|
||||
|
||||
b.ToTable("EFHitLocationCount");
|
||||
b.HasIndex("ClientId", "ServerId");
|
||||
|
||||
b.ToTable("EFHitLocationCounts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServer", b =>
|
||||
@ -151,7 +155,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasKey("ServerId");
|
||||
|
||||
b.ToTable("EFServer");
|
||||
b.ToTable("EFServers");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServerStatistics", b =>
|
||||
@ -194,7 +198,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasIndex("LinkId");
|
||||
|
||||
b.ToTable("Aliases");
|
||||
b.ToTable("EFAlias");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SharedLibraryCore.Database.Models.EFAliasLink", b =>
|
||||
@ -206,7 +210,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasKey("AliasLinkId");
|
||||
|
||||
b.ToTable("AliasLinks");
|
||||
b.ToTable("EFAliasLinks");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SharedLibraryCore.Database.Models.EFClient", b =>
|
||||
@ -247,7 +251,7 @@ namespace SharedLibraryCore.Migrations
|
||||
b.HasIndex("NetworkId")
|
||||
.IsUnique();
|
||||
|
||||
b.ToTable("Clients");
|
||||
b.ToTable("EFClients");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SharedLibraryCore.Database.Models.EFPenalty", b =>
|
||||
@ -280,7 +284,7 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
b.HasIndex("PunisherId");
|
||||
|
||||
b.ToTable("Penalties");
|
||||
b.ToTable("EFPenalties");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("SharedLibraryCore.Helpers.Vector3", b =>
|
||||
@ -357,9 +361,20 @@ namespace SharedLibraryCore.Migrations
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFHitLocationCount", b =>
|
||||
{
|
||||
b.HasOne("SharedLibraryCore.Database.Models.EFClient", "Client")
|
||||
.WithMany()
|
||||
.HasForeignKey("ClientId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFServer", "Server")
|
||||
.WithMany()
|
||||
.HasForeignKey("ServerId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
|
||||
b.HasOne("IW4MAdmin.Plugins.Stats.Models.EFClientStatistics")
|
||||
.WithMany("HitLocations")
|
||||
.HasForeignKey("EFClientStatisticsClientId", "EFClientStatisticsServerId");
|
||||
.HasForeignKey("ClientId", "ServerId")
|
||||
.OnDelete(DeleteBehavior.Cascade);
|
||||
});
|
||||
|
||||
modelBuilder.Entity("IW4MAdmin.Plugins.Stats.Models.EFServerStatistics", b =>
|
||||
|
@ -130,7 +130,10 @@ namespace SharedLibraryCore.RCon
|
||||
#if DEBUG
|
||||
Log.WriteDebug($"Received {bytesRead} bytes from {ServerConnection.RemoteEndPoint}");
|
||||
#endif
|
||||
connectionState.ResponseString.Append(Encoding.UTF7.GetString(connectionState.Buffer, 0, bytesRead).TrimEnd('\0'));
|
||||
connectionState.ResponseString.Append(Encoding.UTF7.GetString(connectionState.Buffer, 0, bytesRead).TrimEnd('\0') + '\n');
|
||||
|
||||
if (!connectionState.Buffer.Take(4).ToArray().SequenceEqual(new byte[] { 0xFF, 0xFF, 0xFF, 0xFF }))
|
||||
throw new NetworkException("Unexpected packet received");
|
||||
|
||||
if (serverConnection.Available > 0)
|
||||
{
|
||||
@ -159,9 +162,9 @@ namespace SharedLibraryCore.RCon
|
||||
public async Task<string[]> SendQueryAsync(StaticHelpers.QueryType type, string parameters = "")
|
||||
{
|
||||
// will this really prevent flooding?
|
||||
if ((DateTime.Now - LastQuery).TotalMilliseconds < 150)
|
||||
if ((DateTime.Now - LastQuery).TotalMilliseconds < 35)
|
||||
{
|
||||
await Task.Delay(150);
|
||||
await Task.Delay(35);
|
||||
}
|
||||
|
||||
LastQuery = DateTime.Now;
|
||||
@ -174,10 +177,10 @@ namespace SharedLibraryCore.RCon
|
||||
{
|
||||
case StaticHelpers.QueryType.DVAR:
|
||||
case StaticHelpers.QueryType.COMMAND:
|
||||
queryString = $"ÿÿÿÿrcon {RConPassword} {parameters}";
|
||||
queryString = $"ÿÿÿÿ\x02rcon {RConPassword} {parameters}";
|
||||
break;
|
||||
case StaticHelpers.QueryType.GET_STATUS:
|
||||
queryString = "ÿÿÿÿgetstatus";
|
||||
queryString = "ÿÿÿÿ\x02getstatus";
|
||||
break;
|
||||
}
|
||||
|
||||
@ -288,8 +291,9 @@ namespace SharedLibraryCore.RCon
|
||||
|
||||
string[] splitResponse = queryResponse.Split(new char[]
|
||||
{
|
||||
StaticHelpers.SeperatorChar
|
||||
}, StringSplitOptions.RemoveEmptyEntries);
|
||||
'\n'
|
||||
}, StringSplitOptions.RemoveEmptyEntries)
|
||||
.Select(line => line.Trim()).ToArray();
|
||||
return splitResponse;
|
||||
}
|
||||
}
|
||||
|
@ -193,7 +193,7 @@ namespace SharedLibraryCore.Services
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
return await context.Clients
|
||||
.Where(c => c.Level == Objects.Player.Permission.Owner)
|
||||
.Where(c => c.Level == Player.Permission.Owner)
|
||||
.ToListAsync();
|
||||
}
|
||||
|
||||
@ -229,18 +229,18 @@ namespace SharedLibraryCore.Services
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
var iqClients = (from alias in context.Aliases
|
||||
.AsNoTracking()
|
||||
where alias.Name
|
||||
.Contains(name)
|
||||
join link in context.AliasLinks
|
||||
on alias.LinkId equals link.AliasLinkId
|
||||
join client in context.Clients
|
||||
.AsNoTracking()
|
||||
on alias.LinkId equals client.AliasLinkId
|
||||
select client)
|
||||
.Distinct()
|
||||
.Include(c => c.CurrentAlias)
|
||||
.Include(c => c.AliasLink.Children);
|
||||
.AsNoTracking()
|
||||
where alias.Name
|
||||
.Contains(name)
|
||||
join link in context.AliasLinks
|
||||
on alias.LinkId equals link.AliasLinkId
|
||||
join client in context.Clients
|
||||
.AsNoTracking()
|
||||
on alias.LinkId equals client.AliasLinkId
|
||||
select client)
|
||||
.Distinct()
|
||||
.Include(c => c.CurrentAlias)
|
||||
.Include(c => c.AliasLink.Children);
|
||||
|
||||
return await iqClients.ToListAsync();
|
||||
}
|
||||
@ -251,17 +251,17 @@ namespace SharedLibraryCore.Services
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
var iqClients = (from alias in context.Aliases
|
||||
.AsNoTracking()
|
||||
where alias.IPAddress == ipAddress
|
||||
join link in context.AliasLinks
|
||||
on alias.LinkId equals link.AliasLinkId
|
||||
join client in context.Clients
|
||||
.AsNoTracking()
|
||||
on alias.LinkId equals client.AliasLinkId
|
||||
select client)
|
||||
.Distinct()
|
||||
.Include(c => c.CurrentAlias)
|
||||
.Include(c => c.AliasLink.Children);
|
||||
.AsNoTracking()
|
||||
where alias.IPAddress == ipAddress
|
||||
join link in context.AliasLinks
|
||||
on alias.LinkId equals link.AliasLinkId
|
||||
join client in context.Clients
|
||||
.AsNoTracking()
|
||||
on alias.LinkId equals client.AliasLinkId
|
||||
select client)
|
||||
.Distinct()
|
||||
.Include(c => c.CurrentAlias)
|
||||
.Include(c => c.AliasLink.Children);
|
||||
|
||||
return await iqClients.ToListAsync();
|
||||
}
|
||||
@ -288,7 +288,7 @@ namespace SharedLibraryCore.Services
|
||||
.AsNoTracking()
|
||||
.Where(c => (DateTime.UtcNow - c.LastConnection).TotalDays >= inactiveDays)
|
||||
.ToListAsync();
|
||||
inactive.ForEach(c => c.Level = Objects.Player.Permission.User);
|
||||
inactive.ForEach(c => c.Level = Player.Permission.User);
|
||||
await context.SaveChangesAsync();
|
||||
return inactive;
|
||||
}
|
||||
|
@ -51,11 +51,14 @@ namespace SharedLibraryCore.Services
|
||||
return this.GetQuery(predicate, orderExpression).AsEnumerable();
|
||||
}
|
||||
|
||||
|
||||
public virtual IQueryable<TEntity> GetQuery(Expression<Func<TEntity, bool>> predicate = null, Func<IQueryable<TEntity>, IOrderedQueryable<TEntity>> orderExpression = null)
|
||||
{
|
||||
IQueryable<TEntity> qry = this.DBSet;
|
||||
|
||||
foreach (var property in this.Context.Model.FindEntityType(typeof(TEntity)).GetNavigations())
|
||||
qry = qry.Include(property.Name);
|
||||
|
||||
|
||||
if (predicate != null)
|
||||
qry = qry.Where(predicate);
|
||||
|
||||
|
@ -14,36 +14,45 @@ namespace SharedLibraryCore.Services
|
||||
{
|
||||
public class PenaltyService : Interfaces.IEntityService<EFPenalty>
|
||||
{
|
||||
public async Task<EFPenalty> Create(EFPenalty entity)
|
||||
public async Task<EFPenalty> Create(EFPenalty newEntity)
|
||||
{
|
||||
using (var context = new DatabaseContext())
|
||||
{
|
||||
entity.Offender = context.Clients.Single(e => e.ClientId == entity.Offender.ClientId);
|
||||
entity.Punisher = context.Clients.Single(e => e.ClientId == entity.Punisher.ClientId);
|
||||
entity.Link = context.AliasLinks.Single(l => l.AliasLinkId == entity.Link.AliasLinkId);
|
||||
// create the actual EFPenalty
|
||||
EFPenalty addedEntity = new EFPenalty()
|
||||
{
|
||||
OffenderId = newEntity.Offender.ClientId,
|
||||
PunisherId = newEntity.Punisher.ClientId,
|
||||
LinkId = newEntity.Link.AliasLinkId,
|
||||
Type = newEntity.Type,
|
||||
Active = true,
|
||||
Expires = newEntity.Expires,
|
||||
Offense = newEntity.Offense,
|
||||
When = newEntity.When,
|
||||
};
|
||||
|
||||
if (entity.Expires == DateTime.MaxValue)
|
||||
entity.Expires = DateTime.Parse(System.Data.SqlTypes.SqlDateTime.MaxValue.ToString());
|
||||
if (addedEntity.Expires == DateTime.MaxValue)
|
||||
addedEntity.Expires = DateTime.Parse(System.Data.SqlTypes.SqlDateTime.MaxValue.ToString());
|
||||
|
||||
// make bans propogate to all aliases
|
||||
if (entity.Type == Objects.Penalty.PenaltyType.Ban)
|
||||
if (addedEntity.Type == Objects.Penalty.PenaltyType.Ban)
|
||||
{
|
||||
await context.Clients
|
||||
.Where(c => c.AliasLinkId == entity.Link.AliasLinkId)
|
||||
.Where(c => c.AliasLinkId == addedEntity.LinkId)
|
||||
.ForEachAsync(c => c.Level = Objects.Player.Permission.Banned);
|
||||
}
|
||||
|
||||
// make flags propogate to all aliases
|
||||
else if (entity.Type == Objects.Penalty.PenaltyType.Flag)
|
||||
else if (addedEntity.Type == Objects.Penalty.PenaltyType.Flag)
|
||||
{
|
||||
await context.Clients
|
||||
.Where(c => c.AliasLinkId == entity.Link.AliasLinkId)
|
||||
.Where(c => c.AliasLinkId == addedEntity.LinkId)
|
||||
.ForEachAsync(c => c.Level = Objects.Player.Permission.Flagged);
|
||||
}
|
||||
|
||||
context.Penalties.Add(entity);
|
||||
context.Penalties.Add(addedEntity);
|
||||
await context.SaveChangesAsync();
|
||||
return entity;
|
||||
return addedEntity;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -362,7 +362,7 @@ namespace SharedLibraryCore
|
||||
Name = client.CurrentAlias.Name,
|
||||
IPAddress = client.CurrentAlias.IPAddress,
|
||||
Level = client.Level,
|
||||
LastConnection = DateTime.UtcNow,
|
||||
LastConnection = client.LastConnection == DateTime.MinValue ? DateTime.UtcNow : client.LastConnection,
|
||||
CurrentAlias = client.CurrentAlias,
|
||||
CurrentAliasId = client.CurrentAlias.AliasId
|
||||
};
|
||||
@ -391,7 +391,9 @@ namespace SharedLibraryCore
|
||||
|
||||
public static async Task<DVAR<T>> GetDvarAsync<T>(this Server server, string dvarName)
|
||||
{
|
||||
string[] LineSplit = await server.RemoteConnection.SendQueryAsync(QueryType.DVAR, dvarName);
|
||||
string[] LineSplit = server.GameName != Game.T6M ?
|
||||
await server.RemoteConnection.SendQueryAsync(QueryType.DVAR, dvarName) :
|
||||
await server.RemoteConnection.SendQueryAsync(QueryType.COMMAND, $"get {dvarName}");
|
||||
|
||||
if (LineSplit.Length != 3)
|
||||
{
|
||||
|
Reference in New Issue
Block a user