using AutomationDAL.DTO.Agent; using AutomationDAL.Query.Agent; using GB5Shared.DTO.Framework.Login; using GB5Shared.QueryExecutor; namespace AutomationDAL.CustomCode.Agent; public class AgentDAL : IAgentDAL { private readonly IQueryExecutor _qe; public AgentDAL(IQueryExecutor qe) => _qe = qe; public async Task UpsertHeartbeat(AgentDTO dto, LoginDTO login, CancellationToken ct) => await _qe.ExecuteIdentityAsync(login, AgentQB.UPSERT_HEARTBEAT, new { dto.AgentName, dto.LocationType, dto.SupportedRuntimes, dto.MaxConcurrency, dto.Status, TenantId = login.ClientId }).ConfigureAwait(false); public async Task> GetAll(LoginDTO login, CancellationToken ct) => await _qe.QueryAsync(login, AgentQB.GET_ALL, new { TenantId = login.ClientId }, cancellationToken: ct).ConfigureAwait(false); public async Task GetById(int agentId, LoginDTO login, CancellationToken ct) { var rows = await _qe.QueryAsync(login, AgentQB.GET_BY_ID, new { AgentId = agentId, TenantId = login.ClientId }, cancellationToken: ct).ConfigureAwait(false); return rows.FirstOrDefault(); } }