migrating to .NET Core 2.0

This commit is contained in:
RaidMax
2018-04-08 01:44:42 -05:00
parent 57fd5fae22
commit fdde7dfdba
121 changed files with 534 additions and 1157 deletions

View File

@ -1,4 +1,6 @@
using SharedLibrary;
using SharedLibraryCore;
using SharedLibraryCore.Dtos;
using SharedLibraryCore.Objects;
using System;
using System.Collections.Generic;
@ -6,7 +8,7 @@ namespace WebfrontCore.Application.API
{
class EventAPI
{
public static Queue<SharedLibrary.Dtos.EventInfo> Events = new Queue<SharedLibrary.Dtos.EventInfo>();
public static Queue<EventInfo> Events = new Queue<EventInfo>();
static DateTime LastFlagEvent;
static string[] FlaggedMessageContains =
{
@ -24,7 +26,7 @@ namespace WebfrontCore.Application.API
public static void OnServerEventOccurred(object sender, Event E)
{
if (E.Type == Event.GType.Say && E.Origin.Level < SharedLibrary.Objects.Player.Permission.Trusted)
if (E.Type == Event.GType.Say && E.Origin.Level < Player.Permission.Trusted)
{
bool flaggedMessage = false;
foreach (string msg in FlaggedMessageContains)
@ -41,9 +43,9 @@ namespace WebfrontCore.Application.API
FlaggedMessageCount = 0;
E.Owner.Broadcast("If you suspect someone of ^5CHEATING ^7use the ^5!report ^7command").Wait();
Events.Enqueue(new SharedLibrary.Dtos.EventInfo(
SharedLibrary.Dtos.EventInfo.EventType.ALERT,
SharedLibrary.Dtos.EventInfo.EventVersion.IW4MAdmin,
Events.Enqueue(new EventInfo(
EventInfo.EventType.ALERT,
EventInfo.EventVersion.IW4MAdmin,
"Chat indicates there may be a cheater",
"Alert",
E.Owner.Hostname, ""));
@ -58,9 +60,9 @@ namespace WebfrontCore.Application.API
if (E.Type == Event.GType.Report)
{
Events.Enqueue(new SharedLibrary.Dtos.EventInfo(
SharedLibrary.Dtos.EventInfo.EventType.ALERT,
SharedLibrary.Dtos.EventInfo.EventVersion.IW4MAdmin,
Events.Enqueue(new EventInfo(
EventInfo.EventType.ALERT,
EventInfo.EventVersion.IW4MAdmin,
$"**{E.Origin.Name}** has reported **{E.Target.Name}** for: {E.Data.Trim()}",
E.Target.Name, E.Origin.Name, ""));
}

View File

@ -1,5 +1,5 @@
using SharedLibrary;
using SharedLibrary.Configuration;
using SharedLibraryCore;
using SharedLibraryCore.Configuration;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -3,7 +3,7 @@ using System.IO;
namespace IW4MAdmin
{
class Logger : SharedLibrary.Interfaces.ILogger
class Logger : SharedLibraryCore.Interfaces.ILogger
{
enum LogType
{

View File

@ -1,12 +1,10 @@

using System;
using System.Runtime.InteropServices;
using SharedLibrary;
using SharedLibraryCore;
using System.Threading.Tasks;
using System.IO;
using SharedLibrary.Objects;
using SharedLibraryCore.Objects;
using System.Reflection;
using System.Linq;
namespace IW4MAdmin
{
@ -31,13 +29,9 @@ namespace IW4MAdmin
try
{
/*var v1 = SharedLibrary.Helpers.Vector3.Parse("(737, 1117, 268)");
var v2 = SharedLibrary.Helpers.Vector3.Parse("(1510, 672.98, -228.66)");
double angleBetween = v1.AngleBetween(v2);*/
CheckDirectories();
ServerManager = ApplicationManager.GetInstance();
SharedLibrary.Database.Repair.Run(ServerManager.Logger);
ServerManager.Init().Wait();
Task.Run(() => ServerManager.Start());

View File

@ -5,17 +5,17 @@ using System.Threading;
using System.IO;
using System.Threading.Tasks;
using SharedLibrary;
using SharedLibrary.Interfaces;
using SharedLibrary.Commands;
using SharedLibrary.Helpers;
using SharedLibrary.Exceptions;
using SharedLibrary.Objects;
using SharedLibrary.Services;
using SharedLibraryCore;
using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Commands;
using SharedLibraryCore.Helpers;
using SharedLibraryCore.Exceptions;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Services;
using WebfrontCore.Application.API;
using Microsoft.Extensions.Configuration;
using WebfrontCore;
using SharedLibrary.Configuration;
using SharedLibraryCore.Configuration;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
@ -136,9 +136,9 @@ namespace IW4MAdmin
#region PLUGINS
SharedLibrary.Plugins.PluginImporter.Load(this);
SharedLibraryCore.Plugins.PluginImporter.Load(this);
foreach (var Plugin in SharedLibrary.Plugins.PluginImporter.ActivePlugins)
foreach (var Plugin in SharedLibraryCore.Plugins.PluginImporter.ActivePlugins)
{
try
{
@ -232,7 +232,7 @@ namespace IW4MAdmin
Commands.Add(new CKillServer());
Commands.Add(new CSetPassword());
foreach (Command C in SharedLibrary.Plugins.PluginImporter.ActiveCommands)
foreach (Command C in SharedLibraryCore.Plugins.PluginImporter.ActiveCommands)
Commands.Add(C);
#endregion

View File

@ -6,13 +6,13 @@ using System.Linq;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using SharedLibrary;
using SharedLibrary.Interfaces;
using SharedLibrary.Objects;
using SharedLibrary.Services;
using SharedLibrary.Database.Models;
using SharedLibrary.Dtos;
using SharedLibrary.Configuration;
using SharedLibraryCore;
using SharedLibraryCore.Interfaces;
using SharedLibraryCore.Objects;
using SharedLibraryCore.Services;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Dtos;
using SharedLibraryCore.Configuration;
using WebfrontCore.Application.Misc;
@ -229,7 +229,7 @@ namespace IW4MAdmin
if (C == null)
{
await E.Origin.Tell("You entered an unknown command");
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} entered unknown command \"{CommandString}\"");
throw new SharedLibraryCore.Exceptions.CommandException($"{E.Origin} entered unknown command \"{CommandString}\"");
}
E.Data = E.Data.RemoveWords(1);
@ -238,14 +238,14 @@ namespace IW4MAdmin
if (E.Origin.Level < C.Permission)
{
await E.Origin.Tell("You do not have access to that command");
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} does not have access to \"{C.Name}\"");
throw new SharedLibraryCore.Exceptions.CommandException($"{E.Origin} does not have access to \"{C.Name}\"");
}
if (Args.Length < (C.RequiredArgumentCount))
{
await E.Origin.Tell($"Not enough arguments supplied");
await E.Origin.Tell(C.Syntax);
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} did not supply enough arguments for \"{C.Name}\"");
throw new SharedLibraryCore.Exceptions.CommandException($"{E.Origin} did not supply enough arguments for \"{C.Name}\"");
}
if (C.RequiresTarget || Args.Length > 0)
@ -293,7 +293,7 @@ namespace IW4MAdmin
if (matchingPlayers.Count > 1)
{
await E.Origin.Tell("Multiple players match that name");
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} had multiple players found for {C.Name}");
throw new SharedLibraryCore.Exceptions.CommandException($"{E.Origin} had multiple players found for {C.Name}");
}
else if (matchingPlayers.Count == 1)
{
@ -307,7 +307,7 @@ namespace IW4MAdmin
{
await E.Origin.Tell($"Not enough arguments supplied!");
await E.Origin.Tell(C.Syntax);
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} did not supply enough arguments for \"{C.Name}\"");
throw new SharedLibraryCore.Exceptions.CommandException($"{E.Origin} did not supply enough arguments for \"{C.Name}\"");
}
}
}
@ -320,7 +320,7 @@ namespace IW4MAdmin
await E.Origin.Tell("Multiple players match that name");
foreach (var p in matchingPlayers)
await E.Origin.Tell($"[^3{p.ClientNumber}^7] {p.Name}");
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} had multiple players found for {C.Name}");
throw new SharedLibraryCore.Exceptions.CommandException($"{E.Origin} had multiple players found for {C.Name}");
}
else if (matchingPlayers.Count == 1)
{
@ -337,7 +337,7 @@ namespace IW4MAdmin
{
await E.Origin.Tell($"Not enough arguments supplied!");
await E.Origin.Tell(C.Syntax);
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} did not supply enough arguments for \"{C.Name}\"");
throw new SharedLibraryCore.Exceptions.CommandException($"{E.Origin} did not supply enough arguments for \"{C.Name}\"");
}
}
}
@ -345,7 +345,7 @@ namespace IW4MAdmin
if (E.Target == null && C.RequiresTarget)
{
await E.Origin.Tell("Unable to find specified player.");
throw new SharedLibrary.Exceptions.CommandException($"{E.Origin} specified invalid player for \"{C.Name}\"");
throw new SharedLibraryCore.Exceptions.CommandException($"{E.Origin} specified invalid player for \"{C.Name}\"");
}
}
E.Data = E.Data.Trim();
@ -360,7 +360,7 @@ namespace IW4MAdmin
await ProcessEvent(E);
((ApplicationManager)Manager).ServerEventOccurred(this, E);
foreach (IPlugin P in SharedLibrary.Plugins.PluginImporter.ActivePlugins)
foreach (IPlugin P in SharedLibraryCore.Plugins.PluginImporter.ActivePlugins)
{
//#if !DEBUG
try
@ -394,7 +394,7 @@ namespace IW4MAdmin
}
// when the server has lost connection
catch (SharedLibrary.Exceptions.NetworkException)
catch (SharedLibraryCore.Exceptions.NetworkException)
{
Throttled = true;
return ClientNum;
@ -456,7 +456,7 @@ namespace IW4MAdmin
LastPoll = DateTime.Now;
}
catch (SharedLibrary.Exceptions.NetworkException e)
catch (SharedLibraryCore.Exceptions.NetworkException e)
{
ConnectionErrors++;
if (ConnectionErrors == 1)
@ -473,7 +473,7 @@ namespace IW4MAdmin
if ((DateTime.Now - tickTime).TotalMilliseconds >= 1000)
{
foreach (var Plugin in SharedLibrary.Plugins.PluginImporter.ActivePlugins)
foreach (var Plugin in SharedLibraryCore.Plugins.PluginImporter.ActivePlugins)
{
if (cts.IsCancellationRequested)
break;
@ -483,11 +483,11 @@ namespace IW4MAdmin
tickTime = DateTime.Now;
}
if ((lastCount - playerCountStart).TotalMinutes >= SharedLibrary.Helpers.PlayerHistory.UpdateInterval)
if ((lastCount - playerCountStart).TotalMinutes >= SharedLibraryCore.Helpers.PlayerHistory.UpdateInterval)
{
while (PlayerHistory.Count > ((60 / SharedLibrary.Helpers.PlayerHistory.UpdateInterval) * 12)) // 12 times a hour for 12 hours
while (PlayerHistory.Count > ((60 / SharedLibraryCore.Helpers.PlayerHistory.UpdateInterval) * 12)) // 12 times a hour for 12 hours
PlayerHistory.Dequeue();
PlayerHistory.Enqueue(new SharedLibrary.Helpers.PlayerHistory(ClientNum));
PlayerHistory.Enqueue(new SharedLibraryCore.Helpers.PlayerHistory(ClientNum));
playerCountStart = DateTime.Now;
}
@ -542,7 +542,7 @@ namespace IW4MAdmin
l_size = LogFile.Length();
if (!((ApplicationManager)Manager).Running)
{
foreach (var plugin in SharedLibrary.Plugins.PluginImporter.ActivePlugins)
foreach (var plugin in SharedLibraryCore.Plugins.PluginImporter.ActivePlugins)
await plugin.OnUnloadAsync();
for (int i = 0; i < Players.Count; i++)
@ -551,7 +551,7 @@ namespace IW4MAdmin
return true;
}
//#if !DEBUG
catch (SharedLibrary.Exceptions.NetworkException)
catch (SharedLibraryCore.Exceptions.NetworkException)
{
Logger.WriteError($"Could not communicate with {IP}:{Port}");
return false;
@ -611,7 +611,7 @@ namespace IW4MAdmin
Website = website.Value;
}
catch (SharedLibrary.Exceptions.DvarException)
catch (SharedLibraryCore.Exceptions.DvarException)
{
Website = "this server's website";
}
@ -656,7 +656,7 @@ namespace IW4MAdmin
{
Logger.WriteError($"Gamelog {logPath} does not exist!");
#if !DEBUG
throw new SharedLibrary.Exceptions.ServerException($"Invalid gamelog file {logPath}");
throw new SharedLibraryCore.Exceptions.ServerException($"Invalid gamelog file {logPath}");
#endif
}
else
@ -714,7 +714,7 @@ namespace IW4MAdmin
C = await ValidateCommand(E);
}
catch (SharedLibrary.Exceptions.CommandException e)
catch (SharedLibraryCore.Exceptions.CommandException e)
{
Logger.WriteInfo(e.Message);
}
@ -963,8 +963,8 @@ namespace IW4MAdmin
override public void InitializeTokens()
{
Manager.GetMessageTokens().Add(new SharedLibrary.Helpers.MessageToken("TOTALPLAYERS", Manager.GetClientService().GetTotalClientsAsync().Result.ToString));
Manager.GetMessageTokens().Add(new SharedLibrary.Helpers.MessageToken("VERSION", Program.Version.ToString));
Manager.GetMessageTokens().Add(new SharedLibraryCore.Helpers.MessageToken("TOTALPLAYERS", Manager.GetClientService().GetTotalClientsAsync().Result.ToString));
Manager.GetMessageTokens().Add(new SharedLibraryCore.Helpers.MessageToken("VERSION", Program.Version.ToString));
}
}
}

View File

@ -5,7 +5,7 @@ set TargetDir=%3
if not exist "%TargetDir%x86" (
echo "Copying SQLCe binaries"
md "%TargetDir%x86"
xcopy /y "%SolutionDir%SharedLibrary\LibSQLCe\x86" "%TargetDir%x86\"
xcopy /y "%SolutionDir%SharedLibraryCore\LibSQLCe\x86" "%TargetDir%x86\"
)
if not exist "%TargetDir%Plugins" (

View File

@ -5,5 +5,5 @@ set TargetDir=%3
if "TargetDir" == "*Undefined*" (
echo "Copying extra files to publish dir"
xcopy /Y "%SolutionDir%BUILD\Plugins" "%SolutionDir%Publish\Plugins\"
xcopy /Y "%SolutionDir%SharedLibrary\LibSQLCe\x86" "%SolutionDir%Publish\x86\"
xcopy /Y "%SolutionDir%SharedLibraryCore\LibSQLCe\x86" "%SolutionDir%Publish\x86\"
)

View File

@ -1,8 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using System;
using SharedLibraryCore.Dtos;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using WebfrontCore.Application.API;
namespace WebfrontCore.Controllers.API
@ -14,7 +13,7 @@ namespace WebfrontCore.Controllers.API
public ActionResult Index()
{
var events = EventAPI.Events;
var eventsDto = new List<SharedLibrary.Dtos.EventInfo>();
var eventsDto = new List<EventInfo>();
while (events.Count > 0)
eventsDto.Add(events.Dequeue());
return Json(eventsDto);

View File

@ -3,6 +3,7 @@ using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication.Cookies;
using System.Security.Claims;
using System;
using Microsoft.AspNetCore.Authentication;
namespace WebfrontCore.Controllers
{
@ -19,7 +20,7 @@ namespace WebfrontCore.Controllers
try
{
var client = IW4MAdmin.Program.ServerManager.PrivilegedClients[clientId];
string[] hashedPassword = await Task.FromResult(SharedLibrary.Helpers.Hashing.Hash(password, client.PasswordSalt));
string[] hashedPassword = await Task.FromResult(SharedLibraryCore.Helpers.Hashing.Hash(password, client.PasswordSalt));
if (hashedPassword[0] == client.Password)
{
@ -32,7 +33,7 @@ namespace WebfrontCore.Controllers
var claimsIdentity = new ClaimsIdentity(claims, "login");
var claimsPrinciple = new ClaimsPrincipal(claimsIdentity);
await HttpContext.Authentication.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, claimsPrinciple, new Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties()
await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, claimsPrinciple, new AuthenticationProperties()
{
AllowRefresh = true,
ExpiresUtc = DateTime.UtcNow.AddDays(30),
@ -55,7 +56,7 @@ namespace WebfrontCore.Controllers
[HttpGet]
public async Task<IActionResult> LogoutAsync()
{
await HttpContext.Authentication.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
await HttpContext.SignOutAsync(CookieAuthenticationDefaults.AuthenticationScheme);
return RedirectToAction("Index", "Home");
}
}

View File

@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SharedLibrary;
using SharedLibraryCore;
using WebfrontCore.ViewModels;
namespace WebfrontCore.Controllers

View File

@ -1,9 +1,10 @@
using IW4MAdmin;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;
using SharedLibrary;
using SharedLibrary.Database.Models;
using SharedLibrary.Objects;
using SharedLibraryCore;
using SharedLibraryCore.Database;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Objects;
using System;
using System.Collections.Generic;
using System.Linq;
@ -14,9 +15,15 @@ namespace WebfrontCore.Controllers
public class BaseController : Controller
{
protected ApplicationManager Manager;
protected readonly DatabaseContext Context;
protected bool Authorized { get; private set; }
protected EFClient User { get; private set; }
/* public BaseController(DatabaseContext ctx)
{
Context = ctx;
}*/
public override void OnActionExecuting(ActionExecutingContext context)
{
Manager = IW4MAdmin.Program.ServerManager;

View File

@ -1,7 +1,8 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibrary;
using SharedLibrary.Dtos;
using SharedLibrary.Services;
using SharedLibraryCore;
using SharedLibraryCore.Database;
using SharedLibraryCore.Dtos;
using SharedLibraryCore.Services;
using System;
using System.Collections.Generic;
using System.Linq;
@ -14,6 +15,7 @@ namespace WebfrontCore.Controllers
public async Task<IActionResult> ProfileAsync(int id)
{
var client = await Manager.GetClientService().Get(id);
var clientDto = new PlayerInfo()
{
Name = client.Name,
@ -46,7 +48,7 @@ namespace WebfrontCore.Controllers
var administeredPenaltiesMeta = await Manager.GetPenaltyService()
.ReadGetClientPenaltiesAsync(client.ClientId, false);
if (Authorized && client.Level > SharedLibrary.Objects.Player.Permission.Trusted)
if (Authorized && client.Level > SharedLibraryCore.Objects.Player.Permission.Trusted)
clientDto.Meta.Add(new ProfileMeta()
{
Key = "Masked",
@ -91,7 +93,7 @@ namespace WebfrontCore.Controllers
var admins = (await Manager.GetClientService().GetPrivilegedClients())
.Where(a => a.Active)
.OrderByDescending(a => a.Level);
var adminsDict = new Dictionary<SharedLibrary.Objects.Player.Permission, IList<ClientInfo>>();
var adminsDict = new Dictionary<SharedLibraryCore.Objects.Player.Permission, IList<ClientInfo>>();
foreach (var admin in admins)
{

View File

@ -1,7 +1,7 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibrary;
using SharedLibrary.Dtos;
using SharedLibrary.Objects;
using SharedLibraryCore;
using SharedLibraryCore.Dtos;
using SharedLibraryCore.Objects;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -4,7 +4,7 @@ using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SharedLibrary.Dtos;
using SharedLibraryCore.Dtos;
namespace WebfrontCore.Controllers
{

View File

@ -1,8 +1,8 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibrary;
using SharedLibrary.Database.Models;
using SharedLibrary.Dtos;
using SharedLibrary.Services;
using SharedLibraryCore;
using SharedLibraryCore.Database.Models;
using SharedLibraryCore.Dtos;
using SharedLibraryCore.Services;
using System;
using System.Collections.Generic;
using System.Linq;
@ -30,7 +30,7 @@ namespace WebfrontCore.Controllers
public async Task<IActionResult> PublicAsync()
{
var penalties = await (new GenericRepository<EFPenalty>())
.FindAsync(p => p.Type == SharedLibrary.Objects.Penalty.PenaltyType.Ban && p.Active);
.FindAsync(p => p.Type == SharedLibraryCore.Objects.Penalty.PenaltyType.Ban && p.Active);
var penaltiesDto = penalties.Select(p => new PenaltyInfo()
{

View File

@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibrary.Dtos;
using SharedLibraryCore.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,7 +1,5 @@
using System;
using System.IO;
using System.IO;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
namespace WebfrontCore
{
@ -9,26 +7,14 @@ namespace WebfrontCore
{
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseUrls(config["Web:Address"])
.Build();
if (!SharedLibrary.Utilities.IsRunningOnMono())
{
host.Run();
}
else
{
Console.ReadLine();
}
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseKestrel()
.UseStartup<Startup>()
.Build();
}
}

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Debug</LastUsedBuildConfiguration>
<LastUsedPlatform>x86</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>65340d7d-5831-406c-acad-b13ba634bde2</ProjectGuid>
<publishUrl>bin\Debug\PublishOutput</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<TargetFramework>net452</TargetFramework>
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>
</PropertyGroup>
</Project>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>65340d7d-5831-406c-acad-b13ba634bde2</ProjectGuid>
<publishUrl>C:\Projects\IW4M-Admin\Publish</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<TargetFramework>net452</TargetFramework>
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>
</PropertyGroup>
</Project>

View File

@ -1,21 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>x86</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>65340d7d-5831-406c-acad-b13ba634bde2</ProjectGuid>
<publishUrl>D:\IW4M-Admin\Publish</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<TargetFramework>net452</TargetFramework>
<RuntimeIdentifier>win7-x86</RuntimeIdentifier>
</PropertyGroup>
</Project>

View File

@ -3,7 +3,7 @@
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:38815/",
"applicationUrl": "http://localhost:61369/",
"sslPort": 0
}
},
@ -15,13 +15,13 @@
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"WebfrontCore": {
"WebfrontCore2": {
"commandName": "Project",
"launchBrowser": true,
"launchUrl": "http://localhost:5000",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
},
"applicationUrl": "http://localhost:61370/"
}
}
}
}

View File

@ -1,15 +1,21 @@
using System;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using SharedLibraryCore.Database;
using System;
using System.IO;
namespace WebfrontCore
{
public class Startup
{
private IHostingEnvironment _appHost;
public static IConfigurationRoot Configuration { get; private set; }
public Startup(IHostingEnvironment env)
{
var builder = new ConfigurationBuilder()
@ -18,28 +24,34 @@ namespace WebfrontCore
.AddEnvironmentVariables();
Configuration = builder.Build();
// fixme: this is really really terrible
if (!SharedLibrary.Utilities.IsRunningOnMono())
{
SharedLibrary.Database.DatabaseContext.ConnectionString = Configuration["ConnectionStrings:WindowsConnection"];
}
else
{
SharedLibrary.Database.DatabaseContext.ConnectionString = Configuration["ConnectionStrings:LinuxConnection"];
}
_appHost = env;
if (!IW4MAdmin.Program.Start())
Environment.Exit(-1);
using (var db = new DatabaseContext())
{
db.Database.EnsureCreated();
db.Database.Migrate();
new ContextSeed(db).Seed().Wait();
}
}
public static IConfigurationRoot Configuration { get; private set; }
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
// Add framework services.
services.AddMvc();
services.AddEntityFrameworkSqlite()
.AddDbContext<DatabaseContext>();
services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
{
options.AccessDeniedPath = "/";
options.LoginPath = "/";
});
if (!IW4MAdmin.Program.Start())
Environment.Exit(-1);
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@ -59,16 +71,7 @@ namespace WebfrontCore
}
app.UseStaticFiles();
app.UseCookieAuthentication(new CookieAuthenticationOptions()
{
AccessDeniedPath = "/",
AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme,
AutomaticAuthenticate = true,
AutomaticChallenge = true,
LoginPath = "/",
ExpireTimeSpan = TimeSpan.FromDays(30),
});
app.UseAuthentication();
app.UseMvc(routes =>
{
@ -76,7 +79,6 @@ namespace WebfrontCore
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
}
}
}

View File

@ -1,6 +1,6 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibrary;
using SharedLibrary.Dtos;
using SharedLibraryCore;
using SharedLibraryCore.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;
@ -40,7 +40,7 @@ namespace WebfrontCore.ViewComponents
Type = p.Type.ToString(),
TimePunished = Utilities.GetTimePassed(p.When, false),
TimeRemaining = DateTime.UtcNow > p.Expires ? "" : Utilities.TimeSpanText(p.Expires - DateTime.UtcNow),
Sensitive = p.Type == SharedLibrary.Objects.Penalty.PenaltyType.Flag
Sensitive = p.Type == SharedLibraryCore.Objects.Penalty.PenaltyType.Flag
});
penaltiesDto = authed ? penaltiesDto.ToList() : penaltiesDto.Where(p => !p.Sensitive).ToList();

View File

@ -1,5 +1,5 @@
using Microsoft.AspNetCore.Mvc;
using SharedLibrary.Dtos;
using SharedLibraryCore.Dtos;
using System;
using System.Collections.Generic;
using System.Linq;

View File

@ -1,4 +1,4 @@
@model List<SharedLibrary.Dtos.PlayerInfo>
@model List<SharedLibraryCore.Dtos.PlayerInfo>
<div class="mr-auto ml-auto col-12 col-lg-7 border-bottom">
<h4 class="pb-2 text-center ">@ViewBag.Title</h4>

View File

@ -1,4 +1,4 @@
@model Dictionary<SharedLibrary.Objects.Player.Permission, IList<SharedLibrary.Dtos.ClientInfo>>
@model Dictionary<SharedLibraryCore.Objects.Player.Permission, IList<SharedLibraryCore.Dtos.ClientInfo>>
<h4 class="pb-2 text-center ">@ViewBag.Title</h4>

View File

@ -1,4 +1,4 @@
@model SharedLibrary.Dtos.PlayerInfo
@model SharedLibraryCore.Dtos.PlayerInfo
@{
string match = System.Text.RegularExpressions.Regex.Match(Model.Name.ToUpper(), "[A-Z]").Value;
string shortCode = match == string.Empty ? "?" : match;
@ -21,13 +21,13 @@
<div id="profile_aliases_btn" class="oi oi-caret-bottom h3 ml-0 ml-md-2"></div>
@if (Model.LevelInt < (int)ViewBag.User.Level &&
(SharedLibrary.Objects.Player.Permission)Model.LevelInt != SharedLibrary.Objects.Player.Permission.Banned)
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt != SharedLibraryCore.Objects.Player.Permission.Banned)
{
<div id="profile_action_ban_btn" class="profile-action oi oi-lock-unlocked text-success h3 ml-2" title="Ban Client" data-action="ban" aria-hidden="true"></div>
}
@if (Model.LevelInt < (int)ViewBag.User.Level &&
(SharedLibrary.Objects.Player.Permission)Model.LevelInt == SharedLibrary.Objects.Player.Permission.Banned)
(SharedLibraryCore.Objects.Player.Permission)Model.LevelInt == SharedLibraryCore.Objects.Player.Permission.Banned)
{
<div id="profile_action_unban_btn" class="profile-action oi oi-lock-locked text-danger h3 ml-2" title="Unban Client" data-action="unban" aria-hidden="true"></div>
}

View File

@ -1,4 +1,4 @@
@model IEnumerable<SharedLibrary.Dtos.ServerInfo>
@model IEnumerable<SharedLibraryCore.Dtos.ServerInfo>
<div class="row justify-content-center">
<div id="console" class="col-md-8">

View File

@ -1,4 +1,4 @@
@model List<SharedLibrary.Dtos.CommandResponseInfo>
@model List<SharedLibraryCore.Dtos.CommandResponseInfo>
@{
Layout = null;
}

View File

@ -2,7 +2,7 @@
Layout = null;
}
@model SharedLibrary.Dtos.PenaltyInfo
@model SharedLibraryCore.Dtos.PenaltyInfo
<tr class="d-table-row d-md-none bg-dark">
<th scope="row" class="bg-primary">Name</th>

View File

@ -1,4 +1,4 @@
@model SharedLibrary.Dtos.ServerInfo
@model SharedLibraryCore.Dtos.ServerInfo
@{
Layout = null;

View File

@ -1,5 +1,5 @@

@model SharedLibrary.Dtos.ServerInfo
@model SharedLibraryCore.Dtos.ServerInfo
@{
Layout = null;

View File

@ -1,7 +1,7 @@
@{
Layout = null;
}
@model List<SharedLibrary.Dtos.PenaltyInfo>
@model List<SharedLibraryCore.Dtos.PenaltyInfo>
@{
foreach (var penalty in Model)

View File

@ -1,7 +1,7 @@
@{
Layout = null;
}
@model IEnumerable<SharedLibrary.Dtos.ServerInfo>
@model IEnumerable<SharedLibraryCore.Dtos.ServerInfo>
@{
foreach (var s in Model)

View File

@ -1,32 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net452</TargetFramework>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>IW4MAdmin</AssemblyName>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TypeScriptToolsVersion>2.6</TypeScriptToolsVersion>
<PackageId>RaidMax.IW4MAdmin.WebfrontCore</PackageId>
<Platforms>AnyCPU;x86</Platforms>
<ApplicationIcon>wwwroot\favicon.ico</ApplicationIcon>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<Version>1.6.0</Version>
<Version>2.0.0</Version>
<Authors>RaidMax</Authors>
<Company>ForeverNone</Company>
<Company>Forever None</Company>
<Product>IW4MAdmin</Product>
<Description>IW4MAdmin is a complete server administration tool for IW4x and most Call of Duty® dedicated server</Description>
<Copyright>2018</Copyright>
<PackageLicenseUrl>https://github.com/RaidMax/IW4M-Admin/blob/master/LICENSE</PackageLicenseUrl>
<Description>Complete administration tool designed for IW4x and compatible with most Call Of Duty® dedicated servers</Description>
<PackageProjectUrl>https://raidmax.org/IW4Madmin/</PackageProjectUrl>
<PackageIconUrl>https://raidmax.org/IW4Madmin/img/iw4adminicon-3.png</PackageIconUrl>
<PackageProjectUrl>https://raidmax.org/IW4MAdmin</PackageProjectUrl>
<RepositoryUrl>https://github.com/RaidMax/IW4M-Admin</RepositoryUrl>
<NeutralLanguage>en</NeutralLanguage>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
<OutputPath>bin\x86\Debug\</OutputPath>
<PackageIconUrl>https://raidmax.org/IW4MAdmin/img/iw4adminicon-3.png</PackageIconUrl>
</PropertyGroup>
<ItemGroup>
@ -36,39 +23,8 @@
</ItemGroup>
<ItemGroup>
<None Update="wwwroot\**\*">
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication.Cookies" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.1.5" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.1.7" />
<PackageReference Include="Microsoft.AspNetCore.Routing" Version="1.1.2" />
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.1.3" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="1.1.3" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="1.1.2" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="1.1.2" />
<PackageReference Include="Microsoft.VisualStudio.Web.BrowserLink" Version="1.1.3" />
</ItemGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'net452' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
<Target Name="PrepublishScript" BeforeTargets="PrepareForPublish">
<Exec Command="$(ProjectDir)..\AfterPublish.bat &quot;$(ProjectDir)..\&quot;" />
</Target>
<ItemGroup>
<DotNetCliToolReference Include="BundlerMinifier.Core" Version="2.2.301" />
<Folder Include="Views\Account\" />
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
@ -78,9 +34,11 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharedLibrary\SharedLibrary.csproj">
<Private>true</Private>
</ProjectReference>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SharedLibraryCore\SharedLibraryCore.csproj" />
</ItemGroup>
<ItemGroup>
@ -92,16 +50,4 @@
</Content>
</ItemGroup>
<ItemGroup>
<Folder Include="Views\Account\" />
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="call BuildScripts/PreBuild.bat $(SolutionDir) $(ProjectDir) $(TargetDir)" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="call BuildScripts/PostBuild.bat $(SolutionDir) $(ProjectDir) $(TargetDir)&#xD;&#xA;call BuildScripts/PostPublish.bat $(SolutionDir) $(ProjectDir) $(TargetDir)" />
</Target>
</Project>