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

[misc bug fixes]

properly hide broadcast failure messages if ignore connection lost is turned on
fix concurent issue for update stats history that happened with new event processing
make get/set additional property thread safe
add ellipse to truncated chat messages on home
This commit is contained in:
RaidMax
2020-04-25 19:01:26 -05:00
parent d5c45717a6
commit 1f7f40f296
26 changed files with 258 additions and 74 deletions

View File

@ -86,7 +86,10 @@ namespace SharedLibraryCore.Database
var connectionString = connectionStringBuilder.ToString();
var connection = new SqliteConnection(connectionString);
optionsBuilder.UseSqlite(connection);
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlite(connection);
}
}
else

View File

@ -1,15 +1,41 @@
using System;
using SharedLibraryCore.Interfaces;
using System;
using System.Collections.Concurrent;
using System.ComponentModel.DataAnnotations.Schema;
namespace SharedLibraryCore.Database.Models
{
public class SharedEntity
public class SharedEntity : IPropertyExtender
{
private readonly ConcurrentDictionary<string, object> _additionalProperties;
/// <summary>
/// indicates if the entity is active
/// </summary>
public bool Active { get; set; } = true;
public SharedEntity()
{
_additionalProperties = new ConcurrentDictionary<string, object>();
}
public T GetAdditionalProperty<T>(string name)
{
return _additionalProperties.ContainsKey(name) ? (T)_additionalProperties[name] : default;
}
public void SetAdditionalProperty(string name, object value)
{
if (_additionalProperties.ContainsKey(name))
{
_additionalProperties[name] = value;
}
else
{
_additionalProperties.TryAdd(name, value);
}
}
///// <summary>
///// Specifies when the entity was created
///// </summary>

View File

@ -0,0 +1,17 @@
using SharedLibraryCore.Database;
namespace SharedLibraryCore.Interfaces
{
/// <summary>
/// describes the capabilities of the database context factory
/// </summary>
public interface IDatabaseContextFactory
{
/// <summary>
/// create or retrieves an existing database context instance
/// </summary>
/// <param name="enableTracking">indicated if entity tracking should be enabled</param>
/// <returns>database context instance</returns>
DatabaseContext CreateContext(bool? enableTracking = true);
}
}

View File

@ -0,0 +1,23 @@
namespace SharedLibraryCore.Interfaces
{
/// <summary>
/// describes the capability of extending properties by name
/// </summary>
interface IPropertyExtender
{
/// <summary>
/// adds or updates property by name
/// </summary>
/// <param name="name">unique name of the property</param>
/// <param name="value">value of the property</param>
void SetAdditionalProperty(string name, object value);
/// <summary>
/// retreives a property by name
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="name">name of the property</param>
/// <returns>property value if exists, otherwise default T</returns>
T GetAdditionalProperty<T>(string name);
}
}

View File

@ -86,10 +86,7 @@ namespace SharedLibraryCore.Database.Models
{
ConnectionTime = DateTime.UtcNow;
ClientNumber = -1;
_additionalProperties = new Dictionary<string, object>
{
{ "_reportCount", 0 }
};
SetAdditionalProperty("_reportCount", 0);
ReceivedPenalties = new List<EFPenalty>();
_processingEvent = new SemaphoreSlim(1, 1);
}
@ -101,7 +98,7 @@ namespace SharedLibraryCore.Database.Models
public override string ToString()
{
return $"{CurrentAlias?.Name ?? "--"}::{NetworkId}";
return $"[Name={CurrentAlias?.Name ?? "--"}, NetworkId={NetworkId.ToString("X")}, IP={(string.IsNullOrEmpty(IPAddressString) ? "--" : IPAddressString)}, ClientSlot={ClientNumber}]";
}
[NotMapped]
@ -643,26 +640,6 @@ namespace SharedLibraryCore.Database.Models
return true;
}
[NotMapped]
readonly Dictionary<string, object> _additionalProperties;
public T GetAdditionalProperty<T>(string name)
{
return _additionalProperties.ContainsKey(name) ? (T)_additionalProperties[name] : default(T);
}
public void SetAdditionalProperty(string name, object value)
{
if (_additionalProperties.ContainsKey(name))
{
_additionalProperties[name] = value;
}
else
{
_additionalProperties.Add(name, value);
}
}
[NotMapped]
public int ClientNumber { get; set; }
[NotMapped]

View File

@ -6,7 +6,7 @@
<ApplicationIcon />
<StartupObject />
<PackageId>RaidMax.IW4MAdmin.SharedLibraryCore</PackageId>
<Version>2.2.8</Version>
<Version>2.2.10</Version>
<Authors>RaidMax</Authors>
<Company>Forever None</Company>
<Configurations>Debug;Release;Prerelease</Configurations>
@ -20,8 +20,8 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Description>Shared Library for IW4MAdmin</Description>
<AssemblyVersion>2.2.8.0</AssemblyVersion>
<FileVersion>2.2.8.0</FileVersion>
<AssemblyVersion>2.2.10.0</AssemblyVersion>
<FileVersion>2.2.10.0</FileVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Prerelease|AnyCPU'">