2023-08-17 23:39:07 -05:00
|
|
|
|
using CoreRCON;
|
2024-08-12 00:15:16 -05:00
|
|
|
|
using LANCommander.SDK.Enums;
|
2024-08-04 18:44:33 -05:00
|
|
|
|
using LANCommander.Server.Data;
|
|
|
|
|
|
using LANCommander.Server.Data.Models;
|
2024-10-07 18:04:26 -05:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2023-08-17 19:06:23 -05:00
|
|
|
|
using System.Diagnostics;
|
2023-08-17 23:39:07 -05:00
|
|
|
|
using System.Net;
|
2024-10-30 17:44:10 -05:00
|
|
|
|
using ZiggyCreatures.Caching.Fusion;
|
2023-08-17 19:06:23 -05:00
|
|
|
|
|
2024-08-04 18:44:33 -05:00
|
|
|
|
namespace LANCommander.Server.Services
|
2023-08-17 19:06:23 -05:00
|
|
|
|
{
|
2023-08-17 19:55:46 -05:00
|
|
|
|
public class ServerConsoleService : BaseDatabaseService<ServerConsole>
|
2023-08-17 19:06:23 -05:00
|
|
|
|
{
|
2024-08-28 20:33:59 -05:00
|
|
|
|
public ServerConsoleService(
|
|
|
|
|
|
ILogger<ServerConsoleService> logger,
|
2024-10-30 17:44:10 -05:00
|
|
|
|
IFusionCache cache,
|
2024-11-25 22:29:56 -06:00
|
|
|
|
RepositoryFactory repositoryFactory) : base(logger, cache, repositoryFactory) { }
|
2023-08-17 19:06:23 -05:00
|
|
|
|
|
2024-11-12 18:32:46 -06:00
|
|
|
|
public async Task<string[]> ReadLogAsync(Guid logId)
|
2023-08-17 19:06:23 -05:00
|
|
|
|
{
|
2024-11-12 18:32:46 -06:00
|
|
|
|
var log = await GetAsync(logId);
|
2023-08-17 19:06:23 -05:00
|
|
|
|
|
2023-08-17 23:39:07 -05:00
|
|
|
|
if (log.Type != ServerConsoleType.LogFile)
|
|
|
|
|
|
throw new Exception("Invalid console type");
|
|
|
|
|
|
|
2023-08-17 19:06:23 -05:00
|
|
|
|
var logPath = Path.Combine(log.Server.WorkingDirectory, log.Path);
|
|
|
|
|
|
|
|
|
|
|
|
return await File.ReadAllLinesAsync(logPath);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|