1
0
mirror of https://github.com/RaidMax/IW4M-Admin.git synced 2025-07-02 18:10:33 -05:00

Stats thread safe

Cleaned up WebService class and shutdown
reimped stats and topstats
moved things out of stats into main code
This commit is contained in:
RaidMax
2018-02-10 00:26:38 -06:00
parent 293d439760
commit d1cdb93cc3
31 changed files with 668 additions and 927 deletions

View File

@ -0,0 +1,44 @@
using SharedLibrary;
using SharedLibrary.Database.Models;
using SharedLibrary.Services;
using StatsPlugin.Models;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StatsPlugin.Pages
{
public class ClientMessageJson : IPage
{
public string GetName() => "Client Chat JSON";
public string GetPath() => "/_clientchat";
public string GetContentType() => "application/json";
public bool Visible() => false;
public async Task<HttpResponse> GetPage(NameValueCollection querySet, IDictionary<string, string> headers)
{
int clientId = Convert.ToInt32(querySet["clientid"]);
var messageSvc = new GenericRepository<EFClientMessage>();
var clientMessages = (await messageSvc.FindAsync(m => m.ClientId == clientId));
HttpResponse resp = new HttpResponse()
{
contentType = GetContentType(),
content = clientMessages.Select(c => new
{
ClientID = c.ClientId,
ServerID = c.ServerId,
c.Message,
c.TimeSent,
ClientName = c.Client.Name,
}),
additionalHeaders = new Dictionary<string, string>()
};
return resp;
}
}
}

View File

@ -0,0 +1,30 @@
using SharedLibrary;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StatsPlugin.Pages
{
public class ClientMessages : HTMLPage
{
public override string GetContent(NameValueCollection querySet, IDictionary<string, string> headers)
{
StringBuilder S = new StringBuilder();
S.Append(LoadHeader());
IFile chat = new IFile("webfront\\chat.html");
S.Append(chat.GetText());
chat.Close();
S.Append(LoadFooter());
return S.ToString();
}
public override string GetName() => "Word Cloud";
public override string GetPath() => "/chat";
}
}

View File

@ -0,0 +1,30 @@
using SharedLibrary;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StatsPlugin.Pages
{
public class LiveStats : HTMLPage
{
public override string GetContent(NameValueCollection querySet, IDictionary<string, string> headers)
{
StringBuilder S = new StringBuilder();
S.Append(LoadHeader());
IFile stats = new IFile("webfront\\stats.html");
S.Append(stats.GetText());
stats.Close();
S.Append(LoadFooter());
return S.ToString();
}
public override string GetName() => "Server Stats";
public override string GetPath() => "/stats";
}
}

View File

@ -0,0 +1,48 @@
using SharedLibrary;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StatsPlugin.Pages
{
class LiveStatsJson : IPage
{
public string GetName() => "Kill Stats JSON";
public string GetPath() => "/_killstats";
public string GetContentType() => "application/json";
public bool Visible() => false;
public async Task<HttpResponse> GetPage(NameValueCollection querySet, IDictionary<string, string> headers)
{
// todo: redo this
return await Task.FromResult(new HttpResponse());
/*int selectCount = Stats.MAX_KILLEVENTS;
if (querySet.Get("count") != null)
selectCount = Int32.Parse(querySet.Get("count"));
HttpResponse resp = new HttpResponse()
{
contentType = GetContentType(),
content = new
{
Servers = Stats.ManagerInstance.GetServers().Select(s => new
{
ServerName = s.Hostname,
ServerMap = s.CurrentMap.Alias,
ServerInfo = Stats.ServerStats[s.GetPort()],
Minimap = MinimapConfig.Read(@"Config\minimaps.cfg").MapInfo.Where(m => m.MapName == s.CurrentMap.Name),
MapKills = selectCount < 999 ? Stats.ServerStats[s.GetPort()].GetKillQueue().ToArray()
.Skip(Math.Min(Stats.MAX_KILLEVENTS - selectCount, Stats.ServerStats[s.GetPort()].GetKillQueue().Count - selectCount)) :
Stats.statLists.FirstOrDefault(x => x.Port == s.GetPort()).playerStats.GetKillsByMap(s.CurrentMap, selectCount)
})
},
additionalHeaders = new Dictionary<string, string>()
};
return resp;*/
}
}
}

View File

@ -0,0 +1,32 @@
using SharedLibrary;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StatsPlugin.Pages
{
public class WordCloudJson : IPage
{
public string GetName() => "Word Cloud JSON";
public string GetPath() => "/_words";
public string GetContentType() => "application/json";
public bool Visible() => false;
public async Task<HttpResponse> GetPage(NameValueCollection querySet, IDictionary<string, string> headers)
{
// todo: this
HttpResponse resp = new HttpResponse()
{
contentType = GetContentType(),
content = null,
additionalHeaders = new Dictionary<string, string>()
};
return resp;
}
}
}