using System; using Newtonsoft.Json; using Serilog; using MassTransit; using LCU.Api.Internal.FTP.Configuration; using LCU.Api.Internal.FTPLib.Models.Enums; using LCU.Api.Internal.FTPLib.Models; using LCU.Library.Internal.Exceptions; using LCU.Library.Internal.LcuMassTransitModels; namespace LCU.Api.Internal.FTP.Services; public class QueueSshFtpService : IQueueSshFtpService { private readonly ISendEndpoint _sendEndpoint; public QueueSshFtpService(IBusControl busControl, ReceiveEndpointConfiguration receiveEndpointsConfiguration) { _sendEndpoint = busControl.GetSendEndpoint(receiveEndpointsConfiguration.ReceiveEndpointUri).Result; } public void QueueSshFtpRequest(SshFtpRequest request) { try { var queueRequest = new QueueRequest(); queueRequest = new QueueRequest() { Request = JsonConvert.SerializeObject(request), FtpType = FtpType.SshFtp }; _sendEndpoint.Send(queueRequest); Log.Debug($"Queued ssh ftp request to host {request.HostName}"); } catch (Exception ex) { Log.Error(ex, $"Failed to queue ssh ftp request to host {request.HostName}"); throw new ServiceException($"Failed to queue ssh ftp request to host {request.HostName}"); } } }