login logout logs
This commit is contained in:
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Entities.Logs
|
||||||
|
{
|
||||||
|
public class LoginLogoutLogEntry
|
||||||
|
{
|
||||||
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
public string Username { get; set; }
|
||||||
|
|
||||||
|
public string SocialClubName { get; set; }
|
||||||
|
|
||||||
|
public User User { get; set; }
|
||||||
|
|
||||||
|
public long PlayerId { get; set; }
|
||||||
|
|
||||||
|
public string IpAddress { get; set; }
|
||||||
|
|
||||||
|
public bool LoginLogout { get; set; }
|
||||||
|
|
||||||
|
public DateTime Time { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
2051
ReallifeGamemode.Database/Migrations/20210419100958_LoginLogoutLogs.Designer.cs
generated
Normal file
2051
ReallifeGamemode.Database/Migrations/20210419100958_LoginLogoutLogs.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,48 @@
|
|||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
|
{
|
||||||
|
public partial class LoginLogoutLogs : Migration
|
||||||
|
{
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "LoginLogoutLogs",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<long>(nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Username = table.Column<string>(nullable: true),
|
||||||
|
SocialClubName = table.Column<string>(nullable: true),
|
||||||
|
UserId = table.Column<int>(nullable: true),
|
||||||
|
PlayerId = table.Column<long>(nullable: false),
|
||||||
|
IpAddress = table.Column<string>(nullable: true),
|
||||||
|
LoginLogout = table.Column<bool>(nullable: false),
|
||||||
|
Time = table.Column<DateTime>(nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_LoginLogoutLogs", x => x.Id);
|
||||||
|
table.ForeignKey(
|
||||||
|
name: "FK_LoginLogoutLogs_Users_UserId",
|
||||||
|
column: x => x.UserId,
|
||||||
|
principalTable: "Users",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Restrict);
|
||||||
|
});
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_LoginLogoutLogs_UserId",
|
||||||
|
table: "LoginLogoutLogs",
|
||||||
|
column: "UserId");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "LoginLogoutLogs");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -872,6 +872,40 @@ namespace ReallifeGamemode.Database.Migrations
|
|||||||
b.ToTable("DeathLogs");
|
b.ToTable("DeathLogs");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.LoginLogoutLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.Property<long>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("IpAddress")
|
||||||
|
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||||
|
|
||||||
|
b.Property<bool>("LoginLogout")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<long>("PlayerId")
|
||||||
|
.HasColumnType("bigint");
|
||||||
|
|
||||||
|
b.Property<string>("SocialClubName")
|
||||||
|
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||||
|
|
||||||
|
b.Property<DateTime>("Time")
|
||||||
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<int?>("UserId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Username")
|
||||||
|
.HasColumnType("longtext CHARACTER SET utf8mb4");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.HasIndex("UserId");
|
||||||
|
|
||||||
|
b.ToTable("LoginLogoutLogs");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.News", b =>
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.News", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@@ -1898,6 +1932,13 @@ namespace ReallifeGamemode.Database.Migrations
|
|||||||
.IsRequired();
|
.IsRequired();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.Logs.LoginLogoutLogEntry", b =>
|
||||||
|
{
|
||||||
|
b.HasOne("ReallifeGamemode.Database.Entities.User", "User")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("UserId");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("ReallifeGamemode.Database.Entities.News", b =>
|
modelBuilder.Entity("ReallifeGamemode.Database.Entities.News", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("ReallifeGamemode.Database.Entities.User", "User")
|
b.HasOne("ReallifeGamemode.Database.Entities.User", "User")
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ namespace ReallifeGamemode.Database.Models
|
|||||||
public DbSet<Entities.Logs.BankAccountTransactionHistory> BankAccountTransactionLogs { get; set; }
|
public DbSet<Entities.Logs.BankAccountTransactionHistory> BankAccountTransactionLogs { get; set; }
|
||||||
public DbSet<Entities.Logs.Death> DeathLogs { get; set; }
|
public DbSet<Entities.Logs.Death> DeathLogs { get; set; }
|
||||||
public DbSet<Entities.Logs.CommandLogEntry> CommandLogs { get; set; }
|
public DbSet<Entities.Logs.CommandLogEntry> CommandLogs { get; set; }
|
||||||
|
public DbSet<Entities.Logs.LoginLogoutLogEntry> LoginLogoutLogs { get; set; }
|
||||||
|
|
||||||
//Saves
|
//Saves
|
||||||
public DbSet<Entities.ATM> ATMs { get; set; }
|
public DbSet<Entities.ATM> ATMs { get; set; }
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ using ReallifeGamemode.Server.Report;
|
|||||||
using ReallifeGamemode.Server.Factions.Medic;
|
using ReallifeGamemode.Server.Factions.Medic;
|
||||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||||
using ReallifeGamemode.Server.Inventory;
|
using ReallifeGamemode.Server.Inventory;
|
||||||
|
using ReallifeGamemode.Database.Entities.Logs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||||
@@ -40,6 +41,19 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var logEntry = new LoginLogoutLogEntry()
|
||||||
|
{
|
||||||
|
LoginLogout = false,
|
||||||
|
User = user,
|
||||||
|
PlayerId = player.Handle.Value,
|
||||||
|
Username = player.Name,
|
||||||
|
SocialClubName = player.SocialClubName,
|
||||||
|
IpAddress = player.Address,
|
||||||
|
Time = DateTime.Now,
|
||||||
|
};
|
||||||
|
|
||||||
|
saveUser.LoginLogoutLogs.Add(logEntry);
|
||||||
|
|
||||||
if (type == DisconnectionType.Left)
|
if (type == DisconnectionType.Left)
|
||||||
{
|
{
|
||||||
NAPI.Util.ConsoleOutput(player.Name + " left");
|
NAPI.Util.ConsoleOutput(player.Name + " left");
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ using ReallifeGamemode.Database.Entities;
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using ReallifeGamemode.Server.Inventory.Interfaces;
|
using ReallifeGamemode.Server.Inventory.Interfaces;
|
||||||
|
using ReallifeGamemode.Database.Entities.Logs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Event Login (Login.cs)
|
* @overview Life of German Reallife - Event Login (Login.cs)
|
||||||
@@ -56,6 +57,20 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var logEntry = new LoginLogoutLogEntry()
|
||||||
|
{
|
||||||
|
IpAddress = player.Address,
|
||||||
|
User = user,
|
||||||
|
PlayerId = player.Handle.Value,
|
||||||
|
SocialClubName = player.SocialClubName,
|
||||||
|
Username = player.Name,
|
||||||
|
LoginLogout = true,
|
||||||
|
Time = DateTime.Now
|
||||||
|
};
|
||||||
|
|
||||||
|
dbContext.LoginLogoutLogs.Add(logEntry);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
player.SetData("dbId", user.Id);
|
player.SetData("dbId", user.Id);
|
||||||
player.Name = username;
|
player.Name = username;
|
||||||
player.TriggerEvent("SERVER:Login_Success");
|
player.TriggerEvent("SERVER:Login_Success");
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using ReallifeGamemode.Database.Models;
|
|||||||
using ReallifeGamemode.Server.Extensions;
|
using ReallifeGamemode.Server.Extensions;
|
||||||
using ReallifeGamemode.Server.Util;
|
using ReallifeGamemode.Server.Util;
|
||||||
using System;
|
using System;
|
||||||
|
using ReallifeGamemode.Database.Entities.Logs;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @overview Life of German Reallife - Event Register (Register.cs)
|
* @overview Life of German Reallife - Event Register (Register.cs)
|
||||||
@@ -51,7 +52,20 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var logEntry = new LoginLogoutLogEntry()
|
||||||
|
{
|
||||||
|
IpAddress = player.Address,
|
||||||
|
User = user,
|
||||||
|
PlayerId = player.Handle.Value,
|
||||||
|
SocialClubName = player.SocialClubName,
|
||||||
|
Username = player.Name,
|
||||||
|
LoginLogout = true,
|
||||||
|
Time = DateTime.Now
|
||||||
|
};
|
||||||
|
|
||||||
dbContext.Users.Add(user);
|
dbContext.Users.Add(user);
|
||||||
|
dbContext.LoginLogoutLogs.Add(logEntry);
|
||||||
|
|
||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
|
|
||||||
player.SetData("dbId", user.Id);
|
player.SetData("dbId", user.Id);
|
||||||
|
|||||||
Reference in New Issue
Block a user