diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index c74c9176a..b383110ad 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -10,7 +10,6 @@ using static SharedLibraryCore.Database.Models.EFClient; namespace SharedLibraryCore.Services { - public class ClientService : Interfaces.IEntityService { public async Task Create(EFClient entity) @@ -579,19 +578,20 @@ namespace SharedLibraryCore.Services /// public async Task> GetRecentClients() { + var startOfPeriod = DateTime.UtcNow.AddHours(-24); + using (var context = new DatabaseContext(true)) { var iqClients = context.Clients .Where(_client => _client.CurrentAlias.IPAddress != null) + .Where(_client => _client.LastConnection >= startOfPeriod) .Select(_client => new PlayerInfo() { ClientId = _client.ClientId, Name = _client.CurrentAlias.Name, IPAddress = _client.CurrentAlias.IPAddress.ConvertIPtoString(), LastConnection = _client.FirstConnection - }) - .OrderByDescending(_client => _client.ClientId) - .Take(10); + }); #if DEBUG var sql = iqClients.ToSql(); #endif diff --git a/WebfrontCore/Views/Shared/Components/ProfileMetaList/_List.cshtml b/WebfrontCore/Views/Shared/Components/ProfileMetaList/_List.cshtml index 40595b51e..1a37eeac3 100644 --- a/WebfrontCore/Views/Shared/Components/ProfileMetaList/_List.cshtml +++ b/WebfrontCore/Views/Shared/Components/ProfileMetaList/_List.cshtml @@ -4,7 +4,7 @@ var timeSinceLastEvent = DateTime.MinValue; - string formatPenalty(SharedLibraryCore.Dtos.ProfileMeta meta) + dynamic formatPenaltyInfo(SharedLibraryCore.Dtos.ProfileMeta meta) { var penalty = meta.Value as SharedLibraryCore.Dtos.PenaltyInfo; @@ -15,21 +15,15 @@ string localizationMessage = SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex[localizationKey]; var regexMatch = System.Text.RegularExpressions.Regex.Match(localizationMessage, @"^.*{{([^{}]+)}}.+$"); string penaltyType = regexMatch.Groups[1].Value.ToString(); + var secondMatch = System.Text.RegularExpressions.Regex.Match(localizationMessage, @"\{\{.+\}\}(.+)\{0\}(.+)\{1\}"); - localizationMessage = localizationMessage.Replace(penaltyType, $"{penaltyType}"); - - return meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized ? - string.Format(localizationMessage, - $"{penalty.OffenderName}", - $"{penalty.Offense} {(ViewBag.Authorized ? penalty.AdditionalPenaltyInformation : "")}") - .Replace("{", "") - .Replace("}", "") : - string.Format(localizationMessage, - $"{penalty.PunisherName}", - $"{penalty.Offense} {(ViewBag.Authorized ? penalty.AdditionalPenaltyInformation : "")}", - penalty.Offense) - .Replace("{", "") - .Replace("}", ""); + return new + { + Type = meta.Type, + Match = secondMatch, + Penalty = penalty, + PenaltyType = penaltyType + }; } } @@ -61,7 +55,40 @@ break; case SharedLibraryCore.Dtos.ProfileMeta.MetaType.ReceivedPenalty: case SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized: -
+
+ @{ var penaltyInfo = formatPenaltyInfo(meta); } + @if (meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.Penalized) + { + @penaltyInfo.PenaltyType + @penaltyInfo.Match.Groups[1].ToString() + + + + + + + + @penaltyInfo.Match.Groups[2].ToString() + @(ViewBag.Authorized ? penaltyInfo.Penalty.AdditionalPenaltyInformation : "") + } + + @if (meta.Type == SharedLibraryCore.Dtos.ProfileMeta.MetaType.ReceivedPenalty) + { + @penaltyInfo.PenaltyType + @penaltyInfo.Match.Groups[1].ToString() + + + + + + @penaltyInfo.Match.Groups[2] + + @(ViewBag.Authorized ? penaltyInfo.Penalty.AdditionalPenaltyInformation : "") + + } +
break; } } \ No newline at end of file