Files
monorepo/LCU.API.Internal.FTP/LCU.Api.Internal.FTP/Services/QueueSshFtpService.cs
T
2026-03-24 15:28:37 -05:00

42 lines
1.3 KiB
C#

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}");
}
}
}