3defd3f486
* don't run build commands in release
* fix test file
* Set up CI with Azure Pipelines
[skip ci]
* Include fonts and fix automessage hidden command
* more project changes
* migration from bower to libman
* more lib man changes
* project update for sneaky commands
* add missing canvas.js dep
update projects not to have stupid extra dlls
include in previous
* update pipeline file
* update post publish script and pipeline definition
* fix broken yaml
* move encoding conversion to seperate script
* remove extra uneeded rank icons
remove garbage language files being created
remove frontend lib when done
* fix publish script path
* grab localizations through powershell
* fix broken batch 🤷
* actually fixed
* only include runtime compilation in debug mode for webfront
* don't deploy un minified css
use full jquery version
* add step to download the scss for open iconic
change the font path
* update mkdir for iconic path
* don't include old iconic css
* correct font path for real now
* copy script plugins
* lots of changes for deployment
* build the projects
* use projectdir instead of solution dir
* nerf script commands plugin
fix live radar left over command
* actually kill script command post build
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
* fix the font file copy (I think)
* maybe fix delete folder issue
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
* Update azure-pipelines.yml for Azure Pipelines
106 lines
3.4 KiB
C#
106 lines
3.4 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using SharedLibraryCore;
|
|
using SharedLibraryCore.Database.Models;
|
|
using SharedLibraryCore.Dtos;
|
|
using SharedLibraryCore.Interfaces;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace WebfrontCore.Controllers
|
|
{
|
|
public class ConsoleController : BaseController
|
|
{
|
|
public ConsoleController(IManager manager) : base(manager)
|
|
{
|
|
|
|
}
|
|
|
|
public IActionResult Index()
|
|
{
|
|
var activeServers = Manager.GetServers().Select(s => new ServerInfo()
|
|
{
|
|
Name = s.Hostname,
|
|
ID = s.EndPoint,
|
|
});
|
|
|
|
ViewBag.Description = "Use the IW4MAdmin web console to execute commands";
|
|
ViewBag.Title = Localization["WEBFRONT_CONSOLE_TITLE"];
|
|
ViewBag.Keywords = "IW4MAdmin, console, execute, commands";
|
|
|
|
return View(activeServers);
|
|
}
|
|
|
|
public async Task<IActionResult> ExecuteAsync(long serverId, string command)
|
|
{
|
|
var server = Manager.GetServers().First(s => s.EndPoint == serverId);
|
|
|
|
var client = new EFClient()
|
|
{
|
|
ClientId = Client.ClientId,
|
|
Level = Client.Level,
|
|
NetworkId = Client.NetworkId,
|
|
CurrentServer = server,
|
|
CurrentAlias = new EFAlias()
|
|
{
|
|
Name = Client.Name
|
|
}
|
|
};
|
|
|
|
var remoteEvent = new GameEvent()
|
|
{
|
|
Type = GameEvent.EventType.Command,
|
|
Data = command,
|
|
Origin = client,
|
|
Owner = server,
|
|
IsRemote = true
|
|
};
|
|
|
|
Manager.GetEventHandler().AddEvent(remoteEvent);
|
|
List<CommandResponseInfo> response = null;
|
|
|
|
try
|
|
{
|
|
var completedEvent = await remoteEvent.WaitAsync(Utilities.DefaultCommandTimeout, server.Manager.CancellationToken);
|
|
// wait for the event to process
|
|
if (!completedEvent.Failed)
|
|
{
|
|
response = server.CommandResult.Where(c => c.ClientId == client.ClientId).ToList();
|
|
|
|
// remove the added command response
|
|
for (int i = 0; i < response.Count; i++)
|
|
{
|
|
server.CommandResult.Remove(response[i]);
|
|
}
|
|
}
|
|
|
|
else if (completedEvent.FailReason == GameEvent.EventFailReason.Timeout)
|
|
{
|
|
response = new List<CommandResponseInfo>()
|
|
{
|
|
new CommandResponseInfo()
|
|
{
|
|
ClientId = client.ClientId,
|
|
Response = Utilities.CurrentLocalization.LocalizationIndex["SERVER_ERROR_COMMAND_TIMEOUT"]
|
|
}
|
|
};
|
|
}
|
|
}
|
|
|
|
catch (System.OperationCanceledException)
|
|
{
|
|
response = new List<CommandResponseInfo>()
|
|
{
|
|
new CommandResponseInfo()
|
|
{
|
|
ClientId = client.ClientId,
|
|
Response = Utilities.CurrentLocalization.LocalizationIndex["COMMADS_RESTART_SUCCESS"]
|
|
}
|
|
};
|
|
}
|
|
|
|
return View("_Response", response);
|
|
}
|
|
}
|
|
}
|