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

-added back player history graphs (past 12 hours every 15 minutes)

-fixed issue with configurationmanager files and threading
-servers on webfront listed in descending player count
-fixed resolution of tempban times from console feedback
-Added tests plugin to simulate functionality
This commit is contained in:
RaidMax
2017-09-27 15:07:43 -05:00
parent 9227335d25
commit 8d52d7ddc5
21 changed files with 470 additions and 127 deletions

View File

@ -1,35 +1,38 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
namespace SharedLibrary.Helpers
{
public class ConfigurationManager
{
Dictionary<string, Dictionary<string, object>> ConfigurationSet;
ConcurrentDictionary<string, Dictionary<string, object>> ConfigurationSet;
Type PluginType;
public ConfigurationManager(Type PluginType)
{
ConfigurationSet = new Dictionary<string, Dictionary<string, object>>();
ConfigurationSet = new ConcurrentDictionary<string, Dictionary<string, object>>();
this.PluginType = PluginType;
}
public void AddConfiguration(Server S)
{
/* if (ConfigurationSet.ContainsKey(S.ToString()))
{
S.Logger.WriteWarning($"not adding server configuration for {S} as it already exists");
return;
}*/
try
{
var Config = Interfaces.Serialize<Dictionary<string, object>>.Read($"config/{PluginType.ToString()}_{S.ToString()}.cfg");
lock (ConfigurationSet)
{
ConfigurationSet.Add(S.ToString(), Config);
}
ConfigurationSet.TryAdd(S.ToString(), Config);
}
catch (Exceptions.SerializeException)
{
ConfigurationSet.Add(S.ToString(), new Dictionary<string, object>());
ConfigurationSet.TryAdd(S.ToString(), new Dictionary<string, object>());
}
}
public void AddProperty(Server S, KeyValuePair<string, object> Property)

View File

@ -4,12 +4,45 @@ namespace SharedLibrary.Helpers
{
public class PlayerHistory
{
public PlayerHistory(DateTime w, int cNum)
public PlayerHistory(int cNum)
{
When = w;
Players = cNum;
DateTime t = DateTime.UtcNow;
When = new DateTime(t.Year, t.Month, t.Day, t.Hour, 5 * (int)Math.Round(t.Minute / 5.0), 0);
PlayerCount = cNum;
}
#if DEBUG
public PlayerHistory(DateTime t, int cNum)
{
When = new DateTime(t.Year, t.Month, t.Day, t.Hour, 15 * (int)Math.Round(t.Minute / 15.0), 0);
PlayerCount = cNum;
}
#endif
private DateTime When;
private int PlayerCount;
/// <summary>
/// Used by CanvasJS as a point on the x axis
/// </summary>
public double x
{
get
{
return (When - DateTime.MinValue).TotalSeconds;
}
}
/// <summary>
/// Used by CanvasJS as a point on the y axis
/// </summary>
public int y
{
get
{
return PlayerCount;
}
}
public DateTime When { get; private set; }
public int Players { get; private set; }
}
}

View File

@ -17,5 +17,6 @@ namespace SharedLibrary.Interfaces
IList<Player> GetActiveClients();
IList<Player> GetAliasClients(Player player);
IList<Aliases> GetAliases(Player player);
IList<Player> GetPrivilegedClients();
}
}

View File

@ -98,7 +98,7 @@ namespace SharedLibrary.Network
if (LineSplit.Length != 3)
{
var e = new Exceptions.DvarException("DVAR does not exist");
var e = new Exceptions.DvarException($"DVAR \"{dvarName}\" does not exist");
e.Data["dvar_name"] = dvarName;
throw e;
}

View File

@ -293,16 +293,18 @@ namespace SharedLibrary
public static string TimeSpanText(this TimeSpan span)
{
if (span.TotalMinutes < 6)
return $"{span.Minutes} minutes";
else if (span.TotalHours < 24)
return $"{span.Hours} hours";
else if (span.TotalDays < 7)
return $"{span.Days} days";
else if (span.TotalDays > 7 && span.TotalDays < 365)
return $"{Math.Ceiling(span.Days / 7.0)} weeks";
else if (span.TotalDays >= 365)
return $"{Math.Ceiling(span.Days / 365.0)} years";
if (span.TotalMinutes < 60)
return $"{span.Minutes} minute(s)";
else if (span.Hours >= 1 && span.TotalHours < 24)
return $"{span.Hours} hour(s)";
else if (span.TotalDays >= 1 && span.TotalDays < 7)
return $"{span.Days} day(s)";
else if (span.TotalDays >= 7 && span.TotalDays < 365)
return $"{Math.Ceiling(span.Days / 7.0)} week(s)";
else if (span.TotalDays >= 365 && span.TotalDays < 36500)
return $"{Math.Ceiling(span.Days / 365.0)} year(s)";
else if (span.TotalDays >= 36500)
return "Forever";
return "1 hour";
}