migrated to ASP.Net Core

This commit is contained in:
RaidMax
2018-02-21 19:29:23 -06:00
parent 8aae31d10d
commit 3f82ecacfc
4407 changed files with 311698 additions and 124726 deletions

View File

@ -0,0 +1,90 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibrary;
using SharedLibrary.Dtos;
using SharedLibrary.Services;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebfrontCore.Controllers
{
public class ClientController : Controller
{
public async Task<IActionResult> ProfileAsync(int id)
{
var client = await IW4MAdmin.ApplicationManager.GetInstance().GetClientService().Get(id);
var clientDto = new PlayerInfo()
{
Name = client.Name,
Level = client.Level.ToString(),
ClientId = client.ClientId,
IPAddress = client.IPAddressString,
NetworkId = client.NetworkId,
ConnectionCount = client.Connections,
FirstSeen = Utilities.GetTimePassed(client.FirstConnection, false),
LastSeen = Utilities.GetTimePassed(client.LastConnection, false),
TimePlayed = Math.Round(client.TotalConnectionTime / 3600.0, 1).ToString("#,##0"),
Meta = new List<ProfileMeta>(),
Aliases = client.AliasLink.Children
.Where(a => a.Name != client.Name)
.Select(a => a.Name)
.Distinct()
.OrderBy(a => a)
.ToList(),
IPs = client.AliasLink.Children
.Select(i => i.IPAddress.ConvertIPtoString())
.Distinct()
.OrderBy(i => i)
.ToList(),
};
clientDto.Meta.AddRange(await MetaService.GetMeta(client.ClientId));
clientDto.Meta.AddRange(await IW4MAdmin.ApplicationManager.GetInstance().GetPenaltyService().ReadGetClientPenaltiesAsync(client.ClientId));
clientDto.Meta.AddRange(await IW4MAdmin.ApplicationManager.GetInstance().GetPenaltyService().ReadGetClientPenaltiesAsync(client.ClientId, false));
clientDto.Meta = clientDto.Meta.OrderByDescending(m => m.When).ToList();
return View("Profile/Index", clientDto);
}
public async Task<IActionResult> PrivilegedAsync()
{
var admins = (await IW4MAdmin.ApplicationManager.GetInstance().GetClientService().GetPrivilegedClients())
.Where(a => a.Active)
.OrderByDescending(a => a.Level);
var adminsDict = new Dictionary<SharedLibrary.Objects.Player.Permission, IList<ClientInfo>>();
foreach (var admin in admins)
{
if (!adminsDict.ContainsKey(admin.Level))
adminsDict.Add(admin.Level, new List<ClientInfo>());
adminsDict[admin.Level].Add(new ClientInfo()
{
Name = admin.Name,
ClientId = admin.ClientId
});
}
ViewBag.Title = "Current Privileged Users";
return View("Privileged/Index", adminsDict);
}
public async Task<IActionResult> FindAsync(string clientName)
{
var clients = (await IW4MAdmin.ApplicationManager.GetInstance().GetClientService().GetClientByName(clientName))
.OrderByDescending(c => c.LastConnection);
var clientsDto = clients.Select(c => new PlayerInfo()
{
Name = c.Name,
Level = c.Level.ToString(),
ClientId = c.ClientId,
LastSeen = Utilities.GetTimePassed(c.LastConnection, false)
})
.ToList();
ViewBag.Name = $"Clients Matching \"{clientName}\"";
return View("Find/Index", clientsDto);
}
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SharedLibrary.Dtos;
namespace WebfrontCore.Controllers
{
public class HomeController : Controller
{
public IActionResult Index()
{
return View();
}
public IActionResult Error()
{
// return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
return null;
}
}
}

View File

@ -0,0 +1,25 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibrary;
using SharedLibrary.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WebfrontCore.ViewComponents;
namespace WebfrontCore.Controllers
{
public class PenaltyController : Controller
{
public IActionResult List()
{
ViewBag.Title = "Penalty List";
return View();
}
public async Task<IActionResult> ListAsync(int offset = 0)
{
return View("_List", offset);
}
}
}

View File

@ -0,0 +1,41 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibrary.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace WebfrontCore.Controllers
{
public class ServerController : Controller
{
[HttpGet]
public IActionResult ClientActivity(int id)
{
var s = IW4MAdmin.Program.ServerManager.GetServers().FirstOrDefault(s2 => s2.GetHashCode() == id);
if (s == null)
return View("Error", "Invalid server!");
var serverInfo = new ServerInfo()
{
Name = s.Hostname,
ID = s.GetHashCode(),
Port = s.GetPort(),
Map = s.CurrentMap.Alias,
ClientCount = s.ClientNum,
MaxClients = s.MaxClients,
GameType = s.Gametype,
Players = s.Players.Where(p => p != null).Select(p => new PlayerInfo
{
Name = p.Name,
ClientId = p.ClientId
}).ToList(),
ChatHistory = s.ChatHistory,
PlayerHistory = s.PlayerHistory.ToArray()
};
return PartialView("_ClientActivity", serverInfo);
}
}
}