using C4IT.DataHistoryProvider.Base.DataSources; using C4IT.FASD.Base; using C4IT.FASD.Communication.Agent; using System; using System.Threading; using System.Threading.Tasks; namespace C4IT.DataHistoryProvider.Base.Modules.Agent { public class AgentRemoteDesktopManager : IRemoteDesktopManager { private readonly AgentApiHandler _agentApiHandler; public AgentRemoteDesktopManager(cAgentApiConfiguration agentConfig) { _agentApiHandler = new AgentApiHandler(agentConfig); } public async Task GetConnectionStatus(Guid connectionId) { return await _agentApiHandler.Request($"api/management/c4it/phoenix-connections/{connectionId}/status", HTTP.eHttpMethod.get); } public async Task InitiateConnectionOfClient(AgentRemoteClientInfo clientInfos, bool isElevated, CancellationToken token) { string url = "api/management/c4it/phoenix-connections"; if (isElevated) url += "/admin"; return await _agentApiHandler.Request(url, HTTP.eHttpMethod.post, clientInfos, token); } public async Task TerminateConnection(Guid connectionId) { await _agentApiHandler.Request($"api/management/c4it/phoenix-connections/{connectionId}", HTTP.eHttpMethod.delete); } public bool IsActive() => true; public Task GetHealthInfo() { // todo Agent Server has to implement an "health" endpoint and return its result return Task.FromResult(new HealthInformation(HealthStatus.healthy)); } } }