Downloader
using Relativity.DataExchange.Export.VolumeManagerV2.Metadata.Writers;
using Relativity.Logging;
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Security;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Threading;
using System.Threading.Tasks;
namespace Relativity.DataExchange.Export.VolumeManagerV2.Download
{
public class Downloader : IDownloader
{
private List<ExportRequest> _fileExportRequests;
private List<LongTextExportRequest> _longTextExportRequests;
private readonly IPhysicalFilesDownloader _physicalFilesDownloader;
private readonly ILongTextDownloader _longTextDownloader;
private readonly IErrorFileWriter _errorFileWriter;
private readonly ILog _logger;
private readonly IExportRequestRetriever _exportRequestRetriever;
public Downloader(IExportRequestRetriever exportRequestRetriever, IPhysicalFilesDownloader physicalFilesDownloader, ILongTextDownloader longTextDownloader, ILongTextFileDownloadSubscriber longTextFileDownloadSubscriber, IErrorFileWriter errorFileWriter, IFileDownloadSubscriber fileSubscriber, ILog logger)
{
_physicalFilesDownloader = physicalFilesDownloader;
_longTextDownloader = longTextDownloader;
_logger = logger;
_exportRequestRetriever = exportRequestRetriever;
_errorFileWriter = errorFileWriter;
longTextFileDownloadSubscriber?.RegisterSubscriber(fileSubscriber);
if (AppSettings.Instance.SuppressServerCertificateValidation)
ServicePointManager.ServerCertificateValidationCallback = (RemoteCertificateValidationCallback)Delegate.Combine(ServicePointManager.ServerCertificateValidationCallback, (RemoteCertificateValidationCallback)((object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) => true));
}
[AsyncStateMachine(typeof(<DownloadFilesForArtifactsAsync>d__8))]
public Task DownloadFilesForArtifactsAsync(CancellationToken cancellationToken)
{
<DownloadFilesForArtifactsAsync>d__8 stateMachine = default(<DownloadFilesForArtifactsAsync>d__8);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
private void RetrieveExportRequests()
{
_fileExportRequests = _exportRequestRetriever.RetrieveFileExportRequests();
_longTextExportRequests = _exportRequestRetriever.RetrieveLongTextExportRequests();
}
[AsyncStateMachine(typeof(<DownloadRequests>d__10))]
private Task DownloadRequests(CancellationToken cancellationToken)
{
<DownloadRequests>d__10 stateMachine = default(<DownloadRequests>d__10);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = this;
stateMachine.cancellationToken = cancellationToken;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
}
}
}